Exemple #1
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 #2
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());
  }