added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / main / java / org / oran / otf / common / model / local / WorkflowRequest.java
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\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
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\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
15 \r
16 \r
17 package org.oran.otf.common.model.local;\r
18 \r
19 import org.oran.otf.common.utility.gson.Convert;\r
20 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
21 import java.io.Serializable;\r
22 import java.util.Map;\r
23 import org.bson.types.ObjectId;\r
24 \r
25 @JsonIgnoreProperties(ignoreUnknown = true)\r
26 public class WorkflowRequest implements Serializable {\r
27 \r
28   private static final long serialVersionUID = 1L;\r
29 \r
30   private boolean async = false;\r
31   private ObjectId executorId = null;\r
32   private ObjectId testInstanceId = null;\r
33   private Map<String, ParallelFlowInput> pfloInput = null;\r
34   private Map<String, Object> testData = null;\r
35   private Map<String, Object> vthInput = null;\r
36   private long maxExecutionTimeInMillis = 0L;\r
37 \r
38   public WorkflowRequest() throws Exception {\r
39     this.validate();\r
40   }\r
41 \r
42   public WorkflowRequest(\r
43           boolean async,\r
44           ObjectId executorId,\r
45           ObjectId testInstanceId,\r
46           Map<String, ParallelFlowInput> pfloInput,\r
47           Map<String, Object> testData,\r
48           Map<String, Object> vthInput,\r
49           int maxExecutionTimeInMillis)\r
50           throws Exception {\r
51     this.async = async;\r
52     this.executorId = executorId;\r
53     this.testInstanceId = testInstanceId;\r
54     this.pfloInput = pfloInput;\r
55     this.testData = testData;\r
56     this.vthInput = vthInput;\r
57     this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
58 \r
59     this.validate();\r
60   }\r
61 \r
62   public WorkflowRequest(\r
63           boolean async,\r
64           String executorId,\r
65           String testInstanceId,\r
66           Map<String, ParallelFlowInput> pfloInput,\r
67           Map<String, Object> testData,\r
68           Map<String, Object> vthInput,\r
69           int maxExecutionTimeInMillis)\r
70           throws Exception {\r
71     this.async = async;\r
72     this.executorId = new ObjectId(executorId);\r
73     this.testInstanceId = new ObjectId(testInstanceId);\r
74     this.pfloInput = pfloInput;\r
75     this.testData = testData;\r
76     this.vthInput = vthInput;\r
77     this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
78 \r
79     this.validate();\r
80   }\r
81 \r
82   private void validate() throws Exception {\r
83     String missingFieldFormat = "Missing required field %s.";\r
84     //    if (this.async && this.asyncTopic == null) {\r
85     //      throw new Exception(String.format(missingFieldFormat, "asyncTopic"));\r
86     //    }\r
87 \r
88     // Only required on the Camunda engine\r
89     //    if (this.executorId == null) {\r
90     //      throw new Exception(String.format(missingFieldFormat, "executorId"));\r
91     //    }\r
92 \r
93     // Only required on the Camunda engine\r
94     //    if (this.testInstanceId == null) {\r
95     //      throw new Exception(String.format(missingFieldFormat, "testInstanceId"));\r
96     //    }\r
97 \r
98     if (this.maxExecutionTimeInMillis < 0L) {\r
99       this.maxExecutionTimeInMillis = 0L;\r
100     }\r
101   }\r
102 \r
103   public boolean isAsync() {\r
104     return async;\r
105   }\r
106 \r
107   public void setAsync(boolean async) {\r
108     this.async = async;\r
109   }\r
110 \r
111   public ObjectId getExecutorId() {\r
112     return executorId;\r
113   }\r
114 \r
115   public void setExecutorId(ObjectId executorId) {\r
116     this.executorId = executorId;\r
117   }\r
118 \r
119   public ObjectId getTestInstanceId() {\r
120     return testInstanceId;\r
121   }\r
122 \r
123   public void setTestInstanceId(ObjectId testInstanceId) {\r
124     this.testInstanceId = testInstanceId;\r
125   }\r
126 \r
127   public Map<String, ParallelFlowInput> getPfloInput() {\r
128     return pfloInput;\r
129   }\r
130 \r
131   public void setPfloInput(Map<String, ParallelFlowInput> pfloInput) {\r
132     this.pfloInput = pfloInput;\r
133   }\r
134 \r
135   public Map<String, Object> getTestData() {\r
136     return testData;\r
137   }\r
138 \r
139   public void setTestData(Map<String, Object> testData) {\r
140     this.testData = testData;\r
141   }\r
142 \r
143   public Map<String, Object> getVthInput() {\r
144     return vthInput;\r
145   }\r
146 \r
147   public void setVthInput(Map<String, Object> vthInput) {\r
148     this.vthInput = vthInput;\r
149   }\r
150 \r
151   public long getMaxExecutionTimeInMillis() {\r
152     return maxExecutionTimeInMillis;\r
153   }\r
154 \r
155   public void setMaxExecutionTimeInMillis(long maxExecutionTimeInMillis) {\r
156     this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
157   }\r
158 \r
159   @Override\r
160   public String toString() {\r
161     return Convert.objectToJson(this);\r
162   }\r
163 }