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.common.model.historic;
\r
19 import org.oran.otf.common.model.TestDefinition;
\r
20 import org.oran.otf.common.model.local.BpmnInstance;
\r
21 import org.oran.otf.common.utility.gson.Convert;
\r
22 import java.io.Serializable;
\r
23 import java.util.ArrayList;
\r
24 import java.util.Date;
\r
25 import java.util.List;
\r
26 import org.bson.types.ObjectId;
\r
28 public class TestDefinitionHistoric implements Serializable {
\r
30 private static final long serialVersionUID = 1L;
\r
32 private ObjectId _id;
\r
33 private String testName;
\r
34 private String testDescription;
\r
35 private String processDefinitionKey;
\r
36 private List<BpmnInstance> bpmnInstances;
\r
37 private ObjectId groupId;
\r
38 private Date createdAt;
\r
39 private Date updatedAt;
\r
40 private ObjectId createdBy;
\r
41 private ObjectId updatedBy;
\r
43 public TestDefinitionHistoric() {
\r
46 public TestDefinitionHistoric(TestDefinition testDefinition, String processDefinitionId) {
\r
47 this._id = testDefinition.get_id();
\r
48 this.testName = testDefinition.getTestName();
\r
49 this.testDescription = testDefinition.getTestDescription();
\r
50 this.processDefinitionKey = testDefinition.getProcessDefinitionKey();
\r
51 this.bpmnInstances =
\r
52 getHistoricBpmnInstanceAsList(testDefinition.getBpmnInstances(), processDefinitionId);
\r
53 this.groupId = testDefinition.getGroupId();
\r
54 this.createdAt = testDefinition.getCreatedAt();
\r
55 this.updatedAt = testDefinition.getUpdatedAt();
\r
56 this.createdBy = testDefinition.getCreatedBy();
\r
57 this.updatedBy = testDefinition.getUpdatedBy();
\r
60 public TestDefinitionHistoric(
\r
63 String testDescription,
\r
64 String processDefinitionKey,
\r
65 List<BpmnInstance> bpmnInstances,
\r
70 ObjectId updatedBy) {
\r
72 this.testName = testName;
\r
73 this.testDescription = testDescription;
\r
74 this.processDefinitionKey = processDefinitionKey;
\r
75 this.bpmnInstances = bpmnInstances;
\r
76 this.groupId = groupId;
\r
77 this.createdAt = createdAt;
\r
78 this.updatedAt = updatedAt;
\r
79 this.createdBy = createdBy;
\r
80 this.updatedBy = updatedBy;
\r
83 private List<BpmnInstance> getHistoricBpmnInstanceAsList(
\r
84 List<BpmnInstance> bpmnInstances, String processDefinitionId) {
\r
85 BpmnInstance bpmnInstance =
\r
86 bpmnInstances.stream()
\r
89 return _bpmnInstance.isDeployed()
\r
90 && _bpmnInstance.getProcessDefinitionId() != null
\r
91 && _bpmnInstance.getProcessDefinitionId().equals(processDefinitionId);
\r
96 List<BpmnInstance> historicBpmnInstance = new ArrayList<>();
\r
97 if (bpmnInstance != null) {
\r
98 historicBpmnInstance.add(bpmnInstance);
\r
101 return historicBpmnInstance;
\r
104 public ObjectId get_id() {
\r
108 public void set_id(ObjectId _id) {
\r
112 public String getTestName() {
\r
116 public void setTestName(String testName) {
\r
117 this.testName = testName;
\r
120 public String getTestDescription() {
\r
121 return testDescription;
\r
124 public void setTestDescription(String testDescription) {
\r
125 this.testDescription = testDescription;
\r
128 public String getProcessDefinitionKey() {
\r
129 return processDefinitionKey;
\r
132 public void setProcessDefinitionKey(String processDefinitionKey) {
\r
133 this.processDefinitionKey = processDefinitionKey;
\r
136 public List<BpmnInstance> getBpmnInstances() {
\r
137 return bpmnInstances;
\r
140 public void setBpmnInstances(List<BpmnInstance> bpmnInstances) {
\r
141 this.bpmnInstances = bpmnInstances;
\r
144 public ObjectId getGroupId() {
\r
148 public void setGroupId(ObjectId groupId) {
\r
149 this.groupId = groupId;
\r
152 public Date getCreatedAt() {
\r
156 public void setCreatedAt(Date createdAt) {
\r
157 this.createdAt = createdAt;
\r
160 public Date getUpdatedAt() {
\r
164 public void setUpdatedAt(Date updatedAt) {
\r
165 this.updatedAt = updatedAt;
\r
168 public ObjectId getCreatedBy() {
\r
172 public void setCreatedBy(ObjectId createdBy) {
\r
173 this.createdBy = createdBy;
\r
176 public ObjectId getUpdatedBy() {
\r
180 public void setUpdatedBy(ObjectId updatedBy) {
\r
181 this.updatedBy = updatedBy;
\r
185 public String toString() {
\r
186 return Convert.objectToJson(this);
\r