Beispiel #1
0
  @Test
  public void testPlatforms() {
    try {
      // get row count of experiments in the dataset
      int expected = getDataSet().getTable("Platform").getRowCount();

      // get number of experiments from the DAO
      int actual = getPlatformDAO().count();

      // test data contains 2 experiments, check size of returned list
      TestCase.assertEquals("Wrong number of Platform", expected, actual);
      System.out.println("Expected number of Platform: " + expected + ", actual: " + actual);

      for (Platform d : random(getPlatformDAO(), actual, 5)) {
        TestCase.assertNotNull(d);
        TestCase.assertNotNull(d.getPlatformId());
      }
    } catch (Exception e) {
      e.printStackTrace();
      TestCase.fail();
    }
  }
Beispiel #2
0
 public Platform mapRow(ResultSet rs, int rowNum) throws SQLException {
   Platform p = new PlatformImpl();
   p.setPlatformId(rs.getLong("platformId"));
   p.setPlatformType(PlatformType.get(rs.getString("name")));
   p.setDescription(rs.getString("description"));
   p.setInstrumentModel(rs.getString("instrumentModel"));
   p.setNumContainers(rs.getInt("numContainers"));
   return p;
 }
Beispiel #3
0
  public long save(Platform platform) throws IOException {
    // execute this procedure...
    MapSqlParameterSource params = new MapSqlParameterSource();
    params
        .addValue("name", platform.getPlatformType().getKey())
        .addValue("instrumentModel", platform.getInstrumentModel())
        .addValue("description", platform.getDescription())
        .addValue("numContainers", platform.getNumContainers());

    if (platform.getPlatformId() == null) {
      SimpleJdbcInsert insert =
          new SimpleJdbcInsert(template)
              .withTableName(TABLE_NAME)
              .usingGeneratedKeyColumns("platformId");
      Number newId = insert.executeAndReturnKey(params);
      platform.setPlatformId(newId.longValue());
    } else {
      params.addValue("platformId", platform.getPlatformId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PLATFORM_UPDATE, params);
    }

    return platform.getPlatformId();
  }
 @Transactional(readOnly = false)
 public long save(Platform platform) throws IOException {
   getHibernateTemplate().saveOrUpdate(platform);
   return platform.getPlatformId();
 }