added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / main / java / org / oran / otf / common / model / local / WorkflowRequest.java
diff --git a/otf-service-api/src/main/java/org/oran/otf/common/model/local/WorkflowRequest.java b/otf-service-api/src/main/java/org/oran/otf/common/model/local/WorkflowRequest.java
new file mode 100644 (file)
index 0000000..f7089a0
--- /dev/null
@@ -0,0 +1,163 @@
+/*  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.common.utility.gson.Convert;\r
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
+import java.io.Serializable;\r
+import java.util.Map;\r
+import org.bson.types.ObjectId;\r
+\r
+@JsonIgnoreProperties(ignoreUnknown = true)\r
+public class WorkflowRequest implements Serializable {\r
+\r
+  private static final long serialVersionUID = 1L;\r
+\r
+  private boolean async = false;\r
+  private ObjectId executorId = null;\r
+  private ObjectId testInstanceId = null;\r
+  private Map<String, ParallelFlowInput> pfloInput = null;\r
+  private Map<String, Object> testData = null;\r
+  private Map<String, Object> vthInput = null;\r
+  private long maxExecutionTimeInMillis = 0L;\r
+\r
+  public WorkflowRequest() throws Exception {\r
+    this.validate();\r
+  }\r
+\r
+  public WorkflowRequest(\r
+          boolean async,\r
+          ObjectId executorId,\r
+          ObjectId testInstanceId,\r
+          Map<String, ParallelFlowInput> pfloInput,\r
+          Map<String, Object> testData,\r
+          Map<String, Object> vthInput,\r
+          int maxExecutionTimeInMillis)\r
+          throws Exception {\r
+    this.async = async;\r
+    this.executorId = executorId;\r
+    this.testInstanceId = testInstanceId;\r
+    this.pfloInput = pfloInput;\r
+    this.testData = testData;\r
+    this.vthInput = vthInput;\r
+    this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
+\r
+    this.validate();\r
+  }\r
+\r
+  public WorkflowRequest(\r
+          boolean async,\r
+          String executorId,\r
+          String testInstanceId,\r
+          Map<String, ParallelFlowInput> pfloInput,\r
+          Map<String, Object> testData,\r
+          Map<String, Object> vthInput,\r
+          int maxExecutionTimeInMillis)\r
+          throws Exception {\r
+    this.async = async;\r
+    this.executorId = new ObjectId(executorId);\r
+    this.testInstanceId = new ObjectId(testInstanceId);\r
+    this.pfloInput = pfloInput;\r
+    this.testData = testData;\r
+    this.vthInput = vthInput;\r
+    this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
+\r
+    this.validate();\r
+  }\r
+\r
+  private void validate() throws Exception {\r
+    String missingFieldFormat = "Missing required field %s.";\r
+    //    if (this.async && this.asyncTopic == null) {\r
+    //      throw new Exception(String.format(missingFieldFormat, "asyncTopic"));\r
+    //    }\r
+\r
+    // Only required on the Camunda engine\r
+    //    if (this.executorId == null) {\r
+    //      throw new Exception(String.format(missingFieldFormat, "executorId"));\r
+    //    }\r
+\r
+    // Only required on the Camunda engine\r
+    //    if (this.testInstanceId == null) {\r
+    //      throw new Exception(String.format(missingFieldFormat, "testInstanceId"));\r
+    //    }\r
+\r
+    if (this.maxExecutionTimeInMillis < 0L) {\r
+      this.maxExecutionTimeInMillis = 0L;\r
+    }\r
+  }\r
+\r
+  public boolean isAsync() {\r
+    return async;\r
+  }\r
+\r
+  public void setAsync(boolean async) {\r
+    this.async = async;\r
+  }\r
+\r
+  public ObjectId getExecutorId() {\r
+    return executorId;\r
+  }\r
+\r
+  public void setExecutorId(ObjectId executorId) {\r
+    this.executorId = executorId;\r
+  }\r
+\r
+  public ObjectId getTestInstanceId() {\r
+    return testInstanceId;\r
+  }\r
+\r
+  public void setTestInstanceId(ObjectId testInstanceId) {\r
+    this.testInstanceId = testInstanceId;\r
+  }\r
+\r
+  public Map<String, ParallelFlowInput> getPfloInput() {\r
+    return pfloInput;\r
+  }\r
+\r
+  public void setPfloInput(Map<String, ParallelFlowInput> pfloInput) {\r
+    this.pfloInput = pfloInput;\r
+  }\r
+\r
+  public Map<String, Object> getTestData() {\r
+    return testData;\r
+  }\r
+\r
+  public void setTestData(Map<String, Object> testData) {\r
+    this.testData = testData;\r
+  }\r
+\r
+  public Map<String, Object> getVthInput() {\r
+    return vthInput;\r
+  }\r
+\r
+  public void setVthInput(Map<String, Object> vthInput) {\r
+    this.vthInput = vthInput;\r
+  }\r
+\r
+  public long getMaxExecutionTimeInMillis() {\r
+    return maxExecutionTimeInMillis;\r
+  }\r
+\r
+  public void setMaxExecutionTimeInMillis(long maxExecutionTimeInMillis) {\r
+    this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    return Convert.objectToJson(this);\r
+  }\r
+}
\ No newline at end of file