use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractMonitoringObjectEncoder method setBroader.
private void setBroader(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
if (abstractMonitoringObject.isSetBroader()) {
Hierarchy broader = abstractMonitoringObject.getBroader();
if (broader.isSetSimpleAttrs()) {
Broader b = amot.addNewBroader();
b.setHref(broader.getSimpleAttrs().getHref());
if (broader.getSimpleAttrs().isSetTitle()) {
b.setTitle(broader.getSimpleAttrs().getTitle());
}
} else {
amot.addNewBroader().addNewHierarchy().set(encodeEF(broader));
}
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractMonitoringObjectEncoder method setSupersedes.
private void setSupersedes(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
if (abstractMonitoringObject.isSetSupersedes()) {
for (AbstractMonitoringObject supersedes : abstractMonitoringObject.getSupersedes()) {
if (supersedes.isSetSimpleAttrs()) {
Supersedes s = amot.addNewSupersedes();
s.setHref(supersedes.getSimpleAttrs().getHref());
if (supersedes.getSimpleAttrs().isSetTitle()) {
s.setTitle(supersedes.getSimpleAttrs().getTitle());
}
} else {
amot.addNewSupersedes().addNewAbstractMonitoringObject().set(encodeEF(supersedes));
}
}
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method encode.
@Override
public void encode(Object objectToEncode, OutputStream outputStream, EncodingContext ctx) throws EncodingException {
try {
XmlOptions xmlOptions = getXmlOptions();
if (ctx.has(StreamingEncoderFlags.EMBEDDED)) {
xmlOptions.setSaveNoXmlDecl();
}
encode(objectToEncode, ctx.with(StreamingEncoderFlags.ENCODER, this)).save(outputStream, xmlOptions);
} catch (IOException ioe) {
throw new EncodingException("Error while writing element to stream!", ioe);
} finally {
if (ctx.has(StreamingEncoderFlags.EMBEDDED)) {
getXmlOptions().remove(XmlOptions.SAVE_NO_XML_DECL);
}
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof OmObservation) {
encodedObject = encodeOmObservation((OmObservation) element, additionalValues);
} else if (element instanceof NamedValue) {
NamedValueType nvt = createNamedValue((NamedValue<?>) element);
if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
NamedValueDocument nvd = NamedValueDocument.Factory.newInstance();
nvd.setNamedValue(nvt);
encodedObject = nvd;
} else if (additionalValues.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
NamedValuePropertyType nvpt = NamedValuePropertyType.Factory.newInstance();
nvpt.setNamedValue(nvt);
encodedObject = nvpt;
} else {
encodedObject = nvt;
}
} else if (element instanceof AbstractFeature) {
encodedObject = encodeFeatureOfInterest((AbstractFeature) element);
} else if (element instanceof SosProcedureDescription) {
encodedObject = encodeProcedureDescription((SosProcedureDescription<?>) element);
} else {
throw new UnsupportedEncoderInputException(this, element);
}
// XmlHelper.validateDocument(encodedObject));
return encodedObject;
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method setValidTime.
private void setValidTime(OmObservation observation, OMObservationType xb) throws EncodingException {
Time validTime = observation.getValidTime();
if (validTime == null) {
return;
}
if (validTime.getGmlId() == null) {
validTime.setGmlId(OmConstants.VALID_TIME_NAME + "_" + observation.getObservationID());
}
xb.addNewValidTime().addNewTimePeriod().set(encodeGML(validTime));
}
Aggregations