Class Query
- java.lang.Object
-
- org.ametys.plugins.repository.AbstractAmetysObject
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
-
- org.ametys.plugins.repository.jcr.DefaultAmetysObject<QueryFactory>
-
- org.ametys.plugins.queriesdirectory.Query
-
- All Implemented Interfaces:
ACLAmetysObject,AmetysObject,JCRAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableACLAmetysObject,ModifiableAmetysObject,MovableAmetysObject,RemovableAmetysObject,DataAndVersionAwareAmetysObject,ModifiableDataAwareVersionableAmetysObject,VersionableAmetysObject,VersionAwareAmetysObject
public class Query extends DefaultAmetysObject<QueryFactory> implements MovableAmetysObject
Class representing a query, backed by a JCR node.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQuery.QueryProfileRights profilesstatic classQuery.TypeType of a Querystatic classQuery.VisibilityVisibility of a Query
-
Field Summary
Fields Modifier and Type Field Description static StringAUTHORProperty name for query authorstatic StringCONTENTProperty name for query contentstatic StringDESCRIPTIONProperty name for query descriptionstatic StringGROUPSProperty name for query groupsstatic StringLASTMODIFICATIONDATEProperty name for query last modification datestatic StringPROFILE_READ_ACCESSProperty name for query read accessstatic StringPROFILE_WRITE_ACCESSProperty name for query write accessstatic StringTITLEProperty name for query titlestatic StringTYPEProperty name for query typestatic StringUSERSProperty name for query usersstatic StringVISIBILITYProperty name for query visibility-
Fields inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
PROTECTED_PROPERTIES
-
-
Constructor Summary
Constructors Constructor Description Query(Node node, String parentPath, QueryFactory factory)Creates anQuery.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Node_getOrCreateNode(Node parent, String name, String type)booleancanMoveTo(AmetysObject newParent)Test if a move can be a success or if it is impossible (e.g.booleancanRead(UserIdentity user)Determines if an user has READ access to this query.booleancanWrite(UserIdentity user)Determines if an user has WRITE access to this query.UserIdentitygetAuthor()Get the author of the queryStringgetContent()Get the content of the queryStringgetDescription()Get the description of the querySet<GroupIdentity>getGrantedGroups(Query.QueryProfile profile)Get the granted groupsSet<UserIdentity>getGrantedUsers(Query.QueryProfile profile)Get the granted usersDategetLastModificationDate()Get the date of the last modification of the queryStringgetTitle()Get the title of the queryStringgetType()Get the type of the queryQuery.VisibilitygetVisibility()Get the visibility of the queryvoidmoveTo(AmetysObject newParent, boolean renameIfExist)Move the current object as a new child of the given object.voidorderBefore(AmetysObject siblingNode)Order a node before another sibling node (or as the last node)voidsetAuthor(UserIdentity author)Set the author of this query.voidsetContent(String content)Set the content of this query.voidsetDescription(String description)Set the description of this query.voidsetGrantedGroups(Query.QueryProfile profile, Set<GroupIdentity> groups)Set the granted groupsvoidsetGrantedUsers(Query.QueryProfile profile, Set<UserIdentity> users)Set the granted usersvoidsetLastModificationDate(Date lastModificationDate)Set the date of the last modification.voidsetTitle(String title)Set the title of this query.voidsetType(String type)Set the type of this query.voidsetVisibility(Query.Visibility visibility)Set the query visibility-
Methods inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, addLabel, checkpoint, copyNode, disallowInheritance, getAllLabels, getAllRevisions, getBaseNode, getBaseVersion, getLabels, getLabels, getNode, getProfilesForAnonymousAndAnyConnectedUser, getProfilesForGroups, getProfilesForUsers, getRevision, getRevisionTimestamp, getRevisionTimestamp, getUnversionedDataHolder, getVersionHistory, isInheritanceDisallowed, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers, removeLabel, restoreFromLabel, restoreFromNode, restoreFromRevision, switchToLabel, switchToRevision
-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
-
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
-
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
-
-
-
-
Field Detail
-
TITLE
public static final String TITLE
Property name for query title- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
Property name for query type- See Also:
- Constant Field Values
-
DESCRIPTION
public static final String DESCRIPTION
Property name for query description- See Also:
- Constant Field Values
-
CONTENT
public static final String CONTENT
Property name for query content- See Also:
- Constant Field Values
-
AUTHOR
public static final String AUTHOR
Property name for query author- See Also:
- Constant Field Values
-
LASTMODIFICATIONDATE
public static final String LASTMODIFICATIONDATE
Property name for query last modification date- See Also:
- Constant Field Values
-
VISIBILITY
public static final String VISIBILITY
Property name for query visibility- See Also:
- Constant Field Values
-
PROFILE_READ_ACCESS
public static final String PROFILE_READ_ACCESS
Property name for query read access- See Also:
- Constant Field Values
-
PROFILE_WRITE_ACCESS
public static final String PROFILE_WRITE_ACCESS
Property name for query write access- See Also:
- Constant Field Values
-
GROUPS
public static final String GROUPS
Property name for query groups- See Also:
- Constant Field Values
-
USERS
public static final String USERS
Property name for query users- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Query
public Query(Node node, String parentPath, QueryFactory factory)
Creates anQuery.- Parameters:
node- the node backing thisAmetysObjectparentPath- the parentPath in the Ametys hierarchyfactory- the DefaultAmetysObjectFactory which created the AmetysObject
-
-
Method Detail
-
setTitle
public void setTitle(String title)
Set the title of this query.- Parameters:
title- the description
-
setType
public void setType(String type)
Set the type of this query.- Parameters:
type- the description
-
setDescription
public void setDescription(String description)
Set the description of this query.- Parameters:
description- the description
-
setContent
public void setContent(String content)
Set the content of this query.- Parameters:
content- the content
-
setAuthor
public void setAuthor(UserIdentity author)
Set the author of this query.- Parameters:
author- the author
-
setLastModificationDate
public void setLastModificationDate(Date lastModificationDate)
Set the date of the last modification.- Parameters:
lastModificationDate- the last modification date to set.
-
setVisibility
public void setVisibility(Query.Visibility visibility)
Set the query visibility- Parameters:
visibility- the visibility
-
getDescription
public String getDescription()
Get the description of the query- Returns:
- The description
-
getContent
public String getContent()
Get the content of the query- Returns:
- The content
-
getAuthor
public UserIdentity getAuthor()
Get the author of the query- Returns:
- The author
-
getVisibility
public Query.Visibility getVisibility()
Get the visibility of the query- Returns:
- The visibility
-
getGrantedUsers
public Set<UserIdentity> getGrantedUsers(Query.QueryProfile profile)
Get the granted users- Parameters:
profile- teh query profile- Returns:
- the logins of granted users
-
getGrantedGroups
public Set<GroupIdentity> getGrantedGroups(Query.QueryProfile profile)
Get the granted groups- Parameters:
profile- the query profile- Returns:
- the granted groups
-
canRead
public boolean canRead(UserIdentity user)
Determines if an user has READ access to this query.- Parameters:
user- The user- Returns:
trueif the user has read access,falseotherwise
-
canWrite
public boolean canWrite(UserIdentity user)
Determines if an user has WRITE access to this query.- Parameters:
user- The user- Returns:
trueif the user has write access,falseotherwise
-
setGrantedUsers
public void setGrantedUsers(Query.QueryProfile profile, Set<UserIdentity> users)
Set the granted users- Parameters:
profile- the query profileusers- the granted users
-
setGrantedGroups
public void setGrantedGroups(Query.QueryProfile profile, Set<GroupIdentity> groups)
Set the granted groups- Parameters:
profile- the query profilegroups- the granted groups
-
_getOrCreateNode
private Node _getOrCreateNode(Node parent, String name, String type) throws RepositoryException
- Throws:
RepositoryException
-
getLastModificationDate
public Date getLastModificationDate()
Get the date of the last modification of the query- Returns:
- The date
-
canMoveTo
public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectTest if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveToin interfaceMovableAmetysObject- Parameters:
newParent- See moveTo.- Returns:
- true if the move operation may succeed. If false is returned and you call moveTo anyway, you may encontered a RuntimeException (such as UnsupportedOperationException)
- Throws:
AmetysRepositoryException- if an error occurs.
-
moveTo
public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException
Description copied from interface:MovableAmetysObjectMove the current object as a new child of the given object. This node will be the last child. You should call canMoveTo to know if this is a supported operation.- Specified by:
moveToin interfaceMovableAmetysObject- Parameters:
newParent- The new parent for the current object. Can not be null. Can not be a child of the current node. Must be a TraversableAmetyObject.renameIfExist- true to rename moved page if a page with same name already exist- Throws:
AmetysRepositoryException- if an error occurs.RepositoryIntegrityViolationException- if a page with the same name already exists.
-
orderBefore
public void orderBefore(AmetysObject siblingNode) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectOrder a node before another sibling node (or as the last node)- Specified by:
orderBeforein interfaceMovableAmetysObject- Parameters:
siblingNode- The node that will be the next sibling node of the current node. Must have the same parent as the current node. Can be null to set the current node as the last node.- Throws:
AmetysRepositoryException- if an error occurs.
-
-