Class Linker
java.lang.Object
com.erudika.para.core.Linker
- All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable
This class represents a many-to-many relationship (link) between two objects.
- Author:
- Alex Bogdanovski [[email protected]]
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Votable
Votable.VoteValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an object to nest inside the linker object.countChildren(String type) Counts the number of children of a certain type.countLinks(String type2) Counts the number of links to other objects of a certain type.create()Persists the object to the database.voiddelete()Deletes the object from the database.voiddeleteChildren(String type) Deletes all children of a certain type.booleanReturns true if this object is equal to another.booleanexists()Returns true if the object exists in the database.<P extends ParaObject>
List<P> findChildren(String type, String query, Pager... pager) Finds children of a certain type that match a specific query.<P extends ParaObject>
List<P> findLinkedObjects(String type, String field, String query, Pager... pager) Finds linked objects of a certain type that match a specific field and query.getAppid()Returns the app identifier.Returns true if the object is cached.<P extends ParaObject>
List<P> getChildren(String type, Pager... pager) Returns a list of children of a certain type.<P extends ParaObject>
List<P> getChildren(String type, String field, String term, Pager... pager) Returns a list of children of a certain type that match a specific field and term.Returns the creator ID.getId()Returns the object ID.getId1()Returns the id of the first object in the link.getId2()Returns the id of the second object in the link.getIdFieldNameFor(String type) Returns "id1" or "id2" depending on the alphabetical order of type.Returns true if the object is indexed.<P extends ParaObject>
List<P> getLinkedObjects(String type, Pager... pager) Returns a list of linked objects of a certain type.Returns a list of links to other objects of a certain type.Returns the additional information about the link.getName()Returns the object name.getNstd()Get the nested objects that are linked by this link.Returns the object URI.Returns the parent ID.Returns the plural form of the object type.Returns true if the object is stored in the database.getTags()Returns the tags.Returns the timestamp.getType()Returns the object type.getType1()Returns the type of the first object in the link.getType2()Returns the type of the second object in the link.Returns the updated timestamp.Returns the version of the object.getVotes()Returns the number of votes.inthashCode()Returns the hash code for this object.booleanChecks if the position of a given object is first or second.booleanisLinked(ParaObject toObj) Returns true if the object is linked to another object.booleanReturns true if the object is linked to another object of a certain type and ID.Links the object to another object of a certain type and ID.voidSets the app identifier.voidSets the cached flag.voidsetCreatorid(String creatorid) Sets the creator ID.voidSets the object ID.voidSets the id of the first object in the link.voidSets the id of the second object in the link.voidsetIndexed(Boolean indexed) Sets the indexed flag.voidsetMetadata(String metadata) Sets additional information about the link.voidSets the object name.voidSets the nested array of objects that are linked by this link.voidsetParentid(String parentid) Sets the parent ID.voidSets the stored flag.voidSets the tags.voidsetTimestamp(Long timestamp) Sets the timestamp.voidSets the object type.voidSets the type of the first object in the link.voidSets the type of the second object in the link.voidsetUpdated(Long updated) Sets the updated timestamp.voidsetVersion(Long version) Sets the version of the object.voidSets the number of votes.toString()Returns a JSON string representation of this object.voidUnlinks the object from another object of a certain type and ID.voidUnlinks the object from all other objects.voidupdate()Updates the object in the database.booleanVotes down for the object.booleanVotes up for the object.
-
Constructor Details
-
Linker
public Linker()No-args constructor. -
Linker
-
-
Method Details
-
getId2
-
setId2
Sets the id of the second object in the link.- Parameters:
id2- a new id
-
getId1
-
setId1
Sets the id of the first object in the link.- Parameters:
id1- a new id
-
getType1
-
setType1
Sets the type of the first object in the link.- Parameters:
type1- the type
-
getType2
-
setType2
Sets the type of the second object in the link.- Parameters:
type2- second type
-
getMetadata
-
setMetadata
Sets additional information about the link.- Parameters:
metadata- some info
-
isFirst
Checks if the position of a given object is first or second.- Parameters:
type2- the given class of object- Returns:
- true if the object's type is equal to
getType1()
-
getIdFieldNameFor
-
getNstd
-
setNstd
-
addNestedObject
Add an object to nest inside the linker object. Used for joining queries when searching objects in a many-to-many relationship.- Parameters:
obj- object
-
getId
Returns the object ID.- Specified by:
getIdin interfaceParaObject- Returns:
- the id
-
setId
Sets the object ID.- Specified by:
setIdin interfaceParaObject- Parameters:
id- the id
-
getType
Returns the object type.- Specified by:
getTypein interfaceParaObject- Returns:
- the type
-
setType
Sets the object type.- Specified by:
setTypein interfaceParaObject- Parameters:
type- the type
-
getAppid
Returns the app identifier.- Specified by:
getAppidin interfaceParaObject- Returns:
- the appid
-
setAppid
Sets the app identifier.- Specified by:
setAppidin interfaceParaObject- Parameters:
appid- the appid
-
getObjectURI
Returns the object URI.- Specified by:
getObjectURIin interfaceParaObject- Returns:
- the URI
- See Also:
-
getTags
Returns the tags.- Specified by:
getTagsin interfaceParaObject- Returns:
- the tags
- See Also:
-
setTags
Sets the tags.- Specified by:
setTagsin interfaceParaObject- Parameters:
tags- the tags
-
getStored
Returns true if the object is stored in the database.- Specified by:
getStoredin interfaceParaObject- Returns:
- true if stored
-
setStored
Sets the stored flag.- Specified by:
setStoredin interfaceParaObject- Parameters:
stored- the stored flag
-
getIndexed
Returns true if the object is indexed.- Specified by:
getIndexedin interfaceParaObject- Returns:
- true if indexed
-
setIndexed
Sets the indexed flag.- Specified by:
setIndexedin interfaceParaObject- Parameters:
indexed- the indexed flag
-
getCached
Returns true if the object is cached.- Specified by:
getCachedin interfaceParaObject- Returns:
- true if cached
-
setCached
Sets the cached flag.- Specified by:
setCachedin interfaceParaObject- Parameters:
cached- the cached flag
-
getTimestamp
Returns the timestamp.- Specified by:
getTimestampin interfaceParaObject- Returns:
- the timestamp
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestampin interfaceParaObject- Parameters:
timestamp- the timestamp
-
getCreatorid
Returns the creator ID.- Specified by:
getCreatoridin interfaceParaObject- Returns:
- the creatorid
-
setCreatorid
Sets the creator ID.- Specified by:
setCreatoridin interfaceParaObject- Parameters:
creatorid- the creatorid
-
getName
Returns the object name.- Specified by:
getNamein interfaceParaObject- Returns:
- the name
-
setName
Sets the object name.- Specified by:
setNamein interfaceParaObject- Parameters:
name- the name
-
getPlural
Returns the plural form of the object type.- Specified by:
getPluralin interfaceParaObject- Returns:
- the plural name
-
getParentid
Returns the parent ID.- Specified by:
getParentidin interfaceParaObject- Returns:
- the parentid
-
setParentid
Sets the parent ID.- Specified by:
setParentidin interfaceParaObject- Parameters:
parentid- the parentid
-
getUpdated
Returns the updated timestamp.- Specified by:
getUpdatedin interfaceParaObject- Returns:
- the updated timestamp
-
setUpdated
Sets the updated timestamp.- Specified by:
setUpdatedin interfaceParaObject- Parameters:
updated- the updated timestamp
-
create
Persists the object to the database.- Specified by:
createin interfaceParaObject- Returns:
- the object ID
- See Also:
-
update
public void update()Updates the object in the database.- Specified by:
updatein interfaceParaObject- See Also:
-
delete
public void delete()Deletes the object from the database.- Specified by:
deletein interfaceParaObject- See Also:
-
exists
public boolean exists()Returns true if the object exists in the database.- Specified by:
existsin interfaceParaObject- Returns:
- true if exists
- See Also:
-
voteUp
-
voteDown
-
getVotes
-
setVotes
-
getVersion
Returns the version of the object.- Specified by:
getVersionin interfaceParaObject- Returns:
- the version
-
setVersion
Sets the version of the object.- Specified by:
setVersionin interfaceParaObject- Parameters:
version- the version
-
countLinks
Counts the number of links to other objects of a certain type.- Specified by:
countLinksin interfaceLinkable- Parameters:
type2- the other type- Returns:
- the number of links
-
getLinks
-
getLinkedObjects
Returns a list of linked objects of a certain type.- Specified by:
getLinkedObjectsin interfaceLinkable- Type Parameters:
P- the type of linked objects- Parameters:
type- the other typepager- a pager- Returns:
- a list of linked objects
-
findLinkedObjects
public <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager) Finds linked objects of a certain type that match a specific field and query.- Specified by:
findLinkedObjectsin interfaceLinkable- Type Parameters:
P- the type of linked objects- Parameters:
type- the other typefield- the field to search inquery- the search querypager- a pager- Returns:
- a list of linked objects
-
isLinked
-
isLinked
Returns true if the object is linked to another object. -
link
-
unlink
-
unlinkAll
-
countChildren
Counts the number of children of a certain type.- Specified by:
countChildrenin interfaceLinkable- Parameters:
type- the child type- Returns:
- the number of children
-
getChildren
Returns a list of children of a certain type.- Specified by:
getChildrenin interfaceLinkable- Type Parameters:
P- the type of children- Parameters:
type- the child typepager- a pager- Returns:
- a list of children
-
getChildren
public <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager) Returns a list of children of a certain type that match a specific field and term.- Specified by:
getChildrenin interfaceLinkable- Type Parameters:
P- the type of children- Parameters:
type- the child typefield- the field to search interm- the search termpager- a pager- Returns:
- a list of children
-
findChildren
Finds children of a certain type that match a specific query.- Specified by:
findChildrenin interfaceLinkable- Type Parameters:
P- the type of children- Parameters:
type- the child typequery- the search querypager- a pager- Returns:
- a list of children
-
deleteChildren
Deletes all children of a certain type.- Specified by:
deleteChildrenin interfaceLinkable- Parameters:
type- the child type
-
hashCode
-
equals
-
toString
-