use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.
the class AbstractXmlResponseEncoder method encode.
@Override
public XmlObject encode(T response, EncodingContext additionalValues) throws EncodingException {
if (response == null) {
throw new UnsupportedEncoderInputException(this, (String) null);
}
XmlObject xml = create(response);
setSchemaLocations(xml);
if (validate) {
XmlHelper.validateDocument(xml, EncodingException::new);
}
return xml;
}
use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.
the class EnvironmentalMonitoringFaciltityDocumentEncoder method encode.
@Override
public XmlObject encode(AbstractFeature abstractFeature, EncodingContext context) throws EncodingException {
if (abstractFeature instanceof EnvironmentalMonitoringFacility) {
EnvironmentalMonitoringFacilityDocument emfpd = EnvironmentalMonitoringFacilityDocument.Factory.newInstance();
emfpd.setEnvironmentalMonitoringFacility(createEnvironmentalMonitoringFaciltityType((EnvironmentalMonitoringFacility) abstractFeature));
return emfpd;
}
throw new UnsupportedEncoderInputException(this, abstractFeature);
}
use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.
the class DeleteObservationEncoder method create.
@Override
protected XmlObject create(DeleteObservationResponse dor) throws EncodingException {
if (dor == null) {
throw new UnsupportedEncoderInputException(this, DeleteObservationResponse.class);
}
String observationId = dor.getObservationId();
DeleteObservationResponseDocument xbDeleteObsDoc = DeleteObservationResponseDocument.Factory.newInstance(getXmlOptions());
DeleteObservationResponseType xbDeleteObservationResponse = xbDeleteObsDoc.addNewDeleteObservationResponse();
xbDeleteObservationResponse.setDeletedObservation(observationId);
return xbDeleteObsDoc;
}
use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.
the class SamplingEncoderv100 method createFeature.
private XmlObject createFeature(AbstractFeature absFeature) throws EncodingException {
if (absFeature instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sampFeat = (AbstractSamplingFeature) absFeature;
if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGPOINT) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT) || sampFeat.getGeometry() instanceof Point) {
SamplingPointDocument xbSamplingPointDoc = SamplingPointDocument.Factory.newInstance(getXmlOptions());
SamplingPointType xbSamplingPoint = xbSamplingPointDoc.addNewSamplingPoint();
addValuesToFeature(xbSamplingPoint, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingPoint.addNewPosition().addNewPoint().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingPointDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGCURVE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE) || sampFeat.getGeometry() instanceof LineString) {
SamplingCurveDocument xbSamplingCurveDoc = SamplingCurveDocument.Factory.newInstance(getXmlOptions());
SamplingCurveType xbSamplingCurve = xbSamplingCurveDoc.addNewSamplingCurve();
addValuesToFeature(xbSamplingCurve, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingCurve.addNewShape().addNewCurve().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingCurveDoc;
} else if (sampFeat.getFeatureType().equals(SfConstants.FT_SAMPLINGSURFACE) || sampFeat.getFeatureType().equals(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_SURFACE) || sampFeat.getGeometry() instanceof Polygon) {
SamplingSurfaceDocument xbSamplingSurfaceDoc = SamplingSurfaceDocument.Factory.newInstance(getXmlOptions());
SamplingSurfaceType xbSamplingSurface = xbSamplingSurfaceDoc.addNewSamplingSurface();
addValuesToFeature(xbSamplingSurface, sampFeat);
XmlObject xbGeomety = getEncodedGeometry(sampFeat.getGeometry(), absFeature.getGmlId());
xbSamplingSurface.addNewShape().addNewSurface().set(xbGeomety);
sampFeat.wasEncoded();
return xbSamplingSurfaceDoc;
}
} else if (absFeature instanceof FeatureCollection) {
createFeatureCollection((FeatureCollection) absFeature);
}
throw new UnsupportedEncoderInputException(this, absFeature);
}
use of org.n52.svalbard.encode.exception.UnsupportedEncoderInputException in project arctic-sea by 52North.
the class SweCommonEncoderv101 method encode.
@Override
public XmlObject encode(Object element, EncodingContext context) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof SweAbstractSimpleType) {
encodedObject = createSimpleType((SweAbstractSimpleType<?>) element, context);
// }
// if (element instanceof SweBoolean) {
// encodedObject = createBoolean((SweBoolean) element);
// } else if (element instanceof SweCategory) {
// encodedObject = createCategory((SweCategory) element);
// } else if (element instanceof SweCount) {
// encodedObject = createCount((SweCount) element);
// } else if (element instanceof SweObservableProperty) {
// encodedObject = createObservableProperty((SweObservableProperty)
// element);
// } else if (element instanceof SweQuantity) {
// encodedObject = createQuantity((SweQuantity) element);
// } else if (element instanceof SweQuantityRange) {
// encodedObject = createQuantityRange((SweQuantityRange) element);
// } else if (element instanceof SweText) {
// encodedObject = createText((SweText) element);
// } else if (element instanceof SweTime) {
// encodedObject = createTime((SweTime) element);
// } else if (element instanceof SweTimeRange) {
// encodedObject = createTimeRange((SweTimeRange) element);
} else if (element instanceof SweCoordinate) {
encodedObject = createCoordinate((SweCoordinate<?>) element);
} else if (element instanceof SweDataArray) {
encodedObject = createDataArray((SweDataArray) element);
} else if (element instanceof SweDataRecord) {
DataRecordType drt = createDataRecord((SweDataRecord) element);
if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
DataRecordDocument drd = DataRecordDocument.Factory.newInstance(getXmlOptions());
drd.setDataRecord(drt);
encodedObject = drd;
} else {
encodedObject = drt;
}
} else if (element instanceof SweEnvelope) {
encodedObject = createEnvelope((SweEnvelope) element);
} else if (element instanceof SweSimpleDataRecord) {
encodedObject = createSimpleDataRecord((SweSimpleDataRecord) element);
} else if (element instanceof TimePeriod) {
encodedObject = createTimeGeometricPrimitivePropertyType((TimePeriod) element);
} else {
throw new UnsupportedEncoderInputException(this, element);
}
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
Aggregations