2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.dao.model;
26 import com.google.gson.JsonObject;
27 import com.google.gson.annotations.Expose;
29 import java.io.Serializable;
30 import java.util.HashSet;
33 import javax.persistence.CascadeType;
34 import javax.persistence.Column;
35 import javax.persistence.Entity;
36 import javax.persistence.EnumType;
37 import javax.persistence.Enumerated;
38 import javax.persistence.FetchType;
39 import javax.persistence.Id;
40 import javax.persistence.JoinColumn;
41 import javax.persistence.JoinTable;
42 import javax.persistence.ManyToMany;
43 import javax.persistence.OneToMany;
44 import javax.persistence.Table;
46 import org.hibernate.annotations.Type;
47 import org.hibernate.annotations.TypeDef;
48 import org.hibernate.annotations.TypeDefs;
49 import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
52 @Table(name = "loops")
53 @TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
54 public class Loop implements Serializable {
59 private static final long serialVersionUID = -286522707701388642L;
63 @Column(nullable = false, name = "name", unique = true)
67 @Column(name = "dcae_deployment_id")
68 private String dcaeDeploymentId;
71 @Column(name = "dcae_deployment_status_url")
72 private String dcaeDeploymentStatusUrl;
75 @Column(name = "dcae_blueprint_id")
76 private String dcaeBlueprintId;
79 @Column(name = "svg_representation")
80 private String svgRepresentation;
84 @Column(columnDefinition = "json", name = "global_properties_json")
85 private JsonObject globalPropertiesJson;
88 @Column(nullable = false, name = "blueprint_yaml")
89 private String blueprint;
92 @Column(nullable = false, name = "last_computed_state")
93 @Enumerated(EnumType.STRING)
94 private LoopState lastComputedState;
97 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
98 private Set<OperationalPolicy> operationalPolicies = new HashSet<>();
101 @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
102 @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
103 private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
106 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
107 private Set<LoopLog> loopLogs = new HashSet<>();
109 public String getName() {
113 public void setName(String name) {
117 public String getDcaeDeploymentId() {
118 return dcaeDeploymentId;
121 public void setDcaeDeploymentId(String dcaeDeploymentId) {
122 this.dcaeDeploymentId = dcaeDeploymentId;
125 public String getDcaeDeploymentStatusUrl() {
126 return dcaeDeploymentStatusUrl;
129 public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
130 this.dcaeDeploymentStatusUrl = dcaeDeploymentStatusUrl;
133 public String getSvgRepresentation() {
134 return svgRepresentation;
137 public void setSvgRepresentation(String svgRepresentation) {
138 this.svgRepresentation = svgRepresentation;
141 public String getBlueprint() {
145 public void setBlueprint(String blueprint) {
146 this.blueprint = blueprint;
149 public LoopState getLastComputedState() {
150 return lastComputedState;
153 public void setLastComputedState(LoopState lastComputedState) {
154 this.lastComputedState = lastComputedState;
157 public Set<OperationalPolicy> getOperationalPolicies() {
158 return operationalPolicies;
161 public void setOperationalPolicies(Set<OperationalPolicy> operationalPolicies) {
162 this.operationalPolicies = operationalPolicies;
165 public Set<MicroServicePolicy> getMicroServicePolicies() {
166 return microServicePolicies;
169 public void setMicroServicePolicies(Set<MicroServicePolicy> microServicePolicies) {
170 this.microServicePolicies = microServicePolicies;
173 public JsonObject getGlobalPropertiesJson() {
174 return globalPropertiesJson;
177 public void setGlobalPropertiesJson(JsonObject globalPropertiesJson) {
178 this.globalPropertiesJson = globalPropertiesJson;
181 public Set<LoopLog> getLoopLogs() {
185 public void setLoopLogs(Set<LoopLog> loopLogs) {
186 this.loopLogs = loopLogs;
189 public void addOperationalPolicy(OperationalPolicy opPolicy) {
190 opPolicy.setLoop(this);
191 operationalPolicies.add(opPolicy);
194 public void addMicroServicePolicy(MicroServicePolicy microServicePolicy) {
195 microServicePolicies.add(microServicePolicy);
196 microServicePolicy.getUsedByLoops().add(this);
199 public void addLog(LoopLog log) {
204 public String getDcaeBlueprintId() {
205 return dcaeBlueprintId;
208 public void setDcaeBlueprintId(String dcaeBlueprintId) {
209 this.dcaeBlueprintId = dcaeBlueprintId;
213 public int hashCode() {
214 final int prime = 31;
216 result = prime * result + ((name == null) ? 0 : name.hashCode());
221 public boolean equals(Object obj) {
226 if (getClass() != obj.getClass())
228 Loop other = (Loop) obj;
230 if (other.name != null)
232 } else if (!name.equals(other.name))