905648d5c64b5fc2980cec910e0f8add26c53ef6
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / RuleAlgorithms.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 package org.onap.policy.rest.jpa;
21
22 import java.io.Serializable;
23
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.NamedQuery;
30 import javax.persistence.Table;
31 import javax.persistence.Transient;
32
33 import com.att.research.xacml.api.Identifier;
34
35 @Entity
36 @Table(name="RuleAlgorithms")
37 @NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d")
38 public class RuleAlgorithms implements Serializable {
39     private static final long serialVersionUID = 1L;
40
41     public static final char STANDARD = 'S';
42     public static final char CUSTOM = 'C';
43
44     @Id
45     @GeneratedValue(strategy = GenerationType.AUTO)
46     @Column(name="id")
47     private int id;
48
49     @Column(name="is_standard", nullable=false)
50     private char isStandard;
51
52     @Column(name="xacml_id", nullable=false, unique=true, length=255)
53     private String xacmlId;
54
55     @Column(name="short_name", nullable=false, length=64)
56     private String shortName;
57
58     public RuleAlgorithms(Identifier id, char standard) {
59         if (id != null) {
60             this.xacmlId = id.stringValue();
61         }
62         this.isStandard = standard;
63     }
64     public RuleAlgorithms(Identifier id) {
65         this(id, RuleAlgorithms.STANDARD);
66     }
67
68     public RuleAlgorithms() {
69         this(null, RuleAlgorithms.STANDARD);
70     }
71
72     public int getId() {
73         return this.id;
74     }
75
76     public void setId(int id) {
77         this.id = id;
78     }
79
80     public char getIsStandard() {
81         return this.isStandard;
82     }
83
84     public void setIsStandard(char isStandard) {
85         this.isStandard = isStandard;
86     }
87
88     @Transient
89     public boolean isStandard() {
90         return this.isStandard == RuleAlgorithms.STANDARD;
91     }
92
93     @Transient
94     public boolean isCustom() {
95         return this.isStandard == RuleAlgorithms.CUSTOM;
96     }
97
98     public String getXacmlId() {
99         return this.xacmlId;
100     }
101
102     public void setXacmlId(String xacmlId) {
103         this.xacmlId = xacmlId;
104     }
105
106     public String getShortName() {
107         return shortName;
108     }
109
110     public void setShortName(String shortName) {
111         this.shortName = shortName;
112     }
113
114 }