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;
45 public void save(String dictionaryName, CldsDao cldsDao, String userId) {
46 // Check if dictionary exists.
47 List<CldsDictionary> list = cldsDao.getDictionary(this.getDictionaryId(), dictionaryName);
48 if (list != null && !list.isEmpty()) {
49 // Dictionary found. We can add or update the dictionary element
50 CldsDictionary cldsDictionary = list.stream().findFirst().get();
51 List<CldsDictionaryItem> dictionaryItems = cldsDao.getDictionaryElements(dictionaryName,
52 cldsDictionary.getDictionaryId(), this.getDictElementShortName());
53 if (dictionaryItems != null && !dictionaryItems.isEmpty()) {
54 CldsDictionaryItem item = dictionaryItems.stream().findFirst().get();
55 cldsDao.updateDictionaryElements(item.getDictElementId(), this, userId);
56 this.setCreatedBy(item.getCreatedBy());
59 this.setCreatedBy(userId);
60 this.setUpdatedBy(userId);
61 cldsDao.insDictionarElements(this, userId);
67 * @return the dictElementId
69 public String getDictElementId() {
74 * @param dictElementId
75 * the dictElementId to set
77 public void setDictElementId(String dictElementId) {
78 this.dictElementId = dictElementId;
82 * @return the dictionaryId
84 public String getDictionaryId() {
90 * the dictionaryId to set
92 public void setDictionaryId(String dictionaryId) {
93 this.dictionaryId = dictionaryId;
97 * @return the dictElementName
99 public String getDictElementName() {
100 return dictElementName;
104 * @param dictElementName
105 * the dictElementName to set
107 public void setDictElementName(String dictElementName) {
108 this.dictElementName = dictElementName;
112 * @return the dictElementShortName
114 public String getDictElementShortName() {
115 return dictElementShortName;
119 * @param dictElementShortName
120 * the dictElementShortName to set
122 public void setDictElementShortName(String dictElementShortName) {
123 this.dictElementShortName = dictElementShortName;
127 * @return the dictElementDesc
129 public String getDictElementDesc() {
130 return dictElementDesc;
134 * @param dictElementDesc
135 * the dictElementDesc to set
137 public void setDictElementDesc(String dictElementDesc) {
138 this.dictElementDesc = dictElementDesc;
142 * @return the dictElementType
144 public String getDictElementType() {
145 return dictElementType;
149 * @param dictElementType
150 * the dictElementType to set
152 public void setDictElementType(String dictElementType) {
153 this.dictElementType = dictElementType;
157 * @return the createdBy
159 public String getCreatedBy() {
165 * the createdBy to set
167 public void setCreatedBy(String createdBy) {
168 this.createdBy = createdBy;
172 * @return the updatedBy
174 public String getUpdatedBy() {
180 * the updatedBy to set
182 public void setUpdatedBy(String updatedby) {
183 updatedBy = updatedby;
187 * @return the lastUpdatedDate
189 public String getLastUpdatedDate() {
190 return lastUpdatedDate;
194 * @param lastUpdatedDate
195 * the lastUpdatedDate to set
197 public void setLastUpdatedDate(String lastUpdatedDate) {
198 this.lastUpdatedDate = lastUpdatedDate;