Search in sources :

Example 1 with PropertyKey

use of ambit2.core.processors.structure.key.PropertyKey in project ambit-mirror by ideaconsult.

the class PropertyImporter method setPropertyKey.

public void setPropertyKey(IStructureKey propertyKey) {
    this.queryKey = propertyKey;
    if ((propertyKey instanceof SmilesKey) || (propertyKey instanceof InchiKey)) {
        query_property = new QueryStructure();
    } else if ((propertyKey.getType() == Number.class) || (propertyKey.getType() == Integer.class) || (propertyKey.getType() == Double.class))
        query_property = new QueryFieldNumeric();
    else
        query_property = new QueryField();
    query_property.setId(-1);
}
Also used : QueryField(ambit2.db.search.structure.QueryField) QueryStructure(ambit2.db.search.structure.QueryStructure) SmilesKey(ambit2.core.processors.structure.key.SmilesKey) QueryFieldNumeric(ambit2.db.search.structure.QueryFieldNumeric) InchiKey(ambit2.core.processors.structure.key.InchiKey)

Example 2 with PropertyKey

use of ambit2.core.processors.structure.key.PropertyKey in project ambit-mirror by ideaconsult.

the class RepositoryWriterToXMLTest method write.

public int write(IRawReader<IStructureRecord> reader, Connection connection, PropertyKey key) throws Exception {
    RepositoryWriter writer = new RepositoryWriter();
    if (key != null)
        writer.setPropertyKey(key);
    writer.setDataset(new SourceDataset("TEST INPUT", LiteratureEntry.getInstance("File", "file:study.toxml")));
    writer.setConnection(connection);
    writer.open();
    int records = 0;
    while (reader.hasNext()) {
        IStructureRecord record = reader.nextRecord();
        writer.write(record);
        records++;
    }
    reader.close();
    writer.close();
    return records;
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) RepositoryWriter(ambit2.db.processors.RepositoryWriter) SourceDataset(ambit2.base.data.SourceDataset)

Example 3 with PropertyKey

use of ambit2.core.processors.structure.key.PropertyKey in project ambit-mirror by ideaconsult.

the class SubstanceWriterTest method write.

public int write(SubstanceEndpointsBundle bundle, IRawReader<IStructureRecord> reader, Connection connection, PropertyKey key, boolean splitRecord, boolean clearMeasurements, boolean clearComposition) throws Exception {
    DBSubstanceWriter writer;
    if (bundle != null)
        writer = new DBBundleStudyWriter(bundle, DBSubstanceWriter.datasetMeta(), new SubstanceRecord());
    else
        writer = new DBSubstanceWriter(DBSubstanceWriter.datasetMeta(), new SubstanceRecord(), clearMeasurements, clearComposition);
    writer.setSplitRecord(splitRecord);
    writer.setConnection(connection);
    writer.open();
    int records = 0;
    while (reader.hasNext()) {
        Object record = reader.next();
        if (record == null)
            continue;
        Assert.assertTrue(record instanceof IStructureRecord);
        if (record instanceof SubstanceRecord)
            writer.setImportedRecord((SubstanceRecord) record);
        writer.process((IStructureRecord) record);
        records++;
    }
    writer.close();
    return records;
}
Also used : DBSubstanceWriter(ambit2.db.substance.processor.DBSubstanceWriter) IStructureRecord(ambit2.base.interfaces.IStructureRecord) DBBundleStudyWriter(ambit2.db.substance.processor.DBBundleStudyWriter) SubstanceRecord(ambit2.base.data.SubstanceRecord)

Example 4 with PropertyKey

use of ambit2.core.processors.structure.key.PropertyKey in project ambit-mirror by ideaconsult.

the class RepositoryWriterTest method write.

public int write(IRawReader<IStructureRecord> reader, Connection connection, PropertyKey key, boolean useExistingStructure, int maxrecords) throws Exception {
    RepositoryWriter writer = new RepositoryWriter();
    writer.setUseExistingStructure(useExistingStructure);
    if (key != null)
        writer.setPropertyKey(key);
    writer.setDataset(new SourceDataset("TEST INPUT", LiteratureEntry.getInstance("File", "file:input.sdf")));
    writer.setConnection(connection);
    writer.open();
    int records = 0;
    while (reader.hasNext()) {
        IStructureRecord record = reader.nextRecord();
        writer.write(record);
        records++;
        if (maxrecords <= 0 || (records <= maxrecords))
            continue;
        else
            break;
    }
    reader.close();
    writer.close();
    return records;
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) RepositoryWriter(ambit2.db.processors.RepositoryWriter) SourceDataset(ambit2.base.data.SourceDataset)

Example 5 with PropertyKey

use of ambit2.core.processors.structure.key.PropertyKey in project ambit-mirror by ideaconsult.

the class NanoWriterTest method write.

public int write(IRawReader<IStructureRecord> reader, Connection connection, PropertyKey key) throws Exception {
    RepositoryWriter writer = new RepositoryWriter();
    if (key != null)
        writer.setPropertyKey(key);
    writer.setDataset(new SourceDataset("TEST INPUT", LiteratureEntry.getInstance("File", "file:input.nmx")));
    writer.setConnection(connection);
    writer.open();
    int records = 0;
    while (reader.hasNext()) {
        IStructureRecord record = reader.nextRecord();
        writer.write(record);
        records++;
    }
    reader.close();
    writer.close();
    return records;
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) RepositoryWriter(ambit2.db.processors.RepositoryWriter) SourceDataset(ambit2.base.data.SourceDataset)

Aggregations

IStructureRecord (ambit2.base.interfaces.IStructureRecord)11 SourceDataset (ambit2.base.data.SourceDataset)6 RepositoryWriter (ambit2.db.processors.RepositoryWriter)6 SubstanceRecord (ambit2.base.data.SubstanceRecord)5 DBSubstanceWriter (ambit2.db.substance.processor.DBSubstanceWriter)5 ILiteratureEntry (ambit2.base.data.ILiteratureEntry)2 PropertyKey (ambit2.core.processors.structure.key.PropertyKey)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 SQLException (java.sql.SQLException)2 OperationNotSupportedException (javax.naming.OperationNotSupportedException)2 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 StructureRecord (ambit2.base.data.StructureRecord)1 InchiKey (ambit2.core.processors.structure.key.InchiKey)1 ReferenceSubstanceUUID (ambit2.core.processors.structure.key.ReferenceSubstanceUUID)1 SmilesKey (ambit2.core.processors.structure.key.SmilesKey)1 QueryField (ambit2.db.search.structure.QueryField)1 QueryFieldNumeric (ambit2.db.search.structure.QueryFieldNumeric)1 QueryStructure (ambit2.db.search.structure.QueryStructure)1