org.apache.xmlbeans.XmlObject Java Examples

The following examples show how to use org.apache.xmlbeans.XmlObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TsmlTVPEncoderv10Test.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSetDefaultCumulativeProperty() throws EncodingException {
    XmlObject encodedElement = encoder.encode(mv);

    MatcherAssert.assertThat(encodedElement, CoreMatchers.instanceOf(TimeseriesTVPDocument.class));
    final TimeseriesTVPDocument timeseriesDocument =
            (TimeseriesTVPDocument) encodedElement;
    MatcherAssert.assertThat(timeseriesDocument.getTimeseriesTVP().isSetMetadata(), Is.is(true));
    MatcherAssert.assertThat(timeseriesDocument.getTimeseriesTVP().getMetadata().getTimeseriesMetadata(),
            CoreMatchers.instanceOf(TimeseriesMetadataType.class));
    final TimeseriesMetadataType measurementTimeseriesMetadataType =
            timeseriesDocument.getTimeseriesTVP().getMetadata()
                    .getTimeseriesMetadata();
    MatcherAssert.assertThat(measurementTimeseriesMetadataType.isSetCumulative(), Is.is(true));
    MatcherAssert.assertThat(measurementTimeseriesMetadataType.getCumulative(), Is.is(false));
}
 
Example #2
Source File: XmlHelper.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
public static XmlObject parseXmlString(String xmlString) throws DecodingException {
    try {
        return XmlObject.Factory.parse(xmlString);
    } catch (final XmlException xmle) {
        throw new DecodingException("An xml error occured when parsing the request!", xmle);
    }
}
 
Example #3
Source File: ExtensibleResponseDecoder.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
default Extensions parseExtensibleResponseExtension(XmlObject[] extensionArray)
        throws DecodingException {
    if (CollectionHelper.isNotNullOrEmpty(extensionArray)) {
        Extensions extensions = new Extensions();
        for (XmlObject xbExtension : extensionArray) {

            Object obj = decodeXmlElement(xbExtension);
            if (obj instanceof Extension<?>) {
                extensions.addExtension((Extension<?>) obj);
            } else if (obj instanceof SweAbstractDataComponent) {
                extensions.addExtension(new SwesExtension<>().setValue((SweAbstractDataComponent) obj));
            }
        }
        return extensions;
    }
    return null;
}
 
