Moti Asayag has uploaded a new change for review. Change subject: engine: Refactor VnicProfile row mapper ......................................................................
engine: Refactor VnicProfile row mapper The VnicProfile row mapper is being refactored into a base mapper which will serve both the VnicProfile and the VnicProfileView entities mapping. Change-Id: Iedf16874379c535471f0fb398da315f2eaa3c3a8 Signed-off-by: Moti Asayag <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java 1 file changed, 17 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/17017/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java index 39ba2ca..e1ddbe6 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java @@ -81,21 +81,31 @@ return VnicProfileRowMapper.INSTANCE; } - static class VnicProfileRowMapper implements RowMapper<VnicProfile> { - - public final static VnicProfileRowMapper INSTANCE = new VnicProfileRowMapper(); + static abstract class VnicProfileRowMapperBase<T extends VnicProfile> implements RowMapper<T> { @Override @SuppressWarnings("unchecked") - public VnicProfile mapRow(ResultSet rs, int rowNum) throws SQLException { - VnicProfile entity = new VnicProfile(); - entity.setId(Guid.createGuidFromString(rs.getString("id"))); + public T mapRow(ResultSet rs, int rowNum) throws SQLException { + T entity = createVnicProfileEntity(); + entity.setId(getGuid(rs, "id")); entity.setName(rs.getString("name")); - entity.setNetworkId(Guid.createGuidFromString(rs.getString("network_id"))); + entity.setNetworkId(getGuid(rs, "network_id")); entity.setCustomProperties(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); entity.setPortMirroring(rs.getBoolean("port_mirroring")); return entity; } + + abstract protected T createVnicProfileEntity(); + } + + private static class VnicProfileRowMapper extends VnicProfileRowMapperBase<VnicProfile> { + + public static final VnicProfileRowMapper INSTANCE = new VnicProfileRowMapper(); + + @Override + protected VnicProfile createVnicProfileEntity() { + return new VnicProfile(); + } } } -- To view, visit http://gerrit.ovirt.org/17017 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iedf16874379c535471f0fb398da315f2eaa3c3a8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Moti Asayag <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
