summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-10-30 18:47:34 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-10-30 19:00:08 +0100
commit9434371e811ba74364b4495120391524d5478283 (patch)
treea516925dfa0fd73ad00945e12ae3972953d23c7b /src/main
parentb09c24d40e8e11d03a0c51e628b256c27fd1b0d8 (diff)
Add new class for DAO
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>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/CldsDao.java23
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModelProp.java68
2 files changed, 91 insertions, 0 deletions
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
index 6aa5f9127..c5332a6b3 100644
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
@@ -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
index 000000000..dd304b56e
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/CldsModelProp.java
@@ -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;
+ }
+
+}