use of org.n52.shetland.ogc.swe.simpleType.SweObservableProperty 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;
}
use of org.n52.shetland.ogc.swe.simpleType.SweObservableProperty in project arctic-sea by 52North.
the class SweHelper method createBlock.
@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private List<String> createBlock(SweAbstractDataComponent elementType, Time phenomenonTime, String phenID, Value<?> value) {
if (elementType instanceof SweDataRecord) {
SweDataRecord elementTypeRecord = (SweDataRecord) elementType;
List<String> block = new ArrayList<>(elementTypeRecord.getFields().size());
if (!(value instanceof NilTemplateValue)) {
elementTypeRecord.getFields().forEach(field -> {
if (field.getElement() instanceof SweTime || field.getElement() instanceof SweTimeRange) {
block.add(DateTimeHelper.format(phenomenonTime));
} else if (field.getElement() instanceof SweAbstractDataComponent && field.getElement().getDefinition().equals(phenID)) {
block.add(value.getValue().toString());
} else if (field.getElement() instanceof SweObservableProperty) {
block.add(phenID);
}
});
}
return block;
}
String exceptionMsg = String.format("Type of ElementType is not supported: %s", elementType != null ? elementType.getClass().getName() : "null");
LOGGER.debug(exceptionMsg);
throw new IllegalArgumentException(exceptionMsg);
}
use of org.n52.shetland.ogc.swe.simpleType.SweObservableProperty in project arctic-sea by 52North.
the class FieldDecoderTest method testObservablePropertyWithValue.
@Test
public void testObservablePropertyWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.OBSERVABLE_PROPERTY_TYPE).put(JSONConstants.VALUE, OBSERVED_PROPERTY_VALUE);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweObservableProperty.class)));
SweObservableProperty swe = (SweObservableProperty) field.getElement();
errors.checkThat(swe.getValue(), is(OBSERVED_PROPERTY_VALUE));
}
use of org.n52.shetland.ogc.swe.simpleType.SweObservableProperty in project arctic-sea by 52North.
the class FieldDecoderTest method testObservableProperty.
@Test
public void testObservableProperty() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.OBSERVABLE_PROPERTY_TYPE);
SweField field = checkCommon(json, false);
assertThat(field.getElement(), is(instanceOf(SweObservableProperty.class)));
SweObservableProperty swe = (SweObservableProperty) field.getElement();
errors.checkThat(swe.getValue(), is(nullValue()));
}
use of org.n52.shetland.ogc.swe.simpleType.SweObservableProperty in project arctic-sea by 52North.
the class FieldEncoder method encodeSweObservableProperyField.
private ObjectNode encodeSweObservableProperyField(SweField field) {
ObjectNode jfield = createField(field);
jfield.put(JSONConstants.TYPE, JSONConstants.OBSERVABLE_PROPERTY_TYPE);
SweObservableProperty sweObservableProperty = (SweObservableProperty) field.getElement();
if (sweObservableProperty.isSetValue()) {
jfield.put(JSONConstants.VALUE, sweObservableProperty.getValue());
}
return jfield;
}
Aggregations