Search in sources :

Example 1 with GeneratorMain

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());
}
Also used : GeneratorMain(de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorMain)

Example 2 with GeneratorMain

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);
    }
}
Also used : GeneratorMain(de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorMain) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Schema(javax.xml.validation.Schema) Node(org.w3c.dom.Node) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document) URL(java.net.URL) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) AbortException(de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException) SAXException(org.xml.sax.SAXException)

Aggregations

GeneratorMain (de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorMain)2 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URL (java.net.URL)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Schema (javax.xml.validation.Schema)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1 SAXException (org.xml.sax.SAXException)1