示例#1
0
  private static DataType getDataType(ADValue val) {
    DataType type = null;

    if (val.getBooleanValue() != null) {
      type = DataType.BOOLEAN;
    }

    if (val.getLongValue() != null) {
      type = DataType.INTEGER;
    }

    if (val.getDateValue() != null) {
      type = DataType.DATE;
    }

    if (val.getDoubleValue() != null) {
      type = DataType.DOUBLE;
    }

    if (val.getStringValue() != null) {
      type = DataType.STRING;
    }

    return type;
  }
示例#2
0
  private static Map<String, List<DocumentLine>> getDetails(Collection<DetailModel> details) {
    Map<String, List<DocumentLine>> lines = new HashMap<>();

    for (DetailModel lineModel : details) {
      DocumentLine line = new DocumentLine();
      line.setDocumentId(lineModel.getDocument().getId());
      line.setId(lineModel.getId());
      line.setName(lineModel.getName());

      for (ADValue value : lineModel.getValues()) {
        Value val = getValue(value, getDataType(value));
        line.addValue(value.getFieldName(), val);
      }

      List<DocumentLine> detailz = new ArrayList<>();
      if (lines.get(line.getName()) != null) {
        detailz = lines.get(line.getName());
      } else {
        lines.put(line.getName(), detailz);
      }

      if (!detailz.contains(line)) detailz.add(line);
    }

    return lines;
  }
示例#3
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;
  }