Rev 1830 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1830 | Rev 1848 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.services.courses.coursereport.documentmodel; |
1 | package pt.estgp.estgweb.services.courses.coursereport.documentmodel; |
2 | 2 | ||
3 | import com.owlike.genson.Genson; |
3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.GensonBuilder; |
4 | import com.owlike.genson.GensonBuilder; |
5 | import org.apache.log4j.Logger; |
5 | import org.apache.log4j.Logger; |
6 | import org.json.JSONException; |
6 | import org.json.JSONException; |
7 | import org.json.JSONObject; |
7 | import org.json.JSONObject; |
8 | import pt.estgp.estgweb.domain.utils.JsonView; |
8 | import pt.estgp.estgweb.domain.utils.JsonView; |
9 | import pt.estgp.estgweb.utils.documentBuilder.Document; |
9 | import pt.estgp.estgweb.utils.documentBuilder.Document; |
10 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
10 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
11 | 11 | ||
12 | import java.util.Date; |
12 | import java.util.Date; |
13 | import java.util.List; |
13 | import java.util.List; |
14 | 14 | ||
15 | /** |
15 | /** |
16 | * Created by jorgemachado on 14/10/17. |
16 | * Created by jorgemachado on 14/10/17. |
17 | */ |
17 | */ |
18 | public class ReportCourseDocument extends 5+0%2Fdocs%2Fapi+Document">Document implements JsonView |
18 | public class CourseReportDocument extends 5+0%2Fdocs%2Fapi+Document">Document implements JsonView |
19 | { |
19 | { |
20 | 20 | ||
21 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(ReportCourseDocument.class); |
21 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseReportDocument.class); |
22 | 22 | ||
23 | public ReportCourseDocument() |
23 | public CourseReportDocument() |
24 | { |
24 | { |
25 | 25 | ||
26 | } |
26 | } |
27 | 27 | ||
28 | public void init() |
28 | public void init() |
29 | { |
29 | { |
30 | 30 | ||
31 | //1 - Introducao |
31 | //1 - Introducao |
32 | IntroSection introSection = new IntroSection(); |
32 | IntroSection introSection = new IntroSection(); |
33 | introSection.init(); |
33 | introSection.init(); |
34 | getSections().add(introSection); |
34 | getSections().add(introSection); |
35 | 35 | ||
36 | //2 - Mapa Sintese dos Relatórios dos Responsáveis das UC's |
36 | //2 - Mapa Sintese dos Relatórios dos Responsáveis das UC's |
37 | ReportsUcSummarySection reportsUcSummarySection = new ReportsUcSummarySection(); |
37 | ReportsUcSummarySection reportsUcSummarySection = new ReportsUcSummarySection(); |
38 | reportsUcSummarySection.init(); |
38 | reportsUcSummarySection.init(); |
39 | getSections().add(reportsUcSummarySection); |
39 | getSections().add(reportsUcSummarySection); |
40 | 40 | ||
41 | //3 - Resultados da Aprendizagem |
41 | //3 - Resultados da Aprendizagem |
42 | LearningResultsSection learningResultsSection = new LearningResultsSection(); |
42 | LearningResultsSection learningResultsSection = new LearningResultsSection(); |
43 | learningResultsSection.init(); |
43 | learningResultsSection.init(); |
44 | getSections().add(learningResultsSection); |
44 | getSections().add(learningResultsSection); |
45 | 45 | ||
46 | //4 - Inquéritos |
46 | //4 - Inquéritos |
47 | SurveysSection surveysSection = new SurveysSection(); |
47 | SurveysSection surveysSection = new SurveysSection(); |
48 | surveysSection.init(); |
48 | surveysSection.init(); |
49 | getSections().add(surveysSection); |
49 | getSections().add(surveysSection); |
50 | 50 | ||
51 | //5 - Conclusões |
51 | //5 - Conclusões |
52 | ConclusionsSection conclusionsSection = new ConclusionsSection(); |
52 | ConclusionsSection conclusionsSection = new ConclusionsSection(); |
53 | conclusionsSection.init(); |
53 | conclusionsSection.init(); |
54 | getSections().add(conclusionsSection); |
54 | getSections().add(conclusionsSection); |
55 | 55 | ||
56 | //5 - Unidades Curriculares |
56 | //5 - Unidades Curriculares |
57 | CourseUnitsReportsSection courseUnitsReportsSection = new CourseUnitsReportsSection(); |
57 | CourseUnitsReportsSection courseUnitsReportsSection = new CourseUnitsReportsSection(); |
58 | courseUnitsReportsSection.init(); |
58 | courseUnitsReportsSection.init(); |
59 | getSections().add(courseUnitsReportsSection); |
59 | getSections().add(courseUnitsReportsSection); |
60 | } |
60 | } |
61 | 61 | ||
62 | 62 | ||
63 | 63 | ||
64 | public DocumentSection findDocumentSection(1.5.0/docs/api/java/lang/Class.html">Class sectionClass) |
64 | public DocumentSection findDocumentSection(1.5.0/docs/api/java/lang/Class.html">Class sectionClass) |
65 | { |
65 | { |
66 | if(getSections() != null) |
66 | if(getSections() != null) |
67 | for(DocumentSection section: getSections()) |
67 | for(DocumentSection section: getSections()) |
68 | { |
68 | { |
69 | if(section.getClass().equals(sectionClass)) |
69 | if(section.getClass().equals(sectionClass)) |
70 | { |
70 | { |
71 | return section; |
71 | return section; |
72 | } |
72 | } |
73 | } |
73 | } |
74 | return null; |
74 | return null; |
75 | } |
75 | } |
76 | 76 | ||
77 | 77 | ||
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | private static Genson gensonGenericLoad; |
81 | private static Genson gensonGenericLoad; |
82 | static{ |
82 | static{ |
83 | gensonGenericLoad = new GensonBuilder() |
83 | gensonGenericLoad = new GensonBuilder() |
84 | .useMethods(true) |
84 | .useMethods(true) |
85 | .useFields(true) |
85 | .useFields(true) |
86 | .useRuntimeType(true) //para ignorar a CGLIB do courseUnitEvaluation |
86 | .useRuntimeType(true) //para ignorar a CGLIB do courseUnitEvaluation |
87 | .useClassMetadata(true) |
87 | .useClassMetadata(true) |
88 | .useDateAsTimestamp(true) |
88 | .useDateAsTimestamp(true) |
89 | .exclude(1.5.0/docs/api/java/lang/Class.html">Class.class) |
89 | .exclude(1.5.0/docs/api/java/lang/Class.html">Class.class) |
90 | .exclude(5+0%2Fdocs%2Fapi+Date">Date.class) |
90 | .exclude(5+0%2Fdocs%2Fapi+Date">Date.class) |
91 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Timestamp">Timestamp.class) |
91 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Timestamp">Timestamp.class) |
92 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Date">Date.class) |
92 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Date">Date.class) |
93 | .create(); |
93 | .create(); |
94 | } |
94 | } |
95 | 95 | ||
96 | public static ReportCourseDocument fromJson(1.5.0/docs/api/java/lang/String.html">String json) |
96 | public static CourseReportDocument fromJson(1.5.0/docs/api/java/lang/String.html">String json) |
97 | { |
97 | { |
98 | return gensonGenericLoad.deserialize(json,ReportCourseDocument.class); |
98 | return gensonGenericLoad.deserialize(json,CourseReportDocument.class); |
99 | } |
99 | } |
100 | 100 | ||
101 | 101 | ||
102 | 102 | ||
103 | public List<String> getJsonExcludedProperties() { |
103 | public List<String> getJsonExcludedProperties() { |
104 | return null; |
104 | return null; |
105 | } |
105 | } |
106 | 106 | ||
107 | /** |
107 | /** |
108 | * Generic Json Object only for local class methods |
108 | * Generic Json Object only for local class methods |
109 | * @return |
109 | * @return |
110 | * @throws org.json.JSONException |
110 | * @throws org.json.JSONException |
111 | */ |
111 | */ |
112 | public JSONObject toJsonObject() throws JSONException |
112 | public JSONObject toJsonObject() throws JSONException |
113 | { |
113 | { |
114 | return new JSONObject(toJson()); |
114 | return new JSONObject(toJson()); |
115 | } |
115 | } |
116 | 116 | ||
117 | /** |
117 | /** |
118 | * * Generic Json Object only for local class methods |
118 | * * Generic Json Object only for local class methods |
119 | * @return |
119 | * @return |
120 | * @throws java.io.IOException |
120 | * @throws java.io.IOException |
121 | */ |
121 | */ |
122 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
122 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
123 | { |
123 | { |
124 | return gensonGenericLoad.serialize(this); |
124 | return gensonGenericLoad.serialize(this); |
125 | } |
125 | } |
126 | 126 | ||
127 | 127 | ||
128 | 128 | ||
129 | } |
129 | } |
130 | 130 |