コード例 #1
0
ファイル: DocumentDaoHelper.java プロジェクト: dastko/WIRA
  /**
   * @param model
   * @return
   */
  public static Document getDoc(DocumentModel model) {
    if (model == null) {
      return null;
    }
    Document doc = new Document();
    doc.setCreated(model.getCreated());
    doc.setDescription(model.getDescription());
    doc.setDocumentDate(model.getDocumentDate());
    doc.setId(model.getId());
    doc.setOwner(LoginHelper.get().getUser(model.getCreatedBy()));
    doc.setCaseNo(model.getSubject());
    doc.setType(getType(model.getType()));
    doc.setDocumentDate(model.getDocumentDate());
    doc.setPartner(model.getPartner());
    doc.setPriority(model.getPriority());
    doc.setValue(model.getValue());
    doc.setStatus(model.getStatus());
    doc.setProcessInstanceId(model.getProcessInstanceId());

    if (model.getProcessInstanceId() != null) {
      ProcessInstanceLog log =
          JPAProcessInstanceDbLog.findProcessInstance(model.getProcessInstanceId());
      if (log != null) doc.setDateSubmitted(log.getStart());
    }

    if (model.getProcessInstanceId() != null) {
      try {
        JBPMHelper.get().loadProgressInfo(doc, model.getProcessInstanceId());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    if (model.getProcessId() == null && model.getType() != null) {
      doc.setProcessId(model.getType().getProcessDef().getProcessId());
    } else {
      doc.setProcessId(model.getProcessId());
    }

    if (doc.getProcessId() != null) {
      doc.setProcessName(JBPMHelper.get().getProcessName(doc.getProcessId()));
    }

    doc.setSessionId(model.getSessionId());
    doc.setHasAttachment(DB.getAttachmentDao().getHasAttachment(model.getId()));
    Collection<ADValue> values = model.getValues();
    if (values != null) {
      for (ADValue val : values) {
        // val.
        DataType type = getDataType(val);

        doc.setValue(val.getFieldName(), getValue(val, type));
      }
    }

    doc.setDetails(getDetails(model.getDetails()));

    return doc;
  }
  @Test
  public void historyLogListTest() throws Exception {
    JaxbHistoryLogList resp = new JaxbHistoryLogList();

    testRoundTrip(resp);

    // vLog
    org.jbpm.process.audit.VariableInstanceLog vLog =
        new org.jbpm.process.audit.VariableInstanceLog(
            23, "process", "varInst", "var", "two", "one");
    vLog.setExternalId("domain");
    Field dateField = org.jbpm.process.audit.VariableInstanceLog.class.getDeclaredField("date");
    dateField.setAccessible(true);
    dateField.set(vLog, new Date());
    Field idField = org.jbpm.process.audit.VariableInstanceLog.class.getDeclaredField("id");
    idField.setAccessible(true);
    idField.set(vLog, 32l);
    resp.getHistoryLogList().add(new JaxbVariableInstanceLog(vLog));

    // pLog
    org.jbpm.process.audit.ProcessInstanceLog pLog =
        new org.jbpm.process.audit.ProcessInstanceLog(23, "process");
    pLog.setDuration(2000l);
    pLog.setEnd(new Date());
    pLog.setExternalId("domain");
    pLog.setIdentity("id");
    pLog.setOutcome("error");
    pLog.setParentProcessInstanceId(42);
    pLog.setProcessName("name");
    pLog.setProcessVersion("1-SNAP");
    pLog.setStatus(2);
    idField = org.jbpm.process.audit.ProcessInstanceLog.class.getDeclaredField("id");
    idField.setAccessible(true);
    idField.set(pLog, 32l);
    resp.getHistoryLogList().add(new JaxbProcessInstanceLog(pLog));

    // nLog
    org.jbpm.process.audit.NodeInstanceLog nLog =
        new org.jbpm.process.audit.NodeInstanceLog(0, 23, "process", "nodeInst", "node", "wally");
    idField = org.jbpm.process.audit.NodeInstanceLog.class.getDeclaredField("id");
    idField.setAccessible(true);
    idField.set(nLog, 32l);
    dateField = org.jbpm.process.audit.NodeInstanceLog.class.getDeclaredField("date");
    dateField.setAccessible(true);
    dateField.set(nLog, new Date());
    nLog.setNodeType("type");
    nLog.setWorkItemId(88l);
    nLog.setConnection("connex");
    nLog.setExternalId("domain");
    resp.getHistoryLogList().add(new JaxbNodeInstanceLog(nLog));

    testRoundTrip(resp);
  }
コード例 #3
0
 public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId) {
   ProcessInstanceLog processInstance =
       JPAProcessInstanceDbLog.findProcessInstance(new Long(instanceId));
   if (processInstance == null) {
     throw new IllegalArgumentException("Could not find process instance " + instanceId);
   }
   Map<String, NodeInstanceLog> nodeInstances = new HashMap<String, NodeInstanceLog>();
   for (NodeInstanceLog nodeInstance :
       JPAProcessInstanceDbLog.findNodeInstances(new Long(instanceId))) {
     if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) {
       nodeInstances.put(nodeInstance.getNodeInstanceId(), nodeInstance);
     } else {
       nodeInstances.remove(nodeInstance.getNodeInstanceId());
     }
   }
   if (!nodeInstances.isEmpty()) {
     List<ActiveNodeInfo> result = new ArrayList<ActiveNodeInfo>();
     for (NodeInstanceLog nodeInstance : nodeInstances.values()) {
       boolean found = false;
       DiagramInfo diagramInfo = getDiagramInfo(processInstance.getProcessId());
       for (DiagramNodeInfo nodeInfo : diagramInfo.getNodeList()) {
         if (nodeInfo.getName().equals("id=" + nodeInstance.getNodeId())) {
           result.add(
               new ActiveNodeInfo(diagramInfo.getWidth(), diagramInfo.getHeight(), nodeInfo));
           found = true;
           break;
         }
       }
       if (!found) {
         throw new IllegalArgumentException(
             "Could not find info for node "
                 + nodeInstance.getNodeId()
                 + " of process "
                 + processInstance.getProcessId());
       }
     }
     return result;
   }
   return null;
 }
