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";
41 public static final String ACTION_DISTRIBUTE = "DISTRIBUTE";
43 public static final String ACTION_DEPLOY = "DEPLOY";
45 public static final String ACTION_UNDEPLOY = "UNDEPLOY";
46 public static final String ACTION_UPDATE = "UPDATE";
47 public static final String ACTION_DELETE = "DELETE";
48 public static final String ACTION_STOP = "STOP";
49 public static final String ACTION_RESTART = "RESTART";
51 public static final String ACTION_STATE_INITIATED = "INITIATED";
52 public static final String ACTION_STATE_SENT = "SENT";
53 public static final String ACTION_STATE_COMPLETED = "COMPLETED";
54 public static final String ACTION_STATE_RECEIVED = "RECEIVED";
55 public static final String ACTION_STATE_ERROR = "ERROR";
56 public static final String ACTION_STATE_ANY = null;
59 private String actionCd;
60 private String actionStateCd;
61 private String processInstanceId;
62 private String userid;
64 public String getId() {
68 public void setId(String id) {
77 * @param actionStateCd
78 * @param processInstanceId
81 public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd,
82 String actionStateCd, String processInstanceId) {
83 CldsModel model = CldsModel.createUsingControlName(controlName);
84 return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId);
88 * Insert event using controlNameUuid to find the model. This method meant
89 * for processing events from dcae.
95 * @param actionStateCd
96 * @param processInstanceId
99 public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd,
100 String actionStateCd, String processInstanceId) {
101 CldsEvent event = new CldsEvent();
102 event.setUserid(userId);
103 event.setActionCd(actionCd);
104 event.setActionStateCd(actionStateCd);
105 event.setProcessInstanceId(processInstanceId);
106 cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event);
111 * Check if actionCd is equal to the supplied checkActionCd checkActionCd
112 * should not be null.
114 * @param checkActionCd
117 public boolean isActionCd(String checkActionCd) {
118 if (actionCd == null) {
121 return actionCd.equals(checkActionCd);
125 * Check if actionCd and actionStateCd are equal to the supplied
126 * checkActionCd and checkActionStateCd. Treat checkActionStateCd == null as
127 * a wildcard checkActionCd should not be null.
129 * @param checkActionCd
130 * @param checkActionStateCd
133 public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) {
134 if (actionCd == null) {
137 // treat checkActionStateCd == null as a wildcard (same for
138 // actionStateCd, although it shouln't be null...)
139 if (checkActionStateCd == null || actionStateCd == null) {
140 return actionCd.equals(checkActionCd);
142 return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd);
146 * Check if actionStateCd is equal to the supplied checkActionStateCd.
147 * checkActionCd should not be null.
149 * @param checkActionStateCd
152 public boolean isActionStateCd(String checkActionStateCd) {
153 return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd);
157 * @return the actionCd
159 public String getActionCd() {
165 * the actionCd to set
167 public void setActionCd(String actionCd) {
168 this.actionCd = actionCd;
172 * @return the actionStateCd
174 public String getActionStateCd() {
175 return actionStateCd;
179 * @param actionStateCd
180 * the actionStateCd to set
182 public void setActionStateCd(String actionStateCd) {
183 this.actionStateCd = actionStateCd;
187 * @return the processInstanceId
189 public String getProcessInstanceId() {
190 return processInstanceId;
194 * @param processInstanceId
195 * the processInstanceId to set
197 public void setProcessInstanceId(String processInstanceId) {
198 this.processInstanceId = processInstanceId;
204 public String getUserid() {
212 public void setUserid(String userid) {
213 this.userid = userid;