use of de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorMain in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method loadData.
@Override
public MultipleObjectsBundle loadData() {
if (LOG.isVerbose()) {
LOG.verbose("Loading specification ...");
}
GeneratorMain gen = loadXMLSpecification();
if (testAgainstModel != null) {
gen.setTestAgainstModel(testAgainstModel.booleanValue());
}
gen.setReassignPattern(reassign);
gen.setReassignByDistance(reassignByDistance);
if (LOG.isVerbose()) {
LOG.verbose("Generating clusters ...");
}
return super.invokeBundleFilters(gen.generate());
}
use of de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorMain in project elki by elki-project.
the class GeneratorXMLDatabaseConnection method loadXMLSpecification.
/**
* Load the XML configuration file.
*
* @return Generator
*/
private GeneratorMain loadXMLSpecification() {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
URL url = ClassLoader.getSystemResource(GENERATOR_SCHEMA_FILE);
if (url != null) {
try {
Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(url);
dbf.setSchema(schema);
dbf.setIgnoringElementContentWhitespace(true);
} catch (Exception e) {
LOG.warning("Could not set up XML Schema validation for specification file.", e);
}
} else {
LOG.warning("Could not set up XML Schema validation for specification file.");
}
Document doc = dbf.newDocumentBuilder().parse(specfile);
Node root = doc.getDocumentElement();
if (TAG_DATASET.equals(root.getNodeName())) {
GeneratorMain gen = new GeneratorMain();
processElementDataset(gen, root);
return gen;
} else {
throw new AbortException("Experiment specification has incorrect document element: " + root.getNodeName());
}
} catch (FileNotFoundException e) {
throw new AbortException("Can't open specification file.", e);
} catch (SAXException e) {
throw new AbortException("Error parsing specification file.", e);
} catch (IOException e) {
throw new AbortException("IO Exception loading specification file.", e);
} catch (ParserConfigurationException e) {
throw new AbortException("Parser Configuration Error", e);
}
}
Aggregations