ProcessEvents.scala 1.95 KB
Newer Older
1
2
package eu.nomad_lab.integrated_pipeline.messages

3
4
import java.nio.file.Path

5
import eu.nomad_lab.integrated_pipeline.FileTree
6
7
import eu.nomad_lab.parsers.ParseResult.ParseResult

8
9
10
11
12
/*These events are distinct from the messages passed between the different processing stage because
  they model both input and output of each stage. Also, they do not contain any heavy payload (like
  the in-memory results of a parsing task) and thus can be stored by EventListener implementations.
 */

13
sealed trait TreeParserEvent {
14
  def treeTask: FileTree
15
}
16

17
case class TreeParserEventStart(
18
  treeTask: FileTree
19
) extends TreeParserEvent
20
21

case class TreeParserEventCandidate(
22
  treeTask: FileTree,
23
24
  relativePath: Path,
  parser: String
25
) extends TreeParserEvent
26

27
case class TreeParserEventScanError(
28
  treeTask: FileTree,
29
30
31
32
  relativePath: Path,
  error: Throwable
) extends TreeParserEvent

33
case class TreeParserEventTreeFailure(
34
  treeTask: FileTree,
35
36
37
  error: Throwable
) extends TreeParserEvent

38
case class TreeParserEventEnd(
39
  treeTask: FileTree,
40
  numCandidates: Long
41
) extends TreeParserEvent
42

43
sealed trait CalculationParserEvent {
44
  def treeTask: FileTree
45
46
47
48
49
  def relativePath: Path
  def parser: String
}

case class CalculationParserEventStart(
50
  treeTask: FileTree,
51
52
53
54
55
  relativePath: Path,
  parser: String
) extends CalculationParserEvent

case class CalculationParserEventEnd(
56
  treeTask: FileTree,
57
58
59
60
61
  relativePath: Path,
  parser: String,
  result: ParseResult,
  error: Option[String]
) extends CalculationParserEvent
62

63
sealed trait ResultWriterEvent {
64
  def treeTask: FileTree
65
66
67
}

case class ResultWriterEventStart(
68
  treeTask: FileTree
69
) extends ResultWriterEvent
70

71
case class ResultWriterEventResult(
72
  treeTask: FileTree,
73
74
75
76
77
78
79
  relativePath: Path,
  parser: String,
  result: ParseResult,
  error: Option[String]
) extends ResultWriterEvent

case class ResultWriterEventEnd(
80
  treeTask: FileTree,
81
82
83
84
  numCalculations: Long,
  numParsingFailures: Long,
  outputLocation: Path
) extends ResultWriterEvent