Example #4
Source File: GmlDecoderv311.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Override
public Object decode(XmlObject xmlObject) throws DecodingException {
    if (xmlObject instanceof EnvelopeDocument) {
        return getGeometry4BBOX((EnvelopeDocument) xmlObject);
    } else if (xmlObject instanceof TimeInstantType) {
        return parseTimeInstant((TimeInstantType) xmlObject);
    } else if (xmlObject instanceof TimePeriodType) {
        return parseTimePeriod((TimePeriodType) xmlObject);
    } else if (xmlObject instanceof TimeInstantDocument) {
        return parseTimeInstant(((TimeInstantDocument) xmlObject).getTimeInstant());
    } else if (xmlObject instanceof TimePeriodDocument) {
        return parseTimePeriod(((TimePeriodDocument) xmlObject).getTimePeriod());
    } else if (xmlObject instanceof CodeType) {
        return parseCodeType((CodeType) xmlObject);
    } else if (xmlObject instanceof PointType) {
        return parsePointType((PointType) xmlObject);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
}
 
Example #5
Source File: RawCopier.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get Xml With Ouput relation Id.
 * 
 * @param inputRelationIdToOutputMap
 *            the relation ID mapping
 * @param inputPartURIToOutputPartURI
 *            the mapping form input part {@link PackagePartName} to output par {@link PackagePartName}
 * @param outputBody
 *            the input {@link IBody}
 * @param inputBody
 *            the ouput {@link IBody}
 * @param xmlObject
 *            the {@link XmlObject} to walk
 * @throws XmlException
 *             XmlException
 * @throws InvalidFormatException
 *             if image copy fails
 * @throws IOException
 *             if a {@link PackagePart} can't be read
 * @throws NoSuchAlgorithmException
 *             if MD5 can't be read
 */
private void updateRelationIds(Map<String, String> inputRelationIdToOutputMap,
        Map<URI, URI> inputPartURIToOutputPartURI, IBody inputBody, IBody outputBody, XmlObject xmlObject)
        throws XmlException, InvalidFormatException, NoSuchAlgorithmException, IOException {
    final XmlObject idAttr = xmlObject.selectAttribute(RELATIONSHIPS_URI, "id");
    if (idAttr != null) {
        updateRelationAttribute(inputRelationIdToOutputMap, inputPartURIToOutputPartURI, inputBody, outputBody,
                idAttr);
    } else {
        final XmlObject embedAttr = xmlObject.selectAttribute(RELATIONSHIPS_URI, "embed");
        if (embedAttr != null) {
            updateRelationAttribute(inputRelationIdToOutputMap, inputPartURIToOutputPartURI, inputBody, outputBody,
                    embedAttr);
        }
    }
    final XmlCursor cursor = xmlObject.newCursor();
    if (cursor.toFirstChild()) {
        updateRelationIds(inputRelationIdToOutputMap, inputPartURIToOutputPartURI, inputBody, outputBody,
                cursor.getObject());
        while (cursor.toNextSibling()) {
            updateRelationIds(inputRelationIdToOutputMap, inputPartURIToOutputPartURI, inputBody, outputBody,
                    cursor.getObject());
        }
    }
    cursor.dispose();
}
 
Example #6
Source File: SweCommonEncoderv20.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
private DataRecordType.Field createField(SweField field)
        throws EncodingException {
    SweAbstractDataComponent element = field.getElement();
    DataRecordType.Field xmlField = DataRecordType.Field.Factory.newInstance(getXmlOptions());

    if (field.isSetName()) {
        xmlField.setName(NcName.makeValid(field.getName().getValue()));
    }

    if (element != null) {
        XmlObject encodeObjectToXml = createAbstractDataComponent(element, EncodingContext.empty());
        XmlObject substituteElement =
                XmlHelper.substituteElement(xmlField.addNewAbstractDataComponent(), encodeObjectToXml);
        substituteElement.set(encodeObjectToXml);
    }
    return xmlField;
}
 
Example #7
Source File: XML.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo)
{
    XScriptAnnotation anno;
    XmlCursor curs = xo.newCursor();
    if (curs.currentTokenType().isStartdoc())
    {
        curs.toFirstContentToken();
    }
    try {
        anno = new XScriptAnnotation(curs);
        curs.setBookmark(anno);
    } finally {
        curs.dispose();
    }
    return new XML(lib, anno);
}
 
Example #8
Source File: SweCommonEncoderv101Test.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Test
public void should_encode_simpleDatarecord_with_fieldBoolean() throws EncodingException {
    final String field1Name = "field-1";
    final Boolean field1Value = Boolean.TRUE;

    final XmlObject encode =
            sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name,
                    new SweBoolean().setValue(field1Value))));

    assertThat(encode, instanceOf(SimpleDataRecordType.class));

    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);

    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetBoolean(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getBoolean().getValue(), is(field1Value));
}
 
Example #9
Source File: TypeGen.java    From j-road with Apache License 2.0 6 votes vote down vote up
/**
 * Return the schemas contained in the given wsdl:types node.
 *
 * @param typesNode
 * @param additionalNs
 * @return A collection of schemas found under the Node
 * @throws Exception
 */
private static Collection<XmlObject> getSchemas(Node typesNode, Map<String, String> additionalNs, String schemaPath)
    throws Exception {
  List<XmlObject> schemas = new ArrayList<XmlObject>();
  NodeList schemaNodes = typesNode.getChildNodes();
  XmlOptions options = new XmlOptions();
  options.setLoadAdditionalNamespaces(additionalNs);
  for (int i = 0; i < schemaNodes.getLength(); i++) {
    Node schemaNode = schemaNodes.item(i);
    if (SCHEMA_NS.equals(schemaNode.getNamespaceURI()) && "schema".equals(schemaNode.getLocalName())) {
      XmlObject schema = XmlObject.Factory.parse(schemaNode, options);
      schema.documentProperties().setSourceName("file://" + schemaPath.replace(File.separator, "/") + "/");
      schemas.add(schema);
    } else if (schemaNode.getNodeType() != Node.TEXT_NODE && schemaNode.getNodeType() != Node.COMMENT_NODE) {
      // TODO: Add xs:import support outside schemas.
      throw new IllegalStateException("Encountered unsupported element in WSDL types definition: ({"
          + schemaNode.getNamespaceURI() + "}" + schemaNode.getLocalName() + ")!");
    }
  }

  return schemas;
}
 
