コード例 #1
0
  // cache the template...
  protected Transformer getTransformer(Presentation presentation, Map request)
      throws PersistenceException {
    Id renderer = presentation.getTemplate().getRenderer();
    TransformerWrapper wrapper = (TransformerWrapper) presentationTemplateCache.get(renderer);

    if (wrapper == null) {
      wrapper = new TransformerWrapper();
      wrapper.modified = 0;
    }

    Node xsl = getPresentationManager().getNode(renderer);

    if (xsl.getTechnicalMetadata().getLastModified().getTime() > wrapper.modified) {
      try {
        wrapper.transformer =
            TransformerFactory.newInstance().newTransformer(new StreamSource(xsl.getInputStream()));
        wrapper.modified = xsl.getTechnicalMetadata().getLastModified().getTime();
      } catch (TransformerConfigurationException e) {
        throw new OspException(e);
      }
    }

    wrapper.transformer.clearParameters();

    // send request params in as transform params
    for (Iterator i = request.keySet().iterator(); i.hasNext(); ) {
      String paramName = (String) i.next();
      wrapper.transformer.setParameter(paramName, request.get(paramName));
    }

    presentationTemplateCache.put(renderer, wrapper);

    return wrapper.transformer;
  }
コード例 #2
0
  /** * Return boolean array if item feedback is allowed based on feedback options */
  protected Boolean[] getAllowItemFeedback(
      int feedbackOption, List reviews, List<Node> cellForms, List attachments) {
    Boolean[] allowItemFeedback = new Boolean[cellForms.size() + attachments.size()];
    int index = -1;

    // First loop through forms
    for (Iterator cIt = cellForms.iterator(); cIt.hasNext(); ) {
      index++;
      Node thisNode = (Node) cIt.next();

      if (feedbackOption == WizardMatrixConstants.FEEDBACK_OPTION_SINGLE) {
        allowItemFeedback[index] = true;
        for (Iterator rIt = reviews.iterator(); rIt.hasNext(); ) {
          Review thisReview = (Review) rIt.next();
          if (thisReview.getItemId() != null
              && thisReview.getItemId().equals(thisNode.getId().getValue())) {
            allowItemFeedback[index] = false;
            break;
          }
        }
      } else if (feedbackOption == WizardMatrixConstants.FEEDBACK_OPTION_NONE) {
        allowItemFeedback[index] = false;
      } else {
        allowItemFeedback[index] = true;
      }
    }

    // Second loop through attachments
    for (Iterator aIt = attachments.iterator(); aIt.hasNext(); ) {
      index++;
      Node thisNode = (Node) aIt.next();

      if (feedbackOption == WizardMatrixConstants.FEEDBACK_OPTION_SINGLE) {
        allowItemFeedback[index] = true;
        for (Iterator rIt = reviews.iterator(); rIt.hasNext(); ) {
          Review thisReview = (Review) rIt.next();
          if (thisReview.getItemId() != null
              && thisReview.getItemId().equals(thisNode.getId().getValue())) {
            allowItemFeedback[index] = false;
            break;
          }
        }
      } else if (feedbackOption == WizardMatrixConstants.FEEDBACK_OPTION_NONE) {
        allowItemFeedback[index] = false;
      } else {
        allowItemFeedback[index] = true;
      }
    }

    return allowItemFeedback;
  }
コード例 #3
0
 protected String getStyleUrl(Style style) {
   Node styleNode = getMatrixManager().getNode(style.getStyleFile());
   return styleNode.getExternalUri();
 }
コード例 #4
0
 public int compare(Node n1, Node n2) {
   return n1.getName().compareToIgnoreCase(n2.getName());
 }