private String mapItemParamsToAdviceCaseParams(
      String adviceName, List<YParameter> inAspectParams, String data) {
    org.jdom2.Element result = new org.jdom2.Element(adviceName);

    SAXBuilder builder = new SAXBuilder();
    org.jdom2.Element root = null;
    try {
      org.jdom2.Document document = builder.build(new StringReader(data));
      root = document.getRootElement();
    } catch (Exception e) {
      System.out.println(e);
    }
    for (YParameter param : inAspectParams) {
      String paramName = param.getName();
      org.jdom2.Element advElem = root.getChild(paramName);
      try {
        if (advElem != null) {
          org.jdom2.Element copy = (org.jdom2.Element) advElem.clone();
          result.addContent(copy);
        } else {
          result.addContent(new org.jdom2.Element(paramName));
        }
      } catch (IllegalAddException iae) {
        System.out.println("+++++++++++++++++ error:" + iae.getMessage());
      }
    }
    return JDOMUtil.elementToString(result);
  }
    // POST the event
    public void run() {

      Map<String, String> paramsMap = new HashMap<String, String>();
      try {

        // all events have an event type
        paramsMap.put("action", String.valueOf(_command));

        // additional params as required
        switch (_command) {
          case InterfaceX_EngineSideClient.NOTIFY_CHECK_CASE_CONSTRAINTS:
            paramsMap.put("specID", _specID.getIdentifier());
            paramsMap.put("specVersion", _specID.getVersionAsString());
            paramsMap.put("specURI", _specID.getUri());
            paramsMap.put("caseID", _caseID);
            paramsMap.put("preCheck", String.valueOf(_preCheck));
            paramsMap.put("data", _dataStr);
            break;
          case InterfaceX_EngineSideClient.NOTIFY_CHECK_ITEM_CONSTRAINTS:
            paramsMap.put("workItem", _workItem.toXML());
            paramsMap.put("preCheck", String.valueOf(_preCheck));
            paramsMap.put("data", JDOMUtil.documentToString(_dataDoc));
            break;
          case InterfaceX_EngineSideClient.NOTIFY_CANCELLED_CASE:
            paramsMap.put("caseID", _caseID);
            break;
          case InterfaceX_EngineSideClient.NOTIFY_TIMEOUT:
            paramsMap.put("workItem", _workItem.toXML());
            if (_taskList != null) paramsMap.put("taskList", _taskList.toString());
            break;
        }

        // run the post with the appropriate params
        executePost(_observerURI, paramsMap);

      } catch (IOException e) {
        logger.error("failed to call YAWL service", e);
        e.printStackTrace();
      }
    }
Exemplo n.º 3
0
  /** updates a workitem after editing on a dynamic form */
  private void postEditWIR() {
    if (_sb.isWirEdit()) {
      WorkItemRecord wir = _sb.getVisualiserEditedWIR();
      if (wir != null) {
        Element data =
            JDOMUtil.stringToElement(((DynFormFactory) getBean("DynFormFactory")).getDataList());
        wir.setUpdatedData(data);
        _rm.getWorkItemCache().update(wir);

        if (_sb.isCompleteAfterEdit()) {
          completeWorkItem(wir, _sb.getParticipant());
        }
      } else {
        msgPanel.error("Could not complete workitem. Check log for details.");
      }
    }
    _sb.setWirEdit(false);
    _sb.setCompleteAfterEdit(false);
    _sb.setVisualiserReferred(false);
    _sb.setVisualiserEditedWIR(null);
    if (msgPanel.hasMessage()) forceRefresh();
  }