Example #10
Source File: WmlTVPEncoderv20Test.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSetDefaultCumulativeProperty() throws EncodingException {
    XmlObject encodedElement = encoder.encode(mv);

    assertThat(encodedElement, CoreMatchers.instanceOf(MeasurementTimeseriesDocument.class));
    final MeasurementTimeseriesDocument measurementTimeseriesDocument =
            (MeasurementTimeseriesDocument) encodedElement;
    assertThat(measurementTimeseriesDocument.getTimeseries().isSetMetadata(), Is.is(true));
    assertThat(measurementTimeseriesDocument.getTimeseries().getMetadata().getTimeseriesMetadata(),
            CoreMatchers.instanceOf(MeasurementTimeseriesMetadataType.class));
    final MeasurementTimeseriesMetadataType measurementTimeseriesMetadataType =
            (MeasurementTimeseriesMetadataType) measurementTimeseriesDocument.getTimeseries().getMetadata()
                    .getTimeseriesMetadata();
    assertThat(measurementTimeseriesMetadataType.isSetCumulative(), Is.is(true));
    assertThat(measurementTimeseriesMetadataType.getCumulative(), Is.is(false));
}
 
Example #11
Source File: FesEncoderv20.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof org.n52.shetland.ogc.filter.FilterCapabilities) {
        encodedObject = encodeFilterCapabilities((org.n52.shetland.ogc.filter.FilterCapabilities) element);
        // LOGGER.debug("Encoded object {} is valid: {}",
        // encodedObject.schemaType().toString(),
        // XmlHelper.validateDocument(encodedObject));
    } else if (element instanceof TemporalFilter) {
        encodedObject = encodeTemporalFilter((TemporalFilter) element);
    } else if (element instanceof SpatialFilter) {
        encodedObject = encodeSpatialFilter((SpatialFilter) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    return encodedObject;

}
 
Example #12
Source File: Iso19139GmdDecoder.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
@Override
public Object decode(XmlObject element) throws DecodingException {
    if (element instanceof CIResponsiblePartyDocument) {
        return decodeCIResponsibleParty(((CIResponsiblePartyDocument) element).getCIResponsibleParty());
    } else if (element instanceof CIResponsiblePartyPropertyType) {
        return decodeCIResponsiblePartyPropertyType((CIResponsiblePartyPropertyType) element);
    } else if (element instanceof CIResponsiblePartyType) {
        return decodeCIResponsibleParty((CIResponsiblePartyType) element);
    } else if (element instanceof PTFreeTextDocument) {
        return decodePTFreeTextType(((PTFreeTextDocument) element).getPTFreeText());
    } else if (element instanceof PTFreeTextPropertyType) {
        return decodePTFreeTextType(((PTFreeTextPropertyType) element).getPTFreeText());
    } else if (element instanceof PTFreeTextType) {
        return decodePTFreeTextType((PTFreeTextType) element);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, element);
    }
}
 
Example #13
Source File: SosDecoderv20.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
private OwsServiceRequest parseInsertResultTemplate(final InsertResultTemplateDocument insertResultTemplateDoc)
        throws DecodingException {
    InsertResultTemplateRequest sosInsertResultTemplate = new InsertResultTemplateRequest();
    InsertResultTemplateType insertResultTemplate = insertResultTemplateDoc.getInsertResultTemplate();
    sosInsertResultTemplate.setService(insertResultTemplate.getService());
    sosInsertResultTemplate.setVersion(insertResultTemplate.getVersion());
    ResultTemplateType resultTemplate = insertResultTemplate.getProposedTemplate().getResultTemplate();
    sosInsertResultTemplate.setIdentifier(resultTemplate.getIdentifier());
    OmObservationConstellation sosObservationConstellation =
            parseObservationTemplate(resultTemplate.getObservationTemplate());
    sosObservationConstellation.addOffering(resultTemplate.getOffering());
    sosInsertResultTemplate.setObservationTemplate(sosObservationConstellation);
    try {
        sosInsertResultTemplate.setResultStructure(
                parseResultStructure(XmlObject.Factory.parse(resultTemplate.getResultStructure()
                        .xmlText(getXmlOptions()))));
        sosInsertResultTemplate
                .setResultEncoding(parseResultEncoding(XmlObject.Factory.parse(resultTemplate.getResultEncoding()
                        .xmlText(getXmlOptions()))));
    } catch (XmlException e) {
        throw new DecodingException(e, "Error while parsing InsertResultTemplate request!");
    }
    sosInsertResultTemplate.setExtensions(parseExtensibleRequest(insertResultTemplate));
    return sosInsertResultTemplate;
}
 
