Exemple #1
0
  /**
   * Appends the XML representation of the given <code>OutputFormatType</code> (as FormatType[]) to
   * the passed <code>Element</code>.
   *
   * @param root
   * @param formats
   */
  public static void appendOutputFormats(Element root, FormatType[] formats) {
    LOG.entering();

    Element outputFormatsNode = XMLTools.appendElement(root, WFS, "wfs:OutputFormats");
    for (int i = 0; i < formats.length; i++) {
      Element formatNode =
          XMLTools.appendElement(outputFormatsNode, WFS, "wfs:Format", formats[i].getValue());
      if (formats[i].getInFilter() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(), "deegree:inFilter", formats[i].getInFilter().toString());
      }
      if (formats[i].getOutFilter() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(), "deegree:outFilter", formats[i].getOutFilter().toString());
      }
      if (formats[i].getSchemaLocation() != null) {
        formatNode.setAttributeNS(
            DEEGREEWFS.toString(),
            "deegree:schemaLocation",
            formats[i].getSchemaLocation().toString());
      }
    }

    LOG.exiting();
  }
Exemple #2
0
  /**
   * Appends the XML representation of the <code>wfs:GMLObjectTypeType</code>- element to the passed
   * <code>Element</code>.
   *
   * @param root
   * @param gmlObjectType
   */
  public static void appendGMLObjectTypeType(Element root, GMLObject gmlObjectType) {
    LOG.entering();
    Element gmlObjectTypeNode = XMLTools.appendElement(root, WFS, "wfs:GMLObjectType");

    if (gmlObjectType.getName().getPrefix() != null) {
      XMLTools.appendNSBinding(
          gmlObjectTypeNode,
          gmlObjectType.getName().getPrefix(),
          gmlObjectType.getName().getNamespace());
    }
    XMLTools.appendElement(
        gmlObjectTypeNode, WFS, "wfs:Name", gmlObjectType.getName().getAsString());
    if (gmlObjectType.getTitle() != null) {
      XMLTools.appendElement(gmlObjectTypeNode, WFS, "wfs:Title", gmlObjectType.getTitle());
    }
    String abstract_ = gmlObjectType.getAbstract();
    if (abstract_ != null) {
      XMLTools.appendElement(gmlObjectTypeNode, WFS, "wfs:Abstract", gmlObjectType.getAbstract());
    }
    Keywords[] keywords = gmlObjectType.getKeywords();
    if (keywords != null) {
      appendOWSKeywords(gmlObjectTypeNode, keywords);
    }
    FormatType[] formats = gmlObjectType.getOutputFormats();
    if (formats != null) {
      appendOutputFormats(gmlObjectTypeNode, formats);
    }
    LOG.exiting();
  }
Exemple #3
0
 /**
  * Appends a 'wfs:TransactionSummary' element to the given element.
  *
  * @param root
  * @param totalInserted
  * @param totalUpdated
  * @param totalDeleted
  */
 private static void appendTransactionSummary(
     Element root, int totalInserted, int totalUpdated, int totalDeleted) {
   Element taSummary = XMLTools.appendElement(root, WFS, "wfs:TransactionSummary");
   XMLTools.appendElement(taSummary, WFS, "wfs:totalInserted", "" + totalInserted);
   XMLTools.appendElement(taSummary, WFS, "wfs:totalUpdated", "" + totalUpdated);
   XMLTools.appendElement(taSummary, WFS, "wfs:totalDeleted", "" + totalDeleted);
 }
Exemple #4
0
  /**
   * Adds the XML representation of an <code>Update</code> operation to the given element.
   *
   * <p>Respects the deegree-specific extension to the Update operation: instead of specifying
   * properties and their values, it's also possible to only specify just one feature that replaces
   * the matched feature.
   *
   * @param root
   * @param update
   * @throws SAXException
   * @throws IOException
   * @throws FeatureException
   */
  private static void appendUpdate(Element root, Update update)
      throws FeatureException, IOException, SAXException {

    Element el = XMLTools.appendElement(root, WFS, "Update");
    if (update.getHandle() != null) {
      el.setAttribute("handle", update.getHandle());
    }
    // TODO What about the namespace binding here?
    el.setAttribute("typeName", update.getTypeName().getAsString());

    Feature replacement = update.getFeature();
    if (replacement != null) {
      GMLFeatureAdapter adapter = new GMLFeatureAdapter();
      adapter.append(root, replacement);
    } else {
      Map<PropertyPath, Node> replaces = update.getRawProperties();
      for (PropertyPath propertyName : replaces.keySet()) {
        Element propElement = XMLTools.appendElement(el, WFS, "Property");
        Element nameElement = XMLTools.appendElement(propElement, WFS, "Name");
        org.deegree.ogcbase.XMLFactory.appendPropertyPath(nameElement, propertyName);
        Element valueElement = XMLTools.appendElement(propElement, WFS, "Value");
        Node value = replaces.get(propertyName);
        Node imported = valueElement.getOwnerDocument().importNode(value, true);
        valueElement.appendChild(imported);
      }
    }

    Filter filter = update.getFilter();
    if (filter != null) {
      org.deegree.model.filterencoding.XMLFactory.appendFilter(el, filter);
    }
    root.appendChild(el);
  }
