Rework the Clamp db model
[clamp.git] / src / main / java / org / onap / clamp / clds / model / CldsTemplate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.model;
25
26 import javax.ws.rs.NotFoundException;
27
28 import org.onap.clamp.clds.dao.CldsDao;
29
30 /**
31  * Represent a CLDS Model.
32  */
33 public class CldsTemplate {
34
35     public static final String STATUS_DESIGN   = "DESIGN";
36     public static final String STATUS_ACTIVE   = "ACTIVE";
37     public static final String STATUS_STOPPED  = "STOPPED";
38     public static final String STATUS_DELETING = "DELETING";
39     public static final String STATUS_ERROR    = "ERROR";   // manual
40                                                             // intervention
41                                                             // required
42     public static final String STATUS_UNKNOWN  = "UNKNOWN";
43
44     private String             id;
45     private String             name;
46     private String             controlNamePrefix;
47     private String             controlNameUuid;
48     private String             bpmnId;
49     private String             bpmnUserid;
50     private String             bpmnText;
51     private String             imageId;
52     private String             imageUserid;
53     private String             imageText;
54     private String             propId;
55     private String             propUserid;
56     private String             propText;
57
58     private boolean            userAuthorizedToUpdate;
59
60     /**
61      * Save template to DB.
62      *
63      * @param cldsDao
64      * @param userid
65      */
66     public void save(CldsDao cldsDao, String userid) {
67         cldsDao.setTemplate(this, userid);
68     }
69
70     /**
71      * Retrieve from DB.
72      *
73      * @param cldsDao
74      * @param name
75      * @return
76      */
77     public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
78         // get from db
79         CldsTemplate template = cldsDao.getTemplate(name);
80         if (template.getId() == null && !okIfNotFound) {
81             throw new NotFoundException();
82         }
83         return template;
84     }
85
86     public String getBpmnUserid() {
87         return bpmnUserid;
88     }
89
90     public void setBpmnUserid(String bpmnUserid) {
91         this.bpmnUserid = bpmnUserid;
92     }
93
94     public String getBpmnText() {
95         return bpmnText;
96     }
97
98     public void setBpmnText(String bpmnText) {
99         this.bpmnText = bpmnText;
100     }
101
102     public String getImageUserid() {
103         return imageUserid;
104     }
105
106     public void setImageUserid(String imageUserid) {
107         this.imageUserid = imageUserid;
108     }
109
110     public String getImageText() {
111         return imageText;
112     }
113
114     public void setImageText(String imageText) {
115         this.imageText = imageText;
116     }
117
118     public String getName() {
119         return name;
120     }
121
122     public void setName(String name) {
123         this.name = name;
124     }
125
126     public String getControlNamePrefix() {
127         return controlNamePrefix;
128     }
129
130     public void setControlNamePrefix(String controlNamePrefix) {
131         this.controlNamePrefix = controlNamePrefix;
132     }
133
134     public String getControlNameUuid() {
135         return controlNameUuid;
136     }
137
138     public void setControlNameUuid(String controlNameUuid) {
139         this.controlNameUuid = controlNameUuid;
140     }
141
142     public String getPropId() {
143         return propId;
144     }
145
146     public void setPropId(String propId) {
147         this.propId = propId;
148     }
149
150     public String getPropUserid() {
151         return propUserid;
152     }
153
154     public void setPropUserid(String propUserid) {
155         this.propUserid = propUserid;
156     }
157
158     public String getPropText() {
159         return propText;
160     }
161
162     public void setPropText(String propText) {
163         this.propText = propText;
164     }
165
166     public String getId() {
167         return id;
168     }
169
170     public void setId(String id) {
171         this.id = id;
172     }
173
174     public String getBpmnId() {
175         return bpmnId;
176     }
177
178     public void setBpmnId(String bpmnId) {
179         this.bpmnId = bpmnId;
180     }
181
182     public String getImageId() {
183         return imageId;
184     }
185
186     public void setImageId(String imageId) {
187         this.imageId = imageId;
188     }
189
190     public boolean isUserAuthorizedToUpdate() {
191         return userAuthorizedToUpdate;
192     }
193
194     public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) {
195         this.userAuthorizedToUpdate = userAuthorizedToUpdate;
196     }
197 }