2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 package org.onap.clamp.clds.model;
26 import org.onap.clamp.clds.dao.CldsDao;
29 * Represent a CLDS Event.
31 public class CldsEvent {
33 * The constant ACTION_TEST.
35 public static final String ACTION_TEST = "TEST";
37 * The constant ACTION_CREATE.
39 public static final String ACTION_CREATE = "CREATE";
41 * The constant ACTION_MODIFY.
43 public static final String ACTION_MODIFY = "MODIFY";
45 * The constant ACTION_SUBMIT.
47 public static final String ACTION_SUBMIT = "SUBMIT";
49 * The constant ACTION_RESUBMIT.
51 // an update before model is active
52 public static final String ACTION_RESUBMIT = "RESUBMIT";
54 * The constant ACTION_SUBMITDCAE.
56 // For simplified models
57 public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
59 * The constant ACTION_SUBMITPOLICY.
61 public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
63 * The constant ACTION_DISTRIBUTE.
66 public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
68 * The constant ACTION_DEPLOY.
71 public static final String ACTION_DEPLOY = "DEPLOY";
73 * The constant ACTION_UNDEPLOY.
76 public static final String ACTION_UNDEPLOY = "UNDEPLOY";
78 * The constant ACTION_UPDATE.
80 public static final String ACTION_UPDATE = "UPDATE";
82 * The constant ACTION_DELETE.
84 public static final String ACTION_DELETE = "DELETE";
86 * The constant ACTION_STOP.
88 public static final String ACTION_STOP = "STOP";
90 * The constant ACTION_RESTART.
92 public static final String ACTION_RESTART = "RESTART";
95 * The constant ACTION_STATE_INITIATED.
97 public static final String ACTION_STATE_INITIATED = "INITIATED";
99 * The constant ACTION_STATE_SENT.
101 public static final String ACTION_STATE_SENT = "SENT";
103 * The constant ACTION_STATE_COMPLETED.
105 public static final String ACTION_STATE_COMPLETED = "COMPLETED";
107 * The constant ACTION_STATE_RECEIVED.
109 public static final String ACTION_STATE_RECEIVED = "RECEIVED";
111 * The constant ACTION_STATE_ERROR.
113 public static final String ACTION_STATE_ERROR = "ERROR";
115 * The constant ACTION_STATE_ANY.
117 public static final String ACTION_STATE_ANY = null;
120 private String actionCd;
121 private String actionStateCd;
122 private String processInstanceId;
123 private String userid;
130 public String getId() {
139 public void setId(String id) {
144 * Ins event clds event.
146 * @param cldsDao the clds dao
147 * @param controlName the control name
148 * @param userid the userid
149 * @param actionCd the action cd
150 * @param actionStateCd the action state cd
151 * @param processInstanceId the process instance id
154 public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd,
155 String actionStateCd, String processInstanceId) {
156 CldsModel model = CldsModel.createUsingControlName(controlName);
157 return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId);
161 * Insert event using controlNameUuid to find the model. This method meant for
162 * processing events from dcae.
164 * @param cldsDao the clds dao
165 * @param model the model
166 * @param userId the user id
167 * @param actionCd the action cd
168 * @param actionStateCd the action state cd
169 * @param processInstanceId the process instance id
172 public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd,
173 String actionStateCd, String processInstanceId) {
174 CldsEvent event = new CldsEvent();
175 event.setUserid(userId);
176 event.setActionCd(actionCd);
177 event.setActionStateCd(actionStateCd);
178 event.setProcessInstanceId(processInstanceId);
179 cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event);
184 * Check if actionCd is equal to the supplied checkActionCd checkActionCd should
187 * @param checkActionCd the check action cd
190 public boolean isActionCd(String checkActionCd) {
191 if (actionCd == null) {
194 return actionCd.equals(checkActionCd);
198 * Check if actionCd and actionStateCd are equal to the supplied checkActionCd
199 * and checkActionStateCd. Treat checkActionStateCd == null as a wildcard
200 * checkActionCd should not be null.
202 * @param checkActionCd the check action cd
203 * @param checkActionStateCd the check action state cd
206 public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) {
207 if (actionCd == null) {
210 // treat checkActionStateCd == null as a wildcard (same for
211 // actionStateCd, although it shouln't be null...)
212 if (checkActionStateCd == null || actionStateCd == null) {
213 return actionCd.equals(checkActionCd);
215 return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd);
219 * Check if actionStateCd is equal to the supplied checkActionStateCd.
220 * checkActionCd should not be null.
222 * @param checkActionStateCd the check action state cd
225 public boolean isActionStateCd(String checkActionStateCd) {
226 return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd);
232 * @return the actionCd
234 public String getActionCd() {
241 * @param actionCd the actionCd to set
243 public void setActionCd(String actionCd) {
244 this.actionCd = actionCd;
248 * Gets action state cd.
250 * @return the actionStateCd
252 public String getActionStateCd() {
253 return actionStateCd;
257 * Sets action state cd.
259 * @param actionStateCd the actionStateCd to set
261 public void setActionStateCd(String actionStateCd) {
262 this.actionStateCd = actionStateCd;
266 * Gets process instance id.
268 * @return the processInstanceId
270 public String getProcessInstanceId() {
271 return processInstanceId;
275 * Sets process instance id.
277 * @param processInstanceId the processInstanceId to set
279 public void setProcessInstanceId(String processInstanceId) {
280 this.processInstanceId = processInstanceId;
288 public String getUserid() {
295 * @param userid the userid to set
297 public void setUserid(String userid) {
298 this.userid = userid;