コード例 #1
0
  @Override
  public void formatRepeats(
      SubmissionRepeat repeat, FormElementModel repeatElement, Row row, CallingContext cc)
      throws ODKDatastoreException {
    if (repeat == null) {
      row.addFormattedValue(null);
      return;
    }

    List<SubmissionSet> sets = repeat.getSubmissionSets();
    if (sets.size() == 0) {
      row.addFormattedValue(null);
      return;
    }

    Map<String, String> properties = new HashMap<String, String>();
    properties.put(ServletConsts.FORM_ID, repeat.constructSubmissionKey().toString());

    String url =
        HtmlUtil.createHrefWithProperties(
            baseWebServerUrl + BasicConsts.FORWARDSLASH + FormMultipleValueServlet.ADDR,
            properties,
            FormTableConsts.VIEW_LINK_TEXT,
            false);
    row.addFormattedValue(url);
  }
コード例 #2
0
  @Override
  public void formatBinary(
      BlobSubmissionType blobSubmission,
      FormElementModel element,
      String ordinalValue,
      Row row,
      CallingContext cc)
      throws ODKDatastoreException {
    if (blobSubmission == null
        || (blobSubmission.getAttachmentCount(cc) == 0)
        || (blobSubmission.getContentHash(1, cc) == null)) {
      row.addFormattedValue(null);
      return;
    }

    SubmissionKey key = blobSubmission.getValue();
    String linkText;
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(ServletConsts.BLOB_KEY, key.toString());
    if (binariesAsDownloadLink) {
      properties.put(ServletConsts.AS_ATTACHMENT, "yes");
      linkText = FormTableConsts.DOWNLOAD_LINK_TEXT;
      if (blobSubmission.getAttachmentCount(cc) == 1) {
        linkText = blobSubmission.getUnrootedFilename(1, cc);
        if (linkText == null || linkText.length() == 0) {
          linkText = FormTableConsts.DOWNLOAD_LINK_TEXT;
        }
      }
    } else {
      linkText = FormTableConsts.VIEW_LINK_TEXT;
    }
    String url =
        HtmlUtil.createHrefWithProperties(
            baseWebServerUrl + BasicConsts.FORWARDSLASH + BinaryDataServlet.ADDR,
            properties,
            linkText,
            !binariesAsDownloadLink);
    row.addFormattedValue(url);
  }