Search in sources :

Example 6 with ProtocolEffectRecord

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

the class ProtocolEffectRecord2SubstanceProperty method process.

@Override
public SubstanceProperty process(ProtocolEffectRecord<String, IParams, String> detail) throws Exception {
    SubstanceProperty key = new SubstanceProperty(detail.getProtocol().getTopCategory(), detail.getProtocol().getCategory(), detail.getEndpoint() == null ? "interpretation_result" : detail.getEndpoint(), detail.getUnit(), getReference(detail));
    key.setExtendedURI(true);
    key.setIdentifier(detail.getSampleID());
    key.setAnnotations(conditions2annotations(detail));
    try {
        key.setStudyResultType(_r_flags.valueOf(detail.getStudyResultType().replace(":", "").replace("_", "").replace(" ", "").replace("-", "").replace(")", "").replace("(", "")));
    } catch (Exception x) {
        key.setStudyResultType(null);
    }
    return key;
}
Also used : SubstanceProperty(ambit2.base.data.substance.SubstanceProperty) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 7 with ProtocolEffectRecord

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

the class ProtocolEffectRecord2SubstanceProperty method processValue.

public static Value processValue(ProtocolEffectRecord<String, String, String> detail, boolean istextvalue) {
    if (istextvalue) {
        Value<String> value = new Value<String>();
        if (detail.getTextValue() == null)
            if (detail.getInterpretationResult() == null)
                value.setLoValue("");
            else
                value.setLoValue(detail.getInterpretationResult());
        else
            value.setLoValue(detail.getTextValue().toString());
        return value;
    } else {
        Value value = new Value();
        value.setLoQualifier(detail.getLoQualifier());
        value.setUpQualifier(detail.getUpQualifier());
        value.setUpValue(detail.getUpValue());
        value.setLoValue(detail.getLoValue());
        return value;
    }
}
Also used : MultiValue(ambit2.base.data.study.MultiValue) Value(ambit2.base.data.study.Value)

Example 8 with ProtocolEffectRecord

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

the class CallableSubstancePropertyCreatorTest method testCreateSubstancePropertyFromRDF.

@Test
public void testCreateSubstancePropertyFromRDF() throws Exception {
    URL url = getClass().getClassLoader().getResource("feature.rdf");
    File file = new File(url.getFile());
    Assert.assertTrue(file.exists());
    try {
        PropertyURIReporter reporter = new PropertyURIReporter(new Reference("http://localhost:8081/ambit2"));
        CallableSubstancePropertyCreator callable = new CallableSubstancePropertyCreator(reporter, Method.POST, file, MediaType.APPLICATION_RDF_XML, null, null);
        TaskResult task = callable.call();
        ProtocolEffectRecord2SubstanceProperty p = new ProtocolEffectRecord2SubstanceProperty();
        ProtocolEffectRecord<String, IParams, String> effect = new ProtocolEffectRecord<String, IParams, String>();
        Protocol protocol = new Protocol(null);
        Protocol._categories category = Protocol._categories.EC_DAPHNIATOX_SECTION;
        protocol.setCategory(category.name());
        protocol.setTopCategory(category.getTopCategory());
        protocol.addGuideline("http://localhost:8080/ambit2/dataset/Method%3A+other%3A+Am.+Soc.+Test.+Mater.+%281980%29+and+U.S.+EPA+%281975%29");
        effect.setProtocol(protocol);
        effect.setEndpoint("EC10");
        effect.setUnit("mg/L");
        effect.setConditions(new Params());
        /*
			 * Value value = new Value(); value.setLoValue(48.0);
			 * value.setUnits("h"); effect.getConditions().put("Exposure",
			 * value);
			 */
        SubstanceProperty prop = p.process(effect);
        prop.setIdentifier(prop.createHashedIdentifier(effect.getConditions()));
        Assert.assertEquals(reporter.getURI(prop), task.getUri());
    } catch (Exception x) {
        throw x;
    } finally {
    }
}
Also used : Reference(org.restlet.data.Reference) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) Params(ambit2.base.data.study.Params) IParams(ambit2.base.data.study.IParams) URL(java.net.URL) PropertyURIReporter(ambit2.rest.property.PropertyURIReporter) ProtocolEffectRecord(ambit2.base.data.study.ProtocolEffectRecord) TaskResult(net.idea.restnet.i.task.TaskResult) IParams(ambit2.base.data.study.IParams) SubstanceProperty(ambit2.base.data.substance.SubstanceProperty) ProtocolEffectRecord2SubstanceProperty(ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty) CallableSubstancePropertyCreator(ambit2.rest.substance.property.CallableSubstancePropertyCreator) Protocol(ambit2.base.data.study.Protocol) File(java.io.File) DbUnitTest(net.idea.restnet.db.test.DbUnitTest) Test(org.junit.Test)

