1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 package org.oran.otf.common.model.local;
\r
19 import org.oran.otf.camunda.model.ExecutionConstants;
\r
20 import org.camunda.bpm.engine.history.*;
\r
21 import org.camunda.bpm.engine.impl.history.event.HistoricExternalTaskLogEntity;
\r
22 import org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity;
\r
23 import org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity;
\r
25 import java.io.Serializable;
\r
26 import java.util.ArrayList;
\r
27 import java.util.HashMap;
\r
28 import java.util.List;
\r
29 import java.util.Map;
\r
31 public class OTFProcessInstanceCompletionResponse implements Serializable {
\r
32 private HistoricProcessInstance historicProcessInstance;
\r
33 private List<HistoricActivityInstance> historicActivityInstance;
\r
34 private List<HistoricIncident> historicIncident;
\r
35 private List<Map<String, Object>> historicJobLog;
\r
36 private List<Map<String, Object>> historicExternalTaskLog;
\r
37 private List<Map<String, Object>> historicVariableInstance;
\r
39 public OTFProcessInstanceCompletionResponse() {
\r
43 public HistoricProcessInstance getHistoricProcessInstance() {
\r
44 return historicProcessInstance;
\r
47 public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
\r
48 this.historicProcessInstance = historicProcessInstance;
\r
51 public List<HistoricActivityInstance> getHistoricActivityInstance() {
\r
52 return historicActivityInstance;
\r
55 public void setHistoricActivityInstance(List<HistoricActivityInstance> historicActivityInstance) {
\r
56 this.historicActivityInstance = historicActivityInstance;
\r
59 public List<HistoricIncident> getHistoricIncident() {
\r
60 return historicIncident;
\r
63 public void setHistoricIncident(List<HistoricIncident> historicIncident) {
\r
64 this.historicIncident = historicIncident;
\r
67 public List<Map<String, Object>> getHistoricJobLog() {
\r
68 return historicJobLog;
\r
71 public void setHistoricJobLog(List<HistoricJobLog> historicJobLog) {
\r
72 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
\r
73 for(HistoricJobLog jobLog: historicJobLog){
\r
74 HistoricJobLogEventEntity log = (HistoricJobLogEventEntity) jobLog;
\r
75 HashMap map = new HashMap();
\r
77 map.put("id", log.getId());
\r
78 map.put("executionId", log.getExecutionId());
\r
79 map.put("activityId", log.getActivityId());
\r
80 map.put("eventType", log.getEventType());
\r
81 map.put("sequenceCounter", log.getSequenceCounter());
\r
82 map.put("retries", log.getJobRetries());
\r
83 map.put("jobExceptionMessage", log.getJobExceptionMessage());
\r
84 map.put("jobDefinitionType", log.getJobDefinitionType());
\r
85 map.put("jobDefinitionConfiguration", log.getJobDefinitionConfiguration());
\r
86 map.put("processDefinitionKey", log.getProcessDefinitionKey());
\r
87 map.put("state", convertState(log.getState()));
\r
91 this.historicJobLog = list;
\r
94 public List<Map<String, Object>> getHistoricExternalTaskLog() {
\r
95 return this.historicExternalTaskLog;
\r
98 public void setHistoricExternalTaskLog(List<HistoricExternalTaskLog> historicExternalTaskLog) {
\r
99 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
\r
100 for(HistoricExternalTaskLog externalTaskLog: historicExternalTaskLog){
\r
101 HistoricExternalTaskLogEntity log = (HistoricExternalTaskLogEntity) externalTaskLog;
\r
102 HashMap map = new HashMap();
\r
104 map.put("id", log.getId());
\r
105 map.put("executionId", log.getExecutionId());
\r
106 map.put("activityId", log.getActivityId());
\r
107 map.put("state", convertState(log.getState()));
\r
108 map.put("retries", log.getRetries());
\r
109 map.put("processDefinitionKey", log.getProcessDefinitionKey());
\r
110 map.put("errorMessage", log.getErrorMessage());
\r
112 map.put("errorDetails", log.getErrorDetails());
\r
114 catch (Exception e){}
\r
115 map.put("workerId", log.getWorkerId());
\r
116 map.put("topic", log.getTopicName());
\r
119 this.historicExternalTaskLog = list;
\r
122 public List<Map<String, Object>> getHistoricVariableInstance() {
\r
123 return historicVariableInstance;
\r
126 public void setHistoricVariableInstance(List<HistoricVariableInstance> historicVariableInstance) {
\r
127 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
\r
128 for(HistoricVariableInstance variableInstanceEntity: historicVariableInstance){
\r
129 HistoricVariableInstanceEntity variable = (HistoricVariableInstanceEntity) variableInstanceEntity;
\r
130 HashMap map = new HashMap();
\r
131 if (variable.getVariableName().equalsIgnoreCase(ExecutionConstants.ExecutionVariable.TEST_EXECUTION)){
\r
134 map.put("id", variable.getId());
\r
135 map.put("executionId", variable.getExecutionId());
\r
136 map.put("processDefinitionKey", variable.getProcessDefinitionKey());
\r
137 map.put("taskId", variable.getTaskId());
\r
138 map.put("eventType", variable.getVariableName());
\r
139 map.put("errorMessage", variable.getErrorMessage());
\r
140 map.put("state", variable.getState());
\r
141 map.put("variableName", variable.getVariableName());
\r
142 map.put("type", variable.getTypedValue().getType());
\r
143 map.put("value", variable.getTypedValue().getValue());
\r
144 map.put("persistentState", variable.getPersistentState());
\r
148 this.historicVariableInstance = list;
\r
151 private String convertState(int state){
\r
158 return "SUCCESSFUL";
\r