Rev 1784 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1505 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1626 | jmachado | 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; |
||
1505 | jmachado | 7 | import pt.estgp.estgweb.utils.ConfigProperties; |
8 | |||
1626 | jmachado | 9 | import java.io.IOException; |
1505 | jmachado | 10 | import java.io.Serializable; |
1626 | jmachado | 11 | import java.util.ArrayList; |
1505 | jmachado | 12 | |
13 | /** |
||
14 | * Created by jorgemachado on 14/09/16. |
||
15 | */ |
||
16 | public class CourseDepartmentImpl extends CourseDepartment { |
||
17 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
18 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() { |
||
19 | return getSigla(); |
||
20 | } |
||
21 | |||
22 | public 1.5.0/docs/api/java/lang/String.html">String getSchoolFromInstitutionalCode() |
||
23 | { |
||
1795 | jmachado | 24 | if(getCourseSchool() != null) |
25 | return ConfigProperties.getProperty("institution.code.prefix." + getCourseSchool().getInstitutionalCode()); |
||
26 | return null; |
||
1505 | jmachado | 27 | } |
1626 | jmachado | 28 | |
1782 | jmachado | 29 | public void setSchoolFromInstitutionalCode(1.5.0/docs/api/java/lang/String.html">String garbage) |
30 | { |
||
31 | |||
32 | } |
||
33 | |||
1784 | jmachado | 34 | static Genson courseDepartmentGenson = new GensonBuilder() |
1626 | jmachado | 35 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
1670 | jmachado | 36 | .include(CourseDepartmentImpl.class) |
1782 | jmachado | 37 | .useRuntimeType(true) |
38 | .useMethods(true) |
||
39 | .useFields(false) |
||
40 | .useClassMetadata(true) |
||
41 | .include("sigla", CourseDepartment.class) |
||
42 | .include("active", CourseDepartment.class) |
||
43 | .include("name", CourseDepartment.class) |
||
44 | .include("nameEn", CourseDepartment.class) |
||
45 | .include("nameEs", CourseDepartment.class) |
||
46 | .include("nameFr",CourseDepartment.class) |
||
47 | .include("directorRole",CourseDepartment.class) |
||
48 | .include("boardRole",CourseDepartment.class) |
||
49 | .include("courseSchool",CourseDepartment.class) |
||
50 | .include("schoolFromInstitutionalCode",CourseDepartmentImpl.class) |
||
51 | |||
52 | .include("id",CourseSchool.class) |
||
53 | |||
1626 | jmachado | 54 | .create(); |
55 | |||
1780 | jmachado | 56 | public 1.5.0/docs/api/java/lang/String.html">String toJson() { |
1626 | jmachado | 57 | return courseDepartmentGenson.serialize(this); |
58 | } |
||
1780 | jmachado | 59 | public JSONObject toJsonObject() throws JSONException |
1670 | jmachado | 60 | { |
61 | return new JSONObject(courseDepartmentGenson.serialize(this)); |
||
62 | } |
||
1626 | jmachado | 63 | |
1779 | jmachado | 64 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(ArrayList<CourseDepartment> departments) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1626 | jmachado | 65 | { |
66 | return courseDepartmentGenson.serialize(departments); |
||
67 | } |
||
1670 | jmachado | 68 | |
1776 | jmachado | 69 | public static CourseDepartmentImpl 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 | 70 | { |
71 | return courseDepartmentGenson.deserialize(json,CourseDepartmentImpl.class); |
||
72 | } |
||
1778 | jmachado | 73 | |
1782 | jmachado | 74 | |
1505 | jmachado | 75 | } |