예제 #1
0
  public String btnView_action() {
    String itemID = (String) hdnSelectedItemID.getValue();
    if (itemID == null) {
      msgPanel.error("No work item selected. Please select a work item to view.");
      return null;
    }

    WorkItemRecord selectedWIR = getSelectedWIR(itemID);

    // maybe the wir isn't started or was part of a cancellation set and now it's gone
    if (selectedWIR == null) {
      msgPanel.error(
          "Cannot view item contents - it appears that the "
              + "selected item may have been removed or cancelled. "
              + "Please see the log files for details.");
      return null;
    }

    _sb.setDynFormType(ApplicationBean.DynFormType.tasklevel);
    DynamicForm df = (DynamicForm) getBean("DynFormFactory");
    String title = "YAWL 3.0 - Edit Work Item";
    String header = "Edit Work Item: " + selectedWIR.getCaseID();
    if (df.makeForm(title, header, _sb.getTaskSchema(selectedWIR), selectedWIR)) {
      _sb.setVisualiserReferred(true);
      _sb.setVisualiserEditedWIR(selectedWIR);
      return "showDynForm";
    } else {
      msgPanel.error(
          "Cannot view item contents - problem initialising "
              + "dynamic form from task specification. "
              + "Please see the log files for details.");
      return null;
    }
  }
