Merge pull request #41 from RS7-SECIOTSRK/develop
[platform/core/security/suspicious-activity-monitor.git] / servers / commons / src / main / java / com / samsung / commons / domain / Report.java
1 /*
2  * In Samsung Ukraine R&D Center (SRK under a contract between)
3  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4  * Copyright (C) 2017 Samsung Electronics Co., Ltd. All rights reserved.
5  */
6 package com.samsung.commons.domain;
7
8 import org.hibernate.annotations.Type;
9
10 import javax.persistence.*;
11
12 /**
13  * <h1>Report DAO table</h1> DAO representation of Report class. Reports are
14  * send by client TV to TDM Server in ASIS format.
15  *
16  * @author <A HREF="mailto:a.motchanyi@samsung.com">Artem Motchanyi</A>
17  * @version 1.0
18  * @see ReportType
19  * @file Report.java
20  * @brief Report DAO table
21  * @date Created : 1/9/2016
22  * @date Modified : 11/2/2017
23  */
24 @Entity
25 @Table(name = "report")
26 public class Report {
27
28     /** The unique ID in database table. */
29     @Id
30     @SequenceGenerator(name = "report_id_seq", sequenceName = "report_id_seq", allocationSize = 1)
31     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "report_id_seq")
32     @Column
33     private Long id;
34
35     /** The report type. */
36     @ManyToOne
37     @JoinColumn(name = "type_id", nullable = false)
38     private ReportType type;
39
40     /** Report body. */
41     @Column
42     @Type(type = "text")
43     private String report;
44
45     /**
46      * ID of the client TV, so server is able to associate Report with concrete
47      * registered TV.
48      */
49     @ManyToOne
50     @JoinColumn(name = "device_id", nullable = false)
51     private Device device;
52
53     /**
54      * Report generation date
55      */
56     @Column
57     private String date;
58
59     /**
60      * Report verdict, 0 - ok, others - error code
61      */
62     @Column
63     private Integer result;
64
65     /**
66      * Instantiates a new report.
67      */
68     public Report() {
69     }
70
71     /**
72      * Instantiates a new report.
73      *
74      * @param type   Report type.
75      * @param report The {@link String} with report body.
76      * @param date   The report generation date
77      * @param result Report verdict
78      * @param device The {@link Device} ID of client TV, so server is able to            associate Report with concrete registered client TV.
79      */
80     public Report(ReportType type, String report, String date, Integer result, Device device) {
81         this.type = type;
82         this.report = report;
83         this.date = date;
84         this.result = result;
85         this.device = device;
86     }
87
88     /**
89      * Gets the id.
90      *
91      * @return the id
92      */
93     public Long getId() {
94         return id;
95     }
96
97     /**
98      * Sets the id.
99      *
100      * @param id the new id
101      */
102     public void setId(Long id) {
103         this.id = id;
104     }
105
106     /**
107      * Gets the report type.
108      *
109      * @return {@link ReportType}
110      */
111     public ReportType getType() {
112         return type;
113     }
114
115     /**
116      * Sets the type.
117      *
118      * @param type the new {@link ReportType}
119      */
120     public void setType(ReportType type) {
121         this.type = type;
122     }
123
124     /**
125      * Gets the report.
126      *
127      * @return the report
128      */
129     public String getReport() {
130         return report;
131     }
132
133     /**
134      * Sets the report contents.
135      *
136      * @param report the new report string
137      */
138     public void setReport(String report) {
139         this.report = report;
140     }
141
142     /**
143      * Gets the device.
144      *
145      * @return {@link Device}
146      */
147     public Device getDevice() {
148         return device;
149     }
150
151     /**
152      * Sets the device.
153      *
154      * @param device the new {@link Device}
155      */
156     public void setDevice(Device device) {
157         this.device = device;
158     }
159
160     /**
161      * Gets report generation date
162      *
163      * @return report generation date
164      */
165     public String getDate() {
166         return date;
167     }
168
169     /**
170      * Sets report generation date
171      *
172      * @param date report generation date
173      */
174     public void setDate(String date) {
175         this.date = date;
176     }
177
178     /**
179      * Gets report verdict
180      *
181      * @return report verdict
182      */
183     public Integer getResult() {
184         return result;
185     }
186
187     /**
188      * Sets report verdict
189      *
190      * @param result the result
191      */
192     public void setResult(Integer result) {
193         this.result = result;
194     }
195
196     /**
197      * Method provides reflection to print names and values of all fields
198      * <em>declared in this class</em>. Note that superclass fields are left out
199      * of this implementation.
200      * 
201      * @return String with names and values of all fields declared in this
202      *         class.
203      */
204     @Override
205     public String toString() {
206         return "Report [id=" + id + ", type=" + type + ", report=" + report + ", device=" + device + "]";
207     }
208 }