Allon Mureinik has uploaded a new change for review. Change subject: core: Singleton row mapper for vds_spm_id_map ......................................................................
core: Singleton row mapper for vds_spm_id_map Added a singleton row mapper for VdsSpmIdMapDAO, as specified by http://www.ovirt.org/Backend_Coding_Standards . Change-Id: I04b439e9e2868d66f612144dd91e4f65becd9936 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsSpmIdMapDAODbFacadeImpl.java 1 file changed, 22 insertions(+), 39 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/12472/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsSpmIdMapDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsSpmIdMapDAODbFacadeImpl.java index 06e5a30..8e1f76b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsSpmIdMapDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsSpmIdMapDAODbFacadeImpl.java @@ -15,22 +15,14 @@ * {@link org.ovirt.engine.core.dal.dbbroker.DbFacade}. */ public class VdsSpmIdMapDAODbFacadeImpl extends BaseDAODbFacade implements VdsSpmIdMapDAO{ + + @Override public vds_spm_id_map get(Guid vdsId) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vds_id", vdsId); - - ParameterizedRowMapper<vds_spm_id_map> mapper = new ParameterizedRowMapper<vds_spm_id_map>() { - @Override - public vds_spm_id_map mapRow(ResultSet rs, int rowNum) throws SQLException { - vds_spm_id_map entity = new vds_spm_id_map(); - entity.setstorage_pool_id(Guid.createGuidFromString(rs.getString("storage_pool_id"))); - entity.setId(Guid.createGuidFromString(rs.getString("vds_id"))); - entity.setvds_spm_id(rs.getInt("vds_spm_id")); - return entity; - } - }; - - return getCallsHandler().executeRead("Getvds_spm_id_mapByvds_id", mapper, parameterSource); + return getCallsHandler().executeRead("Getvds_spm_id_mapByvds_id", + VdsSpmIdMapRowMapper.instance, + parameterSource); } @Override @@ -53,19 +45,9 @@ public List<vds_spm_id_map> getAll(Guid storagePoolId) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("storage_pool_id", storagePoolId); - - ParameterizedRowMapper<vds_spm_id_map> mapper = new ParameterizedRowMapper<vds_spm_id_map>() { - @Override - public vds_spm_id_map mapRow(ResultSet rs, int rowNum) throws SQLException { - vds_spm_id_map entity = new vds_spm_id_map(); - entity.setstorage_pool_id(Guid.createGuidFromString(rs.getString("storage_pool_id"))); - entity.setId(Guid.createGuidFromString(rs.getString("vds_id"))); - entity.setvds_spm_id(rs.getInt("vds_spm_id")); - return entity; - } - }; - - return getCallsHandler().executeReadList("Getvds_spm_id_mapBystorage_pool_id", mapper, parameterSource); + return getCallsHandler().executeReadList("Getvds_spm_id_mapBystorage_pool_id", + VdsSpmIdMapRowMapper.instance, + parameterSource); } @Override @@ -80,20 +62,8 @@ public vds_spm_id_map get(Guid storagePoolId, int spmId ) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("storage_pool_id", storagePoolId).addValue("vds_spm_id", spmId); - - ParameterizedRowMapper<vds_spm_id_map> mapper = new ParameterizedRowMapper<vds_spm_id_map>() { - @Override - public vds_spm_id_map mapRow(ResultSet rs, int rowNum) throws SQLException { - vds_spm_id_map entity = new vds_spm_id_map(); - entity.setstorage_pool_id(Guid.createGuidFromString(rs.getString("storage_pool_id"))); - entity.setId(Guid.createGuidFromString(rs.getString("vds_id"))); - entity.setvds_spm_id(rs.getInt("vds_spm_id")); - return entity; - } - }; - return getCallsHandler().executeRead("Getvds_spm_id_mapBystorage_pool_idAndByvds_spm_id", - mapper, + VdsSpmIdMapRowMapper.instance, parameterSource); } @@ -106,4 +76,17 @@ public void update(vds_spm_id_map entity) { throw new NotImplementedException(); } + + private static final class VdsSpmIdMapRowMapper implements ParameterizedRowMapper<vds_spm_id_map> { + public static final VdsSpmIdMapRowMapper instance = new VdsSpmIdMapRowMapper(); + + @Override + public vds_spm_id_map mapRow(ResultSet rs, int rowNum) throws SQLException { + vds_spm_id_map entity = new vds_spm_id_map(); + entity.setstorage_pool_id(Guid.createGuidFromString(rs.getString("storage_pool_id"))); + entity.setId(Guid.createGuidFromString(rs.getString("vds_id"))); + entity.setvds_spm_id(rs.getInt("vds_spm_id")); + return entity; + } + } } -- To view, visit http://gerrit.ovirt.org/12472 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I04b439e9e2868d66f612144dd91e4f65becd9936 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