Exemple #5
0
  /**
   * Appends the DOM representation of the {@link ServiceIdentification} section to the passed
   * {@link Element}.
   *
   * @param root
   * @param serviceIdentification
   */
  protected static void appendServiceIdentification(
      Element root, ServiceIdentification serviceIdentification) {

    // 'ServiceIdentification'-element
    Element serviceIdentificationNode =
        XMLTools.appendElement(root, OWSNS, "ows:ServiceIdentification");

    // 'ServiceType'-element
    XMLTools.appendElement(
        serviceIdentificationNode,
        OWSNS,
        "ows:ServiceType",
        serviceIdentification.getServiceType().getCode());

    // 'ServiceTypeVersion'-elements
    String[] versions = serviceIdentification.getServiceTypeVersions();
    for (int i = 0; i < versions.length; i++) {
      XMLTools.appendElement(
          serviceIdentificationNode, OWSNS, "ows:ServiceTypeVersion", versions[i]);
    }

    // 'Fees'-element
    XMLTools.appendElement(
        serviceIdentificationNode, OWSNS, "ows:Fees", serviceIdentification.getFees());

    // 'AccessConstraints'-element
    String[] constraints = serviceIdentification.getAccessConstraints();
    if (constraints != null) {
      for (int i = 0; i < constraints.length; i++) {
        XMLTools.appendElement(
            serviceIdentificationNode, OWSNS, "ows:AccessConstraints", constraints[i]);
      }
    }
  }
Exemple #6
0
 /**
  * Appends a 'wfs:Feature' element to the given element.
  *
  * @param root
  * @param results
  */
 private static void appendFeatureIds(Element root, InsertResults results) {
   Element featureElement = XMLTools.appendElement(root, WFS, "wfs:Feature");
   String handle = results.getHandle();
   if (handle != null) {
     featureElement.setAttribute("handle", handle);
   }
   Iterator<FeatureId> iter = results.getFeatureIDs().iterator();
   while (iter.hasNext()) {
     Element featureIdElement = XMLTools.appendElement(featureElement, OGCNS, "ogc:FeatureId");
     featureIdElement.setAttribute("fid", iter.next().getAsString());
   }
 }
Exemple #7
0
 /**
  * Appends the XML representation of the given <code>Envelope</code> (as WGS84BoundingBoxType[])
  * to the passed <code>Element</code>.
  *
  * @param root
  * @param envelope
  */
 public static void appendWgs84BoundingBox(Element root, Envelope envelope) {
   LOG.entering();
   Element wgs84BoundingBoxElement = XMLTools.appendElement(root, OWS, "ows:WGS84BoundingBox");
   XMLTools.appendElement(
       wgs84BoundingBoxElement,
       OWS,
       "ows:LowerCorner",
       envelope.getMin().getX() + " " + envelope.getMin().getY());
   XMLTools.appendElement(
       wgs84BoundingBoxElement,
       OWS,
       "ows:UpperCorner",
       envelope.getMax().getX() + " " + envelope.getMax().getY());
   LOG.exiting();
 }
Exemple #8
0
 /**
  * Appends the XML representation of the <code>wfs:ServesGMLObjectTypeList</code>- section to the
  * passed <code>Element</code> as a new element with the given qualified name.
  *
  * @param root
  * @param elementNS
  * @param elementName
  * @param gmlObjectTypes
  */
 public static void appendGMLObjectTypeList(
     Element root, URI elementNS, String elementName, GMLObject[] gmlObjectTypes) {
   LOG.entering();
   Element gmlObjectTypeListNode = XMLTools.appendElement(root, elementNS, elementName);
   for (int i = 0; i < gmlObjectTypes.length; i++) {
     appendGMLObjectTypeType(gmlObjectTypeListNode, gmlObjectTypes[i]);
   }
   LOG.exiting();
 }
