Search in sources :

Example 1 with ProtocolApplicationAnnotated

use of ambit2.base.data.study.ProtocolApplicationAnnotated in project ambit-mirror by ideaconsult.

the class SubstanceStudyParser method parseReliability.

// ProtocolApplicationAnnotated
protected void parseReliability(ObjectNode node, ProtocolApplication record) {
    if (node == null)
        return;
    ReliabilityParams reliability = new ReliabilityParams();
    JsonNode jn = node.get(_FIELDS_RELIABILITY.r_isUsedforMSDS.name());
    try {
        reliability.setIsUsedforMSDS(jn.asBoolean());
    } catch (Exception x) {
    }
    jn = node.get(_FIELDS_RELIABILITY.r_isRobustStudy.name());
    try {
        reliability.setIsRobustStudy(jn.asBoolean());
    } catch (Exception x) {
    }
    jn = node.get(_FIELDS_RELIABILITY.r_isUsedforClassification.name());
    try {
        reliability.setIsUsedforClassification(jn.asBoolean());
    } catch (Exception x) {
    }
    jn = node.get(_FIELDS_RELIABILITY.r_purposeFlag.name());
    try {
        reliability.setPurposeFlag(jn.textValue());
    } catch (Exception x) {
    }
    jn = node.get(_FIELDS_RELIABILITY.r_studyResultType.name());
    try {
        reliability.setStudyResultType(jn.textValue());
    } catch (Exception x) {
    }
    jn = node.get(_FIELDS_RELIABILITY.r_value.name());
    try {
        reliability.setValue(jn.textValue());
    } catch (Exception x) {
    }
    record.setReliability(reliability);
}
Also used : ReliabilityParams(ambit2.base.data.study.ReliabilityParams) JsonNode(com.fasterxml.jackson.databind.JsonNode) CDKException(org.openscience.cdk.exception.CDKException) IOException(java.io.IOException)

Example 2 with ProtocolApplicationAnnotated

use of ambit2.base.data.study.ProtocolApplicationAnnotated in project ambit-mirror by ideaconsult.

the class SubstanceWriterTest method delete.

public int delete(SubstanceEndpointsBundle bundle, IRawReader<IStructureRecord> reader, Connection connection) 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();
		 */
    UpdateExecutor<IQueryUpdate> writer = new UpdateExecutor<IQueryUpdate>();
    writer.setConnection(connection);
    DeleteMatrixValue q = new DeleteMatrixValue();
    q.setGroup(bundle);
    int records = 0;
    while (reader.hasNext()) {
        Object record = reader.next();
        if (record == null)
            continue;
        Assert.assertTrue(record instanceof SubstanceRecord);
        Assert.assertEquals("IUC4-efdb21bb-e79f-3286-a988-b6f6944d3734", ((SubstanceRecord) record).getSubstanceUUID());
        for (ProtocolApplication pa : ((SubstanceRecord) record).getMeasurements()) {
            Assert.assertTrue(pa instanceof ProtocolApplicationAnnotated);
            // System.out.println(((ProtocolApplicationAnnotated) pa)getRecords_to_delete());
            ProtocolApplicationAnnotated paa = (ProtocolApplicationAnnotated) pa;
            List<ValueAnnotated> vaa = paa.getRecords_to_delete();
            for (ValueAnnotated va : vaa) {
                q.setObject(va);
                writer.process(q);
            }
        }
        // writer.setImportedRecord((SubstanceRecord) record);
        // writer.process((IStructureRecord) record);
        records++;
    }
    writer.close();
    return records;
}
Also used : DeleteMatrixValue(ambit2.db.update.bundle.matrix.DeleteMatrixValue) ProtocolApplication(ambit2.base.data.study.ProtocolApplication) UpdateExecutor(net.idea.modbcum.p.UpdateExecutor) ValueAnnotated(ambit2.base.data.study.ValueAnnotated) SubstanceRecord(ambit2.base.data.SubstanceRecord) IQueryUpdate(net.idea.modbcum.i.query.IQueryUpdate) ProtocolApplicationAnnotated(ambit2.base.data.study.ProtocolApplicationAnnotated)

Example 3 with ProtocolApplicationAnnotated

use of ambit2.base.data.study.ProtocolApplicationAnnotated in project ambit-mirror by ideaconsult.

the class SubstanceStudyParser method parseProtocolApplication.

public ProtocolApplication parseProtocolApplication(ObjectNode node) {
    if (node == null)
        return null;
    ProtocolApplication pa = null;
    if (node.get("effects_to_delete") == null) {
        Protocol protocol = parseProtocol((ObjectNode) node.get(ProtocolApplication._fields.protocol.name()));
        pa = new ProtocolApplication(protocol);
        JsonNode docuuid = node.get(ProtocolApplication._fields.uuid.name());
        pa.setDocumentUUID(docuuid == null ? null : docuuid.textValue());
        parseOwner((ObjectNode) node.get(ProtocolApplication._fields.owner.name()), pa);
        parseStudyReference((ObjectNode) node.get(ProtocolApplication._fields.citation.name()), pa);
        parseReliability((ObjectNode) node.get(ProtocolApplication._fields.reliability.name()), pa);
        parseInterpretation((ObjectNode) node.get(ProtocolApplication._fields.interpretation.name()), pa);
        pa.setEffects(parseEffects((ArrayNode) node.get(ProtocolApplication._fields.effects.name()), protocol));
        pa.setParameters(parseParams((ObjectNode) node.get(ProtocolApplication._fields.parameters.name())));
    } else {
        Protocol protocol = parseProtocol((ObjectNode) node.get(ProtocolApplication._fields.protocol.name()));
        pa = new ProtocolApplicationAnnotated(protocol);
        ((ProtocolApplicationAnnotated) pa).setRecords_to_delete(parseValuesAnnotated((ArrayNode) node.get("effects_to_delete"), protocol));
    }
    return pa;
}
Also used : ProtocolApplication(ambit2.base.data.study.ProtocolApplication) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ProtocolApplicationAnnotated(ambit2.base.data.study.ProtocolApplicationAnnotated) Protocol(ambit2.base.data.study.Protocol)

Aggregations

ProtocolApplication (ambit2.base.data.study.ProtocolApplication)2 ProtocolApplicationAnnotated (ambit2.base.data.study.ProtocolApplicationAnnotated)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 SubstanceRecord (ambit2.base.data.SubstanceRecord)1 Protocol (ambit2.base.data.study.Protocol)1 ReliabilityParams (ambit2.base.data.study.ReliabilityParams)1 ValueAnnotated (ambit2.base.data.study.ValueAnnotated)1 DeleteMatrixValue (ambit2.db.update.bundle.matrix.DeleteMatrixValue)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 IQueryUpdate (net.idea.modbcum.i.query.IQueryUpdate)1 UpdateExecutor (net.idea.modbcum.p.UpdateExecutor)1 CDKException (org.openscience.cdk.exception.CDKException)1