/* * (non-Javadoc) * * @see org.cuny.sensors.dao.IDao#save(java.lang.Object) */ @Override public RawFile save(RawFile obj) throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(5); parameters.put(FILE_NAME, obj.getFilename()); parameters.put(FILE_SIZE, obj.getFileSize()); parameters.put(STATUS, obj.getStatus().toString()); parameters.put(BUILDING, obj.getBuilding()); parameters.put(CAMPUS, obj.getCampus()); Number newId = insertActor.executeAndReturnKey(parameters); obj.setId(newId.longValue()); return obj; }
/* * (non-Javadoc) * * @see org.cuny.sensors.dao.IDao#update(java.lang.Object) */ @Override public RawFile update(RawFile obj) throws Exception { RawFile old = get(obj.getId()); this.jdbcTemplate.update( "update " + TABLE_NAME + " set " + FILE_NAME + " = ?, " + FILE_SIZE + " = ?, " + DATASET_COUNT + " = ?, " + SENSOR_COUNT + " = ?, " + RECORD_COUNT + " = ?, " + BUILDING + " = ?," + CAMPUS + " = ?," + STATUS + " = ?," + NOTES + " = ? where " + ID + " = ?", obj.getFilename(), obj.getFileSize(), obj.getDatasetCount(), obj.getSensorCount(), obj.getRecordCount(), obj.getBuilding(), obj.getCampus(), obj.getStatus().toString(), obj.getNotes(), obj.getId()); return old; }
/* * (non-Javadoc) * * @see * org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, * int) */ @Override public RawFile mapRow(ResultSet rs, int rowNum) throws SQLException { RawFile rawfile = new RawFile(); rawfile.setId(rs.getLong(ID)); rawfile.setFilename(rs.getString(FILE_NAME)); rawfile.setFileSize(rs.getLong(FILE_SIZE)); rawfile.setDatasetCount(rs.getInt(DATASET_COUNT)); rawfile.setSensorCount(rs.getInt(SENSOR_COUNT)); rawfile.setRecordCount(rs.getLong(RECORD_COUNT)); rawfile.setBuilding(rs.getString(BUILDING)); rawfile.setCampus(rs.getString(CAMPUS)); rawfile.setStatus(RawFileStatus.valueOf(rs.getString(STATUS))); rawfile.setNotes(rs.getString(NOTES)); rawfile.setImportedTime(rs.getDate(IMPORT_TIME)); rawfile.setBplRawfileId(rs.getLong(BPL_RAW_FILE_ID)); return rawfile; }
/* * (non-Javadoc) * * @see org.cuny.sensors.dao.IDao#remove(java.lang.Object) */ @Override public RawFile remove(RawFile obj) throws Exception { RawFile old = get(obj.getId()); this.jdbcTemplate.update("delete from " + TABLE_NAME + " where " + ID + " = ?", obj.getId()); return old; }