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;
69 fetch = FetchType.EAGER,
70 cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
72 name = "dictionary_to_dictionaryelements",
73 joinColumns = @JoinColumn(name = "dictionary_name", referencedColumnName = "name"),
74 inverseJoinColumns = {@JoinColumn(
75 name = "dictionary_element_short_name",
76 referencedColumnName = "short_name")})
77 private Set<DictionaryElement> dictionaryElements = new HashSet<>();
84 public String getName() {
91 * @param name the name to set
93 public void setName(String name) {
98 * secondLevelDictionary getter.
100 * @return the secondLevelDictionary
102 public int getSecondLevelDictionary() {
103 return secondLevelDictionary;
107 * secondLevelDictionary setter.
109 * @param secondLevelDictionary the secondLevelDictionary to set
111 public void setSecondLevelDictionary(int secondLevelDictionary) {
112 this.secondLevelDictionary = secondLevelDictionary;
116 * subDictionaryType getter.
118 * @return the subDictionaryType
120 public String getSubDictionaryType() {
121 return subDictionaryType;
125 * subDictionaryType setter.
127 * @param subDictionaryType the subDictionaryType to set
129 public void setSubDictionaryType(String subDictionaryType) {
130 this.subDictionaryType = subDictionaryType;
134 * dictionaryElements getter.
136 * @return the dictionaryElements List of dictionary element
138 public Set<DictionaryElement> getDictionaryElements() {
139 return dictionaryElements;
143 * Method to add a new dictionaryElement to the list.
145 * @param dictionaryElement The dictionary element
147 public void addDictionaryElements(DictionaryElement dictionaryElement) {
148 dictionaryElements.add(dictionaryElement);
149 dictionaryElement.getUsedByDictionaries().add(this);
153 * Method to delete a dictionaryElement from the list.
155 * @param dictionaryElement The dictionary element
157 public void removeDictionaryElement(DictionaryElement dictionaryElement) {
158 dictionaryElements.remove(dictionaryElement);
159 dictionaryElement.getUsedByDictionaries().remove(this);
163 * Default Constructor.
165 public Dictionary() {
172 * @param name The Dictionary name
173 * @param secondLevelDictionary defines if dictionary is a secondary level
174 * @param subDictionaryType defines the type of secondary level dictionary
176 public Dictionary(String name, int secondLevelDictionary, String subDictionaryType) {
178 this.secondLevelDictionary = secondLevelDictionary;
179 this.subDictionaryType = subDictionaryType;
183 public int hashCode() {
184 final int prime = 31;
186 result = prime * result + ((name == null) ? 0 : name.hashCode());
191 public boolean equals(Object obj) {
198 if (getClass() != obj.getClass()) {
201 Dictionary other = (Dictionary) obj;
203 if (other.name != null) {
206 } else if (!name.equals(other.name)) {