Beispiel #1
0
  /**
   * @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;
  }
Beispiel #2
0
  /**
   * @param content
   * @return
   */
  public static Document getDocument(Map<String, Object> content) {
    Document doc = new Document();
    if (content.get("documentOut") != null) {

      doc = (Document) content.get("documentOut");
      System.out.println("(1) ::" + doc.getCaseNo());
    } else if (content.get("document") != null) {

      doc = (Document) content.get("document");
      System.out.println("(2) :: " + doc.getCaseNo());

    } else {
      // System.err.println("DocumentDaoHelper.getDocument says Document is null!!");
      String description =
          content.get("description") == null ? null : (String) content.get("description");

      String subject = content.get("subject") == null ? null : (String) content.get("subject");
      if (subject == null) {
        subject = content.get("caseNo") == null ? null : (String) content.get("caseNo");
      }

      String value = content.get("value") == null ? null : (String) content.get("value");

      Integer priority = content.get("priority") == null ? null : (Integer) content.get("priority");

      doc.setDescription(description);
      doc.setCaseNo(subject);
      doc.setValue(value);
      doc.setPriority(priority);
      System.out.println("(3) :: " + doc.getCaseNo());
    }

    if (doc.getId() == null) {

      Object idStr = content.get("documentId");
      if (idStr == null || idStr.equals("null")) {
        idStr = null;
      }
      Long id = idStr == null ? null : new Long(idStr.toString());
      doc.setId(id);
    }

    return doc;
  }