コード例 #1
0
  /**
   * Return the XML test data for a specified task
   *
   * @param caseID
   * @param taskID
   * @return testData
   */
  public String getTaskTestData(String caseID, String taskID) {
    String testData = null;
    File taskInputData = null;

    Set workItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();
      if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
        try {
          File testDataDir = YAdminGUI.getSpecTestDataDirectory(item.getSpecificationID().getKey());
          taskInputData = new File(testDataDir, taskID + ".xml");
          if (taskInputData.exists()) {
            testData = StringUtil.fileToString(taskInputData);
          }
        } catch (Exception e) {
          reportGeneralProblem(e);
        }
      }
    }

    if (testData == null) {
      return testData;
    } else if (testData.startsWith(xmlCommentHeader)) {
      return testData;
    } else {
      return xmlCommentHeader + taskInputData.getName() + " -->\n" + testData;
    }
  }
コード例 #2
0
  public void attemptToFinishActiveJob(String caseID, String taskID) {
    Set workItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();
      if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
        try {
          String outputData = _myActiveTasks.getOutputData(caseID, taskID);

          /** AJH: Write the output data into test data file */
          File testDataDir = YAdminGUI.getSpecTestDataDirectory(item.getSpecificationID().getKey());
          File taskInputData = new File(testDataDir, taskID + ".xml");
          if (!taskInputData.exists()) {
            logger.info("Creating task data file - " + taskInputData.getAbsolutePath());
            taskInputData.createNewFile();
          }
          StringUtil.stringToFile(taskInputData.getAbsolutePath(), outputData);

          //        _engineClient.completeWorkItem(item, outputData, inSequenceWorkitemIDs);
          _engineClient.completeWorkItem(item, outputData, null, YEngine.WorkItemCompletion.Normal);
        } catch (YDataStateException e) {
          String errors = e.getMessage();
          if (errors.indexOf("FAILED TO VALIDATE AGAINST SCHEMA =") != -1) {
            System.out.println(e.getMessage());
            new SpecificationQueryProcessingValidationErrorBox(_frame, item, e);
          } else {
            new UserInputValidationErrorBox(_frame, item, e);
            System.out.println(e.getMessage());
          }
        } catch (Exception e) {
          // todo AJH - Create defalut skeleton at this point????
          reportGeneralProblem(e);
        }
      }
    }
  }
コード例 #3
0
  private void updateSelf() {
    boolean inSequence = false;
    Set availableWorkItems = _engineClient.getAvailableWorkItems();
    for (Iterator iterator = availableWorkItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();

      if (inSequenceWorkitemIDs.contains(item.getTaskID())) {
        inSequence = true;
      } else {
        inSequence = false;
      }

      if (item.getStatus().equals(YWorkItemStatus.statusEnabled)) {
        addEnabledWorkItem(item, inSequence);
      } else if (item.getStatus().equals(YWorkItemStatus.statusFired)) {
        addFiredWorkItem(item, inSequence);
      }
    }
    Set allWorkItems = _engineClient.getAllWorkItems();
    for (Iterator iterator = allWorkItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();

      if (inSequenceWorkitemIDs.contains(item.getTaskID())) {
        inSequence = true;
      } else {
        inSequence = false;
      }

      if (item.getStatus().equals(YWorkItemStatus.statusExecuting)) {
        addStartedWorkItem(item, inSequence);
      }
      if (_paramsDefinitions.getParamsForTask(item.getTaskID()) == null) {
        YTask task = _engineClient.getTaskDefinition(item.getSpecificationID(), item.getTaskID());
        String paramsAsXML = task.getInformation();
        TaskInformation taskInfo = Marshaller.unmarshalTaskInformation(paramsAsXML);
        YParametersSchema paramsForTask = taskInfo.getParamSchema();
        _paramsDefinitions.setParamsForTask(item.getTaskID(), paramsForTask);
      }
    }
  }
コード例 #4
0
 public void rollBackActiveTask(String caseID, String taskID)
     throws YPersistenceException, YLogException {
   Set workItems = _engineClient.getAllWorkItems();
   for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
     YWorkItem item = (YWorkItem) iterator.next();
     if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
       try {
         _engineClient.rollbackWorkItem(item.getIDString());
       } catch (YStateException e) {
         e.printStackTrace();
       }
     }
   }
 }
コード例 #5
0
 public void createNewInstance(String caseID, String taskID, String newInstanceData)
     throws YPersistenceException {
   Set workItems = _engineClient.getAllWorkItems();
   for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
     YWorkItem item = (YWorkItem) iterator.next();
     if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
       try {
         _engineClient.createNewInstance(item, newInstanceData);
       } catch (YStateException e) {
         e.printStackTrace();
       }
     }
   }
 }
コード例 #6
0
 public boolean allowsDynamicInstanceCreation(String caseID, String taskID) {
   Set workItems = _engineClient.getAllWorkItems();
   for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
     YWorkItem item = (YWorkItem) iterator.next();
     if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
       try {
         _engineClient.checkElegibilityToAddInstances(item.getIDString());
         return true;
       } catch (YStateException e) {
         return false;
       }
     }
   }
   return false;
 }
コード例 #7
0
  // MUTATORS ############################################################################
  public void applyForWorkItem(String caseID, String taskID) throws YPersistenceException {
    Set workItems = _engineClient.getAvailableWorkItems();
    for (Iterator iterator = workItems.iterator(); iterator.hasNext(); ) {
      YWorkItem item = (YWorkItem) iterator.next();
      if (item.getCaseID().toString().equals(caseID) && item.getTaskID().equals(taskID)) {
        try {
          _engineClient.startWorkItem(item, null);

        } catch (YStateException e) {
          e.printStackTrace();
          reportGeneralProblem(e);
        } catch (YDataStateException e) {
          e.printStackTrace();
          new SpecificationQueryProcessingValidationErrorBox(_frame, item, e);
        } catch (YAWLException e) {
          e.printStackTrace();
          reportGeneralProblem(e);
        }
      }
    }
  }