Beispiel #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;
  }