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.List;
28 import org.onap.clamp.clds.dao.CldsDao;
31 * Represents a CLDS Dictionary Item.
33 public class CldsDictionaryItem {
35 private String dictElementId;
36 private String dictionaryId;
37 private String dictElementName;
38 private String dictElementShortName;
39 private String dictElementDesc;
40 private String dictElementType;
41 private String createdBy;
42 private String updatedBy;
43 private String lastUpdatedDate;
46 * Save the dictionary item.
47 * @param dictionaryName The name of the dictionary
48 * @param cldsDao The cldsDao
49 * @param userId The user id
51 public void save(String dictionaryName, CldsDao cldsDao, String userId) {
52 // Check if dictionary exists.
53 List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
54 if (list != null && !list.isEmpty()) {
55 // Dictionary found. We can add or update the dictionary element
56 CldsDictionary cldsDictionary = list.stream().findFirst().get();
57 List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName,
58 cldsDictionary.getDictionaryId(), this.getDictElementShortName());
59 if (dictionaryItems != null && !dictionaryItems.isEmpty()) {
60 CldsDictionaryItem item = dictionaryItems.stream().findFirst().get();
61 cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId);
62 this.setCreatedBy(item.getCreatedBy());
65 this.setCreatedBy(userId);
66 this.setUpdatedBy(userId);
67 cldsDao.insDictionarElements(this, userId);
73 * Get the dictionary element id.
74 * @return the dictElementId
76 public String getDictElementId() {
81 * Set the dictionary element id.
82 * @param dictElementId
83 * the dictElementId to set
85 public void setDictElementId(String dictElementId) {
86 this.dictElementId = dictElementId;
90 * Get the dictionary id.
91 * @return the dictionaryId
93 public String getDictionaryId() {
98 * Set the dictionary id.
100 * the dictionaryId to set
102 public void setDictionaryId(String dictionaryId) {
103 this.dictionaryId = dictionaryId;
107 * Get the dictionary name.
108 * @return the dictElementName
110 public String getDictElementName() {
111 return dictElementName;
115 * Set the dictionary name.
116 * @param dictElementName
117 * the dictElementName to set
119 public void setDictElementName(String dictElementName) {
120 this.dictElementName = dictElementName;
124 * Get the dictionary element short name.
125 * @return the dictElementShortName
127 public String getDictElementShortName() {
128 return dictElementShortName;
132 * Set the dictionary element short name.
133 * @param dictElementShortName
134 * the dictElementShortName to set
136 public void setDictElementShortName(String dictElementShortName) {
137 this.dictElementShortName = dictElementShortName;
141 * Get the dictionary element description.
142 * @return the dictElementDesc
144 public String getDictElementDesc() {
145 return dictElementDesc;
149 * Set the dictionary element description.
150 * @param dictElementDesc
151 * the dictElementDesc to set
153 public void setDictElementDesc(String dictElementDesc) {
154 this.dictElementDesc = dictElementDesc;
158 * Get the dictionary element type.
159 * @return the dictElementType
161 public String getDictElementType() {
162 return dictElementType;
166 * Set the dictionary element type.
167 * @param dictElementType
168 * the dictElementType to set
170 public void setDictElementType(String dictElementType) {
171 this.dictElementType = dictElementType;
175 * Get the createdBy info.
176 * @return the createdBy
178 public String getCreatedBy() {
183 * Set the createdBy info.
185 * the createdBy to set
187 public void setCreatedBy(String createdBy) {
188 this.createdBy = createdBy;
192 * Get the updatedBy info.
193 * @return the updatedBy
195 public String getUpdatedBy() {
200 * Set the updatedBy info.
202 * the updatedBy to set
204 public void setUpdatedBy(String updatedby) {
205 updatedBy = updatedby;
209 * Get the last updated date.
210 * @return the lastUpdatedDate
212 public String getLastUpdatedDate() {
213 return lastUpdatedDate;
217 * Set the last updated date.
218 * @param lastUpdatedDate
219 * the lastUpdatedDate to set
221 public void setLastUpdatedDate(String lastUpdatedDate) {
222 this.lastUpdatedDate = lastUpdatedDate;