use of org.n52.shetland.ogc.sensorML.elements.SmlCapability in project arctic-sea by 52North.
the class SmlCapabilities method getCapabilities.
/**
* @return the capabilities
*/
public List<SmlCapability> getCapabilities() {
if (!hasCapabilities() && isSetAbstractDataComponents()) {
List<SmlCapability> caps = Lists.newArrayList();
for (SweAbstractDataComponent component : getAbstractDataComponents()) {
SmlCapability smlCapability = new SmlCapability();
if (component.isSetName()) {
smlCapability.setName(component.getName().getValue());
} else if (component.isSetDefinition()) {
smlCapability.setName(component.getDefinition());
}
smlCapability.setAbstractDataComponent(component);
caps.add(smlCapability);
}
return caps;
}
return this.capabilities;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlCapability in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createCapability.
private Capabilities createCapability(final SmlCapabilities capabilities) throws EncodingException {
Capabilities xbCapabilities = null;
if (capabilities.isSetAbstractDataComponents()) {
xbCapabilities = Capabilities.Factory.newInstance(getXmlOptions());
if (capabilities.isSetName()) {
xbCapabilities.setName(capabilities.getName());
}
CapabilityListType capabilityList = xbCapabilities.addNewCapabilityList();
if (capabilities.isSetCapabilities()) {
for (SmlCapability capability : capabilities.getCapabilities()) {
XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(capability.getAbstractDataComponent());
Capability c = capabilityList.addNewCapability();
if (capability.isSetName()) {
c.setName(NcName.makeValid(capability.getName()));
} else if (capability.getAbstractDataComponent().isSetName()) {
capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getName().getValue()));
} else {
capability.setName(NcName.makeValid(capability.getAbstractDataComponent().getDefinition()));
}
XmlObject substituteElement = XmlHelper.substituteElement(c.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
}
} else if (capabilities.isSetAbstractDataComponents()) {
for (SweAbstractDataComponent component : capabilities.getAbstractDataComponents()) {
XmlObject encodeObjectToXml = encodeObjectToXmlSwe20(component);
Capability capability = capabilityList.addNewCapability();
if (component.isSetName()) {
capability.setName(NcName.makeValid(component.getName().getValue()));
} else {
capability.setName(NcName.makeValid(component.getDefinition()));
}
XmlObject substituteElement = XmlHelper.substituteElement(capability.addNewAbstractDataComponent(), encodeObjectToXml);
substituteElement.set(encodeObjectToXml);
}
}
}
return xbCapabilities;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlCapability in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseCapabilities.
/**
* Parses the capabilities, processing and removing special insertion
* metadata
*
* @param abstractProcess
* The AbstractProcess to which capabilities and insertion
* metadata are added
* @param capabilitiesArray
* XML capabilities
*
* @throws DecodingException
* * if an error occurs
*/
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
for (final Capabilities cs : capabilitiesArray) {
final SmlCapabilities capabilities = new SmlCapabilities(cs.getName());
if (cs.isSetCapabilityList()) {
CapabilityListType cl = cs.getCapabilityList();
if (CollectionHelper.isNotNullOrEmpty(cl.getCapabilityArray())) {
for (Capability c : cl.getCapabilityArray()) {
final SmlCapability capability = new SmlCapability(c.getName());
if (c.isSetAbstractDataComponent()) {
final Object o = decodeXmlElement(c.getAbstractDataComponent());
if (o instanceof SweAbstractDataComponent) {
capability.setAbstractDataComponent((SweAbstractDataComponent) o);
capabilities.addCapability(capability);
} else {
throw new DecodingException(XmlHelper.getLocalName(cs), "Error while parsing the capabilities of " + "the SensorML (the capabilities data record " + "is not of type DataRecordPropertyType)!");
}
} else if (c.isSetHref()) {
capability.setHref(c.getHref());
if (c.isSetTitle()) {
capability.setTitle(c.getTitle());
}
}
}
}
}
abstractProcess.addCapabilities(capabilities);
}
}
Aggregations