Ejemplo n.º 1
0
    public Genetics mapRow(ResultSet rs, int rowNum) throws SQLException {
      Genetics genetics = new Genetics();

      genetics.setId(rs.getLong(ID_FIELD_NAME));
      genetics.setRadarNo(rs.getLong(RADAR_NO_FIELD_NAME));
      genetics.setTestsDone(Genetics.TestsDone.getTestsDone(rs.getInt(TESTS_DONE_FIELD_NAME)));
      genetics.setLabWhereTestWasDone(rs.getString(LAB_WHERE_TESTS_WERE_DONE_FIELD_NAME));
      genetics.setTestDoneOn(rs.getString(TESTS_DONE_ON_FIELD_NAME));
      genetics.setReferenceNumber(rs.getString(REFERENCE_NUMBER_FIELD_NAME));
      genetics.setWhatResultsShowed(rs.getString(WHAT_RESULTS_SHOWED_FIELD_NAME));
      genetics.setKeyEvidence(rs.getString(KEY_EVIDENCE_FIELD_NAME));
      genetics.setDateSent(rs.getDate(DATE_SENT_FIELD_NAME));

      return genetics;
    }
Ejemplo n.º 2
0
  public void save(Genetics genetics) {
    Map<String, Object> geneticsMap = new HashMap<String, Object>();
    geneticsMap.put(ID_FIELD_NAME, genetics.getId());
    geneticsMap.put(RADAR_NO_FIELD_NAME, genetics.getRadarNo());
    if (genetics.getTestsDone() != null) {
      geneticsMap.put(TESTS_DONE_FIELD_NAME, genetics.getTestsDone().getId());
    }
    geneticsMap.put(LAB_WHERE_TESTS_WERE_DONE_FIELD_NAME, genetics.getLabWhereTestWasDone());
    geneticsMap.put(TESTS_DONE_ON_FIELD_NAME, genetics.getTestDoneOn());
    geneticsMap.put(REFERENCE_NUMBER_FIELD_NAME, genetics.getReferenceNumber());
    geneticsMap.put(WHAT_RESULTS_SHOWED_FIELD_NAME, genetics.getWhatResultsShowed());
    geneticsMap.put(KEY_EVIDENCE_FIELD_NAME, genetics.getKeyEvidence());
    geneticsMap.put(DATE_SENT_FIELD_NAME, genetics.getDateSent());

    if (genetics.hasValidId()) {
      namedParameterJdbcTemplate.update(
          buildUpdateQuery(TABLE_NAME, ID_FIELD_NAME, geneticsMap), geneticsMap);
    } else {
      Number id = geneticsInsert.executeAndReturnKey(geneticsMap);
      genetics.setId(id.longValue());
    }
  }