aa8c45ef26c80ca2545f80be761aff076adafc85
[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         // Empty constructor
67     }
68
69     public int getId() {
70         return this.id;
71     }
72
73     public void setId(int id) {
74         this.id = id;
75     }
76
77     public String getType() {
78         return this.type;
79     }
80
81     public void setType(String type) {
82         this.type = type;
83     }
84
85     public Set<PIPConfiguration> getPipconfigurations() {
86         return this.pipconfigurations;
87     }
88
89     public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) {
90         this.pipconfigurations = pipconfigurations;
91     }
92
93     public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) {
94         getPipconfigurations().add(pipconfiguration);
95         pipconfiguration.setPiptype(this);
96
97         return pipconfiguration;
98     }
99
100     public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) {
101         getPipconfigurations().remove(pipconfiguration);
102         pipconfiguration.setPiptype(null);
103
104         return pipconfiguration;
105     }
106
107     @Transient
108     public boolean      isSQL() {
109         return this.type.equals(TYPE_SQL);
110     }
111
112     @Transient
113     public boolean      isLDAP() {
114         return this.type.equals(TYPE_LDAP);
115     }
116
117     @Transient
118     public boolean      isCSV() {
119         return this.type.equals(TYPE_CSV);
120     }
121
122     @Transient
123     public boolean      isHyperCSV() {
124         return this.type.equals(TYPE_HYPERCSV);
125     }
126
127     @Transient
128     public boolean      isCustom() {
129         return this.type.equals(TYPE_CUSTOM);
130     }
131
132 }