Exemple #9
0
 /**
  * Appends an 'wfs:InsertResults' element to the given element (only if necessary).
  *
  * @param root
  * @param insertResults
  */
 private static void appendInsertResults(Element root, Collection<InsertResults> insertResults) {
   if (insertResults.size() > 0) {
     Element insertResultsElement = XMLTools.appendElement(root, WFS, "wfs:InsertResults");
     Iterator<InsertResults> iter = insertResults.iterator();
     while (iter.hasNext()) {
       appendFeatureIds(insertResultsElement, iter.next());
     }
   }
 }
Exemple #10
0
  /**
   * Appends the XML representation of the <code>WFSFeatureType</code> instance to the passed <code>
   * Element</code>.
   *
   * @param root
   * @param featureType
   */
  public static void appendWFSFeatureType(Element root, WFSFeatureType featureType) {
    LOG.entering();
    Element featureTypeNode = XMLTools.appendElement(root, WFS, "wfs:FeatureType");

    if (featureType.getName().getPrefix() != null) {
      XMLTools.appendNSBinding(
          featureTypeNode, featureType.getName().getPrefix(), featureType.getName().getNamespace());
    }
    XMLTools.appendElement(featureTypeNode, WFS, "wfs:Name", featureType.getName().getAsString());
    XMLTools.appendElement(featureTypeNode, WFS, "wfs:Title", featureType.getTitle());
    String abstract_ = featureType.getAbstract();
    if (abstract_ != null) {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:Abstract", featureType.getAbstract());
    }
    Keywords[] keywords = featureType.getKeywords();
    if (keywords != null) {
      appendOWSKeywords(featureTypeNode, keywords);
    }
    URI defaultSrs = featureType.getDefaultSRS();
    if (defaultSrs != null) {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:DefaultSRS", defaultSrs.toString());
      URI[] otherSrs = featureType.getOtherSrs();
      if (otherSrs != null) {
        for (int i = 0; i < otherSrs.length; i++) {
          XMLTools.appendElement(featureTypeNode, WFS, "wfs:OtherSRS", otherSrs[i].toString());
        }
      }
    } else {
      XMLTools.appendElement(featureTypeNode, WFS, "wfs:Title");
    }
    Operation[] operations = featureType.getOperations();
    if (operations != null) {
      Element operationsNode = XMLTools.appendElement(featureTypeNode, WFS, "wfs:Operations");
      for (int i = 0; i < operations.length; i++) {
        XMLTools.appendElement(operationsNode, WFS, "wfs:Operation", operations[i].getOperation());
      }
    }
    FormatType[] formats = featureType.getOutputFormats();
    if (formats != null) {
      appendOutputFormats(featureTypeNode, formats);
    }
    Envelope[] wgs84BoundingBoxes = featureType.getWgs84BoundingBoxes();
    for (int i = 0; i < wgs84BoundingBoxes.length; i++) {
      appendWgs84BoundingBox(featureTypeNode, wgs84BoundingBoxes[i]);
    }

    LOG.exiting();
  }
Exemple #11
0
  /**
   * Appends the XML representation of the <code>wfs:FeatureTypeList</code>- section to the passed
   * <code>Element</code>.
   *
   * @param root
   * @param featureTypeList
   */
  public static void appendFeatureTypeList(Element root, FeatureTypeList featureTypeList) {
    LOG.entering();
    Element featureTypeListNode = XMLTools.appendElement(root, WFS, "wfs:FeatureTypeList", null);
    Operation[] operations = featureTypeList.getGlobalOperations();
    if (operations != null) {
      Element operationsNode = XMLTools.appendElement(featureTypeListNode, WFS, "wfs:Operations");
      for (int i = 0; i < operations.length; i++) {
        XMLTools.appendElement(operationsNode, WFS, "wfs:Operation", operations[i].getOperation());
      }
    }
    WFSFeatureType[] featureTypes = featureTypeList.getFeatureTypes();
    if (featureTypes != null) {
      for (int i = 0; i < featureTypes.length; i++) {
        appendWFSFeatureType(featureTypeListNode, featureTypes[i]);
      }
    }

    LOG.exiting();
  }
