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.annotations.Expose;
27 import com.vladmihalcea.hibernate.type.json.JsonStringType;
29 import java.io.Serializable;
30 import java.util.HashSet;
34 import javax.persistence.CascadeType;
35 import javax.persistence.Column;
36 import javax.persistence.Entity;
37 import javax.persistence.EnumType;
38 import javax.persistence.Enumerated;
39 import javax.persistence.FetchType;
40 import javax.persistence.Id;
41 import javax.persistence.JoinColumn;
42 import javax.persistence.JoinTable;
43 import javax.persistence.ManyToMany;
44 import javax.persistence.OneToMany;
45 import javax.persistence.Table;
47 import org.hibernate.annotations.Type;
48 import org.hibernate.annotations.TypeDef;
51 @Table(name = "loops")
52 //@JsonAdapter(JsonLoopAdapter.class)
53 @TypeDef(name = "json", typeClass = JsonStringType.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 = "svg_representation")
76 private String svgRepresentation;
80 @Column(columnDefinition = "json", name = "global_properties_json")
81 private Map<String, Object> globalPropertiesJson;
84 @Column(nullable = false, name = "blueprint_yaml")
85 private String blueprint;
88 @Column(nullable = false, name = "last_computed_state")
89 @Enumerated(EnumType.STRING)
90 private LoopState lastComputedState;
93 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
94 private Set<OperationalPolicy> operationalPolicies = new HashSet<>();
97 @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
98 @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id"))
99 private Set<MicroServicePolicy> microServicePolicies = new HashSet<>();
102 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
103 private Set<LoopLog> loopLogs = new HashSet<>();
105 public String getName() {
109 public void setName(String name) {
113 public String getDcaeDeploymentId() {
114 return dcaeDeploymentId;
117 public void setDcaeDeploymentId(String dcaeDeploymentId) {
118 this.dcaeDeploymentId = dcaeDeploymentId;
121 public String getDcaeDeploymentStatusUrl() {
122 return dcaeDeploymentStatusUrl;
125 public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
126 this.dcaeDeploymentStatusUrl = dcaeDeploymentStatusUrl;
129 public String getSvgRepresentation() {
130 return svgRepresentation;
133 public void setSvgRepresentation(String svgRepresentation) {
134 this.svgRepresentation = svgRepresentation;
137 public String getBlueprint() {
141 public void setBlueprint(String blueprint) {
142 this.blueprint = blueprint;
145 public LoopState getLastComputedState() {
146 return lastComputedState;
149 public void setLastComputedState(LoopState lastComputedState) {
150 this.lastComputedState = lastComputedState;
153 public Set<OperationalPolicy> getOperationalPolicies() {
154 return operationalPolicies;
157 public void setOperationalPolicies(Set<OperationalPolicy> operationalPolicies) {
158 this.operationalPolicies = operationalPolicies;
161 public Set<MicroServicePolicy> getMicroServicePolicies() {
162 return microServicePolicies;
165 public void setMicroServicePolicies(Set<MicroServicePolicy> microServicePolicies) {
166 this.microServicePolicies = microServicePolicies;
169 public Map<String, Object> getGlobalPropertiesJson() {
170 return globalPropertiesJson;
173 public void setGlobalPropertiesJson(Map<String, Object> globalPropertiesJson) {
174 this.globalPropertiesJson = globalPropertiesJson;
177 public Set<LoopLog> getLoopLogs() {
181 public void setLoopLogs(Set<LoopLog> loopLogs) {
182 this.loopLogs = loopLogs;
185 public void addOperationalPolicy(OperationalPolicy opPolicy) {
186 opPolicy.setLoop(this);
187 operationalPolicies.add(opPolicy);
190 public void addMicroServicePolicy(MicroServicePolicy microServicePolicy) {
191 microServicePolicies.add(microServicePolicy);
192 microServicePolicy.getUsedByLoops().add(this);
195 public void addLog(LoopLog log) {