Example #14
Source File: SensorMLEncoderv101.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a SOS SWE simple type to a XML SML IO component.
 *
 * @param ioComponentPropertyType
 *            SML IO component
 * @param sosSMLIO
 *            SOS SWE simple type.
 *
 * @throws EncodingException
 *             if the encoding fails
 */
private void addIoComponentPropertyType(IoComponentPropertyType ioComponentPropertyType, SmlIo sosSMLIO)
        throws EncodingException {
    ioComponentPropertyType.setName(sosSMLIO.getIoName());
    if (sosSMLIO.isSetHref()) {
        ioComponentPropertyType.setHref(sosSMLIO.getTitle());
        if (sosSMLIO.isSetTitle()) {
            ioComponentPropertyType.setTitle(sosSMLIO.getTitle());
        }
    } else {
        XmlObject encodeObjectToXml;
        XmlObject xml = encodeObjectToXml(SweConstants.NS_SWE_101, sosSMLIO.getIoValue());

        if (xml instanceof DataArrayDocument) {
            encodeObjectToXml = ((DataArrayDocument) xml).getDataArray1();
        } else {
            encodeObjectToXml = xml;
        }

        sosSMLIO.getIoValue().accept(new SweDataComponentAdder(ioComponentPropertyType))
                .map(h -> (AbstractDataComponentType) h.set(encodeObjectToXml))
                .ifPresent(h -> sosSMLIO.getIoValue().accept(new SweDataComponentSubstituter(h)));
    }
}
 
Example #15
Source File: OgcDecoderv100Test.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
@Test
public void parsePropertyIsLike() throws XmlException, IOException, DecodingException {
    XmlObject parse = XmlObject.Factory.parse(getClass().getResourceAsStream("/GetObsPropertyIsLike.xml"));
    Object decode = decoder.decode(((GetObservationDocument)parse).getGetObservation().getResult().getComparisonOps());
    assertThat(decode, instanceOf(ComparisonFilter.class));
    ComparisonFilter filter = (ComparisonFilter) decode;
    assertThat(filter.getOperator(), is(ComparisonOperator.PropertyIsLike));
    assertThat(filter.getWildCard(), is("*"));
    assertThat(filter.getSingleChar(), is("?"));
    assertThat(filter.getEscapeString(), is("\\"));
    assertThat(filter.getValueReference(), is("QualityFlag"));
    assertThat(filter.getValue(), is("4/_(2)%"));
}
 
Example #16
Source File: GmlEncoderv311.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
protected XmlObject createMeasureType(QuantityValue quantityValue) {
    MeasureType measureType = MeasureType.Factory.newInstance(getXmlOptions());
    if (quantityValue.getUnit() != null) {
        measureType.setUom(quantityValue.getUnit());
    } else {
        measureType.setUom("");
    }
    if (quantityValue.getValue() != null) {
        measureType.setDoubleValue(quantityValue.getValue().doubleValue());
    } else {
        measureType.setNil();
    }
    return measureType;
}
 
Example #17
Source File: GmlEncoderv311.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private XmlObject createEnvelope(ReferencedEnvelope sosEnvelope) {
    EnvelopeType envelopeType = EnvelopeType.Factory.newInstance(getXmlOptions());
    MinMax<String> minmax = sosEnvelope.getMinMaxFromEnvelope();
    envelopeType.addNewLowerCorner().setStringValue(minmax.getMinimum());
    envelopeType.addNewUpperCorner().setStringValue(minmax.getMaximum());
    envelopeType.setSrsName(srsNamePrefix + sosEnvelope.getSrid());
    return envelopeType;
}
 
Example #18
Source File: XlinkDecoderv1999.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
@Override
public Object decode(XmlObject xmlObject) throws DecodingException {
    if (xmlObject instanceof HrefAttribute) {
        return encodeHrefAttribute((HrefAttribute) xmlObject);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
}
 
Example #19
Source File: TsmlTDREncoderv10.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
/**
 * Create a SOS DataRecord object from SOS observation and encode to XmlBeans object
 *
 * @param sosObservation SOS observation
 *
 * @return XML DataRecord object
 *
 * @throws EncodingException If an error occurs
 */
private XmlObject createDataRecord(OmObservation sosObservation)
        throws EncodingException {
    AbstractPhenomenon observableProperty = sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observableProperty.getIdentifier());
    quantity.setDescription(observableProperty.getDescription());
    if (observableProperty instanceof OmObservableProperty &&
        ((OmObservableProperty) observableProperty).isSetUnit()) {
        quantity.setUom(((OmObservableProperty) observableProperty).getUnit());
    }
    return createDataRecord(quantity, sosObservation.getObservationID());
}
 
