Initial OpenECOMP policy/engine commit
[policy/engine.git] / ECOMP-REST / src / main / java / org / openecomp / policy / rest / jpa / ObadviceExpression.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP-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.openecomp.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.JoinColumn;
31 import javax.persistence.Lob;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.OneToOne;
35 import javax.persistence.Table;
36
37 import org.openecomp.policy.rest.jpa.Attribute;
38
39
40 /**
41  * The persistent class for the ObadviceExpressions database table.
42  * 
43  */
44 @Entity
45 @Table(name="ObadviceExpressions")
46 @NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o")
47 public class ObadviceExpression implements Serializable {
48         private static final long serialVersionUID = 1L;
49
50         public static final String EXPRESSION_APPLY = "Apply";
51         public static final String EXPRESSION_SELECTOR = "Attribute Selector";
52         public static final String EXPRESSION_VALUE = "Attribute Value";
53         public static final String EXPRESSION_FUNCTION = "Function";
54         public static final String EXPRESSION_REFERENCE = "Varable Reference";
55         public static final String EXPRESSION_DESIGNATOR = "Attribute Designator";
56
57         @Id
58         @GeneratedValue(strategy = GenerationType.AUTO)
59         @Column(name="id")
60         private int id;
61
62         //unidirectional one-to-one association to Attribute
63         @OneToOne
64         @JoinColumn(name="attribute_id")
65         private Attribute attribute;
66
67         @Column(name="type", nullable=false)
68         private String type;
69         
70         /*
71         @Lob
72         @Column(name="expression", nullable=false)
73         private byte[] expression;
74         */
75
76         //bi-directional many-to-one association to Obadvice
77         @ManyToOne
78         @JoinColumn(name="obadvice_id")
79         private Obadvice obadvice;
80
81         public ObadviceExpression() {
82                 type = EXPRESSION_VALUE;
83         }
84
85         public int getId() {
86                 return this.id;
87         }
88
89         public void setId(int id) {
90                 this.id = id;
91         }
92
93         public Attribute getAttribute() {
94                 return this.attribute;
95         }
96
97         public void setAttribute(Attribute attribute) {
98                 this.attribute = attribute;
99         }
100
101         public String getType() {
102                 return this.type;
103         }
104
105         public void setType(String type) {
106                 this.type = type;
107         }
108
109         public Obadvice getObadvice() {
110                 return this.obadvice;
111         }
112
113         public void setObadvice(Obadvice obadvice) {
114                 this.obadvice = obadvice;
115         }
116
117         public ObadviceExpression clone() {
118                 ObadviceExpression expression = new ObadviceExpression();
119                 
120                 expression.attribute = this.attribute;
121                 expression.type = this.type;
122                 expression.obadvice = this.obadvice;
123                 
124                 return expression;
125         }
126 }