ba1097500b91e010073387d70cefe68b1c3c9c8c
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PolicyAlgorithms.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.rest.jpa;
22
23 import java.io.Serializable;
24
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.GenerationType;
29 import javax.persistence.Id;
30 import javax.persistence.NamedQuery;
31 import javax.persistence.Table;
32 import javax.persistence.Transient;
33
34 import com.att.research.xacml.api.Identifier;
35
36 @Entity
37 @Table(name="PolicyAlgorithms")
38 @NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d")
39 public class PolicyAlgorithms implements Serializable {
40     private static final long serialVersionUID = 1L;
41
42     public static final char STANDARD = 'S';
43     public static final char CUSTOM = 'C';
44
45     @Id
46     @GeneratedValue(strategy = GenerationType.AUTO)
47     @Column(name="id")
48     private int id;
49
50     @Column(name="is_standard", nullable=false)
51     private char isStandard;
52
53     @Column(name="xacml_id", nullable=false, unique=true, length=255)
54     private String xacmlId;
55
56     @Column(name="short_name", nullable=false, length=64)
57     private String shortName;
58
59     public PolicyAlgorithms(Identifier identifier, char standard) {
60         this.isStandard = standard;
61         if (identifier != null) {
62             this.xacmlId = identifier.stringValue();
63         }
64     }
65
66     public PolicyAlgorithms(Identifier identifier) {
67         this(identifier, PolicyAlgorithms.STANDARD);
68     }
69
70     public PolicyAlgorithms() {
71         this(null, PolicyAlgorithms.STANDARD);
72     }
73
74     public int getId() {
75         return this.id;
76     }
77
78     public void setId(int id) {
79         this.id = id;
80     }
81
82     public char getIsStandard() {
83         return this.isStandard;
84     }
85
86     public void setIsStandard(char isStandard) {
87         this.isStandard = isStandard;
88     }
89
90     @Transient
91     public boolean isStandard() {
92         return this.isStandard == PolicyAlgorithms.STANDARD;
93     }
94
95     @Transient
96     public boolean isCustom() {
97         return this.isStandard == PolicyAlgorithms.CUSTOM;
98     }
99
100     public String getXacmlId() {
101         return this.xacmlId;
102     }
103
104     public void setXacmlId(String xacmlId) {
105         this.xacmlId = xacmlId;
106     }
107
108     public String getShortName() {
109         return shortName;
110     }
111
112     public void setShortName(String shortName) {
113         this.shortName = shortName;
114     }
115
116 }