use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class SensorMLEncoderv20 method addPhysicalSystemValues.
private void addPhysicalSystemValues(PhysicalSystemType pst, PhysicalSystem abstractPhysicalProcess) throws EncodingException {
addAbstractProcessValues(pst, abstractPhysicalProcess);
addDescribedObjectValues(pst, abstractPhysicalProcess);
addAbstractPhysicalProcessValues(pst, abstractPhysicalProcess);
// set components
if (abstractPhysicalProcess.isSetComponents()) {
List<SmlComponent> smlComponents = checkForComponents(abstractPhysicalProcess);
if (!smlComponents.isEmpty()) {
ComponentListPropertyType clpt = createComponents(smlComponents);
if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
pst.setComponents(clpt);
}
}
}
// set connections
if (abstractPhysicalProcess.isSetConnections() && !pst.isSetConnections()) {
pst.setConnections(createConnections(abstractPhysicalProcess.getConnections()));
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class SensorMLEncoderv20 method addAggregateProcessValues.
private void addAggregateProcessValues(AggregateProcessType apt, AggregateProcess abstractProcess) throws EncodingException {
addAbstractProcessValues(apt, abstractProcess);
addDescribedObjectValues(apt, abstractProcess);
// set components
if (abstractProcess.isSetComponents()) {
List<SmlComponent> smlComponents = checkForComponents(abstractProcess);
if (!smlComponents.isEmpty()) {
ComponentListPropertyType clpt = createComponents(smlComponents);
if (clpt != null && clpt.getComponentList() != null && clpt.getComponentList().sizeOfComponentArray() > 0) {
apt.setComponents(clpt);
}
}
}
// set connections
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createOutputs.
/**
* Creates the outputs section of the SensorML description.
*
* @param sosOutputs
* SOS SWE representation.
*
* @return XML Outputs element
*
* @throws org.n52.svalbard.encode.exception.EncodingException
* if the encoding fails
*/
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
final Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
final OutputListType outputList = outputs.addNewOutputList();
final Set<String> definitions = Sets.newHashSet();
int counter = 1;
final Set<String> outputNames = Sets.newHashSet();
for (final SmlIo sosSMLIo : sosOutputs) {
if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
} else {
sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
}
outputNames.add(sosSMLIo.getIoName());
addOutput(outputList.addNewOutput(), sosSMLIo);
definitions.add(sosSMLIo.getIoValue().getDefinition());
}
}
return outputs;
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createSimpleDataRecord.
private SimpleDataRecordType createSimpleDataRecord(SweSimpleDataRecord simpleDataRecord) throws EncodingException {
SimpleDataRecordType xbSimpleDataRecord = SimpleDataRecordType.Factory.newInstance(getXmlOptions());
if (simpleDataRecord.isSetDefinition()) {
xbSimpleDataRecord.setDefinition(simpleDataRecord.getDefinition());
}
if (simpleDataRecord.isSetDescription()) {
StringOrRefType xbSoR = StringOrRefType.Factory.newInstance();
xbSoR.setStringValue(simpleDataRecord.getDefinition());
xbSimpleDataRecord.setDescription(xbSoR);
}
if (simpleDataRecord.isSetFields()) {
AnyScalarPropertyType[] xbFields = new AnyScalarPropertyType[simpleDataRecord.getFields().size()];
int xbFieldIndex = 0;
for (SweField sweField : simpleDataRecord.getFields()) {
AnyScalarPropertyType xbField = createFieldForSimpleDataRecord(sweField);
xbFields[xbFieldIndex] = xbField;
xbFieldIndex++;
}
xbSimpleDataRecord.setFieldArray(xbFields);
}
return xbSimpleDataRecord;
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.
private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
SweAbstractDataComponent sosElement = sweField.getElement();
AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
if (sweField.isSetName()) {
xbField.setName(sweField.getName().getValue());
}
AbstractDataComponentType xbDCD;
if (sosElement instanceof SweBoolean) {
xbDCD = xbField.addNewBoolean();
xbDCD.set(createSimpleType((SweBoolean) sosElement));
} else if (sosElement instanceof SweCategory) {
xbDCD = xbField.addNewCategory();
xbDCD.set(createSimpleType((SweCategory) sosElement));
} else if (sosElement instanceof SweCount) {
xbDCD = xbField.addNewCount();
xbDCD.set(createSimpleType((SweCount) sosElement));
} else if (sosElement instanceof SweQuantity) {
xbDCD = xbField.addNewQuantity();
xbDCD.set(createSimpleType((SweQuantity) sosElement));
} else if (sosElement instanceof SweText) {
xbDCD = xbField.addNewText();
xbDCD.set(createSimpleType((SweText) sosElement));
} else if (sosElement instanceof SweTime) {
xbDCD = xbField.addNewTime();
xbDCD.set(createSimpleType((SweTime) sosElement));
} else {
throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
}
return xbField;
}
Aggregations