Allon Mureinik has uploaded a new change for review.

Change subject: core: VmTemplateDao extends DefaultGenericDao
......................................................................

core: VmTemplateDao extends DefaultGenericDao

Make VmTemplateDaoDbFacadeImpl implement DefaultGenericDaoDbFacade in
order to save boilerplate code.

Change-Id: I8964b7483fff5af4eb2c000dcdb7d26bec60afd3
Signed-off-by: Allon Mureinik <[email protected]>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
1 file changed, 62 insertions(+), 62 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/13337/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
index 7be0ba6..2f45d6d 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
@@ -24,7 +24,12 @@
 /**
  * <code>VmTemplateDAODbFacadeImpl</code> provides a concrete implementation 
of {@link VmTemplateDAO}.
  */
-public class VmTemplateDAODbFacadeImpl extends BaseDAODbFacade implements 
VmTemplateDAO {
+public class VmTemplateDAODbFacadeImpl extends 
DefaultGenericDaoDbFacade<VmTemplate, Guid> implements VmTemplateDAO {
+
+    public VmTemplateDAODbFacadeImpl() {
+        super("VmTemplate");
+        setProcedureNameForRemove("DeleteVmTemplates");
+    }
 
     @Override
     public VmTemplate get(Guid id) {
@@ -121,71 +126,10 @@
     }
 
     @Override
-    public void save(VmTemplate template) {
-        getCallsHandler().executeModification("InsertVmTemplate", 
getInsertOrUpdateParameters(template));
-    }
-
-    private MapSqlParameterSource getInsertOrUpdateParameters(VmTemplate 
template) {
-        return getCustomMapSqlParameterSource()
-                .addValue("child_count", template.getchild_count())
-                .addValue("creation_date", template.getCreationDate())
-                .addValue("description", template.getDescription())
-                .addValue("mem_size_mb", template.getMemSizeMb())
-                .addValue("name", template.getName())
-                .addValue("num_of_sockets", template.getNumOfSockets())
-                .addValue("cpu_per_socket", template.getCpuPerSocket())
-                .addValue("os", template.getOs())
-                .addValue("vmt_guid", template.getId())
-                .addValue("vds_group_id", template.getVdsGroupId())
-                .addValue("domain", template.getDomain())
-                .addValue("num_of_monitors", template.getNumOfMonitors())
-                .addValue("allow_console_reconnect", 
template.isAllowConsoleReconnect())
-                .addValue("status", template.getstatus())
-                .addValue("usb_policy", template.getUsbPolicy())
-                .addValue("time_zone", template.getTimeZone())
-                .addValue("fail_back", template.isFailBack())
-                .addValue("is_auto_suspend", template.isAutoSuspend())
-                .addValue("vm_type", template.getVmType())
-                .addValue("nice_level", template.getNiceLevel())
-                .addValue("default_boot_sequence",
-                        template.getDefaultBootSequence())
-                .addValue("default_display_type",
-                        template.getDefaultDisplayType())
-                .addValue("priority", template.getPriority())
-                .addValue("auto_startup", template.isAutoStartup())
-                .addValue("is_stateless", template.isStateless())
-                .addValue("is_smartcard_enabled", 
template.isSmartcardEnabled())
-                .addValue("is_delete_protected", template.isDeleteProtected())
-                .addValue("iso_path", template.getIsoPath())
-                .addValue("origin", template.getOrigin())
-                .addValue("initrd_url", template.getInitrdUrl())
-                .addValue("kernel_url", template.getKernelUrl())
-                .addValue("kernel_params", template.getKernelParams())
-                .addValue("is_disabled", template.isDisabled())
-                .addValue("quota_id", template.getQuotaId())
-                .addValue("migration_support", 
template.getMigrationSupport().getValue())
-                .addValue("dedicated_vm_for_vds", 
template.getDedicatedVmForVds())
-                .addValue("tunnel_migration", template.getTunnelMigration())
-                .addValue("vnc_keyboard_layout", 
template.getVncKeyboardLayout())
-                .addValue("min_allocated_mem", template.getMinAllocatedMem());
-    }
-
-    @Override
-    public void update(VmTemplate template) {
-        getCallsHandler().executeModification("UpdateVmTemplate", 
getInsertOrUpdateParameters(template));
-    }
-
-    @Override
     public void updateStatus(Guid id, VmTemplateStatus status) {
         getCallsHandler().executeModification("UpdateVmTemplateStatus", 
getCustomMapSqlParameterSource()
                 .addValue("vmt_guid", id)
                 .addValue("status", status));
-    }
-
-    @Override
-    public void remove(Guid id) {
-        getCallsHandler().executeModification("DeleteVmTemplates", 
getCustomMapSqlParameterSource()
-                .addValue("vmt_guid", id));
     }
 
     @Override
@@ -274,4 +218,60 @@
             return entity;
         }
     }