Example #20
Source File: ResultTimeAdapterTest.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldStripSoapEnvelopeFromResponse() throws Exception {
    XmlObject xml = XmlFileLoader.loadXmlFileViaClassloader(GDA_RESPONSE, getClass());
    ArrayList<String> resultTimes = adapter.getResultTimes(xml);
    Assert.assertThat(resultTimes, is(notNullValue()));
    Assert.assertTrue(resultTimes.size() == 4);
}
 
Example #21
Source File: SensorMLEncoderv20.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private XmlObject encodeAggregateProcess(AggregateProcess abstractProcess, EncodingContext additionalValues)
        throws EncodingException {
    AggregateProcessPropertyType appt = AggregateProcessPropertyType.Factory.newInstance(getXmlOptions());
    addAggregateProcessValues(appt.addNewAggregateProcess(), abstractProcess);
    if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
        AggregateProcessDocument apd = AggregateProcessDocument.Factory.newInstance(getXmlOptions());
        apd.setAbstractProcess(appt.getAggregateProcess());
    } else if (additionalValues.has(XmlBeansEncodingFlags.TYPE)) {
        return appt.getAggregateProcess();
    }
    return appt;
}
 
Example #22
Source File: AbstractRectifiedGridCoverageTypeEncoder.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private XmlObject encodeDomainSet(RectifiedGridCoverage rectifiedGridCoverage) {
    List<ComparableValue<?, ?>> domainSet = rectifiedGridCoverage.getDomainSet();
    if (!checkForRange(domainSet)) {
        SimpleMultiPointDocument smpd = SimpleMultiPointDocument.Factory.newInstance();
        SimpleMultiPointType smpt = smpd.addNewSimpleMultiPoint();
        smpt.setId("smp_" + rectifiedGridCoverage.getGmlId());
        DirectPositionListType dplt = smpt.addNewPosList();
        List<String> uoms = getUoms(domainSet);
        if (!uoms.isEmpty()) {
            dplt.setUomLabels(Lists.newArrayList(uoms));
        }
        dplt.setListValue(getList(rectifiedGridCoverage.getDomainSet()));
        return smpd;
    } else {
        LineStringDocument lsd = LineStringDocument.Factory.newInstance();
        LineStringType lst = lsd.addNewLineString();
        lst.setId("ls_" + rectifiedGridCoverage.getGmlId());
        lst.setUomLabels(getUoms(domainSet));
        for (ComparableValue<?, ?> quantityValued : domainSet) {
            Object value = quantityValued.getValue();
            if (value instanceof Double) {
                lst.addNewPos().setListValue(Lists.newArrayList((Double) value));
            } else if (value instanceof RangeValue) {
                lst.addNewPos().setListValue(((RangeValue) value).getRangeAsList());
            }
        }
        return lsd;
    }
}
 
Example #23
Source File: InspireOmObservationEncoder.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
@Override
public XmlObject encode(Object element, EncodingContext ec) throws EncodingException {
    if (element instanceof OmObservation) {
        return encodeInspireOmsoType((OmObservation) element, ec);
    }
    throw new UnsupportedEncoderInputException(this, element);
}
 
Example #24
Source File: SOSAdapterByGET.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private void checkForExceptionReport(OperationResult result, XmlObject response) throws XmlException,
        ExceptionReport {
    if (isExceptionReportV11(response)) {
        ExceptionReport execRep = parseExceptionReport_100(result);
        OWSException ex = execRep.getExceptionsIterator().next();
        if (ex.getExceptionTexts().length > 0) {
            for (int i = 0; i < ex.getExceptionTexts().length; i++) {
                LOGGER.warn(ex.getExceptionTexts()[i]);
            }
        }
        throw execRep;
    }
}
 
Example #25
Source File: OwsEncoderv110Test.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
@Test
public void should_encode_service_identification_without_service_type_codespace() throws EncodingException {
    String serviceTypeValue = "serviceType";
    OwsServiceIdentification serviceId = new OwsServiceIdentification(new OwsCode(serviceTypeValue), null, null, null, null, null, null, null);
    XmlObject xbEncoded = encodeObjectToXml(OWSConstants.NS_OWS, serviceId);
    assertThat(xbEncoded, instanceOf(ServiceIdentification.class));
    ServiceIdentification xbServiceId = (ServiceIdentification) xbEncoded;
    assertThat(xbServiceId.getServiceType().getStringValue(), equalTo(serviceTypeValue));
    assertThat(xbServiceId.getServiceType().getCodeSpace(), nullValue());
}
 