Exemple #12
0
  /**
   * Adds the XML representation of an <code>Insert</code> operation to the given element.
   *
   * @param root
   * @param insert
   * @throws SAXException
   * @throws IOException
   * @throws FeatureException
   */
  private static void appendInsert(Element root, Insert insert)
      throws IOException, FeatureException, XMLException, SAXException {

    Element el = XMLTools.appendElement(root, WFS, "Insert");
    if (insert.getHandle() != null) {
      el.setAttribute("handle", insert.getHandle());
    }
    if (insert.getIdGen() != null) {
      el.setAttribute("idgen", insert.getIdGen().name());
    }

    GMLFeatureAdapter adapter = new GMLFeatureAdapter();
    adapter.append(el, insert.getFeatures());
  }
Exemple #13
0
  /**
   * Adds the XML representation of a <code>Delete</code> operation to the given element.
   *
   * @param root
   * @param delete
   */
  private static void appendDelete(Element root, Delete delete) {
    Element el = XMLTools.appendElement(root, WFS, "Delete");
    if (delete.getHandle() != null) {
      el.setAttribute("handle", delete.getHandle());
    }
    // TODO What about the namespace binding here?
    el.setAttribute("typeName", delete.getTypeName().getAsString());

    Filter filter = delete.getFilter();
    if (filter != null) {
      org.deegree.model.filterencoding.XMLFactory.appendFilter(el, filter);
    }
    root.appendChild(el);
  }
Exemple #14
0
  /**
   * Appends the XML representation of the given <code>Query</code> to an element.
   *
   * @param query
   */
  private static void appendQuery(Element root, Query query)
      throws IOException, XMLParsingException {

    Element queryElem = XMLTools.appendElement(root, WFS, "wfs:Query");
    if (query.getHandle() != null) {
      queryElem.setAttribute("handle", query.getHandle());
    }
    if (query.getFeatureVersion() != null) {
      queryElem.setAttribute("featureVersion", query.getFeatureVersion());
    }
    QualifiedName[] qn = query.getTypeNames();
    String[] na = new String[qn.length];
    for (int i = 0; i < na.length; i++) {
      na[i] = qn[i].getAsString();
      queryElem.setAttribute("xmlns:" + qn[i].getPrefix(), qn[i].getNamespace().toASCIIString());
    }
    String tn = StringTools.arrayToString(na, ',');
    queryElem.setAttribute("typeName", tn);

    PropertyPath[] propertyNames = query.getPropertyNames();
    for (int i = 0; i < propertyNames.length; i++) {
      Element propertyNameElement = XMLTools.appendElement(queryElem, WFS, "wfs:PropertyName");
      appendPropertyPath(propertyNameElement, propertyNames[i]);
    }
    Function[] fn = query.getFunctions();
    // copy function definitions into query node
    if (fn != null) {
      for (int i = 0; i < fn.length; i++) {
        StringReader sr = new StringReader(fn[i].toXML().toString());
        Document doc;
        try {
          doc = XMLTools.parse(sr);
        } catch (SAXException e) {
          throw new XMLParsingException("could not parse filter function", e);
        }
        XMLTools.copyNode(doc.getDocumentElement(), queryElem);
      }
    }
    // copy filter into query node
    if (query.getFilter() != null) {
      StringReader sr = new StringReader(query.getFilter().toXML().toString());
      Document doc;
      try {
        doc = XMLTools.parse(sr);
      } catch (SAXException e) {
        throw new XMLParsingException("could not parse filter", e);
      }
      Element elem = XMLTools.appendElement(queryElem, OGCNS, "ogc:Filter");
      XMLTools.copyNode(doc.getDocumentElement(), elem);
    }

    SortProperty[] sp = query.getSortProperties();
    if (sp != null) {
      Element sortBy = XMLTools.appendElement(queryElem, OGCNS, "ogc:SortBy");
      for (int i = 0; i < sp.length; i++) {
        Element sortProp = XMLTools.appendElement(sortBy, OGCNS, "ogc:SortProperty");
        XMLTools.appendElement(
            sortProp, OGCNS, "ogc:PropertyName", sp[i].getSortProperty().getAsString());
        if (!sp[i].getSortOrder()) {
          XMLTools.appendElement(sortBy, OGCNS, "ogc:SortOrder", "DESC");
        }
      }
    }
  }