0ef4388c4365d58212c92b87b122dfe719f97333
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / jpa / PIPType.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 import java.util.Set;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.NamedQuery;
32 import javax.persistence.OneToMany;
33 import javax.persistence.Table;
34 import javax.persistence.Transient;
35
36
37 /**
38  * The persistent class for the PIPType database table.
39  * 
40  */
41 @Entity
42 @Table(name="PIPType")
43 @NamedQuery(name="PIPType.findAll", query="SELECT p FROM PIPType p")
44 public class PIPType implements Serializable {
45         private static final long serialVersionUID = 1L;
46         
47         public static final String TYPE_SQL = "SQL";
48         public static final String TYPE_LDAP = "LDAP";
49         public static final String TYPE_CSV = "CSV";
50         public static final String TYPE_HYPERCSV = "Hyper-CSV";
51         public static final String TYPE_CUSTOM = "Custom";
52
53         @Id
54         @GeneratedValue(strategy=GenerationType.AUTO)
55         @Column(name="id")
56         private int id;
57
58         @Column(name="type", nullable=false, length=45)
59         private String type;
60
61         //bi-directional many-to-one association to PIPConfiguration
62         @OneToMany(mappedBy="piptype")
63         private Set<PIPConfiguration> pipconfigurations;
64
65         public PIPType() {
66         }
67
68         public int getId() {
69                 return this.id;
70         }
71
72         public void setId(int id) {
73                 this.id = id;
74         }
75
76         public String getType() {
77                 return this.type;
78         }
79
80         public void setType(String type) {
81                 this.type = type;
82         }
83
84         public Set<PIPConfiguration> getPipconfigurations() {
85                 return this.pipconfigurations;
86         }
87
88         public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) {
89                 this.pipconfigurations = pipconfigurations;
90         }
91
92         public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) {
93                 getPipconfigurations().add(pipconfiguration);
94                 pipconfiguration.setPiptype(this);
95
96                 return pipconfiguration;
97         }
98
99         public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) {
100                 getPipconfigurations().remove(pipconfiguration);
101                 pipconfiguration.setPiptype(null);
102
103                 return pipconfiguration;
104         }
105         
106         @Transient
107         public boolean  isSQL() {
108                 return this.type.equals(TYPE_SQL);
109         }
110
111         @Transient
112         public boolean  isLDAP() {
113                 return this.type.equals(TYPE_LDAP);
114         }
115
116         @Transient
117         public boolean  isCSV() {
118                 return this.type.equals(TYPE_CSV);
119         }
120
121         @Transient
122         public boolean  isHyperCSV() {
123                 return this.type.equals(TYPE_HYPERCSV);
124         }
125
126         @Transient
127         public boolean  isCustom() {
128                 return this.type.equals(TYPE_CUSTOM);
129         }
130
131 }