8f66204bbc57ddee508e89606257ebaada9173c6
[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  * 
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     // manual intervention required
40     public static final String STATUS_ERROR    = "ERROR";
41     public static final String STATUS_UNKNOWN  = "UNKNOWN";
42
43     private String             id;
44     private String             name;
45     private String             controlNamePrefix;
46     private String             controlNameUuid;
47     private String             bpmnId;
48     private String             bpmnUserid;
49     private String             bpmnText;
50     private String             imageId;
51     private String             imageUserid;
52     private String             imageText;
53     private String             propId;
54     private String             propUserid;
55     private String             propText;
56
57     private boolean            userAuthorizedToUpdate;
58
59     /**
60      * Save template to DB.
61      *
62      * @param cldsDao The cldsDao
63      * @param userid The user Id
64      */
65     public void save(CldsDao cldsDao, String userid) {
66         cldsDao.setTemplate(this, userid);
67     }
68
69     /**
70      * Retrieve from DB.
71      *
72      * @param cldsDao The cldsDao
73      * @param name The template name to retrieve
74      * @param okIfNotFound 
75      *     The flag indicating whether exception will be returned in case nothing is found
76      * @return
77      */
78     public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) {
79         // get from db
80         CldsTemplate template = cldsDao.getTemplate(name);
81         if (template.getId() == null && !okIfNotFound) {
82             throw new NotFoundException();
83         }
84         return template;
85     }
86
87     public String getBpmnUserid() {
88         return bpmnUserid;
89     }
90
91     public void setBpmnUserid(String bpmnUserid) {
92         this.bpmnUserid = bpmnUserid;
93     }
94
95     public String getBpmnText() {
96         return bpmnText;
97     }
98
99     public void setBpmnText(String bpmnText) {
100         this.bpmnText = bpmnText;
101     }
102
103     public String getImageUserid() {
104         return imageUserid;
105     }
106
107     public void setImageUserid(String imageUserid) {
108         this.imageUserid = imageUserid;
109     }
110
111     public String getImageText() {
112         return imageText;
113     }
114
115     public void setImageText(String imageText) {
116         this.imageText = imageText;
117     }
118
119     public String getName() {
120         return name;
121     }
122
123     public void setName(String name) {
124         this.name = name;
125     }
126
127     public String getControlNamePrefix() {
128         return controlNamePrefix;
129     }
130
131     public void setControlNamePrefix(String controlNamePrefix) {
132         this.controlNamePrefix = controlNamePrefix;
133     }
134
135     public String getControlNameUuid() {
136         return controlNameUuid;
137     }
138
139     public void setControlNameUuid(String controlNameUuid) {
140         this.controlNameUuid = controlNameUuid;
141     }
142
143     public String getPropId() {
144         return propId;
145     }
146
147     public void setPropId(String propId) {
148         this.propId = propId;
149     }
150
151     public String getPropUserid() {
152         return propUserid;
153     }
154
155     public void setPropUserid(String propUserid) {
156         this.propUserid = propUserid;
157     }
158
159     public String getPropText() {
160         return propText;
161     }
162
163     public void setPropText(String propText) {
164         this.propText = propText;
165     }
166
167     public String getId() {
168         return id;
169     }
170
171     public void setId(String id) {
172         this.id = id;
173     }
174
175     public String getBpmnId() {
176         return bpmnId;
177     }
178
179     public void setBpmnId(String bpmnId) {
180         this.bpmnId = bpmnId;
181     }
182
183     public String getImageId() {
184         return imageId;
185     }
186
187     public void setImageId(String imageId) {
188         this.imageId = imageId;
189     }
190
191     public boolean isUserAuthorizedToUpdate() {
192         return userAuthorizedToUpdate;
193     }
194
195     public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) {
196         this.userAuthorizedToUpdate = userAuthorizedToUpdate;
197     }
198 }