예제 #1
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;
  }
예제 #2
0
  private static void setDetails(DocumentModel docModel, DocumentLine line) {
    DocumentDaoImpl dao = DB.getDocumentDao();

    DetailModel detail = new DetailModel();
    if (line.getId() != null) {
      detail = dao.getDetailById(line.getId());
    }

    detail.setName(line.getName());

    detail.getValues().clear();
    Map<String, Value> vals = line.getValues();
    Collection<Value> values = vals.values();
    for (Value val : values) {
      ADValue previousValue = new ADValue();
      if (val.getId() != null) {
        previousValue = DB.getFormDao().getValue(val.getId());
      }

      ADValue adValue = getValue(previousValue, val);
      assert adValue != null;
      detail.addValue(adValue);
    }

    docModel.addDetail(detail);
  }