Exemplo n.º 1
0
 public static EDLController createEDLController(
     EDocLiteAssociation edlAssociation,
     EDLGlobalConfig edlGlobalConfig,
     DocumentRouteHeaderValue document) {
   EDLController edlController = createEDLController(edlAssociation, edlGlobalConfig);
   try {
     Document defaultDom = edlController.getDefaultDOM();
     Document documentDom = XmlHelper.readXml(document.getDocContent());
     // get the data node and import it into our default DOM
     Element documentData = (Element) documentDom.getElementsByTagName(EDLXmlUtils.DATA_E).item(0);
     if (documentData != null) {
       Element defaultDomEDL = EDLXmlUtils.getEDLContent(defaultDom, false);
       Element defaultDomData =
           (Element) defaultDomEDL.getElementsByTagName(EDLXmlUtils.DATA_E).item(0);
       defaultDomEDL.replaceChild(defaultDom.importNode(documentData, true), defaultDomData);
     }
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           "Created default Node from document id "
               + document.getDocumentId()
               + " content "
               + XmlJotter.jotNode(defaultDom));
     }
   } catch (Exception e) {
     throw new WorkflowRuntimeException(
         "Problems creating controller for EDL "
             + edlAssociation.getEdlName()
             + " document "
             + document.getDocumentId(),
         e);
   }
   return edlController;
 }
Exemplo n.º 2
0
  public List<RuleTemplateBo> parseRuleTemplates(Element element) throws XmlException {
    List<RuleTemplateBo> ruleTemplates = new ArrayList<RuleTemplateBo>();

    // iterate over any RULE_TEMPLATES elements
    Collection<Element> ruleTemplatesElements = XmlHelper.findElements(element, RULE_TEMPLATES);
    Iterator ruleTemplatesIterator = ruleTemplatesElements.iterator();
    while (ruleTemplatesIterator.hasNext()) {
      Element ruleTemplatesElement = (Element) ruleTemplatesIterator.next();
      Collection<Element> ruleTemplateElements =
          XmlHelper.findElements(ruleTemplatesElement, RULE_TEMPLATE);
      for (Iterator iterator = ruleTemplateElements.iterator(); iterator.hasNext(); ) {
        ruleTemplates.add(parseRuleTemplate((Element) iterator.next(), ruleTemplates));
      }
    }
    return ruleTemplates;
  }
Exemplo n.º 3
0
 private static Element getRootElement(DocumentContent docContent) {
   Element rootElement = null;
   try {
     rootElement = XmlHelper.buildJDocument(docContent.getDocument()).getRootElement();
   } catch (Exception e) {
     throw new WorkflowServiceErrorException("Invalid XML submitted", new ArrayList<Object>());
   }
   return rootElement;
 }
Exemplo n.º 4
0
 /**
  * Parses the RuleTemplateAttributes defined on the rule template element
  *
  * @param attributesElement the jdom Element object for the Rule Template attributes
  * @param ruleTemplate the RuleTemplate object
  * @return the RuleTemplateAttributes defined on the rule template element
  * @throws XmlException
  */
 private List<RuleTemplateAttributeBo> parseRuleTemplateAttributes(
     Element attributesElement, RuleTemplateBo ruleTemplate) throws XmlException {
   List<RuleTemplateAttributeBo> ruleTemplateAttributes = new ArrayList<RuleTemplateAttributeBo>();
   Collection<Element> attributeElements = XmlHelper.findElements(attributesElement, ATTRIBUTE);
   for (Iterator iterator = attributeElements.iterator(); iterator.hasNext(); ) {
     ruleTemplateAttributes.add(
         parseRuleTemplateAttribute((Element) iterator.next(), ruleTemplate));
   }
   return ruleTemplateAttributes;
 }
Exemplo n.º 5
0
  public SimpleResult process(RouteContext context, RouteHelper helper) throws Exception {

    LOG.debug("processing FYIByUniversityId node");
    Element rootElement =
        getRootElement(new StandardDocumentContent(context.getDocument().getDocContent()));
    Collection<Element> fieldElements = XmlHelper.findElements(rootElement, "field");
    Iterator<Element> elementIter = fieldElements.iterator();
    while (elementIter.hasNext()) {
      Element field = (Element) elementIter.next();
      Element version = field.getParentElement();
      if (version.getAttribute("current").getValue().equals("true")) {
        LOG.debug("Looking for studentUid field:  " + field.getAttributeValue("name"));
        if (field.getAttribute("name") != null
            && field.getAttributeValue("name").equals("studentUid")) {
          String employeeId = field.getChildText("value");
          LOG.debug("Should send an FYI to employee ID:  " + employeeId);
          if (!StringUtils.isBlank(employeeId)) {
            Person person = KimApiServiceLocator.getPersonService().getPerson(employeeId);

            if (person == null) {
              throw new WorkflowRuntimeException(
                  "Failed to locate a Person with the given employee ID: " + employeeId);
            }
            if (!context.isSimulation()) {
              KEWServiceLocator.getWorkflowDocumentService()
                  .adHocRouteDocumentToPrincipal(
                      person.getPrincipalId(),
                      context.getDocument(),
                      KewApiConstants.ACTION_REQUEST_FYI_REQ,
                      null,
                      null,
                      "Notification Request",
                      person.getPrincipalId(),
                      "Notification Request",
                      true,
                      null);
            }
            // wfDoc.adHocRouteDocumentToPrincipal(KewApiConstants.ACTION_REQUEST_FYI_REQ,
            // "Notification Request", new EmplIdVO(field.getChildText("value")), "Notification
            // Request", true);
            LOG.debug(
                "Sent FYI using the adHocRouteDocumentToPrincipal function to UniversityID:  "
                    + person.getEmployeeId());
            break;
          }
        }
      }
    }
    return super.process(context, helper);
  }
Exemplo n.º 6
0
  public List<RuleTemplateBo> parseRuleTemplates(InputStream input)
      throws IOException, XmlException {

    try {
      Document doc = XmlHelper.trimSAXXml(input);
      Element root = doc.getRootElement();
      return parseRuleTemplates(root);
    } catch (JDOMException e) {
      throw new XmlException("Parse error.", e);
    } catch (SAXException e) {
      throw new XmlException("Parse error.", e);
    } catch (ParserConfigurationException e) {
      throw new XmlException("Parse error.", e);
    }
  }