2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.tosca;
26 import com.google.gson.annotations.Expose;
27 import java.io.Serializable;
28 import java.util.HashSet;
30 import javax.persistence.CascadeType;
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.FetchType;
34 import javax.persistence.Id;
35 import javax.persistence.JoinColumn;
36 import javax.persistence.JoinTable;
37 import javax.persistence.ManyToMany;
38 import javax.persistence.Table;
39 import org.onap.clamp.loop.common.AuditEntity;
42 * Represents Dictionary.
46 @Table(name = "dictionary")
47 public class Dictionary extends AuditEntity implements Serializable {
50 * The serial version id.
52 private static final long serialVersionUID = -286522707701388645L;
56 @Column(nullable = false, name = "name", unique = true)
60 @Column(name = "dictionary_second_level")
61 private int secondLevelDictionary = 0;
64 @Column(name = "dictionary_type")
65 private String subDictionaryType;
68 @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
70 name = "dictionary_to_dictionaryelements",
71 joinColumns = @JoinColumn(name = "dictionary_name", referencedColumnName = "name"),
72 inverseJoinColumns = {@JoinColumn(
73 name = "dictionary_element_short_name",
74 referencedColumnName = "short_name")})
75 private Set<DictionaryElement> dictionaryElements = new HashSet<>();
82 public String getName() {
89 * @param name the name to set
91 public void setName(String name) {
96 * secondLevelDictionary getter.
98 * @return the secondLevelDictionary
100 public int getSecondLevelDictionary() {
101 return secondLevelDictionary;
105 * secondLevelDictionary setter.
107 * @param secondLevelDictionary the secondLevelDictionary to set
109 public void setSecondLevelDictionary(int secondLevelDictionary) {
110 this.secondLevelDictionary = secondLevelDictionary;
114 * subDictionaryType getter.
116 * @return the subDictionaryType
118 public String getSubDictionaryType() {
119 return subDictionaryType;
123 * subDictionaryType setter.
125 * @param subDictionaryType the subDictionaryType to set
127 public void setSubDictionaryType(String subDictionaryType) {
128 this.subDictionaryType = subDictionaryType;
132 * dictionaryElements getter.
134 * @return the dictionaryElements List of dictionary element
136 public Set<DictionaryElement> getDictionaryElements() {
137 return dictionaryElements;
141 * Method to add a new dictionaryElement to the list.
143 * @param dictionaryElement The dictionary element
145 public void addDictionaryElements(DictionaryElement dictionaryElement) {
146 dictionaryElements.add(dictionaryElement);
147 dictionaryElement.getUsedByDictionaries().add(this);
151 * Method to set dictionaryElements.
153 * @param dictionaryElements The dictionary elements set
155 public void setDictionaryElements(Set<DictionaryElement> dictionaryElements) {
156 this.dictionaryElements = dictionaryElements;
160 * Method to delete a dictionaryElement from the list.
162 * @param dictionaryElement The dictionary element
164 public void removeDictionaryElement(DictionaryElement dictionaryElement) {
165 dictionaryElements.remove(dictionaryElement);
166 dictionaryElement.getUsedByDictionaries().remove(this);
170 * Default Constructor.
172 public Dictionary() {
179 * @param name The Dictionary name
180 * @param secondLevelDictionary defines if dictionary is a secondary level
181 * @param subDictionaryType defines the type of secondary level dictionary
183 public Dictionary(String name, int secondLevelDictionary, String subDictionaryType) {
185 this.secondLevelDictionary = secondLevelDictionary;
186 this.subDictionaryType = subDictionaryType;
190 public int hashCode() {
191 final int prime = 31;
193 result = prime * result + ((name == null) ? 0 : name.hashCode());
198 public boolean equals(Object obj) {
205 if (getClass() != obj.getClass()) {
208 Dictionary other = (Dictionary) obj;
210 if (other.name != null) {
213 } else if (!name.equals(other.name)) {