Rev 1862 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1848 | jmachado | 1 | package pt.estgp.estgweb.utils.documentBuilder; |
2 | |||
1912 | grupo6 | 3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.GensonBuilder; |
||
5 | import org.json.JSONException; |
||
6 | import org.json.JSONObject; |
||
1848 | jmachado | 7 | import pt.estgp.estgweb.utils.ClassUtils; |
8 | |||
1912 | grupo6 | 9 | import java.util.Date; |
1848 | jmachado | 10 | import java.util.List; |
11 | |||
12 | /** |
||
13 | * Created by jorgemachado on 07/11/17. |
||
14 | */ |
||
15 | public class ExtensibleDocObject |
||
16 | { |
||
1912 | grupo6 | 17 | |
18 | |||
19 | private static Genson gensonGenericLoad; |
||
20 | static{ |
||
21 | gensonGenericLoad = new GensonBuilder() |
||
22 | .useMethods(true) |
||
23 | .useFields(true) |
||
24 | .useRuntimeType(true) //para ignorar a CGLIB do courseUnitEvaluation |
||
25 | .useClassMetadata(true) |
||
26 | .useDateAsTimestamp(true) |
||
27 | .exclude(1.5.0/docs/api/java/lang/Class.html">Class.class) |
||
28 | .exclude(5+0%2Fdocs%2Fapi+Date">Date.class) |
||
29 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Timestamp">Timestamp.class) |
||
30 | .exclude(java.sql.5+0%2Fdocs%2Fapi+Date">Date.class) |
||
31 | .create(); |
||
32 | } |
||
33 | /** |
||
34 | * Generic Json Object only for local class methods |
||
35 | * @return |
||
36 | * @throws org.json.JSONException |
||
37 | */ |
||
38 | public JSONObject toJsonObject() throws JSONException |
||
39 | { |
||
40 | return new JSONObject(toJson()); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * * Generic Json Object only for local class methods |
||
45 | * @return |
||
46 | * @throws java.io.IOException |
||
47 | */ |
||
48 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
||
49 | { |
||
50 | return gensonGenericLoad.serialize(this); |
||
51 | } |
||
52 | |||
1848 | jmachado | 53 | public List<String> getAllSuperClasses() |
54 | { |
||
55 | return ClassUtils.getAllSuperClasses(this.getClass()); |
||
56 | } |
||
57 | public void setAllSuperClasses(List<String> superclasses) |
||
58 | { |
||
59 | |||
60 | } |
||
61 | } |