2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 {
32 public static final String ACTION_TEST = "TEST";
33 public static final String ACTION_CREATE = "CREATE";
34 public static final String ACTION_MODIFY = "MODIFY";
35 public static final String ACTION_SUBMIT = "SUBMIT";
36 // an update before model is active
37 public static final String ACTION_RESUBMIT = "RESUBMIT";
38 // For simplified models
39 public static final String ACTION_SUBMITDCAE = "SUBMITDCAE";
40 public static final String ACTION_SUBMITPOLICY = "SUBMITPOLICY";
42 public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
44 public static final String ACTION_DEPLOY = "DEPLOY";
46 public static final String ACTION_UNDEPLOY = "UNDEPLOY";
47 public static final String ACTION_UPDATE = "UPDATE";
48 public static final String ACTION_DELETE = "DELETE";
49 public static final String ACTION_STOP = "STOP";
50 public static final String ACTION_RESTART = "RESTART";
52 public static final String ACTION_STATE_INITIATED = "INITIATED";
53 public static final String ACTION_STATE_SENT = "SENT";
54 public static final String ACTION_STATE_COMPLETED = "COMPLETED";
55 public static final String ACTION_STATE_RECEIVED = "RECEIVED";
56 public static final String ACTION_STATE_ERROR = "ERROR";
57 public static final String ACTION_STATE_ANY = null;
60 private String actionCd;
61 private String actionStateCd;
62 private String processInstanceId;
63 private String userid;
65 public String getId() {
69 public void setId(String id) {
78 * @param actionStateCd
79 * @param processInstanceId
82 public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd,
83 String actionStateCd, String processInstanceId) {
84 CldsModel model = CldsModel.createUsingControlName(controlName);
85 return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId);
89 * Insert event using controlNameUuid to find the model. This method meant
90 * for processing events from dcae.
96 * @param actionStateCd
97 * @param processInstanceId
100 public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd,
101 String actionStateCd, String processInstanceId) {
102 CldsEvent event = new CldsEvent();
103 event.setUserid(userId);
104 event.setActionCd(actionCd);
105 event.setActionStateCd(actionStateCd);
106 event.setProcessInstanceId(processInstanceId);
107 cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event);
112 * Check if actionCd is equal to the supplied checkActionCd checkActionCd
113 * should not be null.
115 * @param checkActionCd
118 public boolean isActionCd(String checkActionCd) {
119 if (actionCd == null) {
122 return actionCd.equals(checkActionCd);
126 * Check if actionCd and actionStateCd are equal to the supplied
127 * checkActionCd and checkActionStateCd. Treat checkActionStateCd == null as
128 * a wildcard checkActionCd should not be null.
130 * @param checkActionCd
131 * @param checkActionStateCd
134 public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) {
135 if (actionCd == null) {
138 // treat checkActionStateCd == null as a wildcard (same for
139 // actionStateCd, although it shouln't be null...)
140 if (checkActionStateCd == null || actionStateCd == null) {
141 return actionCd.equals(checkActionCd);
143 return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd);
147 * Check if actionStateCd is equal to the supplied checkActionStateCd.
148 * checkActionCd should not be null.
150 * @param checkActionStateCd
153 public boolean isActionStateCd(String checkActionStateCd) {
154 return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd);
158 * @return the actionCd
160 public String getActionCd() {
166 * the actionCd to set
168 public void setActionCd(String actionCd) {
169 this.actionCd = actionCd;
173 * @return the actionStateCd
175 public String getActionStateCd() {
176 return actionStateCd;
180 * @param actionStateCd
181 * the actionStateCd to set
183 public void setActionStateCd(String actionStateCd) {
184 this.actionStateCd = actionStateCd;
188 * @return the processInstanceId
190 public String getProcessInstanceId() {
191 return processInstanceId;
195 * @param processInstanceId
196 * the processInstanceId to set
198 public void setProcessInstanceId(String processInstanceId) {
199 this.processInstanceId = processInstanceId;
205 public String getUserid() {
213 public void setUserid(String userid) {
214 this.userid = userid;