Example 9 with ProtocolEffectRecord

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

the class BundleMatrixResource method processValue.

@Override
protected Value processValue(ProtocolEffectRecord<String, String, String> detail, boolean istextvalue) {
    ValueAnnotated value = null;
    if (istextvalue) {
        if (detail.getTextValue() == null) {
            if (detail.getInterpretationResult() != null && !"".equals(detail.getInterpretationResult().trim())) {
                value = new ValueAnnotated<Object, String>();
                value.setTextValue(detail.getInterpretationResult());
                value.setIdresult(detail.getDocumentUUID());
                if (detail instanceof ProtocolEffectRecordMatrix)
                    try {
                        value.setCopied(((ProtocolEffectRecordMatrix) detail).isProtocolapp_copied());
                        value.setDeleted(((ProtocolEffectRecordMatrix) detail).isProtocolapp_deleted());
                        value.setRemark(((ProtocolEffectRecordMatrix) detail).getProtocolapp_remarks());
                    } catch (Exception x) {
                    }
                return value;
            } else {
            }
        // now why should we care about empty values?
        // else value.setTextValue("");
        } else {
            value = new ValueAnnotated<Object, Integer>();
            value.setTextValue(detail.getTextValue().toString());
            value.setIdresult(detail.getIdresult());
        }
    } else {
        value = new ValueAnnotated<Object, Integer>();
        value.setLoQualifier(detail.getLoQualifier());
        value.setUpQualifier(detail.getUpQualifier());
        value.setUpValue(detail.getUpValue());
        value.setLoValue(detail.getLoValue());
        value.setIdresult(detail.getIdresult());
    }
    if (value != null)
        if (detail instanceof ProtocolEffectRecordMatrix)
            try {
                value.setCopied(((ProtocolEffectRecordMatrix) detail).isCopied());
                value.setDeleted(((ProtocolEffectRecordMatrix) detail).isDeleted());
                value.setRemark(((ProtocolEffectRecordMatrix) detail).getRemarks());
            } catch (Exception x) {
            }
    return value;
}
Also used : ValueAnnotated(ambit2.base.data.study.ValueAnnotated) ProtocolEffectRecordMatrix(ambit2.base.data.study.ProtocolEffectRecordMatrix) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) ResourceException(org.restlet.resource.ResourceException)

Aggregations

SubstanceProperty (ambit2.base.data.substance.SubstanceProperty)4 ILiteratureEntry (ambit2.base.data.ILiteratureEntry)3 IParams (ambit2.base.data.study.IParams)3 Protocol (ambit2.base.data.study.Protocol)3 ProtocolEffectRecord (ambit2.base.data.study.ProtocolEffectRecord)3 Value (ambit2.base.data.study.Value)3 ProtocolEffectRecord2SubstanceProperty (ambit2.core.io.study.ProtocolEffectRecord2SubstanceProperty)3 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)3 ResourceException (org.restlet.resource.ResourceException)3 LiteratureEntry (ambit2.base.data.LiteratureEntry)2 MultiValue (ambit2.base.data.study.MultiValue)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 StringReader (java.io.StringReader)2 PropertyAnnotation (ambit2.base.data.PropertyAnnotation)1 PropertyAnnotations (ambit2.base.data.PropertyAnnotations)1 SubstanceRecord (ambit2.base.data.SubstanceRecord)1 Params (ambit2.base.data.study.Params)1 ProtocolEffectRecordMatrix (ambit2.base.data.study.ProtocolEffectRecordMatrix)1 ValueAnnotated (ambit2.base.data.study.ValueAnnotated)1