From: Determe, Sebastien (sd378r) Date: Mon, 30 Oct 2017 17:47:34 +0000 (+0100) Subject: Add new class for DAO X-Git-Tag: v1.1.0~14 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F21339%2F1;p=clamp.git 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) --- 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 6aa5f912..c5332a6b 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 00000000..dd304b56 --- /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; + } + +}