Rev 1782 | 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; |
||
1784 | jmachado | 4 | import com.owlike.genson.GensonBuilder; |
1670 | jmachado | 5 | import org.json.JSONException; |
6 | import org.json.JSONObject; |
||
7 | |||
8 | import java.io.IOException; |
||
9 | import java.io.Serializable; |
||
1782 | jmachado | 10 | import java.util.List; |
1670 | jmachado | 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 | |||
1784 | jmachado | 22 | static Genson courseSchoolGenson = new GensonBuilder() |
1670 | jmachado | 23 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
1782 | jmachado | 24 | .useRuntimeType(true) |
25 | .useMethods(true) |
||
26 | .useFields(false) |
||
27 | .useClassMetadata(true) |
||
1670 | jmachado | 28 | .include(CourseSchoolImpl.class) |
1782 | jmachado | 29 | .include("id", CourseSchool.class) |
30 | .include("active", CourseSchool.class) |
||
31 | .include("institutionalCode", CourseSchool.class) |
||
32 | .include("initials", CourseSchool.class) |
||
33 | .include("name", CourseSchool.class) |
||
34 | .include("nameEn", CourseSchool.class) |
||
35 | .include("nameEs", CourseSchool.class) |
||
36 | .include("nameFr",CourseSchool.class) |
||
1670 | jmachado | 37 | |
1782 | jmachado | 38 | .include("schoolDirectorRole", CourseSchool.class) |
39 | .include("schoolBoardRole",CourseSchool.class) |
||
40 | .include("schoolSecretariadoRole",CourseSchool.class) |
||
1670 | jmachado | 41 | |
1782 | jmachado | 42 | .include("ctcPresidentRole",CourseSchool.class) |
43 | .include("ctcMemberRole",CourseSchool.class) |
||
44 | .include("ctcSecretariadoRole",CourseSchool.class) |
||
1670 | jmachado | 45 | |
1782 | jmachado | 46 | .include("pedagogicoPresidentRole",CourseSchool.class) |
47 | .include("pedagogicoMemberRole",CourseSchool.class) |
||
48 | .include("pedagogicoSecretariadoRole",CourseSchool.class) |
||
1728 | jmachado | 49 | |
1782 | jmachado | 50 | .include("funcionarioRole",CourseSchool.class) |
51 | .include("studentRole",CourseSchool.class) |
||
52 | .include("teacherRole",CourseSchool.class) |
||
1670 | jmachado | 53 | .create(); |
54 | |||
1780 | jmachado | 55 | public 1.5.0/docs/api/java/lang/String.html">String toJson() { |
1670 | jmachado | 56 | return courseSchoolGenson.serialize(this); |
57 | } |
||
58 | |||
1782 | jmachado | 59 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(List<CourseSchool> schools) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1670 | jmachado | 60 | { |
61 | return courseSchoolGenson.serialize(schools); |
||
62 | } |
||
63 | |||
1776 | jmachado | 64 | 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 { |
1670 | jmachado | 65 | return courseSchoolGenson.deserialize(json, CourseSchoolImpl.class); |
66 | } |
||
67 | |||
1780 | jmachado | 68 | public JSONObject toJsonObject() throws JSONException { |
1779 | jmachado | 69 | return new JSONObject(toJson()); |
1670 | jmachado | 70 | } |
71 | } |