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.camunda.workflow;
\r
19 import org.oran.otf.common.model.local.ParallelFlowInput;
\r
20 import org.oran.otf.common.utility.gson.Convert;
\r
21 import com.fasterxml.jackson.annotation.JsonCreator;
\r
22 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
\r
23 import com.fasterxml.jackson.annotation.JsonProperty;
\r
24 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
\r
25 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
\r
26 import java.io.Serializable;
\r
27 import java.util.Map;
\r
28 import org.bson.types.ObjectId;
\r
30 @JsonIgnoreProperties(ignoreUnknown = true)
\r
31 public class WorkflowRequest implements Serializable {
\r
33 private static final long serialVersionUID = 1L;
\r
35 private boolean async = false;
\r
36 @JsonSerialize(using = ToStringSerializer.class)
\r
37 private ObjectId executorId = null;
\r
39 @JsonSerialize(using = ToStringSerializer.class)
\r
40 private ObjectId testInstanceId = null;
\r
42 private Map<String, ParallelFlowInput> pfloInput = null;
\r
43 private Map<String, Object> testData = null;
\r
44 private Map<String, Object> vthInput = null;
\r
45 private long maxExecutionTimeInMillis = 0L;
\r
47 public WorkflowRequest() throws Exception {
\r
51 public WorkflowRequest(
\r
54 String testInstanceId,
\r
55 long maxExecutionTimeInMillis) {
\r
57 this.executorId = new ObjectId(executorId);
\r
58 this.testInstanceId = new ObjectId(testInstanceId);
\r
59 this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;
\r
62 public WorkflowRequest(
\r
64 ObjectId executorId,
\r
65 ObjectId testInstanceId,
\r
66 Map<String, ParallelFlowInput> pfloInput,
\r
67 Map<String, Object> testData,
\r
68 Map<String, Object> vthInput,
\r
69 int maxExecutionTimeInMillis)
\r
72 this.executorId = executorId;
\r
73 this.testInstanceId = testInstanceId;
\r
74 this.pfloInput = pfloInput;
\r
75 this.testData = testData;
\r
76 this.vthInput = vthInput;
\r
77 this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;
\r
83 public WorkflowRequest(
\r
84 @JsonProperty(value = "async", required = false) boolean async,
\r
85 @JsonProperty(value = "executorId", required = true) String executorId,
\r
86 @JsonProperty(value = "testInstanceId", required = true) String testInstanceId,
\r
87 @JsonProperty(value = "pfloInput", required = false) Map<String, ParallelFlowInput> pfloInput,
\r
88 @JsonProperty(value = "testData", required = false) Map<String, Object> testData,
\r
89 @JsonProperty(value = "vthInput", required = false) Map<String, Object> vthInput,
\r
90 @JsonProperty(value = "maxExecutionTimeInMillis", required = false)
\r
91 int maxExecutionTimeInMillis) throws Exception {
\r
93 this.executorId = new ObjectId(executorId);
\r
94 this.testInstanceId = new ObjectId(testInstanceId);
\r
95 this.pfloInput = pfloInput;
\r
96 this.testData = testData;
\r
97 this.vthInput = vthInput;
\r
98 this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;
\r
103 private void validate() throws Exception {
\r
104 String missingFieldFormat = "Missing required field %s.";
\r
105 // if (this.executorId == null) {
\r
106 // throw new Exception(String.format(missingFieldFormat, "executorId"));
\r
109 if (this.testInstanceId == null) {
\r
110 throw new Exception(String.format(missingFieldFormat, "testInstanceId"));
\r
113 if (this.maxExecutionTimeInMillis < 0L) {
\r
114 this.maxExecutionTimeInMillis = 0L;
\r
118 public boolean isAsync() {
\r
122 public void setAsync(boolean async) {
\r
123 this.async = async;
\r
126 public ObjectId getExecutorId() {
\r
130 public void setExecutorId(ObjectId executorId) {
\r
131 this.executorId = executorId;
\r
134 public ObjectId getTestInstanceId() {
\r
135 return testInstanceId;
\r
138 public void setTestInstanceId(String testInstanceId) {
\r
139 this.testInstanceId = new ObjectId(testInstanceId);
\r
142 public void setTestInstanceId(ObjectId testInstanceId) {
\r
143 this.testInstanceId = testInstanceId;
\r
146 public Map<String, ParallelFlowInput> getPfloInput() {
\r
150 public void setPfloInput(Map<String, ParallelFlowInput> pfloInput) {
\r
151 this.pfloInput = pfloInput;
\r
154 public Map<String, Object> getTestData() {
\r
158 public void setTestData(Map<String, Object> testData) {
\r
159 this.testData = testData;
\r
162 public Map<String, Object> getVthInput() {
\r
166 public void setVthInput(Map<String, Object> vthInput) {
\r
167 this.vthInput = vthInput;
\r
170 public long getMaxExecutionTimeInMillis() {
\r
171 return maxExecutionTimeInMillis;
\r
174 public void setMaxExecutionTimeInMillis(long maxExecutionTimeInMillis) {
\r
175 this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;
\r
179 public String toString() {
\r
180 return Convert.objectToJson(this);
\r