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 _bpmnInstance.getProcessDefinitionId().equalsIgnoreCase(processDefinitionId))
\r
93 List<BpmnInstance> historicBpmnInstance = new ArrayList<>();
\r
94 if (bpmnInstance != null) {
\r
95 historicBpmnInstance.add(bpmnInstance);
\r
98 return historicBpmnInstance;
\r
101 public ObjectId get_id() {
\r
105 public void set_id(ObjectId _id) {
\r
109 public String getTestName() {
\r
113 public void setTestName(String testName) {
\r
114 this.testName = testName;
\r
117 public String getTestDescription() {
\r
118 return testDescription;
\r
121 public void setTestDescription(String testDescription) {
\r
122 this.testDescription = testDescription;
\r
125 public String getProcessDefinitionKey() {
\r
126 return processDefinitionKey;
\r
129 public void setProcessDefinitionKey(String processDefinitionKey) {
\r
130 this.processDefinitionKey = processDefinitionKey;
\r
133 public List<BpmnInstance> getBpmnInstances() {
\r
134 return bpmnInstances;
\r
137 public void setBpmnInstances(List<BpmnInstance> bpmnInstances) {
\r
138 this.bpmnInstances = bpmnInstances;
\r
141 public ObjectId getGroupId() {
\r
145 public void setGroupId(ObjectId groupId) {
\r
146 this.groupId = groupId;
\r
149 public Date getCreatedAt() {
\r
153 public void setCreatedAt(Date createdAt) {
\r
154 this.createdAt = createdAt;
\r
157 public Date getUpdatedAt() {
\r
161 public void setUpdatedAt(Date updatedAt) {
\r
162 this.updatedAt = updatedAt;
\r
165 public ObjectId getCreatedBy() {
\r
169 public void setCreatedBy(ObjectId createdBy) {
\r
170 this.createdBy = createdBy;
\r
173 public ObjectId getUpdatedBy() {
\r
177 public void setUpdatedBy(ObjectId updatedBy) {
\r
178 this.updatedBy = updatedBy;
\r
182 public String toString() {
\r
183 return Convert.objectToJson(this);
\r