Merge "[UI] Optional trust of all SSL Certificates"
[validation.git] / ui / src / main / java / org / akraino / validation / ui / entity / ValidationDbTestResult.java
1 /*
2  * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may
5  * not use this file except in compliance with the License. You may obtain
6  * a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 package org.akraino.validation.ui.entity;
17
18 import java.io.IOException;
19 import java.io.Serializable;
20 import java.util.Set;
21
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.FetchType;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.OneToMany;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33
34 import com.fasterxml.jackson.core.JsonGenerator;
35 import com.fasterxml.jackson.databind.SerializerProvider;
36 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
37 import com.fasterxml.jackson.databind.ser.std.StdSerializer;
38
39 @Entity
40 @Table(name = "validation_test_result")
41 public class ValidationDbTestResult implements Serializable {
42
43     /**
44      *
45      */
46     private static final long serialVersionUID = 1L;
47
48     @Id
49     @GeneratedValue(strategy = GenerationType.IDENTITY)
50     @Column(name = "id")
51     private int resultId;
52
53     @ManyToOne
54     @JoinColumn(name = "blueprint_instance_id")
55     private BlueprintInstance blueprintInstance;
56
57     @ManyToOne
58     @JoinColumn(name = "lab_id")
59     private LabInfo lab;
60
61     @Column(name = "timestamp")
62     private String timestamp;
63
64     @Column(name = "all_layers")
65     private Boolean allLayers;
66
67     @Column(name = "optional")
68     private Boolean optional;
69
70     @Column(name = "result")
71     private Boolean result;
72
73     @Column(name = "date_of_storage")
74     private String dateStorage;
75
76     @OneToOne
77     @JoinColumn(name = "submission_id")
78     @JsonSerialize(using = SubmissionSerializer.class)
79     private Submission submission;
80
81     @OneToMany(mappedBy = "validationDbTestResult", targetEntity = WRobotDbTestResult.class, fetch = FetchType.EAGER)
82     private Set<WRobotDbTestResult> wRobotDbTestResults;
83
84     public int getResultId() {
85         return resultId;
86     }
87
88     public void setResultId(int resultId) {
89         this.resultId = resultId;
90     }
91
92     public BlueprintInstance getBlueprintInstance() {
93         return blueprintInstance;
94     }
95
96     public void setBlueprintInstance(BlueprintInstance blueprintInstance) {
97         this.blueprintInstance = blueprintInstance;
98     }
99
100     public Boolean getAllLayers() {
101         return allLayers;
102     }
103
104     public void setAllLayers(Boolean allLayers) {
105         this.allLayers = allLayers;
106     }
107
108     public Boolean getOptional() {
109         return optional;
110     }
111
112     public void setOptional(Boolean optional) {
113         this.optional = optional;
114     }
115
116     public LabInfo getLab() {
117         return lab;
118     }
119
120     public void setLab(LabInfo lab) {
121         this.lab = lab;
122     }
123
124     public String getTimestamp() {
125         return timestamp;
126     }
127
128     public void setTimestamp(String timestamp) {
129         this.timestamp = timestamp;
130     }
131
132     public Boolean getResult() {
133         return result;
134     }
135
136     public void setResult(Boolean result) {
137         this.result = result;
138     }
139
140     public String getDateStorage() {
141         return dateStorage;
142     }
143
144     public void setDateStorage(String dateStorage) {
145         this.dateStorage = dateStorage;
146     }
147
148     public Submission getSubmission() {
149         return this.submission;
150     }
151
152     public void setSubmission(Submission submission) {
153         this.submission = submission;
154     }
155
156     public Set<WRobotDbTestResult> getWRobotDbTestResults() {
157         return this.wRobotDbTestResults;
158     }
159
160     public void setWRobotDbTestResults(Set<WRobotDbTestResult> wRobotDbTestResults) {
161         this.wRobotDbTestResults = wRobotDbTestResults;
162     }
163
164     static class SubmissionSerializer extends StdSerializer<Submission> {
165
166         public SubmissionSerializer() {
167             this(null);
168         }
169
170         public SubmissionSerializer(Class<Submission> t) {
171             super(t);
172         }
173
174         @Override
175         public void serialize(Submission submission, JsonGenerator gen, SerializerProvider provider)
176                 throws IOException {
177             Submission result = new Submission();
178             result.setSubmissionId(submission.getSubmissionId());
179             result.setSubmissionStatus(submission.getSubmissionStatus());
180             result.setTimeslot(submission.getTimeslot());
181             gen.writeObject(result);
182         }
183     }
184
185 }