Rev 1670 | Rev 1730 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1670 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
3 | import com.owlike.genson.Genson; |
||
4 | import com.owlike.genson.TransformationException; |
||
5 | import org.json.JSONException; |
||
6 | import org.json.JSONObject; |
||
7 | |||
8 | import java.io.IOException; |
||
9 | import java.io.Serializable; |
||
10 | import java.util.ArrayList; |
||
11 | |||
12 | /** |
||
13 | * Created by jorgemachado on 13/02/17. |
||
14 | */ |
||
15 | public class CourseSchoolImpl extends CourseSchool{ |
||
16 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
17 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() { |
||
18 | return getId(); |
||
19 | } |
||
20 | |||
21 | |||
22 | static Genson courseSchoolGenson = new Genson.Builder() |
||
23 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
24 | .include(CourseSchoolImpl.class) |
||
25 | .include("id", CourseSchoolImpl.class) |
||
26 | .include("active", CourseSchoolImpl.class) |
||
27 | .include("institutionalCode", CourseSchoolImpl.class) |
||
28 | .include("name", CourseSchoolImpl.class) |
||
29 | .include("nameEn", CourseSchoolImpl.class) |
||
30 | .include("nameEs", CourseSchoolImpl.class) |
||
31 | .include("nameFr",CourseSchoolImpl.class) |
||
32 | |||
33 | .include("schoolDirectorRole", CourseSchoolImpl.class) |
||
34 | .include("schoolBoardRole",CourseSchoolImpl.class) |
||
35 | .include("schoolSecretariadoRole",CourseSchoolImpl.class) |
||
36 | |||
37 | .include("ctcPresidentRole",CourseSchoolImpl.class) |
||
38 | .include("ctcMemberRole",CourseSchoolImpl.class) |
||
39 | .include("ctcSecretariadoRole",CourseSchoolImpl.class) |
||
40 | |||
41 | .include("pedagogicoPresidentRole",CourseSchoolImpl.class) |
||
42 | .include("pedagogicoMemberRole",CourseSchoolImpl.class) |
||
43 | .include("pedagogicoSecretariadoRole",CourseSchoolImpl.class) |
||
1728 | jmachado | 44 | |
45 | .include("funcionarioRole",CourseSchoolImpl.class) |
||
46 | .include("studentRole",CourseSchoolImpl.class) |
||
47 | .include("teacherRole",CourseSchoolImpl.class) |
||
1670 | jmachado | 48 | .create(); |
49 | |||
50 | public 1.5.0/docs/api/java/lang/String.html">String getJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
51 | { |
||
52 | return courseSchoolGenson.serialize(this); |
||
53 | } |
||
54 | |||
55 | public static 1.5.0/docs/api/java/lang/String.html">String getJson(ArrayList<CourseSchool> schools) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
56 | { |
||
57 | return courseSchoolGenson.serialize(schools); |
||
58 | } |
||
59 | |||
60 | public static CourseSchoolImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
||
61 | return courseSchoolGenson.deserialize(json, CourseSchoolImpl.class); |
||
62 | } |
||
63 | |||
64 | public JSONObject getJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
||
65 | return new JSONObject(getJson()); |
||
66 | } |
||
67 | } |