Example #26
Source File: XML.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
static XML createEmptyXML(XMLLibImpl lib)
{
    XScriptAnnotation anno;

    XmlObject xo = XmlObject.Factory.newInstance();
    XmlCursor curs = xo.newCursor();
    try {
        anno = new XScriptAnnotation(curs);
        curs.setBookmark(anno);
    } finally {
        curs.dispose();
    }

    return new XML(lib, anno);
}
 
Example #27
Source File: TsmlTDREncoderv10.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private XmlObject createDataRecord(AbstractObservationValue<?> observationValue, String unit)
        throws EncodingException {
    // AbstractPhenomenon observableProperty =
    // sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observationValue.getObservableProperty());
    quantity.setUom(unit);
    return createDataRecord(quantity, observationValue.getObservationID());
}
 
Example #28
Source File: SensorMLEncoderv20.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private XmlObject encodeSimpleProcess(SimpleProcess abstractProcess, EncodingContext additionalValues)
        throws EncodingException {
    SimpleProcessPropertyType sppt = SimpleProcessPropertyType.Factory.newInstance(getXmlOptions());
    addSimpleProcessValues(sppt.addNewSimpleProcess(), abstractProcess);
    if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
        SimpleProcessDocument spd = SimpleProcessDocument.Factory.newInstance(getXmlOptions());
        spd.setSimpleProcess(sppt.getSimpleProcess());
    } else if (additionalValues.has(XmlBeansEncodingFlags.TYPE)) {
        return sppt.getSimpleProcess();
    }
    return sppt;
}
 
Example #29
Source File: SensorMLEncoderv20.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private void addValuesToXmlObject(XmlObject element, AbstractSensorML description)
        throws EncodingException {
    if (element instanceof PhysicalSystemDocument) {
        addPhysicalSystemValues(((PhysicalSystemDocument) element).getPhysicalSystem(),
                (PhysicalSystem) description);
    } else if (element instanceof PhysicalSystemPropertyType) {
        addPhysicalSystemValues(((PhysicalSystemPropertyType) element).getPhysicalSystem(),
                (PhysicalSystem) description);
    } else if (element instanceof PhysicalComponentDocument && description instanceof PhysicalComponent) {
        addPhysicalComponentValues(((PhysicalComponentDocument) element).getPhysicalComponent(),
                (PhysicalComponent) description);
    } else if (element instanceof PhysicalComponentPropertyType && description instanceof PhysicalComponent) {
        addPhysicalComponentValues(((PhysicalComponentPropertyType) element).getPhysicalComponent(),
                (PhysicalComponent) description);
    } else if (element instanceof SimpleProcessDocument && description instanceof SimpleProcess) {
        addSimpleProcessValues(((SimpleProcessDocument) element).getSimpleProcess(), (SimpleProcess) description);
    } else if (element instanceof SimpleProcessPropertyType && description instanceof SimpleProcess) {
        addSimpleProcessValues(((SimpleProcessPropertyType) element).getSimpleProcess(),
                (SimpleProcess) description);
    } else if (element instanceof AggregateProcessDocument && description instanceof AggregateProcess) {
        addAggregateProcessValues(((AggregateProcessDocument) element).getAggregateProcess(),
                (AggregateProcess) description);
    } else if (element instanceof AggregateProcessPropertyType && description instanceof AggregateProcess) {
        addAggregateProcessValues(((AggregateProcessPropertyType) element).getAggregateProcess(),
                (AggregateProcess) description);
    }
}
 
Example #30
Source File: WnsUtil.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
/**
* Send E-Mail to user
* 
   * @param userName
   * @param mail
   * @return {@link String}
   * @throws Exception
   */
  public static String sendToWNSMail(String userName, String mail) throws Exception {
      HttpClient httpClient = new ProxyAwareHttpClient(new SimpleHttpClient());
      String request = createNewUserMailRequest(userName, mail);
      HttpResponse response = httpClient.executePost(SesConfig.wns, request, TEXT_XML);
      XmlObject xmlResponse = readXmlResponse(response);
      String[] userIDs = xmlResponse.xmlText().split("UserID");
      String result = userIDs[1].substring(1, userIDs[1].length() - 2);
      LOGGER.debug("WNS_USER_ID: {}", result);
      return result;
  }