lcsim/resources/org/lcsim/schemas/lcsim/1.0
diff -u -r1.2 -r1.3
--- lcsim.xsd 10 May 2010 22:53:23 -0000 1.2
+++ lcsim.xsd 17 May 2010 18:13:56 -0000 1.3
@@ -4,7 +4,7 @@
elementFormDefault="unqualified"
version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
+
<xs:element name="inputFiles">
<xs:complexType>
<xs:sequence>
@@ -21,6 +21,15 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+ <xs:element name="fileRegExp" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="baseDir" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
lcsim/src/org/lcsim/job
diff -u -r1.36 -r1.37
--- JobControlManager.java 10 May 2010 22:58:33 -0000 1.36
+++ JobControlManager.java 17 May 2010 18:13:56 -0000 1.37
@@ -23,6 +23,8 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.freehep.application.studio.Studio;
import org.freehep.jas.services.DynamicClassLoader;
@@ -71,6 +73,7 @@
File cacheDirectory;
FileCache fileCache; // Start with default dir.
ClassLoader loader;
+ boolean printInputFiles;
boolean printDriverStatistics;
boolean printSystemProperties;
boolean printUserClassPath;
@@ -87,28 +90,6 @@
private static ParameterConverters paramConverter;
/**
- * Hard-coded resolution of schema to resource location in lcsim jar.
- * @author jeremym
- */
- public class LCSimSchemaResolver
- implements EntityResolver
- {
- public LCSimSchemaResolver()
- {}
-
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
- {
- System.out.println("publicId: " + publicId);
- System.out.println("systemId: " + systemId);
- InputStream in = this.getClass().getClassLoader().getResourceAsStream("org/lcsim/schemas/lcsim/1.0/lcsim.xsd");
- InputSource src = new InputSource(in);
- src.setSystemId(systemId);
- src.setPublicId(publicId);
- return src;
- }
- }
-
- /**
* Default no-argument constructor.
*/
public JobControlManager()
@@ -266,7 +247,6 @@
// Setup XML schema validation.
builder.setEntityResolver(new ClasspathEntityResolver());
- //builder.setEntityResolver(new LCSimSchemaResolver());
builder.setValidation(true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
@@ -349,6 +329,7 @@
printSystemProperties = false;
printUserClassPath = false;
printDriversDetailed = false;
+ printInputFiles = true; // Defaults to true.
printVersion = false;
verbose = false;
wasSetup = false;
@@ -498,31 +479,64 @@
inputFiles.add(new File(filePath));
}
}
-
- // Check and print out input files.
- if (verbose)
- {
- logStream.println();
- logStream.println("--- Input Files ---");
- }
- for (File file : inputFiles)
- {
- // Check that input LCIO file exists.
- if (!file.exists())
- {
- throw new RuntimeException("The file " + file.getAbsolutePath() + " does not exist!");
- }
-
- if (verbose)
- logStream.println(file.getAbsolutePath());
- }
- if (verbose)
- {
- logStream.println("--- End Input Files ---");
- logStream.println();
+ // Read fileRegExps.
+ List<Element> fileRegExps = (List<Element>)root.getChild("inputFiles").getChildren("fileRegExp");
+ for (Element fileRegExp : fileRegExps)
+ {
+ Pattern pattern = Pattern.compile(fileRegExp.getText());
+ String basedir = fileRegExp.getAttributeValue("baseDir");
+ File dir = new File(basedir);
+ if (!dir.isDirectory())
+ throw new RuntimeException(basedir + " is not a valid directory!");
+ String dirlist[] = dir.list();
+ if (verbose)
+ logStream.println();
+ for (String file : dirlist)
+ {
+ if (file.endsWith(".slcio"))
+ {
+ Matcher matcher = pattern.matcher(file);
+ if (matcher.matches())
+ {
+ inputFiles.add(new File(basedir + File.separator + file));
+ if (verbose)
+ logStream.println("Matched file <" + file.toString() + "> to pattern <" + pattern.toString() + ">");
+ }
+ else
+ {
+ if (verbose)
+ logStream.println("Did NOT match file <" + file.toString() + "> to pattern <" + pattern.toString() + ">");
+ }
+ }
+ }
}
+ // Check that all files exist.
+ for (File file : inputFiles)
+ {
+ // Check that input LCIO file exists.
+ if (!file.exists())
+ {
+ logStream.println("The file " + file.getAbsolutePath() + " does not exist!");
+ throw new RuntimeException("The file " + file.getAbsolutePath() + " does not exist!");
+ }
+ }
+
+ // Print out input files.
+ if (printInputFiles)
+ {
+ logStream.println();
+ logStream.println("--- Input Files ---");
+
+ for (File file : inputFiles)
+ {
+ logStream.println(file.getAbsolutePath());
+ }
+
+ logStream.println("--- End Input Files ---");
+ logStream.println();
+ }
}
private void setupJobControlParameters()
@@ -535,7 +549,22 @@
// Verbose mode.
Element verboseElement = control.getChild("verbose");
if (verboseElement != null)
+ {
verbose = Boolean.valueOf(verboseElement.getText());
+
+ // If verbose is set to true, then all print output is enabled.
+ // These settings can be overridden individually by their respective
+ // XML elements in the control element, e.g. printInputFiles, etc.
+ if (verbose)
+ {
+ this.printInputFiles = true;
+ this.printDriversDetailed = true;
+ this.printDriverStatistics = true;
+ this.printSystemProperties = true;
+ this.printUserClassPath = true;
+ this.printVersion = true;
+ }
+ }
// Log file setup needs to come first.
Element logFileElement = control.getChild("logFile");
@@ -612,6 +641,15 @@
if (verbose)
logStream.println("cacheDirectory = " + cacheDirectory);
+
+ Element printInputFilesElement = control.getChild("printInputFiles");
+ if (printInputFilesElement != null)
+ {
+ printInputFiles = Boolean.valueOf(printInputFilesElement.getText());
+ }
+
+ if (verbose)
+ logStream.println("printInputFiles = " + printInputFiles);
Element printStatisticsElement = control.getChild("printDriverStatistics");
if (printStatisticsElement != null)