|
1 | 1 | package org.jlab.analysis.postprocess; |
2 | 2 |
|
3 | 3 | import java.io.File; |
4 | | -import java.nio.file.FileSystems; |
5 | | -import java.nio.file.PathMatcher; |
6 | | -import java.util.ArrayList; |
7 | | -import java.util.Arrays; |
8 | 4 | import java.util.HashMap; |
9 | 5 | import java.util.List; |
10 | 6 | import java.util.Map; |
@@ -47,55 +43,30 @@ public class Processor { |
47 | 43 | private HelicitySequenceDelayed helicitySequence = null; |
48 | 44 | private TreeMap<Integer,Integer> eventUnix = null; |
49 | 45 |
|
50 | | - public Processor(File file, boolean restream, boolean rebuild) { |
51 | | - configure(Arrays.asList(file.getAbsolutePath()), restream, rebuild); |
52 | | - } |
53 | | - |
54 | | - public Processor(String dir, boolean restream, boolean rebuild) { |
55 | | - configure(findPreloadFiles(dir,DEF_PRELOAD_GLOB), restream, rebuild); |
56 | | - } |
57 | | - |
58 | | - public Processor(String dir, String glob, boolean restream, boolean rebuild) { |
59 | | - configure(findPreloadFiles(dir,glob), restream, rebuild); |
60 | | - } |
61 | | - |
62 | 46 | public Processor(List<String> files, boolean restream, boolean rebuild) { |
63 | | - configure(files, restream, rebuild); |
64 | | - } |
65 | | - |
66 | | - private void configure(List<String> preloadFiles, boolean restream, boolean rebuild) { |
67 | | - if (!preloadFiles.isEmpty()) { |
68 | | - HipoReader r = new HipoReader(); |
69 | | - r.open(preloadFiles.get(0)); |
70 | | - schemaFactory = r.getSchemaFactory(); |
71 | | - r.close(); |
72 | | - runConfig = new Bank(schemaFactory.getSchema("RUN::config")); |
73 | | - recEvent = new Bank(schemaFactory.getSchema("REC::Event")); |
74 | | - conman = new ConstantsManager(); |
75 | | - conman.init(CCDB_TABLES); |
76 | | - helicitySequence = Util.getHelicity(preloadFiles, schemaFactory, restream, conman); |
77 | | - if (rebuild) chargeSequence = DaqScalersSequence.rebuildSequence(1, conman, preloadFiles); |
78 | | - else chargeSequence = DaqScalersSequence.readSequence(preloadFiles); |
79 | | - eventUnix = getEventUnixMap(schemaFactory, preloadFiles); |
80 | | - } |
| 47 | + HipoReader r = new HipoReader(); |
| 48 | + r.open(files.get(0)); |
| 49 | + schemaFactory = r.getSchemaFactory(); |
| 50 | + r.close(); |
| 51 | + runConfig = new Bank(schemaFactory.getSchema("RUN::config")); |
| 52 | + recEvent = new Bank(schemaFactory.getSchema("REC::Event")); |
| 53 | + conman = new ConstantsManager(); |
| 54 | + conman.init(CCDB_TABLES); |
| 55 | + helicitySequence = Util.getHelicity(files, schemaFactory, restream, conman); |
| 56 | + if (rebuild) chargeSequence = DaqScalersSequence.rebuildSequence(1, conman, files); |
| 57 | + else chargeSequence = DaqScalersSequence.readSequence(files); |
| 58 | + eventUnix = getEventUnixMap(schemaFactory, files); |
81 | 59 | } |
82 | 60 |
|
83 | | - /** |
84 | | - * Get a list of files to preload, from one directory and a glob. |
85 | | - * @param dir |
86 | | - * @param glob |
87 | | - * @return list of preload files |
88 | | - */ |
89 | | - private static List<String> findPreloadFiles(String dir, String glob) { |
90 | | - List<String> ret = new ArrayList<>(); |
91 | | - if (dir != null) { |
92 | | - PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:"+dir+"/"+glob); |
93 | | - for (File f : (new File(dir)).listFiles()) { |
94 | | - if (matcher.matches(f.toPath())) |
95 | | - ret.add(f.getPath()); |
96 | | - } |
97 | | - } |
98 | | - return ret; |
| 61 | + public Processor(List<String> files, SchemaFactory schema, HelicitySequenceDelayed h, DaqScalersSequence s) { |
| 62 | + schemaFactory = schema; |
| 63 | + helicitySequence = h; |
| 64 | + chargeSequence = s; |
| 65 | + runConfig = new Bank(schemaFactory.getSchema("RUN::config")); |
| 66 | + recEvent = new Bank(schemaFactory.getSchema("REC::Event")); |
| 67 | + conman = new ConstantsManager(); |
| 68 | + conman.init(CCDB_TABLES); |
| 69 | + eventUnix = getEventUnixMap(schemaFactory, files); |
99 | 70 | } |
100 | 71 |
|
101 | 72 | /** |
|
0 commit comments