- java.lang.Object
-
- com.erudika.para.core.App
-
- All Implemented Interfaces:
Linkable,ParaObject,Votable,Serializable
public class App extends Object implements ParaObject, Serializable
This is a representation of an application within Para.
It allows the user to create separate apps running on the same infrastructure. EveryParaObjectbelongs to an app.
Apps can have a dedicated table or they can share the same table using prefixed keys. Also, apps can have a dedicated search index or share one. These are controlled by the two flagsisSharingTable()andisSharingIndex().
Usually when we have a multi-app environment there's a parent app (dedicated) and lots of child apps (shared) that share the same index with the parent app.- Author:
- Alex Bogdanovski [alex@erudika.com]
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classApp.AllowedMethodsRepresents HTTP methods allowed to be executed on a specific resource/type.-
Nested classes/interfaces inherited from interface com.erudika.para.core.Votable
Votable.VoteValue
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AppaddAllSettings(Map<String,Object> settings)Adds all settings to map of app settings and invokes allAppSettingAddedListeners.static voidaddAppCreatedListener(AppCreatedListener listener)Registers a new create listener.static voidaddAppDeletedListener(AppDeletedListener listener)Registers a new delete listener.static voidaddAppSettingAddedListener(AppSettingAddedListener listener)Registers a new app setting added listener.static voidaddAppSettingRemovedListener(AppSettingRemovedListener listener)Registers a new app setting removed listener.voidaddDatatype(String pluralDatatype, String datatype)Adds a user-defined data type to the types map.booleanaddDatatypes(ParaObject... objects)Adds unknown types to this app's list of data types.AppaddSetting(String name, Object value)Adds a new setting to the map.booleanaddValidationConstraint(String type, String field, Constraint c)Adds a new constraint to the list of constraints for a given field and type.AppclearSettings()Clears all app settings and invokes eachAppSettingRemovedListeners.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.Stringcreate()Stores this object in the data store.voiddelete()Deletes the object permanently by removing it from the data store.voiddeleteChildren(String type)Deletes all child objects permanently.booleanequals(Object obj)booleanexists()Checks if an object is stored in the data store.<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 toLinkable.findChildren(java.lang.String, java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships.BooleangetActive()Returns true if this application is active (enabled).Map<String,Map<String,List<String>>>getAllResourcePermissions(String... subjectids)Returns all resource permission for a list of subjects ids.Map<String,Map<String,Map<String,Map<String,?>>>>getAllValidationConstraints(String... types)Returns all validation constraints for a list of types.StringgetAppid()The application name.StringgetAppIdentifier()The App identifier (the id but without the prefixapp:).BooleangetCached()Boolean flag which controls whether this object is cached.<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.StringgetCreatorid()The id of the user who created this.Map<String,String>getCredentials()Returns the map containing the app's access key and secret key.Map<String,String>getDatatypes()Returns a set of custom data types for this app.LonggetDeleteOn()The timestamp for when this app must be deleted.StringgetId()The id of an object.BooleangetIndexed()Boolean flag which controls whether this object is indexed by the search engine.<P extends ParaObject>
List<P>getLinkedObjects(String type, Pager... pager)Similar toLinkable.getChildren(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.StringgetName()The name of the object.StringgetObjectURI()The URI of this object.StringgetParentid()The id of the parent object.StringgetPlural()The plural name of the object.BooleangetReadOnly()Gets read-only mode.Map<String,Map<String,List<String>>>getResourcePermissions()Returns a map of resource permissions.StringgetSecret()Returns the app's secret key.ObjectgetSetting(String name)Returns the value of a setting for a given key.Map<String,Object>getSettings()A map of all settings (key/values).BooleangetStored()Boolean flag which controls whether this object is stored in the database or not.List<String>getTags()The tags associated with this object.LonggetTimestamp()The time when the object was created, in milliseconds.LonggetTokenValiditySec()The validity period for access tokens in seconds.StringgetType()The name of the object's class.LonggetUpdated()The last time this object was updated.Map<String,Map<String,Map<String,Map<String,?>>>>getValidationConstraints()Returns a map of user-defined data types and their validation annotations.LonggetVersion()Returns the version number for this object.IntegergetVotes()Returns the total sum of all votes for this object.booleangrantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission)Grants a new permission for a given subject and resource.booleangrantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission, boolean allowGuestAccess)Grants a new permission for a given subject and resource.inthashCode()static Stringid(String id)Returns the correct id of this app with prefix.static Stringidentifier(String appid)Returns the identifier without the "app:" prefix.booleanisAllowedTo(String subjectid, String resourcePath, String httpMethod)Checks if a subject is allowed to call method X on resource Y.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.static booleanisRoot(String appid)Return true if the app is the root app (the first one created).booleanisRootApp()Return true if the app is the root app (the first one created).booleanisSharingIndex()Is this a sharing the search index with other apps.booleanisSharingTable()Is this a sharing the database table with other apps.Stringlink(String id2)Links an object to this one in a many-to-many relationship.booleanpermissionsContainOwnKeyword(User user, ParaObject object)Check if the permissions map contains "OWN" keyword, which restricts access to objects to their creators.voidremoveDatatype(String pluralDatatype)Removes a datatype from the types map.AppremoveSetting(String name)Removes a setting from the map.booleanremoveValidationConstraint(String type, String field, String constraintName)Removes a constraint from the map.voidresetSecret()Resets the secret key by generating a new one.booleanrevokeAllResourcePermissions(String subjectid)Revokes all permissions for a subject id.booleanrevokeResourcePermission(String subjectid, String resourcePath)Revokes a permission for given subject.voidsetActive(Boolean active)Sets the active flag.voidsetAppid(String appid)Sets a new app name.voidsetCached(Boolean cached)Sets the "isCached" flag.voidsetCreatorid(String creatorid)Sets a new creator id.voidsetDatatypes(Map<String,String> datatypes)Sets the data types for this app.voidsetDeleteOn(Long deleteOn)Sets the time for deletion.voidsetId(String id)Sets a new id.voidsetIndexed(Boolean indexed)Sets the "isIndexed" flag.voidsetName(String name)Sets a new name.voidsetParentid(String parentid)Sets a new parent id.voidsetReadOnly(Boolean readOnly)Sets read-only mode.voidsetResourcePermissions(Map<String,Map<String,List<String>>> resourcePermissions)Sets the permissions map.voidsetSecret(String secret)Sets the secret key.voidsetSettings(Map<String,Object> settings)Overwrites the settings map.voidsetSharingIndex(boolean sharingIndex)Sets the sharingIndex flag.voidsetSharingTable(boolean sharingTable)Sets the sharingTable flag.voidsetStored(Boolean stored)Sets the "isStored" flag.voidsetTags(List<String> tags)Merges the given tags with existing tags.voidsetTimestamp(Long timestamp)Sets the timestamp.voidsetTokenValiditySec(Long tokenValiditySec)Sets the access token validity period in seconds.voidsetType(String type)Sets a new object type.voidsetUpdated(Long updated)Sets the last updated timestamp.voidsetValidationConstraints(Map<String,Map<String,Map<String,Map<String,?>>>> validationConstraints)Sets the validation constraints map.voidsetVersion(Long version)Sets the version of this object.voidsetVotes(Integer votes)Sets the total votes for this object.StringtoString()voidunlink(String type, String id2)Unlinks an object from this one.voidunlinkAll()Unlinks all objects that are linked to this one.voidupdate()Updates the object permanently.booleanvoteDown(String userid)Downvotes the object.booleanvoteUp(String userid)Upvotes the object.
-
-
-
Field Detail
-
APP_ROLE
public static final String APP_ROLE
"ROLE_APP".- See Also:
- Constant Field Values
-
ALLOW_ALL
public static final String ALLOW_ALL
"*".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
App
public App()
No-args constructor.
-
App
public App(String id)
Default constructor.- Parameters:
id- the name of the app
-
-
Method Detail
-
id
public static final String id(String id)
Returns the correct id of this app with prefix.- Parameters:
id- an id like "myapp"- Returns:
- the full id, e.g. "app:myapp"
-
identifier
public static final String identifier(String appid)
Returns the identifier without the "app:" prefix.- Parameters:
appid- app id- Returns:
- just the name of the app
-
setId
public final void setId(String id)
Description copied from interface:ParaObjectSets a new id. Must not be null or empty.- Specified by:
setIdin interfaceParaObject- Parameters:
id- the new id
-
addSetting
public App addSetting(String name, Object value)
Adds a new setting to the map.- Parameters:
name- a keyvalue- a value- Returns:
- this
-
addAllSettings
public App addAllSettings(Map<String,Object> settings)
Adds all settings to map of app settings and invokes allAppSettingAddedListeners.- Parameters:
settings- a map settings to add- Returns:
- this
-
getSetting
public Object getSetting(String name)
Returns the value of a setting for a given key.- Parameters:
name- the key- Returns:
- the value
-
removeSetting
public App removeSetting(String name)
Removes a setting from the map.- Parameters:
name- the key- Returns:
- this
-
clearSettings
public App clearSettings()
Clears all app settings and invokes eachAppSettingRemovedListeners.- Returns:
- this
-
getSettings
public Map<String,Object> getSettings()
A map of all settings (key/values).- Returns:
- a map
-
setSettings
public void setSettings(Map<String,Object> settings)
Overwrites the settings map.- Parameters:
settings- a new map
-
getValidationConstraints
public Map<String,Map<String,Map<String,Map<String,?>>>> getValidationConstraints()
Returns a map of user-defined data types and their validation annotations.- Returns:
- the constraints map
-
setValidationConstraints
public void setValidationConstraints(Map<String,Map<String,Map<String,Map<String,?>>>> validationConstraints)
Sets the validation constraints map.- Parameters:
validationConstraints- the constraints map
-
getResourcePermissions
public Map<String,Map<String,List<String>>> getResourcePermissions()
Returns a map of resource permissions.- Returns:
- the permissions map
-
setResourcePermissions
public void setResourcePermissions(Map<String,Map<String,List<String>>> resourcePermissions)
Sets the permissions map.- Parameters:
resourcePermissions- permissions map
-
getAppIdentifier
public String getAppIdentifier()
The App identifier (the id but without the prefixapp:). The identifier may start with a whitespace character e.g. " myapp". This indicates that the app is sharing a table with other apps. This is disabled by default unlesspara.prepend_shared_appids_with_space = true- Returns:
- the identifier (appid)
-
getActive
public Boolean getActive()
Returns true if this application is active (enabled).- Returns:
- true if active
-
setActive
public void setActive(Boolean active)
Sets the active flag. When an app is disabled (active = false) it cannot be accessed through the API.- Parameters:
active- true if active
-
getDeleteOn
public Long getDeleteOn()
The timestamp for when this app must be deleted.- Returns:
- a timestamp
-
setDeleteOn
public void setDeleteOn(Long deleteOn)
Sets the time for deletion.- Parameters:
deleteOn- a timestamp
-
getTokenValiditySec
public Long getTokenValiditySec()
The validity period for access tokens in seconds. This setting is for current app only. Always returns a default value if local setting is null.- Returns:
- period in seconds
-
setTokenValiditySec
public void setTokenValiditySec(Long tokenValiditySec)
Sets the access token validity period in seconds.- Parameters:
tokenValiditySec- seconds
-
getSecret
public String getSecret()
Returns the app's secret key.- Returns:
- the secret key
-
setSecret
public void setSecret(String secret)
Sets the secret key.- Parameters:
secret- a secret key
-
getReadOnly
public Boolean getReadOnly()
Gets read-only mode.- Returns:
- true if app is in read-only mode
-
setReadOnly
public void setReadOnly(Boolean readOnly)
Sets read-only mode.- Parameters:
readOnly- true if app is in read-only mode
-
getDatatypes
public Map<String,String> getDatatypes()
Returns a set of custom data types for this app. An app can have many custom types which describe its domain.- Returns:
- a map of type names (plural form to singular)
-
setDatatypes
public void setDatatypes(Map<String,String> datatypes)
Sets the data types for this app.- Parameters:
datatypes- a map of type names (plural form to singular)
-
isSharingIndex
public boolean isSharingIndex()
Is this a sharing the search index with other apps.- Returns:
- true if it does
-
setSharingIndex
public void setSharingIndex(boolean sharingIndex)
Sets the sharingIndex flag.- Parameters:
sharingIndex- false means this app should have its own dedicated index
-
isSharingTable
public boolean isSharingTable()
Is this a sharing the database table with other apps.- Returns:
- true if it does
-
setSharingTable
public void setSharingTable(boolean sharingTable)
Sets the sharingTable flag.- Parameters:
sharingTable- false means this app should have its own dedicated table
-
isRootApp
public boolean isRootApp()
Return true if the app is the root app (the first one created).- Returns:
- true if root
-
isRoot
public static boolean isRoot(String appid)
Return true if the app is the root app (the first one created).- Parameters:
appid- an app identifier- Returns:
- true if root
-
getAllValidationConstraints
public Map<String,Map<String,Map<String,Map<String,?>>>> getAllValidationConstraints(String... types)
Returns all validation constraints for a list of types.- Parameters:
types- a list of valid Para data types- Returns:
- a map of validation constraints for given types
-
addValidationConstraint
public boolean addValidationConstraint(String type, String field, Constraint c)
Adds a new constraint to the list of constraints for a given field and type.- Parameters:
type- the typefield- the fieldc- the constraint- Returns:
- true if successful
-
removeValidationConstraint
public boolean removeValidationConstraint(String type, String field, String constraintName)
Removes a constraint from the map.- Parameters:
type- the typefield- the fieldconstraintName- the constraint name- Returns:
- true if successful
-
getAllResourcePermissions
public Map<String,Map<String,List<String>>> getAllResourcePermissions(String... subjectids)
Returns all resource permission for a list of subjects ids.- Parameters:
subjectids- subject ids (user ids)- Returns:
- a map of all resource permissions per subject
-
grantResourcePermission
public boolean grantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission)
Grants a new permission for a given subject and resource.- Parameters:
subjectid- the subject to give permissions toresourcePath- the resource name/typepermission- the set or HTTP methods allowed- Returns:
- true if successful
-
grantResourcePermission
public boolean grantResourcePermission(String subjectid, String resourcePath, EnumSet<App.AllowedMethods> permission, boolean allowGuestAccess)
Grants a new permission for a given subject and resource.- Parameters:
subjectid- the subject to give permissions toresourcePath- the resource name/typepermission- the set or HTTP methods allowedallowGuestAccess- if true - all unauthenticated requests will go through, 'false' by default.- Returns:
- true if successful
-
revokeResourcePermission
public boolean revokeResourcePermission(String subjectid, String resourcePath)
Revokes a permission for given subject.- Parameters:
subjectid- subject idresourcePath- resource path or object type- Returns:
- true if successful
-
revokeAllResourcePermissions
public boolean revokeAllResourcePermissions(String subjectid)
Revokes all permissions for a subject id.- Parameters:
subjectid- subject id- Returns:
- true if successful
-
isAllowedTo
public boolean isAllowedTo(String subjectid, String resourcePath, String httpMethod)
Checks if a subject is allowed to call method X on resource Y.- Parameters:
subjectid- subject idresourcePath- resource path or object typehttpMethod- HTTP method name- Returns:
- true if allowed
-
permissionsContainOwnKeyword
public boolean permissionsContainOwnKeyword(User user, ParaObject object)
Check if the permissions map contains "OWN" keyword, which restricts access to objects to their creators.- Parameters:
user- user in contextobject- some object- Returns:
- true if app contains permission for this resource and it is marked with "OWN"
-
addDatatype
public void addDatatype(String pluralDatatype, String datatype)
Adds a user-defined data type to the types map.- Parameters:
pluralDatatype- the plural form of the typedatatype- a datatype, must not be null or empty
-
addDatatypes
public boolean addDatatypes(ParaObject... objects)
Adds unknown types to this app's list of data types. Called on create().- Parameters:
objects- a list of new objects- Returns:
- true if a new data type was added to the list
-
removeDatatype
public void removeDatatype(String pluralDatatype)
Removes a datatype from the types map.- Parameters:
pluralDatatype- a datatype, must not be null or empty
-
resetSecret
public void resetSecret()
Resets the secret key by generating a new one.
-
getCredentials
public Map<String,String> getCredentials()
Returns the map containing the app's access key and secret key.- Returns:
- a map of API keys (never null)
-
addAppCreatedListener
public static void addAppCreatedListener(AppCreatedListener listener)
Registers a new create listener.- Parameters:
listener- the listener
-
addAppDeletedListener
public static void addAppDeletedListener(AppDeletedListener listener)
Registers a new delete listener.- Parameters:
listener- the listener
-
addAppSettingAddedListener
public static void addAppSettingAddedListener(AppSettingAddedListener listener)
Registers a new app setting added listener.- Parameters:
listener- the listener
-
addAppSettingRemovedListener
public static void addAppSettingRemovedListener(AppSettingRemovedListener listener)
Registers a new app setting removed listener.- Parameters:
listener- the listener
-
create
public String create()
Description copied from interface:ParaObjectStores this object in the data store.- Specified by:
createin interfaceParaObject- Returns:
- the id of the object (a new id if object is new)
- See Also:
Stored,DAO.create(com.erudika.para.core.ParaObject)
-
delete
public void delete()
Description copied from interface:ParaObjectDeletes the object permanently by removing it from the data store.- Specified by:
deletein interfaceParaObject- See Also:
DAO.delete(com.erudika.para.core.ParaObject)
-
getId
public final String getId()
Description copied from interface:ParaObjectThe id of an object. Usually an autogenerated unique string of numbers.- Specified by:
getIdin interfaceParaObject- Returns:
- the id
-
getType
public final String getType()
Description copied from interface:ParaObjectThe name of the object's class. This is equivalent toClass.getSimpleName().toLowerCase()- Specified by:
getTypein interfaceParaObject- Returns:
- the simple name of the class
-
setType
public final void setType(String type)
Description copied from interface:ParaObjectSets a new object type. Must not be null or empty.- Specified by:
setTypein interfaceParaObject- Parameters:
type- a new type
-
getAppid
public String getAppid()
Description copied from interface:ParaObjectThe application name. Added to support multiple separate apps. Every object must belong to an app.- Specified by:
getAppidin interfaceParaObject- Returns:
- the app id (name). default: para
-
setAppid
public void setAppid(String appid)
Description copied from interface:ParaObjectSets a new app name. Must not be null or empty.- Specified by:
setAppidin interfaceParaObject- Parameters:
appid- the new app id (name)
-
getObjectURI
public String getObjectURI()
Description copied from interface:ParaObjectThe URI of this object. For example: /users/123- Specified by:
getObjectURIin interfaceParaObject- Returns:
- the URI
- See Also:
Utils.getObjectURI(com.erudika.para.core.ParaObject, boolean, boolean)
-
getTags
public List<String> getTags()
Description copied from interface:ParaObjectThe tags associated with this object. Tags must not be null or empty.- Specified by:
getTagsin interfaceParaObject- Returns:
- a set of tags, or an empty set
- See Also:
Tag
-
setTags
public void setTags(List<String> tags)
Description copied from interface:ParaObjectMerges the given tags with existing tags.- Specified by:
setTagsin interfaceParaObject- Parameters:
tags- the additional tags, or clears all tags if set to null
-
getStored
public Boolean getStored()
Description copied from interface:ParaObjectBoolean flag which controls whether this object is stored in the database or not. Default is true.- Specified by:
getStoredin interfaceParaObject- Returns:
- true if this object is stored in DB.
-
setStored
public void setStored(Boolean stored)
Description copied from interface:ParaObjectSets the "isStored" flag.- Specified by:
setStoredin interfaceParaObject- Parameters:
stored- when set to true, object is stored in DB.
-
getIndexed
public Boolean getIndexed()
Description copied from interface:ParaObjectBoolean flag which controls whether this object is indexed by the search engine. Default is true.- Specified by:
getIndexedin interfaceParaObject- Returns:
- true if this object is indexed
-
setIndexed
public void setIndexed(Boolean indexed)
Description copied from interface:ParaObjectSets the "isIndexed" flag.- Specified by:
setIndexedin interfaceParaObject- Parameters:
indexed- when set to true, object is indexed.
-
getCached
public Boolean getCached()
Description copied from interface:ParaObjectBoolean flag which controls whether this object is cached. Default is true.- Specified by:
getCachedin interfaceParaObject- Returns:
- true if this object is cached on update() and create().
-
setCached
public void setCached(Boolean cached)
Description copied from interface:ParaObjectSets the "isCached" flag.- Specified by:
setCachedin interfaceParaObject- Parameters:
cached- when set to true, object is cached.
-
getTimestamp
public Long getTimestamp()
Description copied from interface:ParaObjectThe time when the object was created, in milliseconds.- Specified by:
getTimestampin interfaceParaObject- Returns:
- the timestamp of creation
-
setTimestamp
public void setTimestamp(Long timestamp)
Description copied from interface:ParaObjectSets the timestamp.- Specified by:
setTimestampin interfaceParaObject- Parameters:
timestamp- a new timestamp in milliseconds.
-
getCreatorid
public String getCreatorid()
Description copied from interface:ParaObjectThe id of the user who created this. Should point to aUserid.- Specified by:
getCreatoridin interfaceParaObject- Returns:
- the id or null
-
setCreatorid
public void setCreatorid(String creatorid)
Description copied from interface:ParaObjectSets a new creator id. Must not be null or empty.- Specified by:
setCreatoridin interfaceParaObject- Parameters:
creatorid- a new id
-
getName
public final String getName()
Description copied from interface:ParaObjectThe name of the object. Can be anything.- Specified by:
getNamein interfaceParaObject- Returns:
- the name. default: [type id]
-
setName
public final void setName(String name)
Description copied from interface:ParaObjectSets a new name. Must not be null or empty.- Specified by:
setNamein interfaceParaObject- Parameters:
name- the new name
-
getPlural
public String getPlural()
Description copied from interface:ParaObjectThe plural name of the object. For example: user - users- Specified by:
getPluralin interfaceParaObject- Returns:
- the plural name
-
getParentid
public String getParentid()
Description copied from interface:ParaObjectThe id of the parent object.- Specified by:
getParentidin interfaceParaObject- Returns:
- the id of the parent or null
-
setParentid
public void setParentid(String parentid)
Description copied from interface:ParaObjectSets a new parent id. Must not be null or empty.- Specified by:
setParentidin interfaceParaObject- Parameters:
parentid- a new id
-
getUpdated
public Long getUpdated()
Description copied from interface:ParaObjectThe last time this object was updated. Timestamp in ms.- Specified by:
getUpdatedin interfaceParaObject- Returns:
- timestamp in milliseconds
-
setUpdated
public void setUpdated(Long updated)
Description copied from interface:ParaObjectSets the last updated timestamp.- Specified by:
setUpdatedin interfaceParaObject- Parameters:
updated- a new timestamp
-
update
public void update()
Description copied from interface:ParaObjectUpdates the object permanently. Changes toLockedfields are ignored.- Specified by:
updatein interfaceParaObject- See Also:
Locked,DAO.update(com.erudika.para.core.ParaObject)
-
exists
public boolean exists()
Description copied from interface:ParaObjectChecks if an object is stored in the data store.- Specified by:
existsin interfaceParaObject- Returns:
- true if the object is persisted to the data store.
- See Also:
DAO.read(java.lang.String)
-
voteUp
public boolean voteUp(String userid)
Description copied from interface:VotableUpvotes the object.
-
voteDown
public boolean voteDown(String userid)
Description copied from interface:VotableDownvotes the object.
-
getVotes
public Integer getVotes()
Description copied from interface:VotableReturns the total sum of all votes for this object. For example: (+6) + (-4) = 2
-
setVotes
public void setVotes(Integer votes)
Description copied from interface:VotableSets the total votes for this object.
-
getVersion
public Long getVersion()
Description copied from interface:ParaObjectReturns the version number for this object. Used primarily for optimistic locking.- Specified by:
getVersionin interfaceParaObject- Returns:
- a positive number,
0if unused or-1, indicating a failed update.
-
setVersion
public void setVersion(Long version)
Description copied from interface:ParaObjectSets the version of this object. This value should come from the database.- Specified by:
setVersionin interfaceParaObject- Parameters:
version- a positive number, different than the current value of the version field
-
countLinks
public Long countLinks(String type2)
Description copied from interface:LinkableCount the total number of links between this object and another type of object.- Specified by:
countLinksin interfaceLinkable- Parameters:
type2- the other type of object- Returns:
- the number of links
-
getLinks
public List<Linker> getLinks(String type2, Pager... pager)
Description copied from interface:LinkableReturns all links between this type object and another type of object.
-
getLinkedObjects
public <P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
Description copied from interface:LinkableSimilar toLinkable.getChildren(java.lang.String, com.erudika.para.core.utils.Pager...)but for many-to-many relationships.- Specified by:
getLinkedObjectsin interfaceLinkable- Type Parameters:
P- type of linked objects- Parameters:
type- type of linked objects to look forpager- aPager- Returns:
- a list of linked objects
-
findLinkedObjects
public <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager)
Description copied from interface:LinkableSimilar toLinkable.findChildren(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.- Specified by:
findLinkedObjectsin interfaceLinkable- Type Parameters:
P- type of linked objects- Parameters:
type- type of linked objects to look forfield- the name of the field to target (within a nested field "nstd")query- a query stringpager- aPager- Returns:
- a list of linked objects matching the search query
-
isLinked
public boolean isLinked(String type2, String id2)
Description copied from interface:LinkableChecks if this object is linked to another.
-
isLinked
public boolean isLinked(ParaObject toObj)
Description copied from interface:LinkableChecks if a given object is linked to this one.
-
link
public String link(String id2)
Description copied from interface:LinkableLinks 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.
-
unlink
public void unlink(String type, String id2)
Description copied from interface:LinkableUnlinks an object from this one. Only a link is deleted. Objects are left untouched.
-
unlinkAll
public void unlinkAll()
Description copied from interface:LinkableUnlinks all objects that are linked to this one. Deletes allLinkerobjects. Only the links are deleted. Objects are left untouched.
-
countChildren
public Long countChildren(String type)
Description copied from interface:LinkableCount the total number of child objects for this object.- Specified by:
countChildrenin interfaceLinkable- Parameters:
type- the other type of object- Returns:
- the number of links
-
getChildren
public <P extends ParaObject> List<P> getChildren(String type, Pager... pager)
Description copied from interface:LinkableReturns all child objects linked to this object.- Specified by:
getChildrenin interfaceLinkable- 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
-
getChildren
public <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
Description copied from interface:LinkableReturns all child objects linked to this object.- Specified by:
getChildrenin interfaceLinkable- 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
-
findChildren
public <P extends ParaObject> List<P> findChildren(String type, String query, Pager... pager)
Description copied from interface:LinkableSearch through all child objects. Only searches child objects directly connected to this parent via theparentidfield.- Specified by:
findChildrenin interfaceLinkable- Type Parameters:
P- the type of children- Parameters:
type- the type of children to look forquery- a query stringpager- aPager- Returns:
- a list of
ParaObjectin a one-to-many relationship with this object
-
deleteChildren
public void deleteChildren(String type)
Description copied from interface:LinkableDeletes all child objects permanently.- Specified by:
deleteChildrenin interfaceLinkable- Parameters:
type- the children's type.
-
-