Search in sources :

Example 1 with ILoggingTool

use of org.openscience.cdk.tools.ILoggingTool in project cdk by cdk.

the class OWLFile method unmarshal.

public static Entry unmarshal(Element entry, String ownNS) {
    ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLFile.class);
    // create a new entry by ID
    Attribute id = entry.getAttribute("ID", rdfNS);
    logger.debug("ID: ", id);
    Entry dbEntry = new Entry(id.getValue());
    // set additional, optional data
    Element label = entry.getFirstChildElement("label", rdfsNS);
    logger.debug("label: ", label);
    if (label != null)
        dbEntry.setLabel(label.getValue());
    dbEntry.setClassName(entry.getQualifiedName());
    logger.debug("class name: ", dbEntry.getClassName());
    Element definition = entry.getFirstChildElement("definition", ownNS);
    if (definition != null) {
        dbEntry.setDefinition(definition.getValue());
    }
    Element description = entry.getFirstChildElement("description", ownNS);
    if (description != null) {
        dbEntry.setDescription(description.getValue());
    }
    if (entry.getQualifiedName().equals("Descriptor"))
        dbEntry.setRawContent(entry);
    return dbEntry;
}
Also used : ILoggingTool(org.openscience.cdk.tools.ILoggingTool) Attribute(nu.xom.Attribute) Element(nu.xom.Element)

Example 2 with ILoggingTool

use of org.openscience.cdk.tools.ILoggingTool in project cdk by cdk.

the class OWLReact method unmarshal.

public static EntryReact unmarshal(Element entry, String ownNS) {
    ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLReact.class);
    // create a new entry by ID
    Attribute id = entry.getAttribute("ID", rdfNS);
    logger.debug("ID: ", id);
    EntryReact dbEntry = new EntryReact(id.getValue());
    // set additional, optional data
    Element label = entry.getFirstChildElement("label", rdfsNS);
    logger.debug("label: ", label);
    if (label != null)
        dbEntry.setLabel(label.getValue());
    dbEntry.setClassName(entry.getQualifiedName());
    logger.debug("class name: ", dbEntry.getClassName());
    Element definition = entry.getFirstChildElement("definition", ownNS);
    if (definition != null) {
        dbEntry.setDefinition(definition.getValue());
        logger.debug("definition name: ", definition.getValue());
    }
    Element description = entry.getFirstChildElement("description", ownNS);
    if (description != null) {
        dbEntry.setDescription(description.getValue());
        logger.debug("description name: ", description.getValue());
    }
    Elements representations = entry.getChildElements("representation", ownNS);
    if (representations != null)
        for (int i = 0; i < representations.size(); i++) {
            // String idRepr = representations.get(i).getAttributeValue("id");
            String contentRepr = representations.get(i).getAttributeValue("content");
            dbEntry.setRepresentation(contentRepr);
        }
    Elements params = entry.getChildElements("parameters", ownNS);
    if (params != null)
        for (int i = 0; i < params.size(); i++) {
            String typeParam = params.get(i).getAttributeValue("dataType");
            typeParam = typeParam.substring(typeParam.indexOf(':') + 1, typeParam.length());
            String nameParam = params.get(i).getAttributeValue("resource");
            String value = params.get(i).getValue();
            dbEntry.setParameters(nameParam, typeParam, value);
        }
    Elements paramsList = entry.getChildElements("parameterList", ownNS);
    if (paramsList != null)
        for (int i = 0; i < paramsList.size(); i++) {
            Elements params2 = paramsList.get(i).getChildElements("parameter2", ownNS);
            if (params2 != null)
                for (int j = 0; j < params2.size(); j++) {
                    String paramClass = params2.get(i).getAttribute(0).getValue();
                    paramClass = paramClass.substring(paramClass.indexOf('#') + 1);
                    logger.debug("parameter class: ", paramClass);
                    String needsToSet = "";
                    String value = "";
                    String dataType = "";
                    Elements paramSubt1 = params2.get(i).getChildElements("isSetParameter", ownNS);
                    if (paramSubt1 != null)
                        for (int k = 0; k < 1; k++) needsToSet = paramSubt1.get(k).getValue();
                    Elements paramSubt2 = params2.get(i).getChildElements("value", ownNS);
                    if (paramSubt1 != null)
                        for (int k = 0; k < 1; k++) {
                            value = paramSubt2.get(k).getValue();
                            dataType = paramSubt2.get(k).getAttributeValue("dataType");
                            dataType = dataType.substring(dataType.indexOf(':') + 1, dataType.length());
                        }
                    List<String> pp = new ArrayList<>();
                    pp.add(paramClass);
                    pp.add(needsToSet);
                    pp.add(dataType);
                    pp.add(value);
                    dbEntry.addParameter(pp);
                }
        }
    Elements mechanismDependence = entry.getChildElements("mechanismDependence", ownNS);
    String mechanism = "";
    if (mechanismDependence != null)
        for (int i = 0; i < mechanismDependence.size(); i++) {
            mechanism = mechanismDependence.get(i).getAttribute(0).getValue();
            mechanism = mechanism.substring(mechanism.indexOf('#') + 1);
            logger.debug("mechanism name: ", mechanism);
        }
    dbEntry.setMechanism(mechanism);
    // System.out.println("mechan: "+mechan);
    Elements exampleReact = entry.getChildElements("example-Reactions", ownNS);
    if (exampleReact != null)
        for (int i = 0; i < exampleReact.size(); i++) {
            Elements reaction = exampleReact.get(i).getChildElements("reaction", ownNS);
            if (reaction != null)
                for (int j = 0; j < reaction.size(); j++) {
                    dbEntry.addExampleReaction(reaction.get(0).toXML());
                }
        }
    return dbEntry;
}
Also used : ILoggingTool(org.openscience.cdk.tools.ILoggingTool) Attribute(nu.xom.Attribute) Element(nu.xom.Element) ArrayList(java.util.ArrayList) Elements(nu.xom.Elements)

