--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.common.model.local;\r
+\r
+import org.oran.otf.camunda.model.ExecutionConstants;\r
+import org.camunda.bpm.engine.history.*;\r
+import org.camunda.bpm.engine.impl.history.event.HistoricExternalTaskLogEntity;\r
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity;\r
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity;\r
+\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+public class OTFProcessInstanceCompletionResponse implements Serializable {\r
+ private HistoricProcessInstance historicProcessInstance;\r
+ private List<HistoricActivityInstance> historicActivityInstance;\r
+ private List<HistoricIncident> historicIncident;\r
+ private List<Map<String, Object>> historicJobLog;\r
+ private List<Map<String, Object>> historicExternalTaskLog;\r
+ private List<Map<String, Object>> historicVariableInstance;\r
+\r
+ public OTFProcessInstanceCompletionResponse() {\r
+ }\r
+\r
+\r
+ public HistoricProcessInstance getHistoricProcessInstance() {\r
+ return historicProcessInstance;\r
+ }\r
+\r
+ public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {\r
+ this.historicProcessInstance = historicProcessInstance;\r
+ }\r
+\r
+ public List<HistoricActivityInstance> getHistoricActivityInstance() {\r
+ return historicActivityInstance;\r
+ }\r
+\r
+ public void setHistoricActivityInstance(List<HistoricActivityInstance> historicActivityInstance) {\r
+ this.historicActivityInstance = historicActivityInstance;\r
+ }\r
+\r
+ public List<HistoricIncident> getHistoricIncident() {\r
+ return historicIncident;\r
+ }\r
+\r
+ public void setHistoricIncident(List<HistoricIncident> historicIncident) {\r
+ this.historicIncident = historicIncident;\r
+ }\r
+\r
+ public List<Map<String, Object>> getHistoricJobLog() {\r
+ return historicJobLog;\r
+ }\r
+\r
+ public void setHistoricJobLog(List<HistoricJobLog> historicJobLog) {\r
+ List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();\r
+ for(HistoricJobLog jobLog: historicJobLog){\r
+ HistoricJobLogEventEntity log = (HistoricJobLogEventEntity) jobLog;\r
+ HashMap map = new HashMap();\r
+\r
+ map.put("id", log.getId());\r
+ map.put("executionId", log.getExecutionId());\r
+ map.put("activityId", log.getActivityId());\r
+ map.put("eventType", log.getEventType());\r
+ map.put("sequenceCounter", log.getSequenceCounter());\r
+ map.put("retries", log.getJobRetries());\r
+ map.put("jobExceptionMessage", log.getJobExceptionMessage());\r
+ map.put("jobDefinitionType", log.getJobDefinitionType());\r
+ map.put("jobDefinitionConfiguration", log.getJobDefinitionConfiguration());\r
+ map.put("processDefinitionKey", log.getProcessDefinitionKey());\r
+ map.put("state", convertState(log.getState()));\r
+\r
+ list.add(map);\r
+ }\r
+ this.historicJobLog = list;\r
+ }\r
+\r
+ public List<Map<String, Object>> getHistoricExternalTaskLog() {\r
+ return this.historicExternalTaskLog;\r
+ }\r
+\r
+ public void setHistoricExternalTaskLog(List<HistoricExternalTaskLog> historicExternalTaskLog) {\r
+ List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();\r
+ for(HistoricExternalTaskLog externalTaskLog: historicExternalTaskLog){\r
+ HistoricExternalTaskLogEntity log = (HistoricExternalTaskLogEntity) externalTaskLog;\r
+ HashMap map = new HashMap();\r
+\r
+ map.put("id", log.getId());\r
+ map.put("executionId", log.getExecutionId());\r
+ map.put("activityId", log.getActivityId());\r
+ map.put("state", convertState(log.getState()));\r
+ map.put("retries", log.getRetries());\r
+ map.put("processDefinitionKey", log.getProcessDefinitionKey());\r
+ map.put("errorMessage", log.getErrorMessage());\r
+ try {\r
+ map.put("errorDetails", log.getErrorDetails());\r
+ }\r
+ catch (Exception e){}\r
+ map.put("workerId", log.getWorkerId());\r
+ map.put("topic", log.getTopicName());\r
+ list.add(map);\r
+ }\r
+ this.historicExternalTaskLog = list;\r
+ }\r
+\r
+ public List<Map<String, Object>> getHistoricVariableInstance() {\r
+ return historicVariableInstance;\r
+ }\r
+\r
+ public void setHistoricVariableInstance(List<HistoricVariableInstance> historicVariableInstance) {\r
+ List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();\r
+ for(HistoricVariableInstance variableInstanceEntity: historicVariableInstance){\r
+ HistoricVariableInstanceEntity variable = (HistoricVariableInstanceEntity) variableInstanceEntity;\r
+ HashMap map = new HashMap();\r
+ if (variable.getVariableName().equalsIgnoreCase(ExecutionConstants.ExecutionVariable.TEST_EXECUTION)){\r
+ continue;\r
+ }\r
+ map.put("id", variable.getId());\r
+ map.put("executionId", variable.getExecutionId());\r
+ map.put("processDefinitionKey", variable.getProcessDefinitionKey());\r
+ map.put("taskId", variable.getTaskId());\r
+ map.put("eventType", variable.getVariableName());\r
+ map.put("errorMessage", variable.getErrorMessage());\r
+ map.put("state", variable.getState());\r
+ map.put("variableName", variable.getVariableName());\r
+ map.put("type", variable.getTypedValue().getType());\r
+ map.put("value", variable.getTypedValue().getValue());\r
+ map.put("persistentState", variable.getPersistentState());\r
+\r
+ list.add(map);\r
+ }\r
+ this.historicVariableInstance = list;\r
+ }\r
+\r
+ private String convertState(int state){\r
+ switch (state){\r
+ case 0 :\r
+ return "CREATED";\r
+ case 1 :\r
+ return "FAILED";\r
+ case 2 :\r
+ return "SUCCESSFUL";\r
+ case 3 :\r
+ return "DELETED";\r
+ default:\r
+ return "UNKNOWN";\r
+ }\r
+ }\r
+\r
+}\r