Rev 1814 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package pt.estgp.estgweb.domain;
import com.owlike.genson.Genson;
import com.owlike.genson.GensonBuilder;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
/**
* Created by jorgemachado on 03/02/16.
*/
public class PageSectionImpl
extends PageSection
{
@
1.5.0/docs/api/java/lang/Override.html">Override
public List
<String
> getOwnerRoles
() {
return null;
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole
() {
return null;
}
@
1.5.0/docs/api/java/lang/Override.html">Override
public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable
() {
return getId
();
}
public Set
<CourseUnit
> courseUnitLookup
()
{
if(getCourseUnits
() !=
null && getCourseUnits
().
size() > 0
)
return getCourseUnits
();
if(getParent
() !=
null)
return ((PageSectionImpl
)getParent
()).
courseUnitLookup();
return null;
}
public Set
<Course
> coursesLookup
()
{
if(getCourses
() !=
null && getCourses
().
size() > 0
)
return getCourses
();
if(getParent
() !=
null)
return ((PageSectionImpl
)getParent
()).
coursesLookup();
return null;
}
public static Genson genson
;
static {
GensonBuilder gensonBuilder =
new GensonBuilder
()
.
exclude(5+0%2Fdocs%2Fapi+Object">Object.
class)
.
useMethods(true)
.
useFields(false)
.
useClassMetadata(true)
.
useRuntimeType(true)
.
include(1.5.0/docs/api/java/lang/Boolean.html">Boolean.
class)
.
exclude("clear")
.
exclude("clearanceInitialized")
.
include(1.5.0/docs/api/java/lang/Integer.html">Integer.
class)
.
include(1.5.0/docs/api/java/lang/Long.html">Long.
class)
.
include(1.5.0/docs/api/java/lang/Double.html">Double.
class)
.
include(1.5.0/docs/api/java/lang/Float.html">Float.
class)
//.useFields(false) //COM ISTO A SLUG VAI A NULL E SEM ISTO DÁ NULLPOINTER EXCEPTION. ISTO NO SERVIÇO!!!
.
include(PageContentImpl.
class)
.
include(PageSectionImpl.
class)
.
include(1.5.0/docs/api/java/security/acl/Acl.html">Acl.
1.5.0/docs/api/java/rmi/server/Operation.html">Operation.
class)
.
include("title", PageContent.
class)
.
include("directory",PageContent.
class)
.
include("file", PageContent.
class)
.
include("description",PageContent.
class)
.
include("path",PageContent.
class)
.
include("acl",PageContent.
class)
.
include("slug",PageContent.
class)
.
include("pathForIdHtml",PageContent.
class)
.
include("html", PageText.
class)
.
include("url",PageContent.
class)
.
include("textBox", PageContent.
class)
//.include("getAclJson", PageContentImpl.class)
.
include("clearances", PageContentImpl.
class)//como FUNCIONA PARA PÔR AS ACL'S DIREITINHAS??
//.include("pageContent", PageContentImpl.class)
//.include("isClear", PageContentImpl.class)
//.include("isDirectory", PageContentImpl.class)
.
exclude("childsInitialized", PageContentImpl.
class)
.
exclude("parentInitialized", PageContentImpl.
class)
.
exclude("parent", PageContent.
class);
genson = gensonBuilder.
create();
}
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 {
return genson.
deserialize(json,PageSectionImpl.
class);
}
public 1.5.0/docs/api/java/lang/String.html">String toJson
()
{
return genson.
serialize(this);
}
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
{
return genson.
serialize(roots
);
}
public JSONObject toJsonObject
() throws JSONException
{
return new JSONObject
(toJson
());
}
/*
public static JSONArray toJsonArray(List<PageSectionImpl> itemGroup) throws IOException, JSONException {
return new JSONArray(genson.serialize(itemGroup));
}*/
/*public String getPath(){
if(getParent()==null)
return getSlug();
else
return getParent().getSlug() + "/" + getSlug();
}*/
}