Example 3 with ILoggingTool

use of org.openscience.cdk.tools.ILoggingTool in project cdk by cdk.

the class AbstractLoggingToolTest method testDebug_Object_Object_Object_Object.

@Test
public void testDebug_Object_Object_Object_Object() throws Exception {
    ILoggingTool logger = getLoggingTool();
    logger.debug(this, this, this, this);
}
Also used : ILoggingTool(org.openscience.cdk.tools.ILoggingTool) Test(org.junit.Test)

Example 4 with ILoggingTool

use of org.openscience.cdk.tools.ILoggingTool in project cdk by cdk.

the class AbstractLoggingToolTest method testInfo_Object_boolean.

@Test
public void testInfo_Object_boolean() throws Exception {
    ILoggingTool logger = getLoggingTool();
    logger.info(this, true);
}
Also used : ILoggingTool(org.openscience.cdk.tools.ILoggingTool) Test(org.junit.Test)

Example 5 with ILoggingTool

use of org.openscience.cdk.tools.ILoggingTool in project cdk by cdk.

the class AbstractLoggingToolTest method testDumpClasspath.

@Test
public void testDumpClasspath() throws Exception {
    ILoggingTool logger = getLoggingTool();
    logger.dumpClasspath();
}
Also used : ILoggingTool(org.openscience.cdk.tools.ILoggingTool) Test(org.junit.Test)

Aggregations

ILoggingTool (org.openscience.cdk.tools.ILoggingTool)44 Test (org.junit.Test)38 IOException (java.io.IOException)4 Element (nu.xom.Element)4 Elements (nu.xom.Elements)3 ArrayList (java.util.ArrayList)2 Attribute (nu.xom.Attribute)2 Builder (nu.xom.Builder)2 Document (nu.xom.Document)2 ParsingException (nu.xom.ParsingException)2 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 CDKException (org.openscience.cdk.exception.CDKException)1 BitSetFingerprint (org.openscience.cdk.fingerprint.BitSetFingerprint)1 HybridizationFingerprinter (org.openscience.cdk.fingerprint.HybridizationFingerprinter)1 IBitFingerprint (org.openscience.cdk.fingerprint.IBitFingerprint)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1 IteratingSDFReader (org.openscience.cdk.io.iterator.IteratingSDFReader)1 InputSource (org.xml.sax.InputSource)1 SAXException (org.xml.sax.SAXException)1 XMLReader (org.xml.sax.XMLReader)1