+
+    @Override
+    protected MapSqlParameterSource createFullParametersMapper(VmTemplate 
template) {
+        return getCustomMapSqlParameterSource()
+                .addValue("child_count", template.getchild_count())
+                .addValue("creation_date", template.getCreationDate())
+                .addValue("description", template.getDescription())
+                .addValue("mem_size_mb", template.getMemSizeMb())
+                .addValue("name", template.getName())
+                .addValue("num_of_sockets", template.getNumOfSockets())
+                .addValue("cpu_per_socket", template.getCpuPerSocket())
+                .addValue("os", template.getOs())
+                .addValue("vmt_guid", template.getId())
+                .addValue("vds_group_id", template.getVdsGroupId())
+                .addValue("domain", template.getDomain())
+                .addValue("num_of_monitors", template.getNumOfMonitors())
+                .addValue("allow_console_reconnect", 
template.isAllowConsoleReconnect())
+                .addValue("status", template.getstatus())
+                .addValue("usb_policy", template.getUsbPolicy())
+                .addValue("time_zone", template.getTimeZone())
+                .addValue("fail_back", template.isFailBack())
+                .addValue("is_auto_suspend", template.isAutoSuspend())
+                .addValue("vm_type", template.getVmType())
+                .addValue("nice_level", template.getNiceLevel())
+                .addValue("default_boot_sequence",
+                        template.getDefaultBootSequence())
+                .addValue("default_display_type",
+                        template.getDefaultDisplayType())
+                .addValue("priority", template.getPriority())
+                .addValue("auto_startup", template.isAutoStartup())
+                .addValue("is_stateless", template.isStateless())
+                .addValue("is_smartcard_enabled", 
template.isSmartcardEnabled())
+                .addValue("is_delete_protected", template.isDeleteProtected())
+                .addValue("iso_path", template.getIsoPath())
+                .addValue("origin", template.getOrigin())
+                .addValue("initrd_url", template.getInitrdUrl())
+                .addValue("kernel_url", template.getKernelUrl())
+                .addValue("kernel_params", template.getKernelParams())
+                .addValue("is_disabled", template.isDisabled())
+                .addValue("quota_id", template.getQuotaId())
+                .addValue("migration_support", 
template.getMigrationSupport().getValue())
+                .addValue("dedicated_vm_for_vds", 
template.getDedicatedVmForVds())
+                .addValue("tunnel_migration", template.getTunnelMigration())
+                .addValue("vnc_keyboard_layout", 
template.getVncKeyboardLayout())
+                .addValue("min_allocated_mem", template.getMinAllocatedMem());
+    }
+
+    @Override
+    protected MapSqlParameterSource createIdParameterMapper(Guid id) {
+        return getCustomMapSqlParameterSource().addValue("vmt_guid", id);
+    }
+
+    @Override
+    protected ParameterizedRowMapper<VmTemplate> createEntityRowMapper() {
+        return VMTemplateRowMapper.instance;
+    }
 }


--
To view, visit http://gerrit.ovirt.org/13337
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8964b7483fff5af4eb2c000dcdb7d26bec60afd3
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

Reply via email to