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;
}
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;
}
}
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;
}
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);
}
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;
}
Aggregations