use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createParameters.
private Parameters createParameters(List<SmlParameter> smlParameters) throws EncodingException {
final Parameters parameters = Parameters.Factory.newInstance(getXmlOptions());
final ParameterListType parameterList = parameters.addNewParameterList();
for (SmlParameter smlParameter : smlParameters) {
Parameter param = parameterList.addNewParameter();
param.setName(smlParameter.getName());
if (smlParameter.isSetHref()) {
param.setHref(smlParameter.getHref());
if (smlParameter.isSetTitle()) {
param.setTitle(smlParameter.getTitle());
}
} else {
XmlObject xmlObject = encodeObjectToXmlSwe20(smlParameter.getParameter());
if (xmlObject != null) {
SweAbstractDataComponent parameter = smlParameter.getParameter();
if (parameter instanceof SmlDataInterface) {
substitute(param.addNewDataInterface(), xmlObject);
} else if (parameter instanceof SweObservableProperty) {
substitute(param.addNewObservableProperty(), xmlObject);
} else {
substitute(param.addNewAbstractDataComponent(), xmlObject);
}
}
}
}
return parameters;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseDataComponentPropertyType.
private SmlParameter parseDataComponentPropertyType(final DataComponentPropertyType xbDataComponentPropertyType) throws DecodingException {
final SmlParameter smlParameter = new SmlParameter();
smlParameter.setName(xbDataComponentPropertyType.getName());
XmlObject toDecode = null;
if (xbDataComponentPropertyType.isSetHref()) {
smlParameter.setHref(xbDataComponentPropertyType.getHref());
if (xbDataComponentPropertyType.isSetTitle()) {
smlParameter.setTitle(xbDataComponentPropertyType.getTitle());
}
return smlParameter;
}
if (xbDataComponentPropertyType.isSetBoolean()) {
toDecode = xbDataComponentPropertyType.getBoolean();
} else if (xbDataComponentPropertyType.isSetCategory()) {
toDecode = xbDataComponentPropertyType.getCategory();
} else if (xbDataComponentPropertyType.isSetCount()) {
toDecode = xbDataComponentPropertyType.getCount();
} else if (xbDataComponentPropertyType.isSetCountRange()) {
toDecode = xbDataComponentPropertyType.getCountRange();
} else if (xbDataComponentPropertyType.isSetQuantity()) {
toDecode = xbDataComponentPropertyType.getQuantity();
} else if (xbDataComponentPropertyType.isSetQuantityRange()) {
toDecode = xbDataComponentPropertyType.getQuantityRange();
} else if (xbDataComponentPropertyType.isSetText()) {
toDecode = xbDataComponentPropertyType.getText();
} else if (xbDataComponentPropertyType.isSetTime()) {
toDecode = xbDataComponentPropertyType.getTime();
} else if (xbDataComponentPropertyType.isSetTimeRange()) {
toDecode = xbDataComponentPropertyType.getTimeRange();
} else if (xbDataComponentPropertyType.isSetAbstractDataArray1()) {
toDecode = xbDataComponentPropertyType.getAbstractDataArray1();
} else if (xbDataComponentPropertyType.isSetAbstractDataRecord()) {
toDecode = xbDataComponentPropertyType.getAbstractDataRecord();
} else {
throw new DecodingException(XmlHelper.getLocalName(xbDataComponentPropertyType), "An 'DataComponentProperty' is not supported");
}
final Object decodedObject = decodeXmlElement(toDecode);
if (decodedObject instanceof SweAbstractDataComponent) {
smlParameter.setParameter((SweAbstractDataComponent) decodedObject);
} else {
throw new DecodingException(XmlHelper.getLocalName(xbDataComponentPropertyType), "The 'DataComponentProperty' with type '%s' as value for '%s' is not supported.", XmlHelper.getLocalName(toDecode), XmlHelper.getLocalName(xbDataComponentPropertyType));
}
return smlParameter;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createParameters.
private Parameters createParameters(List<SmlParameter> smlParameters) throws EncodingException {
final Parameters parameters = Parameters.Factory.newInstance(getXmlOptions());
ParameterList parameterList = parameters.addNewParameterList();
for (SmlParameter smlParameter : smlParameters) {
DataComponentPropertyType param = parameterList.addNewParameter();
param.setName(smlParameter.getName());
if (smlParameter.isSetHref()) {
param.setHref(smlParameter.getHref());
if (smlParameter.isSetTitle()) {
param.setTitle(smlParameter.getTitle());
}
} else {
SweAbstractDataComponent parameter = smlParameter.getParameter();
XmlObject xmlObject = encodeObjectToXml(SweConstants.NS_SWE_101, parameter);
if (xmlObject != null) {
if (parameter instanceof SweBoolean) {
param.addNewBoolean().set(xmlObject);
} else if (parameter instanceof SweCategory) {
param.addNewCategory().set(xmlObject);
} else if (parameter instanceof SweCount) {
param.addNewCount().set(xmlObject);
} else if (parameter instanceof SweQuantity) {
param.addNewQuantity().set(xmlObject);
} else if (parameter instanceof SweText) {
param.addNewText().set(xmlObject);
} else if (parameter instanceof SweTimeRange) {
param.addNewTimeRange().set(xmlObject);
} else if (parameter instanceof SweTime) {
param.addNewTime().set(xmlObject);
} else if (parameter instanceof SweEnvelope) {
param.addNewAbstractDataRecord().set(xmlObject);
param.getAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
} else if (parameter instanceof SweDataRecord) {
param.addNewAbstractDataRecord().set(xmlObject);
param.getAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
} else if (parameter instanceof SweSimpleDataRecord) {
param.addNewAbstractDataRecord().set(xmlObject);
param.getAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
} else if (parameter instanceof SweDataArray) {
param.addNewAbstractDataArray1().set(xmlObject);
param.getAbstractDataArray1().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
} else {
throw new UnsupportedEncoderInputException(this, parameter);
}
}
}
}
return parameters;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseSweParameter.
private SmlParameter parseSweParameter(Parameter xbParameter) throws DecodingException {
SmlParameter param = new SmlParameter();
String name = xbParameter.getName();
if (xbParameter.isSetHref()) {
param.setHref(xbParameter.getHref());
if (xbParameter.isSetTitle()) {
param.setTitle(xbParameter.getTitle());
}
return param;
}
Object parameter = decodeXmlElement(xbParameter.getAbstractDataComponent());
if (parameter instanceof SweAbstractDataComponent) {
if (xbParameter.getName() != null && !xbParameter.getName().isEmpty()) {
((SweAbstractDataComponent) parameter).setName(name);
}
param.setName(name);
param.setParameter((SweAbstractDataComponent) parameter);
return param;
} else {
throw new DecodingException(XmlHelper.getLocalName(xbParameter), "An 'SweAbstractDataComponent' is not supported");
}
}
Aggregations