added svcapi ui and camunda code
[it/otf.git] / otf-service-api / src / main / java / org / oran / otf / common / model / historic / TestDefinitionHistoric.java
diff --git a/otf-service-api/src/main/java/org/oran/otf/common/model/historic/TestDefinitionHistoric.java b/otf-service-api/src/main/java/org/oran/otf/common/model/historic/TestDefinitionHistoric.java
new file mode 100644 (file)
index 0000000..fe2be4b
--- /dev/null
@@ -0,0 +1,185 @@
+/*  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.historic;\r
+\r
+import org.oran.otf.common.model.TestDefinition;\r
+import org.oran.otf.common.model.local.BpmnInstance;\r
+import org.oran.otf.common.utility.gson.Convert;\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.Date;\r
+import java.util.List;\r
+import org.bson.types.ObjectId;\r
+\r
+public class TestDefinitionHistoric implements Serializable {\r
+\r
+  private static final long serialVersionUID = 1L;\r
+\r
+  private ObjectId _id;\r
+  private String testName;\r
+  private String testDescription;\r
+  private String processDefinitionKey;\r
+  private List<BpmnInstance> bpmnInstances;\r
+  private ObjectId groupId;\r
+  private Date createdAt;\r
+  private Date updatedAt;\r
+  private ObjectId createdBy;\r
+  private ObjectId updatedBy;\r
+\r
+  public TestDefinitionHistoric() {\r
+  }\r
+\r
+  public TestDefinitionHistoric(TestDefinition testDefinition, String processDefinitionId) {\r
+    this._id = testDefinition.get_id();\r
+    this.testName = testDefinition.getTestName();\r
+    this.testDescription = testDefinition.getTestDescription();\r
+    this.processDefinitionKey = testDefinition.getProcessDefinitionKey();\r
+    this.bpmnInstances =\r
+        getHistoricBpmnInstanceAsList(testDefinition.getBpmnInstances(), processDefinitionId);\r
+    this.groupId = testDefinition.getGroupId();\r
+    this.createdAt = testDefinition.getCreatedAt();\r
+    this.updatedAt = testDefinition.getUpdatedAt();\r
+    this.createdBy = testDefinition.getCreatedBy();\r
+    this.updatedBy = testDefinition.getUpdatedBy();\r
+  }\r
+\r
+  public TestDefinitionHistoric(\r
+      ObjectId _id,\r
+      String testName,\r
+      String testDescription,\r
+      String processDefinitionKey,\r
+      List<BpmnInstance> bpmnInstances,\r
+      ObjectId groupId,\r
+      Date createdAt,\r
+      Date updatedAt,\r
+      ObjectId createdBy,\r
+      ObjectId updatedBy) {\r
+    this._id = _id;\r
+    this.testName = testName;\r
+    this.testDescription = testDescription;\r
+    this.processDefinitionKey = processDefinitionKey;\r
+    this.bpmnInstances = bpmnInstances;\r
+    this.groupId = groupId;\r
+    this.createdAt = createdAt;\r
+    this.updatedAt = updatedAt;\r
+    this.createdBy = createdBy;\r
+    this.updatedBy = updatedBy;\r
+  }\r
+\r
+  private List<BpmnInstance> getHistoricBpmnInstanceAsList(\r
+      List<BpmnInstance> bpmnInstances, String processDefinitionId) {\r
+    BpmnInstance bpmnInstance =\r
+        bpmnInstances.stream()\r
+            .filter(\r
+                _bpmnInstance ->\r
+                    _bpmnInstance.getProcessDefinitionId().equalsIgnoreCase(processDefinitionId))\r
+            .findFirst()\r
+            .orElse(null);\r
+\r
+    List<BpmnInstance> historicBpmnInstance = new ArrayList<>();\r
+    if (bpmnInstance != null) {\r
+      historicBpmnInstance.add(bpmnInstance);\r
+    }\r
+\r
+    return historicBpmnInstance;\r
+  }\r
+\r
+  public ObjectId get_id() {\r
+    return _id;\r
+  }\r
+\r
+  public void set_id(ObjectId _id) {\r
+    this._id = _id;\r
+  }\r
+\r
+  public String getTestName() {\r
+    return testName;\r
+  }\r
+\r
+  public void setTestName(String testName) {\r
+    this.testName = testName;\r
+  }\r
+\r
+  public String getTestDescription() {\r
+    return testDescription;\r
+  }\r
+\r
+  public void setTestDescription(String testDescription) {\r
+    this.testDescription = testDescription;\r
+  }\r
+\r
+  public String getProcessDefinitionKey() {\r
+    return processDefinitionKey;\r
+  }\r
+\r
+  public void setProcessDefinitionKey(String processDefinitionKey) {\r
+    this.processDefinitionKey = processDefinitionKey;\r
+  }\r
+\r
+  public List<BpmnInstance> getBpmnInstances() {\r
+    return bpmnInstances;\r
+  }\r
+\r
+  public void setBpmnInstances(List<BpmnInstance> bpmnInstances) {\r
+    this.bpmnInstances = bpmnInstances;\r
+  }\r
+\r
+  public ObjectId getGroupId() {\r
+    return groupId;\r
+  }\r
+\r
+  public void setGroupId(ObjectId groupId) {\r
+    this.groupId = groupId;\r
+  }\r
+\r
+  public Date getCreatedAt() {\r
+    return createdAt;\r
+  }\r
+\r
+  public void setCreatedAt(Date createdAt) {\r
+    this.createdAt = createdAt;\r
+  }\r
+\r
+  public Date getUpdatedAt() {\r
+    return updatedAt;\r
+  }\r
+\r
+  public void setUpdatedAt(Date updatedAt) {\r
+    this.updatedAt = updatedAt;\r
+  }\r
+\r
+  public ObjectId getCreatedBy() {\r
+    return createdBy;\r
+  }\r
+\r
+  public void setCreatedBy(ObjectId createdBy) {\r
+    this.createdBy = createdBy;\r
+  }\r
+\r
+  public ObjectId getUpdatedBy() {\r
+    return updatedBy;\r
+  }\r
+\r
+  public void setUpdatedBy(ObjectId updatedBy) {\r
+    this.updatedBy = updatedBy;\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    return Convert.objectToJson(this);\r
+  }\r
+}\r