Roy Golan has uploaded a new change for review.

Change subject: core: share a tranlation table of osinfo with DWH
......................................................................

core: share a tranlation table of osinfo with DWH

Added table dwh_osinfo table with os_id, os_name

On boot, engine loads osinfo, truncates the table and populate it from
what osinfo loaded.

Change-Id: Iad8fc58166534abba0f22d81a733a69bcfaf385b
Signed-off-by: Roy Golan <rgo...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/977740
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
M packaging/dbscripts/create_dwh_views.sql
M packaging/dbscripts/create_tables.sql
3 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/67/17767/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
index 987ebb9..0d72297 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
@@ -2,6 +2,7 @@
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -921,4 +922,22 @@
     public ClusterPolicyDao getClusterPolicyDao() {
         return getDao(ClusterPolicyDao.class);
     }
+
+    /**
+     * This call will populate a translation table of OS Ids to they're name
+     * The translation table shall be in use by DWH
+     *
+     * @param osIdToName OS id to OS Name map
+     */
+    public void populateDwhOsInfo(Map<Integer,String> osIdToName) {
+        // first clear the table
+        getCallsHandler().executeRead("clear_osinfo",)
+        List<MapSqlParameterSource> executions = new 
ArrayList<MapSqlParameterSource>();
+        for (Map.Entry<Integer,String> e : osIdToName.entrySet()) {
+            executions.add(new MapSqlParameterSource()
+                    .addValue("os_id", e.getKey())
+                    .addValue("os_name", e.getValue()));
+        }
+        getCallsHandler().executeStoredProcAsBatch("populateOsInfo", 
executions);
+    }
 }
diff --git a/packaging/dbscripts/create_dwh_views.sql 
b/packaging/dbscripts/create_dwh_views.sql
index 64146f1..d24b994 100644
--- a/packaging/dbscripts/create_dwh_views.sql
+++ b/packaging/dbscripts/create_dwh_views.sql
@@ -503,3 +503,18 @@
                                                  WHERE      (var_name = 
'lastSync')));
 
 
+Create or replace FUNCTION clear_osinfo()
+  RETURNS VOID
+AS $procedure$
+BEGIN
+      TRUNCATE dwh_osinfo;
+END; $procedure$
+LANGUAGE plpgsql;
+
+Create or replace FUNCTION insert_osinfo(v_os_id INTEGER , v_os_name 
VARCHAR(255))
+RETURNS VOID
+   AS $procedure$
+BEGIN
+      INSERT into dwh_osinfo (os_id, os_name) VALUES (v_os_id, v_os_name);
+END; $procedure$
+LANGUAGE plpgsql;
\ No newline at end of file
diff --git a/packaging/dbscripts/create_tables.sql 
b/packaging/dbscripts/create_tables.sql
index 1c6654b..58010fd 100644
--- a/packaging/dbscripts/create_tables.sql
+++ b/packaging/dbscripts/create_tables.sql
@@ -1131,6 +1131,16 @@
 ) WITH OIDS;
 
 -- ----------------------------------------------------------------------
+--  table dwh_osinfo
+-- ----------------------------------------------------------------------
+
+CREATE TABLE dwh_osinfo
+(
+os_id INTEGER NOT NULL,
+os_name VARCHAR(255)
+) WITH OIDS;
+
+-- ----------------------------------------------------------------------
 --  table business_entity_snapshot
 -- ----------------------------------------------------------------------
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad8fc58166534abba0f22d81a733a69bcfaf385b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to