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