@Singleton public final class CoreUtils extends Object implements InitializeListener
ParaObject| Constructor and Description |
|---|
CoreUtils(DAO dao,
Search search,
Cache cache)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
addTags(List<String> objectTags,
String... tag)
Adds any number of tags to the set of tags.
|
Long |
countChildren(ParaObject obj,
String type2)
Count the total number of child objects for this object.
|
Long |
countLinks(ParaObject obj,
String type2)
Count the total number of links between this object and another type of object.
|
void |
deleteChildren(ParaObject obj,
String type2)
Deletes all child objects permanently.
|
Cache |
getCache() |
<P extends ParaObject> |
getChildren(ParaObject obj,
String type2,
Pager... pager)
Returns all child objects linked to this object.
|
<P extends ParaObject> |
getChildren(ParaObject obj,
String type2,
String field,
String term,
Pager... pager)
Returns all child objects linked to this object.
|
<P extends ParaObject> |
getCreator(ParaObject obj)
The user object of the creator.
|
DAO |
getDao() |
static CoreUtils |
getInstance()
Provides a default instance using fake DAO and Search implementations.
|
<P extends ParaObject> |
getLinkedObjects(ParaObject obj,
String type2,
Pager... pager)
Returns all objects linked to the given one.
|
List<Linker> |
getLinks(ParaObject obj,
String type2,
Pager... pager)
Returns a list of all Linker objects for a given object.
|
String |
getName(String name,
String id) |
String |
getObjectURI(ParaObject obj) |
<P extends ParaObject> |
getParent(ParaObject obj)
The parent object.
|
Search |
getSearch() |
boolean |
isLinked(ParaObject obj,
ParaObject toObj)
Checks if a given object is linked to this one.
|
boolean |
isLinked(ParaObject obj,
String type2,
String id2)
Checks if this object is linked to another.
|
String |
link(ParaObject obj,
String id2)
Links an object to this one in a many-to-many relationship.
|
void |
onInitialize()
Code to execute right after initialization.
|
String |
overwrite(ParaObject obj)
Creates the object again (use with caution!).
|
String |
overwrite(String appid,
ParaObject obj)
Creates the object again (use with caution!).
|
List<String> |
removeTags(List<String> objectTags,
String... tag)
Removes a tag from the set of tags.
|
void |
setCache(Cache cache) |
void |
setDao(DAO dao) |
void |
setSearch(Search search) |
void |
unlink(ParaObject obj,
String type2,
String id2)
Unlinks an object from this one.
|
void |
unlinkAll(ParaObject obj)
Unlinks all objects that are linked to this one.
|
boolean |
vote(ParaObject votable,
String userid,
Votable.VoteValue upDown)
Casts a vote on a given object.
|
public void onInitialize()
InitializeListeneronInitialize in interface InitializeListenerpublic static CoreUtils getInstance()
public DAO getDao()
public void setDao(DAO dao)
public Search getSearch()
public void setSearch(Search search)
public Cache getCache()
public void setCache(Cache cache)
public String getObjectURI(ParaObject obj)
public String overwrite(ParaObject obj)
DAO.create(com.erudika.para.core.ParaObject).obj - an objectpublic String overwrite(String appid, ParaObject obj)
DAO.create(java.lang.String, com.erudika.para.core.ParaObject).appid - the app idobj - an objectpublic List<String> addTags(List<String> objectTags, String... tag)
tag - a tag, must not be null or emptyobjectTags - the object tagspublic List<String> removeTags(List<String> objectTags, String... tag)
tag - a tag, must not be null or emptyobjectTags - the objectpublic String link(ParaObject obj, String id2)
id2 - link to the object with this idobj - the object to execute this method onLinker object that is createdpublic void unlink(ParaObject obj, String type2, String id2)
type2 - the other typeobj - the object to execute this method onid2 - the other idpublic void unlinkAll(ParaObject obj)
obj - the object to execute this method on
Deletes all Linker objects.
Only the links are deleted. Objects are left untouched.public List<Linker> getLinks(ParaObject obj, String type2, Pager... pager)
obj - the object to execute this method ontype2 - the other typepager - a Pagerpublic boolean isLinked(ParaObject obj, String type2, String id2)
type2 - the other typeid2 - the other idobj - the object to execute this method onpublic boolean isLinked(ParaObject obj, ParaObject toObj)
toObj - the other objectobj - the object to execute this method onpublic Long countLinks(ParaObject obj, String type2)
type2 - the other type of objectobj - the object to execute this method onpublic Long countChildren(ParaObject obj, String type2)
type2 - the type of the other objectobj - the object to execute this method onpublic <P extends ParaObject> List<P> getChildren(ParaObject obj, String type2, Pager... pager)
P - the type of childrentype2 - the type of children to look forobj - the object to execute this method onpager - a PagerParaObject in a one-to-many relationship with this objectpublic <P extends ParaObject> List<P> getChildren(ParaObject obj, String type2, String field, String term, Pager... pager)
P - the type of childrentype2 - the type of children to look forfield - the field name to use as filterterm - the field value to use as filterobj - the object to execute this method onpager - a PagerParaObject in a one-to-many relationship with this objectpublic void deleteChildren(ParaObject obj, String type2)
obj - the object to execute this method ontype2 - the children's type.public <P extends ParaObject> List<P> getLinkedObjects(ParaObject obj, String type2, Pager... pager)
P - type of linked objectstype2 - type of linked objects to search forobj - the object to execute this method onpager - a Pagerpublic <P extends ParaObject> P getParent(ParaObject obj)
P - type of linked objectsobj - find the parent of this objectobj.getParentid() is nullpublic <P extends ParaObject> P getCreator(ParaObject obj)
P - type of linked objectsobj - find the creator of this objectobj.getCreatorid() is nullUserpublic boolean vote(ParaObject votable, String userid, Votable.VoteValue upDown)
votable - the object to vote onuserid - the voterupDown - up or downCopyright © 2016 Erudika. All rights reserved.