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.loop.template;
26 import com.google.gson.annotations.Expose;
28 import java.io.Serializable;
29 import java.util.HashSet;
32 import javax.persistence.CascadeType;
33 import javax.persistence.Column;
34 import javax.persistence.Entity;
35 import javax.persistence.FetchType;
36 import javax.persistence.Id;
37 import javax.persistence.JoinColumn;
38 import javax.persistence.JoinColumns;
39 import javax.persistence.ManyToOne;
40 import javax.persistence.OneToMany;
41 import javax.persistence.Table;
43 import org.onap.clamp.loop.common.AuditEntity;
46 * This class represents a micro service model for a loop template.
50 @Table(name = "micro_service_models")
51 public class MicroServiceModel extends AuditEntity implements Serializable {
54 * The serial version id.
56 private static final long serialVersionUID = -286522707701376645L;
60 @Column(nullable = false, name = "name", unique = true)
64 * This variable is used to store the type mentioned in the micro-service
68 @Column(nullable = false, name = "policy_type")
69 private String policyType;
71 @Column(nullable = false, name = "blueprint_yaml")
72 private String blueprint;
75 @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
76 @JoinColumns({ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"),
77 @JoinColumn(name = "policy_model_version", referencedColumnName = "version") })
78 private PolicyModel policyModel;
80 @OneToMany(fetch = FetchType.LAZY, mappedBy = "microServiceModel", orphanRemoval = true)
81 private Set<TemplateMicroServiceModel> usedByLoopTemplates = new HashSet<>();
86 * @return the policyModel
88 public PolicyModel getPolicyModel() {
95 * @param policyModel the policyModel to set
97 public void setPolicyModel(PolicyModel policyModel) {
98 this.policyModel = policyModel;
106 public String getName() {
113 * @param name the name to set
115 public void setName(String name) {
122 * @return the policyType
124 public String getPolicyType() {
131 * @param policyType the policyType to set
133 public void setPolicyType(String policyType) {
134 this.policyType = policyType;
140 * @return the blueprint
142 public String getBlueprint() {
149 * @param blueprint the blueprint to set
151 public void setBlueprint(String blueprint) {
152 this.blueprint = blueprint;
156 * usedByLoopTemplates getter.
158 * @return the usedByLoopTemplates
160 public Set<TemplateMicroServiceModel> getUsedByLoopTemplates() {
161 return usedByLoopTemplates;
165 * Default constructor for serialization.
167 public MicroServiceModel() {
173 * @param name The name id
174 * @param policyType The policy model type like
175 * onap.policies.controlloop.operational.common.Apex
176 * @param blueprint The blueprint defined for dcae that contains the policy
178 * @param policyModel The policy model for the policy type mentioned here
180 public MicroServiceModel(String name, String policyType, String blueprint, PolicyModel policyModel) {
182 this.policyType = policyType;
183 this.blueprint = blueprint;
184 this.policyModel = policyModel;
188 public int hashCode() {
189 final int prime = 31;
191 result = prime * result + ((name == null) ? 0 : name.hashCode());
196 public boolean equals(Object obj) {
203 if (getClass() != obj.getClass()) {
206 MicroServiceModel other = (MicroServiceModel) obj;
208 if (other.name != null) {
211 } else if (!name.equals(other.name)) {