-
- All Known Subinterfaces:
ParaObject
- All Known Implementing Classes:
Address,App,Linker,Sysprop,Tag,Translation,User,Vote,Webhook
public interface LinkableApplied to allParaObjects by default. Allows an object to be linked to another object. A link can be: 1-1, 1-* or *-*. One-to-one and one-to-many links are implemented using theparentidfield. Many-to-many links are implemented usingLinkerobjects.- Author:
- Alex Bogdanovski [alex@erudika.com]
- See Also:
Linker
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description LongcountChildren(String type)Count the total number of child objects for this object.LongcountLinks(String type2)Count the total number of links between this object and another type of object.voiddeleteChildren(String type)Deletes all child objects permanently.<P extends ParaObject>
List<P>findChildren(String type, String query, Pager... pager)Search through all child objects.<P extends ParaObject>
List<P>findLinkedObjects(String type, String field, String query, Pager... pager)Similar tofindChildren(java.lang.String, java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships.<P extends ParaObject>
List<P>getChildren(String type, Pager... pager)Returns all child objects linked to this object.<P extends ParaObject>
List<P>getChildren(String type, String field, String term, Pager... pager)Returns all child objects linked to this object.<P extends ParaObject>
List<P>getLinkedObjects(String type, Pager... pager)Similar togetChildren(java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships.List<Linker>getLinks(String type2, Pager... pager)Returns all links between this type object and another type of object.booleanisLinked(ParaObject toObj)Checks if a given object is linked to this one.booleanisLinked(String type2, String id2)Checks if this object is linked to another.Stringlink(String id2)Links an object to this one in a many-to-many relationship.voidunlink(String type, String id2)Unlinks an object from this one.voidunlinkAll()Unlinks all objects that are linked to this one.
-
-
-
Method Detail
-
countLinks
Long countLinks(String type2)
Count the total number of links between this object and another type of object.- Parameters:
type2- the other type of object- Returns:
- the number of links
-
getLinks
List<Linker> getLinks(String type2, Pager... pager)
Returns all links between this type object and another type of object.- Parameters:
type2- the other type of objectpager- aPager- Returns:
- a list of
Linkerobjects in a many-to-many relationship with this object.
-
getLinkedObjects
<P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
Similar togetChildren(java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships.- Type Parameters:
P- type of linked objects- Parameters:
type- type of linked objects to look forpager- aPager- Returns:
- a list of linked objects
-
findLinkedObjects
<P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager)
Similar tofindChildren(java.lang.String, java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships. Searches through all linked objects connected to this via aLinkerobject.- Type Parameters:
P- type of linked objects- Parameters:
type- type of linked objects to look forpager- aPagerfield- the name of the field to target (within a nested field "nstd")query- a query string- Returns:
- a list of linked objects matching the search query
-
isLinked
boolean isLinked(String type2, String id2)
Checks if this object is linked to another.- Parameters:
type2- the other typeid2- the other id- Returns:
- true if the two are linked
-
isLinked
boolean isLinked(ParaObject toObj)
Checks if a given object is linked to this one.- Parameters:
toObj- the other object- Returns:
- true if linked
-
link
String link(String id2)
Links an object to this one in a many-to-many relationship. Only a link is created. Objects are left untouched. The type of the second object is automatically determined on read.- Parameters:
id2- the other id- Returns:
- the id of the
Linkerobject that is created
-
unlink
void unlink(String type, String id2)
Unlinks an object from this one. Only a link is deleted. Objects are left untouched.- Parameters:
type- the other typeid2- the other id
-
unlinkAll
void unlinkAll()
Unlinks all objects that are linked to this one. Deletes allLinkerobjects. Only the links are deleted. Objects are left untouched.
-
countChildren
Long countChildren(String type)
Count the total number of child objects for this object.- Parameters:
type- the other type of object- Returns:
- the number of links
-
getChildren
<P extends ParaObject> List<P> getChildren(String type, Pager... pager)
Returns all child objects linked to this object.- Type Parameters:
P- the type of children- Parameters:
type- the type of children to look forpager- aPager- Returns:
- a list of
ParaObjectin a one-to-many relationship with this object
-
findChildren
<P extends ParaObject> List<P> findChildren(String type, String query, Pager... pager)
Search through all child objects. Only searches child objects directly connected to this parent via theparentidfield.- Type Parameters:
P- the type of children- Parameters:
type- the type of children to look forpager- aPagerquery- a query string- Returns:
- a list of
ParaObjectin a one-to-many relationship with this object
-
getChildren
<P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
Returns all child objects linked to this object.- Type Parameters:
P- the type of children- Parameters:
type- the type of children to look forfield- the field name to use as filterterm- the field value to use as filterpager- aPager- Returns:
- a list of
ParaObjectin a one-to-many relationship with this object
-
deleteChildren
void deleteChildren(String type)
Deletes all child objects permanently.- Parameters:
type- the children's type.
-
-