Rev 1862 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1862 | Rev 1873 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 jomm.dao.impl.AbstractDao; |
|
5 | import org.apache.log4j.Logger; |
6 | import org.apache.log4j.Logger; |
6 | import org.json.JSONException; |
7 | import org.json.JSONException; |
7 | import org.json.JSONObject; |
8 | import org.json.JSONObject; |
- | 9 | import pt.estgp.estgweb.domain.Course; |
|
- | 10 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
|
8 | import pt.estgp.estgweb.domain.utils.JsonView; |
11 | import pt.estgp.estgweb.domain.utils.JsonView; |
9 | import pt.estgp.estgweb.utils.documentBuilder.Document; |
12 | import pt.estgp.estgweb.utils.documentBuilder.Document; |
10 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
13 | import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
11 | 14 | ||
12 | import java.util.Date; |
15 | import java.util.Date; |
Line 18... | Line 21... | ||
18 | public class CourseReportDocument extends 5+0%2Fdocs%2Fapi+Document">Document implements JsonView |
21 | public class CourseReportDocument extends 5+0%2Fdocs%2Fapi+Document">Document implements JsonView |
19 | { |
22 | { |
20 | 23 | ||
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); |
24 | 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 | 25 | ||
- | 26 | private 1.5.0/docs/api/java/lang/String.html">String courseCode; |
|
- | 27 | private 1.5.0/docs/api/java/lang/String.html">String courseName; |
|
- | 28 | private 1.5.0/docs/api/java/lang/String.html">String year; |
|
- | 29 | ||
- | 30 | ||
- | 31 | ||
23 | public CourseReportDocument() |
32 | public CourseReportDocument() |
24 | { |
33 | { |
25 | 34 | ||
26 | } |
35 | } |
27 | 36 | ||
- | 37 | public 1.5.0/docs/api/java/lang/String.html">String getCourseCode() { |
|
- | 38 | return courseCode; |
|
- | 39 | } |
|
- | 40 | ||
- | 41 | public void setCourseCode(1.5.0/docs/api/java/lang/String.html">String courseCode) { |
|
- | 42 | this.courseCode = courseCode; |
|
- | 43 | } |
|
- | 44 | ||
- | 45 | public 1.5.0/docs/api/java/lang/String.html">String getCourseName() { |
|
- | 46 | return courseName; |
|
- | 47 | } |
|
- | 48 | ||
- | 49 | public void setCourseName(1.5.0/docs/api/java/lang/String.html">String courseName) { |
|
- | 50 | this.courseName = courseName; |
|
- | 51 | } |
|
- | 52 | ||
28 | public void init() |
53 | public 1.5.0/docs/api/java/lang/String.html">String getYear() { |
- | 54 | return year; |
|
- | 55 | } |
|
- | 56 | ||
- | 57 | public void setYear(1.5.0/docs/api/java/lang/String.html">String year) { |
|
- | 58 | this.year = year; |
|
- | 59 | } |
|
- | 60 | ||
- | 61 | public void init(Course c,1.5.0/docs/api/java/lang/String.html">String year) |
|
29 | { |
62 | { |
- | 63 | setYear(year); |
|
- | 64 | setCourseCode(c.getCode()); |
|
- | 65 | setCourseName(c.getName()); |
|
30 | 66 | ||
31 | //1 - Introducao |
67 | //1 - Introducao |
32 | IntroSection introSection = new IntroSection(); |
68 | IntroSection introSection = new IntroSection(); |
33 | introSection.init(); |
69 | introSection.init(); |
- | 70 | ||
34 | getSections().add(introSection); |
71 | getSections().add(introSection); |
35 | 72 | ||
36 | //2 - Mapa Sintese dos Relatórios dos Responsáveis das UC's |
73 | //2 - Mapa Sintese dos Relatórios dos Responsáveis das UC's |
37 | ReportsUcSummarySection reportsUcSummarySection = new ReportsUcSummarySection(); |
74 | ReportsUcSummarySection reportsUcSummarySection = new ReportsUcSummarySection(); |
38 | reportsUcSummarySection.init(); |
75 | reportsUcSummarySection.init(); |
Line 122... | Line 159... | ||
122 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
159 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
123 | { |
160 | { |
124 | return gensonGenericLoad.serialize(this); |
161 | return gensonGenericLoad.serialize(this); |
125 | } |
162 | } |
126 | 163 | ||
- | 164 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) |
|
- | 165 | { |
|
- | 166 | CourseReportDocument d = new CourseReportDocument(); |
|
- | 167 | ||
- | 168 | AbstractDao.getCurrentSession().beginTransaction(); |
|
- | 169 | ||
- | 170 | List<Course> cursos = DaoFactory.getCourseDaoImpl().findAll(); |
|
- | 171 | ||
- | 172 | ||
- | 173 | d.init(cursos.get(0),"201718"); |
|
- | 174 | ||
- | 175 | 1.5.0/docs/api/java/lang/String.html">String json = d.toJson(); |
|
- | 176 | 1.5.0/docs/api/java/lang/System.html">System.out.println(json); |
|
- | 177 | CourseReportDocument d2 = CourseReportDocument.fromJson(json); |
|
- | 178 | 1.5.0/docs/api/java/lang/System.html">System.out.println(d2.toJson()); |
|
- | 179 | ||
- | 180 | AbstractDao.getCurrentSession().getTransaction().commit(); |
|
- | 181 | } |
|
- | 182 | ||
127 | 183 | ||
128 | 184 | ||
129 | } |
185 | } |