コード例 #1
0
 private Bind getBindByNodeset(String nodeset) {
   if (context.getForm().getModel() == null) return null;
   for (Bind bind : context.getForm().getModel().getBinds()) {
     Bind result = getBindByNodesetRecursive(bind, nodeset, "");
     if (result != null) return result;
   }
   return null;
 }
コード例 #2
0
 private Submission getSubmissionById(String id) {
   if (context.getForm().getModel() == null) return null;
   for (Submission submission : context.getForm().getModel().getSubmissions()) {
     if (submission.getAttributes().get("id") != null
         && submission.getAttributes().get("id").equals(id)) return submission;
   }
   return null;
 }
コード例 #3
0
  public void exportERDF(Writer writer) {

    for (XFormsUIElement element : context.getForm().getChildElements()) {
      registerResourcesRecursive(element, context.getForm());
    }

    try {
      writer.append("<div class=\"processdata\">");
      appendFormERDF(writer);

      for (XFormsElement element : context.getRegisteredElements()) {
        appendElementERDF(writer, element);
      }

      writer.append("</div>");

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
  private void appendFormERDF(Writer writer) throws IOException {
    String name = context.getForm().getAttributes().get("name");
    if (name == null) name = "";

    String head = "";
    if (context.getForm().getHead() != null) {
      try {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        XMLSerializer serializer = new XMLSerializer();
        serializer.setOutputByteStream(stream);
        serializer.asDOMSerializer();
        serializer.setNamespaces(true);
        serializer.serialize(context.getForm().getHead());
        head = StringEscapeUtils.escapeXml(stream.toString());
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    String nsDeclarations = "";
    for (String key : context.getForm().getNSDeclarations().keySet()) {
      nsDeclarations += "[" + key + "," + context.getForm().getNSDeclarations().get(key) + "]";
    }

    writer.append("<div id=\"" + context.getForm().getResourceId() + "\" class=\"-oryx-canvas\">");
    appendOryxField(writer, "type", STENCILSET_URI + "#" + context.getForm().getStencilId());
    appendXFormsField(writer, "id", "");
    appendXFormsField(writer, "name", name);
    appendXFormsField(writer, "version", "");
    appendXFormsField(writer, "head", head);
    appendXFormsField(writer, "nsdeclarations", nsDeclarations);
    appendOryxField(writer, "mode", "writable");
    appendOryxField(writer, "mode", "fullscreen");
    writer.append(
        "<a rel=\"oryx-stencilset\" href=\"/oryx/stencilsets/xforms/xforms.json\"/>"); // TODO: HACK
                                                                                       // TO MAKE IT
                                                                                       // WORK FOR
                                                                                       // NOW

    for (String id : context.getResourceIds()) {
      writer.append("<a rel=\"oryx-render\" href=\"#" + id + "\"/>");
    }

    writer.append("</div>");
  }