예제 #2
0
 private WorkItemRecord getSelectedWIR(String itemID) {
   Set<WorkItemRecord> wirSet = _sb.getQueue(WorkQueue.STARTED);
   WorkItemRecord selectedWIR = null;
   for (WorkItemRecord wir : wirSet) {
     if (wir.getID().equals(itemID)) {
       selectedWIR = wir;
       break;
     }
   }
   return selectedWIR;
 }
 private void unsuspendCase(String caseID) {
   connect();
   try {
     List<WorkItemRecord> wirList = _ibClient.getWorkItemsForCase(caseID, _handle);
     for (WorkItemRecord i : wirList) {
       if (i.getStatus().equalsIgnoreCase("Suspended")) {
         _ibClient.unsuspendWorkItem(i.getID(), _handle);
       }
     }
   } catch (IOException e1) {
     e1.printStackTrace();
   }
 }
  private void ItemPostConstraint(WorkItemRecord wir, String data) {
    AdviceQuery query = new AdviceQuery();

    List<Advice> advs = query.getAdvicesByAdviceJoinPointID(wir.getID());
    if ((advs != null) && (advs.size() > 0)) {
      suspendCase(wir.getCaseID().substring(0, wir.getCaseID().indexOf('.')));
      System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
      System.out.println(
          "suspended case is " + wir.getCaseID().substring(0, wir.getCaseID().indexOf('.')));
      for (Advice advice : advs) {
        SAXBuilder builder = new SAXBuilder();

        List<org.jdom2.Element> ls = null;
        org.jdom2.Element root = null;
        try {
          org.jdom2.Document document = builder.build(new StringReader(data));
          ls = document.getRootElement().getChildren();
        } catch (Exception e) {
          System.out.println(e);
        }
        String s = "<" + advice.getProceedName() + ">";
        for (org.jdom2.Element l : ls) {
          s = s + "<" + l.getName() + ">" + l.getText() + "</" + l.getName() + ">";
        }
        s = s + "</" + advice.getProceedName() + ">";

        connect();

        advice.setSynched(false);
        this._Persister.beginTransaction();
        this._Persister.update(advice);
        this._Persister.commit();

        System.out.println(
            "*** try to checkin workitem with proceed id of "
                + advice.getProceedID()
                + " - with data: "
                + s);
        try {
          _ibClient.checkInWorkItem(advice.getProceedID(), s, "", _handle);
        } catch (IOException e) {
          System.out.println("************************ problem in checkin");
          e.printStackTrace();
        }
      }
    }
  }
  public void withdrawOffer(WorkItemRecord wir, HashSet<Participant> offeredSet) {
    if (offeredSet != null) {
      for (Participant p : offeredSet) {
        p.getWorkQueues().removeFromQueue(wir, WorkQueue.OFFERED);
        _rm.announceModifiedQueue(p.getID());
      }
    }

    // a fired instance of a multi-instance workitem on the unoffered queue will
    // never have been offered, so the warning should be suppressed for those
    else if (!wir.getStatus().equals(WorkItemRecord.statusFired)) {
      _log.warn(
          "Workitem '"
              + wir.getID()
              + "' does not have 'Offered' status, "
              + "or is no longer active");
    }
  }
 private String getWorkItemData(String taskID, String workitemID) {
   String result = null;
   connect();
   try {
     List<WorkItemRecord> wirl = _ibClient.getWorkItemsForTask(taskID, _handle);
     for (WorkItemRecord r : wirl) {
       if (r.getID().equalsIgnoreCase(workitemID)) {
         result = r.getDataListString();
         if (result == null) {
           System.out.println("---------- the workitem is not yet updated ------------");
           result = getWorkItemData(taskID, workitemID);
         }
       }
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
   return result;
 }
  private void suspendCase(String caseID) {
    connect();
    try {
      List<WorkItemRecord> wirList = null;
      wirList = _ibClient.getLiveWorkItemsForIdentifier("case", caseID, _handle);

      System.out.println(
          "---- There are totally "
              + (wirList == null ? "null" : Integer.valueOf(wirList.size()))
              + " workitems");
      for (WorkItemRecord i : wirList) {
        if (!_ibClient.successful(_ibClient.suspendWorkItem(i.getID(), _handle))) {
          System.out.println(" * problem is suspending the workitem with id " + i.getID());
        }
      }
    } catch (Exception e1) {
      System.out.println("---- error is suspendsion:" + e1.getMessage());
      e1.printStackTrace();
    }
  }
 private String getNetParamValue(WorkItemRecord wir, String name) {
   String result = null;
   try {
     result = _rm.getNetParamValue(wir.getCaseID(), _name);
     if (result == null)
       _log.error(
           "Unable to retrieve value from net parameter '"
               + name
               + "' for deferred allocation of workitem '"
               + wir.getID()
               + "'.");
   } catch (IOException ioe) {
     _log.error(
         "Caught exception attempting to retrieve value from net parameter '"
             + name
             + "' for deferred allocation of workitem '"
             + wir.getID()
             + "'.");
   }
   return result;
 }
예제 #9
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();
  }
  private void ItemPreConstraint(WorkItemRecord wir, String data) {
    Collection<String> advices = evaluateRule(wir.getSpecURI(), wir.getTaskName(), data);
    if (advices.size() > 0) {
      suspendCase(wir.getCaseID().substring(0, wir.getCaseID().indexOf('.')));
      for (String s : advices) {
        try {
          uploadAdvice(s);

          String res = mapItemParamsToAdviceCaseParams(s, getInputParams(getAdviceID(s)), data);

          Advice advice = new Advice();
          advice.setParentSpecID(wir.getSpecIdentifier());
          advice.setParentSpecName(wir.getSpecURI());
          advice.setParentCaseID(wir.getCaseID().substring(0, wir.getCaseID().indexOf('.')));

          advice.setAdjpID(wir.getID());
          advice.setAdjpDataString(data);
          advice.setAdviceName(s);

          advice.setSynched(false);

          this._Persister.beginTransaction();
          this._Persister.insert(advice);
          this._Persister.commit();

          String adviceCaseID = launchAdvice(getAdviceID(s), res);

          advice.setAdviceCaseID(adviceCaseID);

          this._Persister.beginTransaction();
          this._Persister.update(advice);
          this._Persister.commit();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  private void handleProceedPlaceholder(WorkItemRecord enabledWorkItem) {
    connect();
    try {
      WorkItemRecord childWorkItem = checkOut(enabledWorkItem.getID(), _handle);
      AdviceQuery query = new AdviceQuery();

      List<Advice> advs = query.getByAdviceName(enabledWorkItem.getSpecURI());
      System.out.println(">>>> Number of the same advices are " + advs.size());
      if ((advs != null) && (advs.size() > 0)) {
        System.out.println(">>>> Number of the launched advices are " + advs.size());
        do {
          advs = query.getByAdviceCaseID(enabledWorkItem.getCaseID());
        } while ((advs == null) || (advs.size() == 0));
        System.out.println(">>>> Number of the launched advices are " + advs.size());

        Advice advice = (Advice) advs.get(0);
        advice.setSynched(true);
        advice.setProceedName(enabledWorkItem.getTaskName());
        advice.setProceedID(childWorkItem.getID());

        this._Persister.beginTransaction();
        this._Persister.update(advice);
        this._Persister.commit();

        System.out.println(">>>> Proceed Name is " + advice.getProceedName());
        System.out.println(">>>> Proceed ID is " + advice.getProceedID());

        org.jdom2.Element d =
            getDataforCase(
                advice.getParentSpecName(),
                advice.getParentCaseID(),
                _ibClient.getCaseData(enabledWorkItem.getCaseID(), _handle));

        this._ixClient.updateCaseData(advice.getParentCaseID(), d, _handle);

        weaving(advice.getParentCaseID(), advice.getAdjpID(), false);
      }
    } catch (IOException | YAWLException e) {
      e.printStackTrace();
    }
  }
예제 #12
0
 private String checkParticipantHasQueuedItem(Participant p, WorkItemRecord wir, int qType) {
   String result = success;
   boolean queuedItem = false;
   if (p != null) {
     QueueSet qSet = p.getWorkQueues();
     if (qSet != null) {
       Set<WorkItemRecord> items = qSet.getQueuedWorkItems(qType);
       if (items != null) {
         queuedItem = items.contains(wir);
       }
     }
     if (!queuedItem) {
       result =
           "Work item '"
               + wir.getID()
               + "' is no longer in the "
               + "participant's queue. Please refresh your worklist.";
     }
   } else {
     result = "Could not locate participant with userid supplied.";
   }
   return result;
 }
예제 #13
0
파일: TestUuid.java 프로젝트: Geocent/CTPOS
  public static final void main(final String[] args) throws Exception {

    // This simulates the method:
    // public YParameter[] describeRequiredParams()

    // NOTE: with the addition of Ehcache, RabbitMQ use is required for end
    // of life cycle tasks; e.g., writing data to Gate, to a Neo4J Db, or
    // to a file, etc.
    // The YAWL engine startup and a YawlGatewayObserver class MessagingLoader
    // will load this when in a Yawl server environment, we load here, for
    // testing. BUT, a RabbitMQ server SHALL be running someplace as referenced in the
    // RabbitMqConnection.properties config file.
    LOGGER.info("------------------------------ STARTUP ---------------------------------");
    LOGGER.info("------------------------------------------------------------------------");
    LOGGER.info(
        "Like sands through the hourglass, so are the days of our lives: {}",
        StringUtil.dateAsRfc822(false));
    LOGGER.info("------------------------------------------------------------------------");

    LOGGER.info("----------------------------  EHCACHE   --------------------------------");
    // This gives the system a chance to load the Ehcache properties file
    // and to set up the BootstrapPropertiesFetcher and BootstrapConfigFinder
    // classes, again to bootstrap - individual web apps will
    // need to create their own instances.
    //		BootstrapPropertiesFetcher bspf = new BootstrapPropertiesFetcher();
    //		LOGGER.info("BootstrapPropertiesFetcher: using this server: {}",
    //				bspf.getProperties().getProperty("ehcache.client.serviceurl"));

    LOGGER.info("------------------------------  GATE   ---------------------------------");

    if (null == GateDataStore.getInstance()) {
      LOGGER.info("Gate: Failure on GateDataStore.getInstance(): Gate not available.");
    }

    LOGGER.info("------------------------------  NEO4J  ---------------------------------");

    LOGGER.info("----------------  Using the server instance of Neo4J.  -----------------");

    // Using the Neo4J server instead of embedded due to issues with single instance
    // within this environment.
    // See the PersistenceConnection.properties file.

    LOGGER.info("-------------------------  CAMEL FILEMOVER  ----------------------------");

    FileMover fm = new FileMover("FileMover.properties");
    fm.prepareCamelContext();

    LOGGER.info("----------------------  CAMEL FILEPROCESSOR  ---------------------------");

    FileProcessor fp = new FileProcessor("FileProcessor.properties");
    fp.prepareCamelContext();

    LOGGER.info("----------------------  CAMEL IMAPPROCESSOR  ---------------------------");

    ImapProcessor imp = new ImapProcessor("ImapProcessor.properties");
    imp.prepareCamelContext();

    LOGGER.info("----------------------  CAMEL GATEPROCESSOR  ---------------------------");

    GateProcessor gp = new GateProcessor("GateFileProcessor.properties");
    gp.prepareCamelContext();

    LOGGER.info("--------------------  CAMEL TIKAFILEPROCESSOR  -------------------------");

    TikaFileProcessor tfp = new TikaFileProcessor("TikaFileProcessor.properties");
    tfp.prepareCamelContext();

    LOGGER.info("----------------------  CAMEL TIKAPROCESSOR  ---------------------------");

    // TikaProcessor is currently using a singleton due to issues writing to
    // Lucene index - one writer per index - always ...
    if (null == TikaLuceneProcessor.getInstance()) {
      LOGGER.info(
          "TikaProcessor: Failure on TikaProcessor.getInstance(): TikaProcessor not available.");
    }

    LOGGER.info("----------------------  CAMEL CMISPROCESSOR  ---------------------------");

    CmisProcessor cp = new CmisProcessor("CmisFileProcessor.properties");
    cp.prepareCamelContext();

    LOGGER.info("------------------------------ RabbitMq --------------------------------");
    LOGGER.info("MessagingLoader: announceEngineInitialised: IS using RabbitMQ listener.");

    if (ProcessKonstants.YDS_MESSAGE_QUEUE_AVAILABLE.equalsIgnoreCase("true")) {
      LOGGER.info("MessagingLoader: announceEngineInitialised: Starting YDS message listener.");
      // Spin off the Receiver instance.
      new Thread(
              new Runnable() {
                public void run() {
                  Receiver.getInstance().receiver(null);
                }
              })
          .start();
    }

    LOGGER.info("------------  PAUSING TO ALLOW ABOVE INSTANCES TO SPIN UP  -------------\n");
    try {
      LOGGER.info("I'm so sleepy, I'll take a quick nap ... {}\n", StringUtil.dateAsRfc822(false));
      Thread.sleep(20000);

    } catch (InterruptedException e) {
      LOGGER.error("Startup Pause: Error in Thread.sleep(20000): ", e.getLocalizedMessage());
    }
    LOGGER.info(
        "Wow, great nap - you've been busy already - let's play! {}\n",
        StringUtil.dateAsRfc822(false));
    LOGGER.info("---------------------------- END STARTUP -------------------------------\n");

    // SNIPPET START: Replace form here down to the last SNIPPET END ...
    LOGGER.info("----------------------------- START TEST -------------------------------");
    LOGGER.info(
        SERVICE_NAME + " TEST: describeRequiredParams: {}", SERVICE_NAME + ProcessKonstants.AVRO);
    LOGGER.info("------------------------------------------------------------------------\n");

    final YParameter[] params =
        SchemaToInputElement.loadRequiredYawlParams(
            SERVICE_NAME + ProcessKonstants.AVRO, ProcessKonstants.RETURN_DATA_SCHEMA);

    // Use the first params element to store documentation
    if (null != params) {
      params[0].setDocumentation("Add a documentation string here.");
    }

    // ----------------------------------------------------------------------
    // This simulates the method:
    // prepareToExecuteCommand()

    String result = SERVICE_NAME + " TEST: Cannot instantiate service: " + CoreKonstants.YDS_FAILED;

    UuidServiceWrapper uuid = new UuidServiceWrapper();

    if (null != uuid) {

      result =
          uuid.updateStatus(
              uuid.getRdm().getResultId(),
              CoreKonstants.YDS_UNKNOWN,
              "Initializing with parameters.",
              SERVICE_NAME);

      //			 {
      //			      "namespace": "org.imsys.naiche.yds.avro",
      //			      "name": "UuidService",
      //			      "type": "record",
      //			      "fields": [
      //			          {"name": "Guid", "type": "string" }
      //			          ]
      //			}

      // Manually create a data element based on corresponding Avro schema.
      Element data = new Element("data");
      Element guid = new Element("Guid");
      guid.setText("yes");
      data.addContent(guid);

      LOGGER.info(SERVICE_NAME + " TEST: data element: {}", data.toString());
      LOGGER.info("---------------------------------------------------------\n");

      Reflection.yawlElementToObject(SERVICE_NAME, data, uuid);

      // Need to build a YawlWorkitemModel object
      WorkItemRecord wir = new WorkItemRecord();

      wir.setCaseID("CaseId50");
      wir.setTaskID(SERVICE_NAME + "-taskId");
      wir.setTaskName(SERVICE_NAME + "-taskName");
      wir.setDataList(data);

      // SNIPPET START
      // Get a json formatted text of the service object.
      ObjectMapper mapper = new ObjectMapper();
      String yawlInputEleAsJson = null;
      try {

        yawlInputEleAsJson = mapper.writeValueAsString(uuid);

        LOGGER.info(SERVICE_NAME + ": prepareToExecuteCommand: Json: {}", yawlInputEleAsJson);

      } catch (JsonParseException e) {
        LOGGER.error(
            SERVICE_NAME
                + ": prepareToExecuteCommand: JsonParseException: {} "
                + e.getLocalizedMessage());
      } catch (JsonMappingException e) {
        LOGGER.error(
            SERVICE_NAME
                + ": prepareToExecuteCommand: JsonMappingException: {} "
                + e.getLocalizedMessage());
      } catch (IOException e) {
        LOGGER.error(
            SERVICE_NAME + ": prepareToExecuteCommand: IOException: {} " + e.getLocalizedMessage());
      }

      // This creates and inputs a YawlWorkitemModel object into a map for later
      // retrieval.
      YawlWorkitemModel ywim =
          new YawlWorkitemModel(
              "serviceRequestId",
              "dataXmlString",
              "serviceName",
              ENGINEUSER,
              ENGINEPASSWORD,
              "wkitemId",
              // inputData will be created when the service object is instantiated
              null,
              // outputData will be created when the service object is instantiated
              null,
              "wkitemTaskName",
              "wkitemTaskId",
              "wkitemCaseId",
              "wkitemSpecUri",
              "wkitemSpecVersion",
              "wkitemSpecIdentifier",
              SERVICE_NAME + ProcessKonstants.AVRO,
              ProcessKonstants.RETURN_DATA_SCHEMA);

      // Optional, will use in graphDB.
      ywim.setTaskId(wir.getTaskID());
      ywim.setCaseId(wir.getCaseID());
      ywim.setSpecUri(SERVICE_NAME + "SPECIFICATION-NAME");
      ywim.setSpecVersion(SERVICE_NAME + "SPECIFCATION-VERSION");
      ywim.setSpecId(SERVICE_NAME + "SPECIFICATION-GUID");

      ywim.setInputSchemaName(SERVICE_NAME + ProcessKonstants.AVRO);
      ywim.setOutputSchemaName(ProcessKonstants.RETURN_DATA_SCHEMA);

      // ywim.putWorkitemToMap(uuid.getRdm().getResultId() , ywim);
      // SNIPPET END.

      // This realizes the goal of the service.
      result = uuid.performService();

      LOGGER.info(SERVICE_NAME + " TEST: result: {}", result);
      LOGGER.info("-----------------------END OF TEST--------------------------\n");

      // SNIPPET END: To here with a service class to test. Leave the other external
      // services running to better test some level of integration prior to doing a
      // full build and running in the container.

      LOGGER.info("CAMEL PROCCESES MAY CONTINUE TO RUN - WATCH FOLDERS AND EMAIL FOR OUTPUT");
      LOGGER.info("-------------------------------- END -----------------------------------\n");
    }

    // Give the running services some time to catch up ...
    try {
      Thread.sleep(10000);
    } catch (InterruptedException e) {
      LOGGER.error("Test: Error in Thread.sleep(10000): ", e.getLocalizedMessage());
    }

    BufferedReader ir = new BufferedReader(new InputStreamReader(System.in));
    String s = null;
    System.out.print("\nshutdown prompt:>>> ");
    while ((s = ir.readLine()).length() > 0) {
      if (s.equals("shutdown")) {
        System.out.println("\nSending shutdown request ...");

        System.out.println("Shutdown successful. Quitting console.\n");

        System.exit(0);
      }
      System.out.print("\nshutdown prompt:>>> ");
    }
  }
 public void handleWorkItemStatusChangeEvent(
     WorkItemRecord workItem, String oldStatus, String newStatus) {
   if ((oldStatus.equalsIgnoreCase("Fired")) && (newStatus.equalsIgnoreCase("Executing"))) {
     ItemPreConstraint(workItem, getWorkItemData(workItem.getTaskID(), workItem.getID()));
   }
 }
예제 #15
0
  private void startAndShow(String userid, WorkItemRecord wir) {
    String errMsg = null;
    WorkItemRecord startedItem = null;
    Participant p = rm.getParticipantFromUserID(userid);
    if (wir.hasStatus(WorkItemRecord.statusEnabled) || wir.hasStatus(WorkItemRecord.statusFired)) {
      if (wir.hasResourceStatus(WorkItemRecord.statusResourceOffered)
          || wir.hasResourceStatus(WorkItemRecord.statusResourceUnoffered)) {
        errMsg = checkParticipantHasQueuedItem(p, wir, WorkQueue.OFFERED);
        if (successful(errMsg)) {
          errMsg = null;
          wir = rm.acceptOffer(p, wir);
          if (wir.hasStatus(WorkItemRecord.statusExecuting)) { // system start
            startedItem = wir;
          }
        }
      }
      if ((errMsg == null) && (startedItem == null)) {
        if (wir.hasResourceStatus(WorkItemRecord.statusResourceAllocated)) {
          errMsg = checkParticipantHasQueuedItem(p, wir, WorkQueue.ALLOCATED);
          if (successful(errMsg)) {
            errMsg = null;
            if (rm.start(p, wir)) {
              startedItem = rm.getExecutingChild(wir);
            } else {
              errMsg =
                  "Could not start workitem '"
                      + wir.getID()
                      + "'. Please see the log files for details.";
            }
          }
        } else {
          errMsg =
              "Could not allocate workitem '"
                  + wir.getID()
                  + "'. Please see the log files for details.";
        }
      }
    } else {
      if (wir.hasResourceStatus(WorkItemRecord.statusResourceSuspended)) {
        errMsg = checkParticipantHasQueuedItem(p, wir, WorkQueue.SUSPENDED);
        if (successful(errMsg)) {
          errMsg = null;
          rm.unsuspendWorkItem(p, wir);
        }
      }
      if (errMsg == null) {
        errMsg = checkParticipantHasQueuedItem(p, wir, WorkQueue.STARTED);
        if (successful(errMsg)) {
          errMsg = null;
          startedItem = wir;
        }
      }
    }
    if ((errMsg == null) && (startedItem == null)) {
      errMsg =
          "Could not start workitem '" + wir.getID() + "'. Please see the log files for details.";
    }

    if (errMsg != null) {
      showMessage(errMsg);
    } else {
      showForm(startedItem);
    }
  }
예제 #16
0
 private void completeWorkItem(WorkItemRecord wir, Participant p) {
   String result = _rm.checkinItem(p, wir);
   if (_rm.successful(result)) _sb.removeWarnedForNonEdit(wir.getID());
   else msgPanel.error(result);
 }