Rev 1784 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1784 | Rev 1789 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.services.courses.xsd; |
1 | package pt.estgp.estgweb.services.courses.xsd; |
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 org.json.JSONException; |
5 | import org.json.JSONException; |
6 | import org.json.JSONObject; |
6 | import org.json.JSONObject; |
7 | import pt.estgp.estgweb.utils.DynamicArrayList; |
7 | import pt.estgp.estgweb.utils.DynamicArrayList; |
8 | 8 | ||
9 | import java.io.IOException; |
9 | import java.io.IOException; |
10 | import java.util.List; |
10 | import java.util.List; |
11 | 11 | ||
12 | /** |
12 | /** |
13 | * Created by jorgemachado on 15/09/16. |
13 | * Created by jorgemachado on 15/09/16. |
14 | */ |
14 | */ |
15 | public class CursoImpl extends Curso |
15 | public class CursoImpl extends Curso |
16 | { |
16 | { |
- | 17 | public static Genson getGensonPlanoEstudosParaApiJsonWS(){ |
|
- | 18 | Genson genson = new GensonBuilder() |
|
- | 19 | .useRuntimeType(true) |
|
- | 20 | .exclude("class") |
|
- | 21 | .exclude("siges", Curso.class) |
|
- | 22 | .exclude("nome",Curso.class) |
|
- | 23 | .exclude("codigoPlanoSiges",Curso.class) |
|
- | 24 | .exclude("anoPlanoSiges",Curso.class) |
|
- | 25 | .exclude("descPlanoSiges",Curso.class) |
|
- | 26 | .exclude("dep") |
|
- | 27 | .exclude("removed",UnidadeType.class) |
|
- | 28 | .exclude("perfilId",Semestre.Perfil.class) |
|
- | 29 | .exclude("semestreId",Semestre.class) |
|
- | 30 | .create(); |
|
- | 31 | return genson; |
|
- | 32 | } |
|
- | 33 | ||
17 | public List<Semestre> getSemestre() |
34 | public List<Semestre> getSemestre() |
18 | { |
35 | { |
19 | if (semestre == null) { |
36 | if (semestre == null) { |
20 | semestre = new DynamicArrayList<Semestre>(SemestreImpl.class); |
37 | semestre = new DynamicArrayList<Semestre>(SemestreImpl.class); |
21 | } |
38 | } |
22 | return this.semestre; |
39 | return this.semestre; |
23 | } |
40 | } |
24 | 41 | ||
25 | //ESTE GENSON e apenas para propositos de interface. O JSON gerado para envio pelas API's e feito no servico |
42 | //ESTE GENSON e apenas para propositos de interface. O JSON gerado para envio pelas API's e feito no servico |
26 | //CourseService.savePlanoEstudosEditado que usa o Genson obtido em CourseService.getGensonPlanoEstudos |
43 | //CourseService.savePlanoEstudosEditado que usa o Genson obtido em CourseService.getGensonPlanoEstudosParaApiJsonWS |
27 | 44 | ||
28 | static Genson genson; |
45 | static Genson genson; |
29 | 46 | ||
30 | static { |
47 | static { |
31 | GensonBuilder gensonBuilder = new GensonBuilder() |
48 | GensonBuilder gensonBuilder = new GensonBuilder() |
32 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
49 | //.exclude(Object.class) |
33 | 50 | ||
34 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
51 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
35 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
52 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
36 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
53 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
37 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
54 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
38 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
55 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
39 | 56 | ||
40 | .include(Curso.class) |
57 | .include(Curso.class) |
41 | .include(UnidadeType.class) |
58 | .include(UnidadeType.class) |
42 | .include(Semestre.Perfil.class) |
59 | .include(Semestre.Perfil.class) |
43 | .include(Semestre.class) |
60 | .include(Semestre.class) |
44 | .include(UnidadeType.HorasContacto.class) |
61 | .include(UnidadeType.HorasContacto.class) |
45 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
62 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
46 | .include(5+0%2Fdocs%2Fapi+List">List.class); |
63 | .include(5+0%2Fdocs%2Fapi+List">List.class); |
47 | 64 | ||
48 | 65 | ||
49 | genson = gensonBuilder.create(); |
66 | genson = gensonBuilder.create(); |
50 | 67 | ||
51 | } |
68 | } |
52 | 69 | ||
53 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(Curso c) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
70 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(Curso c) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
54 | { |
71 | { |
55 | return genson.serialize(c); |
72 | return genson.serialize(c); |
56 | } |
73 | } |
57 | 74 | ||
58 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException |
75 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException |
59 | { |
76 | { |
60 | return genson.serialize(this); |
77 | return genson.serialize(this); |
61 | } |
78 | } |
62 | 79 | ||
63 | public static CursoImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
80 | public static CursoImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
64 | return genson.deserialize(json, CursoImpl.class); |
81 | return genson.deserialize(json, CursoImpl.class); |
65 | } |
82 | } |
66 | 83 | ||
67 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
84 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
68 | return new JSONObject(toJson()); |
85 | return new JSONObject(toJson()); |
69 | } |
86 | } |
- | 87 | ||
- | 88 | public JSONObject toJsonObjectJsonApiWS() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
|
- | 89 | return new JSONObject(getGensonPlanoEstudosParaApiJsonWS().serialize(this)); |
|
- | 90 | } |
|
70 | 91 | ||
71 | 92 | ||
72 | } |
93 | } |
73 | 94 |