Add new class for DAO 39/21339/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Mon, 30 Oct 2017 17:47:34 +0000 (18:47 +0100)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Mon, 30 Oct 2017 18:00:08 +0000 (19:00 +0100)
Add a new class to map differently the existing DB data and
check duplicates

Change-Id: I1eef75775a2d5a7bee82320171d04956b1e94412
Issue-ID: CLAMP-54
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/dao/CldsDao.java
src/main/java/org/onap/clamp/clds/model/CldsModelProp.java [new file with mode: 0644]

index 6aa5f91..c5332a6 100644 (file)
@@ -43,6 +43,7 @@ import org.onap.clamp.clds.model.CldsDBServiceCache;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.model.CldsModelInstance;
+import org.onap.clamp.clds.model.CldsModelProp;
 import org.onap.clamp.clds.model.CldsServiceData;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.ValueItem;
@@ -501,4 +502,26 @@ public class CldsDao {
         jdbcTemplateObject.execute(HEALTHCHECK);
     }
 
+    /**
+     * Method to get all models with model properties.
+     * 
+     * @return list of CldsModelProp
+     */
+    public List<CldsModelProp> getAllModelProperties() {
+        List<CldsModelProp> cldsModelPropList = new ArrayList<CldsModelProp>();
+        String modelsSql = "select m.model_id, m.model_name, mp.model_prop_id, mp.model_prop_text FROM model m, model_properties mp"
+                + " WHERE m.model_prop_id = mp.model_prop_id";
+        List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql);
+        CldsModelProp cldsModelProp = null;
+        for (Map<String, Object> row : rows) {
+            cldsModelProp = new CldsModelProp();
+            cldsModelProp.setId((String) row.get("model_id"));
+            cldsModelProp.setName((String) row.get("model_name"));
+            cldsModelProp.setPropId((String) row.get("model_prop_id"));
+            cldsModelProp.setPropText((String) row.get("model_prop_text"));
+            cldsModelPropList.add(cldsModelProp);
+        }
+        return cldsModelPropList;
+    }
+
 }
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java b/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java
new file mode 100644 (file)
index 0000000..dd304b5
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.model;
+
+/**
+ * Maintain model name and property text data.
+ */
+public class CldsModelProp {
+
+    private String id;
+    private String name;
+    private String propId;
+    private String propText;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPropId() {
+        return propId;
+    }
+
+    public void setPropId(String propId) {
+        this.propId = propId;
+    }
+
+    public String getPropText() {
+        return propText;
+    }
+
+    public void setPropText(String propText) {
+        this.propText = propText;
+    }
+
+}