1 package org.lcsim.job;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.lcsim.conditions.ConditionsManager;
7 import org.lcsim.geometry.Detector;
8 import org.lcsim.util.Driver;
9
10
11
12
13
14
15 public class ConditionsCheckDriver extends Driver {
16
17 List<String> requiredConditions = new ArrayList<String>();
18 List<String> detectors = new ArrayList<String>();
19 boolean checkConditions = true;
20 boolean checkDetector = true;
21
22 ConditionsCheckDriver() {}
23
24 public void detectorChanged(Detector detector) {
25 if (checkDetector) {
26 if (detectors.size() > 0) {
27 if (!detectors.contains(detector.getDetectorName())) {
28 throw new RuntimeException("The detector " + detector.getDetectorName() + " is not in the list of valid detectors.");
29 }
30 }
31 }
32 if (checkConditions) {
33 ConditionsManager mgr = ConditionsManager.defaultInstance();
34 for (String condition : requiredConditions) {
35 try {
36 mgr.getRawConditions(condition);
37 } catch (ConditionsManager.ConditionsSetNotFoundException e) {
38 throw new RuntimeException(e);
39 }
40 }
41 }
42 }
43
44 public void setCondition(String c) {
45 requiredConditions.add(c);
46 }
47
48 public void setDetector(String d) {
49 detectors.add(d);
50 }
51
52 public void setCheckConditions(boolean b) {
53 this.checkConditions = b;
54 }
55
56 public void setCheckDetector(boolean b) {
57 this.checkDetector = b;
58 }
59 }