Rev 1730 | Rev 1779 | 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 org.json.JSONException; |
||
5 | import org.json.JSONObject; |
||
6 | |||
7 | import java.io.IOException; |
||
8 | import java.io.Serializable; |
||
9 | import java.util.ArrayList; |
||
10 | |||
11 | /** |
||
12 | * Created by jorgemachado on 13/02/17. |
||
13 | */ |
||
14 | public class CourseSchoolImpl extends CourseSchool{ |
||
15 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
16 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() { |
||
17 | return getId(); |
||
18 | } |
||
19 | |||
20 | |||
21 | static Genson courseSchoolGenson = new Genson.Builder() |
||
22 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
||
23 | .include(CourseSchoolImpl.class) |
||
24 | .include("id", CourseSchoolImpl.class) |
||
25 | .include("active", CourseSchoolImpl.class) |
||
26 | .include("institutionalCode", CourseSchoolImpl.class) |
||
1730 | jmachado | 27 | .include("initials", CourseSchoolImpl.class) |
1670 | jmachado | 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 | |||
1776 | jmachado | 50 | public 1.5.0/docs/api/java/lang/String.html">String getJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1670 | jmachado | 51 | { |
52 | return courseSchoolGenson.serialize(this); |
||
53 | } |
||
54 | |||
1776 | jmachado | 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 |
1670 | jmachado | 56 | { |
57 | return courseSchoolGenson.serialize(schools); |
||
58 | } |
||
59 | |||
1776 | jmachado | 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 { |
1670 | jmachado | 61 | return courseSchoolGenson.deserialize(json, CourseSchoolImpl.class); |
62 | } |
||
63 | |||
1776 | jmachado | 64 | public JSONObject getJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
1670 | jmachado | 65 | return new JSONObject(getJson()); |
66 | } |
||
67 | } |