added svcapi ui and camunda code
[it/otf.git] / otf-camunda / src / main / java / org / oran / otf / camunda / workflow / WorkflowRequest.java
diff --git a/otf-camunda/src/main/java/org/oran/otf/camunda/workflow/WorkflowRequest.java b/otf-camunda/src/main/java/org/oran/otf/camunda/workflow/WorkflowRequest.java
new file mode 100644 (file)
index 0000000..fa5f10e
--- /dev/null
@@ -0,0 +1,182 @@
+/*  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.camunda.workflow;\r
+\r
+import org.oran.otf.common.model.local.ParallelFlowInput;\r
+import org.oran.otf.common.utility.gson.Convert;\r
+import com.fasterxml.jackson.annotation.JsonCreator;\r
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;\r
+import com.fasterxml.jackson.annotation.JsonProperty;\r
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;\r
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;\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
+  @JsonSerialize(using = ToStringSerializer.class)\r
+  private ObjectId executorId = null;\r
+\r
+  @JsonSerialize(using = ToStringSerializer.class)\r
+  private ObjectId testInstanceId = null;\r
+\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
+      String executorId,\r
+      String testInstanceId,\r
+      long maxExecutionTimeInMillis) {\r
+    this.async = async;\r
+    this.executorId = new ObjectId(executorId);\r
+    this.testInstanceId = new ObjectId(testInstanceId);\r
+    this.maxExecutionTimeInMillis = maxExecutionTimeInMillis;\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
+  @JsonCreator\r
+  public WorkflowRequest(\r
+      @JsonProperty(value = "async", required = false) boolean async,\r
+      @JsonProperty(value = "executorId", required = true) String executorId,\r
+      @JsonProperty(value = "testInstanceId", required = true) String testInstanceId,\r
+      @JsonProperty(value = "pfloInput", required = false) Map<String, ParallelFlowInput> pfloInput,\r
+      @JsonProperty(value = "testData", required = false) Map<String, Object> testData,\r
+      @JsonProperty(value = "vthInput", required = false) Map<String, Object> vthInput,\r
+      @JsonProperty(value = "maxExecutionTimeInMillis", required = false)\r
+          int maxExecutionTimeInMillis) 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.executorId == null) {\r
+//      throw new Exception(String.format(missingFieldFormat, "executorId"));\r
+//    }\r
+\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(String testInstanceId) {\r
+    this.testInstanceId = new ObjectId(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
+}\r