Fixed the Sonar technical debt.
[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
21 /*
22  *                        AT&T - PROPRIETARY
23  *          THIS FILE CONTAINS PROPRIETARY INFORMATION OF
24  *        AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
25  *             ACCORDANCE WITH APPLICABLE AGREEMENTS.
26  *
27  *          Copyright (c) 2014 AT&T Knowledge Ventures
28  *              Unpublished and Not for Publication
29  *                     All Rights Reserved
30  */
31 package org.onap.policy.rest.jpa;
32
33 import java.io.Serializable;
34
35 import javax.persistence.Column;
36 import javax.persistence.Entity;
37 import javax.persistence.GeneratedValue;
38 import javax.persistence.GenerationType;
39 import javax.persistence.Id;
40 import javax.persistence.NamedQuery;
41 import javax.persistence.Table;
42 import javax.persistence.Transient;
43
44 import com.att.research.xacml.api.Identifier;
45
46 @Entity
47 @Table(name="RuleAlgorithms")
48 @NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d")
49 public class RuleAlgorithms implements Serializable {
50         private static final long serialVersionUID = 1L;
51
52         public static final char STANDARD = 'S';
53         public static final char CUSTOM = 'C';
54
55         @Id
56         @GeneratedValue(strategy = GenerationType.AUTO)
57         @Column(name="id")
58         private int id;
59
60         @Column(name="is_standard", nullable=false)
61         private char isStandard;
62
63         @Column(name="xacml_id", nullable=false, unique=true, length=255)
64         private String xacmlId;
65         
66         @Column(name="short_name", nullable=false, length=64)
67         private String shortName;
68
69         public RuleAlgorithms(Identifier id, char standard) {
70                 if (id != null) {
71                         this.xacmlId = id.stringValue();
72                 }
73                 this.isStandard = standard;
74         }
75         public RuleAlgorithms(Identifier id) {
76                 this(id, RuleAlgorithms.STANDARD);
77         }
78
79         public RuleAlgorithms() {
80                 this(null, RuleAlgorithms.STANDARD);
81         }
82
83         public int getId() {
84                 return this.id;
85         }
86
87         public void setId(int id) {
88                 this.id = id;
89         }
90
91         public char getIsStandard() {
92                 return this.isStandard;
93         }
94
95         public void setIsStandard(char isStandard) {
96                 this.isStandard = isStandard;
97         }
98         
99         @Transient
100         public boolean isStandard() {
101                 return this.isStandard == RuleAlgorithms.STANDARD;
102         }
103         
104         @Transient
105         public boolean isCustom() {
106                 return this.isStandard == RuleAlgorithms.CUSTOM;
107         }
108
109         public String getXacmlId() {
110                 return this.xacmlId;
111         }
112
113         public void setXacmlId(String xacmlId) {
114                 this.xacmlId = xacmlId;
115         }
116
117         public String getShortName() {
118                 return shortName;
119         }
120
121         public void setShortName(String shortName) {
122                 this.shortName = shortName;
123         }
124
125 }