From 9434371e811ba74364b4495120391524d5478283 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Mon, 30 Oct 2017 18:47:34 +0100 Subject: 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) --- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 23 ++++++++ .../org/onap/clamp/clds/model/CldsModelProp.java | 68 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsModelProp.java (limited to 'src/main/java/org') 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 getAllModelProperties() { + List cldsModelPropList = new ArrayList(); + 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> rows = jdbcTemplateObject.queryForList(modelsSql); + CldsModelProp cldsModelProp = null; + for (Map 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; + } + +} -- cgit 1.2.3-korg