[UI] Common class for results
[validation.git] / ui / src / main / java / org / akraino / validation / ui / entity / WRobotDbTestResult.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
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Table;
29
30 import com.fasterxml.jackson.core.JsonGenerator;
31 import com.fasterxml.jackson.databind.SerializerProvider;
32 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
33 import com.fasterxml.jackson.databind.ser.std.StdSerializer;
34
35 @Entity
36 @Table(name = "w_robot_test_result")
37 public class WRobotDbTestResult implements Serializable {
38
39     /**
40      *
41      */
42     private static final long serialVersionUID = 1L;
43
44     @Id
45     @GeneratedValue(strategy = GenerationType.IDENTITY)
46     @Column(name = "id")
47     private int wRobotResultId;
48
49     @Column(name = "layer")
50     private String layer;
51
52     @ManyToOne
53     @JoinColumn(name = "validation_test_result_id")
54     @JsonSerialize(using = ValidationDbTestResultSerializer.class)
55     private ValidationDbTestResult validationDbTestResult;
56
57     @Column(name = "robot_test_results")
58     private String robotTestResults;
59
60     public int getWRobotResultId() {
61         return wRobotResultId;
62     }
63
64     public void setWRobotResultId(int wRobotResultId) {
65         this.wRobotResultId = wRobotResultId;
66     }
67
68     public String getLayer() {
69         return layer;
70     }
71
72     public void setLayer(String layer) {
73         this.layer = layer;
74     }
75
76     public ValidationDbTestResult getValidationDbTestResult() {
77         return validationDbTestResult;
78     }
79
80     public void setValidationDbTestResult(ValidationDbTestResult validationDbTestResult) {
81         this.validationDbTestResult = validationDbTestResult;
82     }
83
84     public String getRobotTestResults() {
85         return robotTestResults;
86     }
87
88     public void setRobotTestResults(String robotTestResults) {
89         this.robotTestResults = robotTestResults;
90     }
91
92     static class ValidationDbTestResultSerializer extends StdSerializer<ValidationDbTestResult> {
93
94         public ValidationDbTestResultSerializer() {
95             this(null);
96         }
97
98         public ValidationDbTestResultSerializer(Class<ValidationDbTestResult> t) {
99             super(t);
100         }
101
102         @Override
103         public void serialize(ValidationDbTestResult validationDbTestResult, JsonGenerator gen,
104                 SerializerProvider provider) throws IOException {
105             gen.writeObject(null);
106         }
107
108     }
109 }