Search in sources :

Example 11 with Process

use of org.n52.shetland.inspire.ompr.Process in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseSensorML.

@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private SensorML parseSensorML(final SensorMLDocument xbSensorML) throws DecodingException {
    final SensorML sensorML = new SensorML();
    // get member process
    for (final Member xbMember : xbSensorML.getSensorML().getMemberArray()) {
        if (xbMember.getProcess() != null) {
            if (xbMember.getProcess() instanceof AbstractProcessType) {
                final AbstractProcessType xbAbstractProcess = xbMember.getProcess();
                AbstractProcess abstractProcess = null;
                if (xbAbstractProcess.schemaType() == SystemType.type) {
                    abstractProcess = parseSystem((SystemType) xbAbstractProcess);
                } else if (xbAbstractProcess.schemaType() == ProcessModelType.type) {
                    abstractProcess = parseProcessModel((ProcessModelType) xbAbstractProcess);
                } else if (xbAbstractProcess.schemaType() == ComponentType.type) {
                    abstractProcess = parseComponent((ComponentType) xbAbstractProcess);
                } else {
                    throw unsupportedMemberProcess(xbMember);
                }
                sensorML.addMember(abstractProcess);
            } else {
                throw unsupportedMemberProcess(xbMember);
            }
        } else {
            throw new DecodingException(XmlHelper.getLocalName(xbMember), "The process of a member of the SensorML Document is null (%s)!", xbMember.getProcess());
        }
    }
    sensorML.setXml(xbSensorML.xmlText(getXmlOptions()));
    return sensorML;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) AbstractComponentType(net.opengis.sensorML.x101.AbstractComponentType) AbstractDerivableComponentType(net.opengis.sensorML.x101.AbstractDerivableComponentType) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 12 with Process

use of org.n52.shetland.inspire.ompr.Process in project arctic-sea by 52North.

the class ProcessTypeEncoder method createProcess.

protected ProcessType createProcess(Process process) throws EncodingException {
    if (process.isSetXml()) {
        XmlObject encodedObject = null;
        try {
            encodedObject = XmlObject.Factory.parse(process.getXml());
            if (encodedObject instanceof ProcessType) {
                ProcessType pt = (ProcessType) encodedObject;
                checkForInspireId(pt, process);
                return pt;
            } else if (encodedObject instanceof ProcessDocument) {
                return ((ProcessDocument) encodedObject).getProcess();
            } else if (encodedObject instanceof ProcessPropertyType) {
                return ((ProcessPropertyType) encodedObject).getProcess();
            } else {
                throw new UnsupportedEncoderInputException(this, process);
            }
        } catch (final XmlException xmle) {
            throw new EncodingException(xmle);
        }
    } else {
        ProcessType pt = ProcessType.Factory.newInstance();
        if (!process.isSetGmlID()) {
            process.setGmlId("p_" + JavaHelper.generateID(process.toString()));
        }
        pt.setId(process.getGmlId());
        addInspireId(pt, process);
        addName(pt, process);
        addType(pt, process);
        addDocumentation(pt, process);
        addProcessParameter(pt, process);
        addResponsibleParty(pt, process);
        return pt;
    }
}
Also used : ProcessType(eu.europa.ec.inspire.schemas.ompr.x30.ProcessType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) ProcessPropertyType(eu.europa.ec.inspire.schemas.ompr.x30.ProcessPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) ProcessDocument(eu.europa.ec.inspire.schemas.ompr.x30.ProcessDocument) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 13 with Process

use of org.n52.shetland.inspire.ompr.Process in project arctic-sea by 52North.

the class AbstractProcessDecoder method parseProcessType.

protected Process parseProcessType(ProcessType pt) {
    Process process = new Process();
    parseInspireId(pt, process);
    return process;
}
Also used : Process(org.n52.shetland.inspire.ompr.Process)

Example 14 with Process

use of org.n52.shetland.inspire.ompr.Process in project arctic-sea by 52North.

the class AbstractProcessDecoder method parseInspireId.

private void parseInspireId(ProcessType pt, Process process) {
    IdentifierType identifier = pt.getInspireId().getIdentifier();
    String localId = identifier.getLocalId();
    String namespace = identifier.getNamespace();
    CodeWithAuthority codeWithAuthority;
    if (localId.contains(namespace)) {
        codeWithAuthority = new CodeWithAuthority(localId, namespace);
    } else {
        codeWithAuthority = new CodeWithAuthority(getIdentifier(localId, namespace), namespace);
    }
    process.setIdentifier(codeWithAuthority);
}
Also used : CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) IdentifierType(eu.europa.ec.inspire.schemas.base.x33.IdentifierType)

Example 15 with Process

use of org.n52.shetland.inspire.ompr.Process in project arctic-sea by 52North.

the class TrajectoryObservationTypeEncoderTest method createObservation.

private OmObservation createObservation() throws DecodingException, XmlException, IOException {
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TrajectoryObservation observation = new TrajectoryObservation();
    observation.setObservationID("123");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
    OmObservableProperty observableProperty = new OmObservableProperty(OBSERVABLE_PROPERTY);
    observationConstellation.setObservableProperty(observableProperty);
    observationConstellation.addOffering(OFFERING);
    Process procedure = createProcessFromFile();
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setResultTime(resultTime);
    return observation;
}
Also used : TrajectoryObservation(org.n52.shetland.inspire.omso.TrajectoryObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) Process(org.n52.shetland.inspire.ompr.Process) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Aggregations

Process (org.n52.shetland.inspire.ompr.Process)9 XmlObject (org.apache.xmlbeans.XmlObject)6 Test (org.junit.Test)3 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)2 AbtractProcessDecodingTest (org.n52.svalbard.decode.AbtractProcessDecodingTest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IdentifierType (eu.europa.ec.inspire.schemas.base.x33.IdentifierType)1 ProcessDocument (eu.europa.ec.inspire.schemas.ompr.x30.ProcessDocument)1 ProcessPropertyType (eu.europa.ec.inspire.schemas.ompr.x30.ProcessPropertyType)1 ProcessType (eu.europa.ec.inspire.schemas.ompr.x30.ProcessType)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 AbstractComponentType (net.opengis.sensorML.x101.AbstractComponentType)1 AbstractDerivableComponentType (net.opengis.sensorML.x101.AbstractDerivableComponentType)1 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)1 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)1 ComponentType (net.opengis.sensorML.x101.ComponentType)1