2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.model;
26 import java.util.ArrayList;
27 import java.util.List;
29 import org.onap.clamp.clds.dao.CldsDao;
32 * Represents a CLDS Dictionary.
35 public class CldsDictionary {
37 private String dictionaryId;
38 private String dictionaryName;
39 private String createdBy;
40 private String updatedBy;
41 private String lastUpdatedDate;
42 private List<CldsDictionaryItem> cldsDictionaryItems = new ArrayList<>();
45 * Creates or updates dictionary item for a dictionary in DB
47 * @param dictionaryName
51 public void save(String dictionaryName, CldsDao cldsDao, String userId) {
52 List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
53 if (list != null && !list.isEmpty()) {
54 CldsDictionary cldsDictionary = list.stream().findFirst().get();
55 if (!cldsDictionary.getDictionaryName().equalsIgnoreCase(this.getDictionaryName())) {
56 cldsDao.updateDictionary(cldsDictionary.getDictionaryId(), this, userId);
57 this.setCreatedBy(cldsDictionary.getCreatedBy());
59 this.setDictionaryId(cldsDictionary.getDictionaryId());
60 this.setCreatedBy(cldsDictionary.getCreatedBy());
61 this.setUpdatedBy(cldsDictionary.getUpdatedBy());
62 this.setLastUpdatedDate(cldsDictionary.getLastUpdatedDate());
65 this.setCreatedBy(userId);
66 this.setUpdatedBy(userId);
67 cldsDao.insDictionary(this);
72 * @return the dictionaryId
74 public String getDictionaryId() {
80 * the dictionaryId to set
82 public void setDictionaryId(String dictionaryId) {
83 this.dictionaryId = dictionaryId;
87 * @return the dictionaryName
89 public String getDictionaryName() {
90 return dictionaryName;
94 * @param dictionaryName
95 * the dictionaryName to set
97 public void setDictionaryName(String dictionaryName) {
98 this.dictionaryName = dictionaryName;
102 * @return the createdBy
104 public String getCreatedBy() {
110 * the createdBy to set
112 public void setCreatedBy(String createdBy) {
113 this.createdBy = createdBy;
117 * @return the updatedBy
119 public String getUpdatedBy() {
125 * the updatedBy to set
127 public void setUpdatedBy(String updatedby) {
128 updatedBy = updatedby;
132 * @return the lastUpdatedDate
134 public String getLastUpdatedDate() {
135 return lastUpdatedDate;
139 * @param lastUpdatedDate
140 * the lastUpdatedDate to set
142 public void setLastUpdatedDate(String lastUpdatedDate) {
143 this.lastUpdatedDate = lastUpdatedDate;
147 * @return the cldsDictionaryItems
149 public List<CldsDictionaryItem> getCldsDictionaryItems() {
150 return cldsDictionaryItems;
154 * @param cldsDictionaryItems
155 * the cldsDictionaryItems to set
157 public void setCldsDictionaryItems(List<CldsDictionaryItem> cldsDictionaryItems) {
158 this.cldsDictionaryItems = cldsDictionaryItems;