コード例 #4
0
  @GET
  @Path("/process/{processDefId: [a-zA-Z0-9-:\\._]+}")
  public Response process_procDefId(@PathParam("processDefId") String processId) {
    Map<String, List<String>> params = getRequestParams(uriInfo);
    Number statusParam = getNumberParam("status", false, params, getRelativePath(uriInfo), false);
    String oper = getRelativePath(uriInfo);
    int[] pageInfo = getPageNumAndPageSize(params, oper);

    Object result;
    if (statusParam != null) {
      if (statusParam.intValue() == ProcessInstance.STATE_ACTIVE) {
        result = getAuditLogService().findActiveProcessInstances(processId);
      } else {
        result = getAuditLogService().findProcessInstances(processId);
      }
    } else {
      result = getAuditLogService().findProcessInstances(processId);
    }

    List<ProcessInstanceLog> procInstLogList = (List<ProcessInstanceLog>) result;

    if (statusParam != null && !statusParam.equals(ProcessInstance.STATE_ACTIVE)) {
      List<ProcessInstanceLog> filteredProcLogList = new ArrayList<ProcessInstanceLog>();
      for (int i = 0;
          i < procInstLogList.size()
              && filteredProcLogList.size() < getMaxNumResultsNeeded(pageInfo);
          ++i) {
        ProcessInstanceLog procLog = procInstLogList.get(i);
        if (procLog.getStatus().equals(statusParam.intValue())) {
          filteredProcLogList.add(procLog);
        }
      }
    }
    procInstLogList = paginate(pageInfo, procInstLogList);
    return createCorrectVariant(new JaxbHistoryLogList(procInstLogList), headers);
  }
  @Test
  public void processInstanceLogNillable() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));

    org.jbpm.process.audit.ProcessInstanceLog origLog =
        new org.jbpm.process.audit.ProcessInstanceLog(54, "org.hospital.patient.triage");
    origLog.setDuration(65l);
    origLog.setEnd(new Date((new Date()).getTime() + 1000));
    origLog.setExternalId("testDomainId");
    origLog.setIdentity("identityNotMemory");

    // nullable/nillable
    // origLog.setStatus(2);
    // origLog.setOutcome("descriptiveErrorCodeOfAnError");
    // origLog.setParentProcessInstanceId(65l);

    origLog.setProcessName("org.process.not.technical");
    origLog.setProcessVersion("v3.14");

    JaxbProcessInstanceLog xmlLog = new JaxbProcessInstanceLog(origLog);
    JaxbProcessInstanceLog newXmlLog = testRoundTrip(xmlLog);

    assertEquals(xmlLog.getProcessInstanceId(), newXmlLog.getProcessInstanceId());
    assertEquals(xmlLog.getProcessId(), newXmlLog.getProcessId());

    assertEquals(xmlLog.getDuration(), newXmlLog.getDuration());
    assertEquals(xmlLog.getEnd(), newXmlLog.getEnd());
    assertEquals(xmlLog.getExternalId(), newXmlLog.getExternalId());
    assertEquals(xmlLog.getIdentity(), newXmlLog.getIdentity());

    assertEquals(xmlLog.getStatus(), newXmlLog.getStatus());
    assertEquals(xmlLog.getOutcome(), newXmlLog.getOutcome());
    assertEquals(xmlLog.getParentProcessInstanceId(), newXmlLog.getParentProcessInstanceId());

    assertEquals(xmlLog.getProcessName(), newXmlLog.getProcessName());
    assertEquals(xmlLog.getProcessVersion(), newXmlLog.getProcessVersion());
  }
  @Test
  public void processInstanceLogTest() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));

    org.jbpm.process.audit.ProcessInstanceLog origLog =
        new org.jbpm.process.audit.ProcessInstanceLog(54, "org.hospital.patient.triage");
    origLog.setDuration(65l);
    origLog.setDuration(234l);
    origLog.setEnd(new Date((new Date()).getTime() + 1000));
    origLog.setExternalId("testDomainId");
    origLog.setIdentity("identityNotMemory");
    origLog.setProcessInstanceDescription("What a process, say!");

    // nullable
    origLog.setStatus(2);
    origLog.setOutcome("descriptiveErrorCodeOfAnError");
    origLog.setParentProcessInstanceId(65l);

    origLog.setProcessName("org.process.not.technical");
    origLog.setProcessVersion("v3.14");

    JaxbProcessInstanceLog xmlLog = new JaxbProcessInstanceLog(origLog);
    xmlLog.setCommandName("test-cmd");
    xmlLog.setIndex(2);
    JaxbProcessInstanceLog newXmlLog = testRoundTrip(xmlLog);
    ComparePair.compareObjectsViaFields(xmlLog, newXmlLog, "id");

    ProcessInstanceLog newLog = newXmlLog.getResult();
    ProcessInstanceLog origCmpLog = origLog;
    assertEquals(origLog.getExternalId(), newLog.getExternalId());
    assertEquals(origCmpLog.getIdentity(), newLog.getIdentity());
    assertEquals(origCmpLog.getOutcome(), newLog.getOutcome());
    assertEquals(origCmpLog.getProcessId(), newLog.getProcessId());
    assertEquals(origCmpLog.getProcessName(), newLog.getProcessName());
    assertEquals(origCmpLog.getProcessVersion(), newLog.getProcessVersion());
    assertEquals(origCmpLog.getDuration(), newLog.getDuration());
    assertEquals(origCmpLog.getEnd(), newLog.getEnd());
    assertEquals(origCmpLog.getParentProcessInstanceId(), newLog.getParentProcessInstanceId());
    assertEquals(origCmpLog.getProcessInstanceId(), newLog.getProcessInstanceId());
    assertEquals(origCmpLog.getStart(), newLog.getStart());
    assertEquals(origCmpLog.getStatus(), newLog.getStatus());
  }