Rev 1814 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1814 | Rev 1827 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.domain; |
1 | package pt.estgp.estgweb.domain; |
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.JSONArray; |
- | |
6 | import org.json.JSONException; |
5 | import org.json.JSONException; |
7 | import org.json.JSONObject; |
6 | import org.json.JSONObject; |
8 | import pt.estgp.estgweb.services.virtualfilesystem.dto.VfsAbstractPageContentDto; |
- | |
9 | 7 | ||
10 | import java.io.IOException; |
8 | import java.io.IOException; |
11 | import java.io.Serializable; |
9 | import java.io.Serializable; |
12 | import java.util.ArrayList; |
- | |
13 | import java.util.List; |
10 | import java.util.List; |
14 | import java.util.Set; |
11 | import java.util.Set; |
15 | 12 | ||
16 | /** |
13 | /** |
17 | * Created by jorgemachado on 03/02/16. |
14 | * Created by jorgemachado on 03/02/16. |
18 | */ |
15 | */ |
19 | public class PageSectionImpl extends PageSection { |
16 | public class PageSectionImpl extends PageSection { |
20 | @1.5.0/docs/api/java/lang/Override.html">Override |
17 | @1.5.0/docs/api/java/lang/Override.html">Override |
21 | public List<String> getOwnerRoles() { |
18 | public List<String> getOwnerRoles() { |
22 | return null; |
19 | return null; |
23 | } |
20 | } |
24 | 21 | ||
25 | @1.5.0/docs/api/java/lang/Override.html">Override |
22 | @1.5.0/docs/api/java/lang/Override.html">Override |
26 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() { |
23 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() { |
27 | return null; |
24 | return null; |
28 | } |
25 | } |
29 | 26 | ||
30 | @1.5.0/docs/api/java/lang/Override.html">Override |
27 | @1.5.0/docs/api/java/lang/Override.html">Override |
31 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() { |
28 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() { |
32 | return getId(); |
29 | return getId(); |
33 | } |
30 | } |
34 | 31 | ||
35 | public Set<CourseUnit> courseUnitLookup() |
32 | public Set<CourseUnit> courseUnitLookup() |
36 | { |
33 | { |
37 | if(getCourseUnits() != null && getCourseUnits().size() > 0) |
34 | if(getCourseUnits() != null && getCourseUnits().size() > 0) |
38 | return getCourseUnits(); |
35 | return getCourseUnits(); |
39 | if(getParent() != null) |
36 | if(getParent() != null) |
40 | return ((PageSectionImpl)getParent()).courseUnitLookup(); |
37 | return ((PageSectionImpl)getParent()).courseUnitLookup(); |
41 | return null; |
38 | return null; |
42 | } |
39 | } |
43 | 40 | ||
44 | public Set<Course> coursesLookup() |
41 | public Set<Course> coursesLookup() |
45 | { |
42 | { |
46 | if(getCourses() != null && getCourses().size() > 0) |
43 | if(getCourses() != null && getCourses().size() > 0) |
47 | return getCourses(); |
44 | return getCourses(); |
48 | if(getParent() != null) |
45 | if(getParent() != null) |
49 | return ((PageSectionImpl)getParent()).coursesLookup(); |
46 | return ((PageSectionImpl)getParent()).coursesLookup(); |
50 | return null; |
47 | return null; |
51 | } |
48 | } |
52 | 49 | ||
53 | 50 | ||
54 | public static Genson genson; |
51 | public static Genson genson; |
55 | 52 | ||
56 | static { |
53 | static { |
57 | GensonBuilder gensonBuilder = new GensonBuilder() |
54 | GensonBuilder gensonBuilder = new GensonBuilder() |
58 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
55 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
59 | .useMethods(true) |
56 | .useMethods(true) |
60 | .useFields(false) |
57 | .useFields(false) |
61 | .useClassMetadata(true) |
58 | .useClassMetadata(true) |
62 | .useRuntimeType(true) |
59 | .useRuntimeType(true) |
63 | 60 | ||
64 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
61 | .include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.class) |
65 | .exclude("clear") |
62 | .exclude("clear") |
66 | .exclude("clearanceInitialized") |
63 | .exclude("clearanceInitialized") |
67 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
64 | .include(1.5.0/docs/api/java/lang/Integer.html">Integer.class) |
68 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
65 | .include(1.5.0/docs/api/java/lang/Long.html">Long.class) |
69 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
66 | .include(1.5.0/docs/api/java/lang/Double.html">Double.class) |
70 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
67 | .include(1.5.0/docs/api/java/lang/Float.html">Float.class) |
71 | //.useFields(false) //COM ISTO A SLUG VAI A NULL E SEM ISTO DÁ NULLPOINTER EXCEPTION. ISTO NO SERVIÇO!!! |
68 | //.useFields(false) //COM ISTO A SLUG VAI A NULL E SEM ISTO DÁ NULLPOINTER EXCEPTION. ISTO NO SERVIÇO!!! |
72 | .include(PageContentImpl.class) |
69 | .include(PageContentImpl.class) |
73 | .include(PageSectionImpl.class) |
70 | .include(PageSectionImpl.class) |
74 | .include(1.5.0/docs/api/java/security/acl/Acl.html">Acl.1.5.0/docs/api/java/rmi/server/Operation.html">Operation.class) |
71 | .include(1.5.0/docs/api/java/security/acl/Acl.html">Acl.1.5.0/docs/api/java/rmi/server/Operation.html">Operation.class) |
75 | .include("title", PageContent.class) |
72 | .include("title", PageContent.class) |
76 | .include("directory",PageContent.class) |
73 | .include("directory",PageContent.class) |
77 | .include("file", PageContent.class) |
74 | .include("file", PageContent.class) |
78 | .include("description",PageContent.class) |
75 | .include("description",PageContent.class) |
79 | .include("path",PageContent.class) |
76 | .include("path",PageContent.class) |
80 | .include("acl",PageContent.class) |
77 | .include("acl",PageContent.class) |
81 | .include("slug",PageContent.class) |
78 | .include("slug",PageContent.class) |
82 | .include("pathForIdHtml",PageContent.class) |
79 | .include("pathForIdHtml",PageContent.class) |
83 | .include("html", PageText.class) |
80 | .include("html", PageText.class) |
84 | .include("url",PageContent.class) |
81 | .include("url",PageContent.class) |
85 | .include("textBox", PageContent.class) |
82 | .include("textBox", PageContent.class) |
86 | //.include("getAclJson", PageContentImpl.class) |
83 | //.include("getAclJson", PageContentImpl.class) |
87 | .include("clearances", PageContentImpl.class)//como FUNCIONA PARA PÔR AS ACL'S DIREITINHAS?? |
84 | .include("clearances", PageContentImpl.class)//como FUNCIONA PARA PÔR AS ACL'S DIREITINHAS?? |
88 | //.include("pageContent", PageContentImpl.class) |
85 | //.include("pageContent", PageContentImpl.class) |
89 | //.include("isClear", PageContentImpl.class) |
86 | //.include("isClear", PageContentImpl.class) |
90 | //.include("isDirectory", PageContentImpl.class) |
87 | //.include("isDirectory", PageContentImpl.class) |
91 | .exclude("childsInitialized", PageContentImpl.class) |
88 | .exclude("childsInitialized", PageContentImpl.class) |
92 | .exclude("parentInitialized", PageContentImpl.class) |
89 | .exclude("parentInitialized", PageContentImpl.class) |
93 | .exclude("parent", PageContent.class); |
90 | .exclude("parent", PageContent.class); |
94 | 91 | ||
95 | 92 | ||
96 | genson = gensonBuilder.create(); |
93 | genson = gensonBuilder.create(); |
97 | } |
94 | } |
98 | 95 | ||
99 | 96 | ||
100 | public static PageSectionImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
97 | public static PageSectionImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
101 | return genson.deserialize(json,PageSectionImpl.class); |
98 | return genson.deserialize(json,PageSectionImpl.class); |
102 | } |
99 | } |
103 | 100 | ||
104 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
101 | public 1.5.0/docs/api/java/lang/String.html">String toJson() |
105 | { |
102 | { |
106 | return genson.serialize(this); |
103 | return genson.serialize(this); |
107 | } |
104 | } |
108 | 105 | ||
109 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(List<PageSection> roots) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException{ |
106 | public static 1.5.0/docs/api/java/lang/String.html">String toJson(List<PageSection> roots) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException{ |
110 | return genson.serialize(roots); |
107 | return genson.serialize(roots); |
111 | } |
108 | } |
112 | 109 | ||
113 | public JSONObject toJsonObject() throws JSONException { |
110 | public JSONObject toJsonObject() throws JSONException { |
114 | return new JSONObject(toJson()); |
111 | return new JSONObject(toJson()); |
115 | } |
112 | } |
116 | 113 | ||
- | 114 | /* |
|
117 | public static JSONArray toJsonArray(List<PageSectionImpl> itemGroup) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
115 | public static JSONArray toJsonArray(List<PageSectionImpl> itemGroup) throws IOException, JSONException { |
118 | return new JSONArray(genson.serialize(itemGroup)); |
116 | return new JSONArray(genson.serialize(itemGroup)); |
119 | } |
117 | }*/ |
120 | 118 | ||
121 | /*public String getPath(){ |
119 | /*public String getPath(){ |
122 | if(getParent()==null) |
120 | if(getParent()==null) |
123 | return getSlug(); |
121 | return getSlug(); |
124 | else |
122 | else |
125 | return getParent().getSlug() + "/" + getSlug(); |
123 | return getParent().getSlug() + "/" + getSlug(); |
126 | }*/ |
124 | }*/ |
127 | } |
125 | } |
128 | 126 |