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.policy.operational;
26 import com.google.gson.JsonObject;
27 import com.google.gson.annotations.Expose;
28 import java.io.Serializable;
30 import javax.persistence.Column;
31 import javax.persistence.Convert;
32 import javax.persistence.Entity;
33 import javax.persistence.FetchType;
34 import javax.persistence.Id;
35 import javax.persistence.JoinColumn;
36 import javax.persistence.ManyToOne;
37 import javax.persistence.Table;
38 import org.hibernate.annotations.Type;
39 import org.hibernate.annotations.TypeDef;
40 import org.hibernate.annotations.TypeDefs;
41 import org.onap.clamp.loop.Loop;
42 import org.onap.clamp.policy.Policy;
43 import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
46 @Table(name = "operational_policies")
47 @TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
48 public class OperationalPolicy implements Serializable, Policy {
52 private static final long serialVersionUID = 6117076450841538255L;
56 @Column(nullable = false, name = "name", unique = true)
61 @Column(columnDefinition = "json", name = "configurations_json")
62 private JsonObject configurationsJson;
64 @ManyToOne(fetch = FetchType.LAZY)
65 @JoinColumn(name = "loop_id", nullable = false)
68 public OperationalPolicy() {
72 public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson) {
75 this.configurationsJson = configurationsJson;
78 public String getName() {
82 public void setLoop(Loop loopName) {
86 public Loop getLoop(){
91 public JsonObject getJsonRepresentation() {
92 return configurationsJson;
95 public JsonObject getConfigurationsJson() {
96 return configurationsJson;
99 public void setConfigurationsJson(JsonObject configurationsJson) {
100 this.configurationsJson = configurationsJson;
104 public int hashCode() {
105 final int prime = 31;
107 result = prime * result + ((name == null) ? 0 : name.hashCode());
112 public boolean equals(Object obj) {
117 if (getClass() != obj.getClass())
119 OperationalPolicy other = (OperationalPolicy) obj;
121 if (other.name != null)
123 } else if (!name.equals(other.name))