示例#1
0
 protected CmShain selectByPkWithRel(CmShainId cmShainId) {
   val cmShain = this.cmShainBhv.selectByPkWithRel(cmShainId.getValL());
   if (isEmpty(cmShain)) {
     throw new AppMessagesException(new AppMessage(ERROR, "valid.exists", prop("shain")));
   }
   return cmShain;
 }
示例#2
0
  public void inputCsv(final CmShainListForm form) {

    CsvConfig conf = new CsvConfig();
    conf.setIgnoreEmptyLines(true);

    try (DoxCsvEntityReader<CmShainCsv> csv =
        new DoxCsvEntityReader<>(form.uploadedCsvFile, conf, CmShainCsv.class)) {

      csv.stream()
          .forEach(
              line -> {
                CmShainId cmShainId = CmShainId.of(line.cmShainId);
                if (cmShainId.isEmpty()) {
                  this.cmShainBhv.insert(line.copyTo(new CmShain()));
                } else {
                  CmShain cmShain = this.cmShainBhv.selectByPK(cmShainId.getValL()).get();
                  this.cmShainBhv.update(line.copyTo(cmShain));
                }
              });

    } catch (IOException e) {
      throw new DoxBusinessRuntimeException(e);
    }
  }