Class UGCRepositoryImpl<T extends UGC>
java.lang.Object
org.craftercms.commons.mongo.AbstractJongoRepository
org.craftercms.social.repositories.SocialJongoRepository
org.craftercms.social.repositories.ugc.impl.UGCRepositoryImpl<T>
- All Implemented Interfaces:
org.craftercms.commons.mongo.CrudRepository
,UGCRepository
public class UGCRepositoryImpl<T extends UGC>
extends SocialJongoRepository
implements UGCRepository
-
Field Summary
Fields inherited from class org.craftercms.social.repositories.SocialJongoRepository
ugcFactory
Fields inherited from class org.craftercms.commons.mongo.AbstractJongoRepository
clazz, collectionName, gridfs, jongo, queries
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
countAllFlagged
(String context, int start, int pageSize, List sortOrder) long
countByTargetId
(String contextId, String threadId, int levels) long
countChildrenOf
(String contextId, String ugcId) long
countFindByModerationStatus
(ModerationStatus status, String targetId, String contextId) void
deleteAttribute
(String ugcId, String contextId, String[] attributesName) Deletes an attribute Has to be full "dot notation" modevoid
Deletes the given UGC and All its children.findAll()
findAllFlagged
(String context, int start, int pageSize, List sortOrder) findByModerationStatus
(ModerationStatus status, String targetId, String contextId, int start, int limit, List sortOrder) findByTargetId
(String targetId, String contextId) Finds all UGC's of a contextId that belongs to the given target-id.findByTargetId
(String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel) findByUserQuery
(String contextId, String query, String sort, int start, int limit) Finds Ugcs by the given user query.findChildren
(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel) Finds all the children of a given ugc.findChildrenOf
(String ugcId, int childrenCount, String contextId) Finds all the ugc and all its children.Finds a ugc with the given id and contextId.void
setAttributes
(String ugcId, String contextId, Map attributes) Adds the given attributes to the ugc.void
setTenantConfigurationServiceImpl
(TenantConfigurationService tenantConfigurationService) toUgcList
(List<BaseTreeUgc> as) Methods inherited from class org.craftercms.social.repositories.SocialJongoRepository
init, setUgcFactory
Methods inherited from class org.craftercms.commons.mongo.AbstractJongoRepository
count, count, count, createSortQuery, deleteFile, deleteFile, find, find, findByStringId, findOne, findOne, getCollection, getFileInfo, getFileInfo, getQueryFor, insert, insert, listFilesByName, readFile, readFile, remove, remove, removeById, removeByStringId, returnList, returnSimple, save, save, saveFile, saveFile, setJongo, setQueries, update, update, update, update, updateFile, updateFile, updateFile, validateObject, validateObject
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.craftercms.commons.mongo.CrudRepository
count, count, count, deleteFile, deleteFile, find, find, findByStringId, findOne, findOne, getFileInfo, getFileInfo, insert, insert, listFilesByName, readFile, readFile, remove, remove, removeById, removeByStringId, save, save, saveFile, saveFile, update, update, update, update, updateFile, updateFile, updateFile
-
Constructor Details
-
UGCRepositoryImpl
Creates a instance of a Jongo Repository.- Throws:
Exception
-
-
Method Details
-
findAll
-
findChildrenOf
public List<T> findChildrenOf(String ugcId, int childrenCount, String contextId) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Finds all the ugc and all its children.- Specified by:
findChildrenOf
in interfaceUGCRepository<T extends UGC>
- Parameters:
ugcId
- Id of the ugc to find and its children.childrenCount
- How many Children Levels.contextId
- Context ID of the UGCs.- Returns:
- List of the ugc and all its tree. (first element is the "ROOT" UGC) this is ordered by ancestors size and created date (descending).
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findById
-
findByTargetId
public Iterable<T> findByTargetId(String targetId, String contextId) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Finds all UGC's of a contextId that belongs to the given target-id.- Specified by:
findByTargetId
in interfaceUGCRepository<T extends UGC>
- Parameters:
targetId
- Target Id which the ugs belongs to.contextId
- Context ID of the UGCs.- Returns:
- A Iterable of UGC that belong to the contextId and are associated to the target.
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
deleteAttribute
public void deleteAttribute(String ugcId, String contextId, String[] attributesName) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Deletes an attribute Has to be full "dot notation" mode- Specified by:
deleteAttribute
in interfaceUGCRepository<T extends UGC>
- Parameters:
ugcId
- Id of the ugc to remove the attribute.contextId
- Context ID of the UGCs.attributesName
- Attributes name(Full dot notation) to unset/delete- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findUGC
public T findUGC(String contextId, String ugcId) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Finds a ugc with the given id and contextId.- Specified by:
findUGC
in interfaceUGCRepository<T extends UGC>
- Parameters:
contextId
- Context ID of the UGCs.ugcId
- Id of the ugc- Returns:
- The Found
UGC
. - Throws:
org.craftercms.commons.mongo.MongoDataException
-
setAttributes
public void setAttributes(String ugcId, String contextId, Map attributes) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Adds the given attributes to the ugc.- Specified by:
setAttributes
in interfaceUGCRepository<T extends UGC>
- Parameters:
ugcId
- Id of the ugc to add the attributes.contextId
- Context ID of the UGCs.attributes
- Attributes to add/removeWatcher to the UGC.- Throws:
org.craftercms.commons.mongo.MongoDataException
-
deleteUgc
public void deleteUgc(String ugcId, String contextId) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Deletes the given UGC and All its children.- Specified by:
deleteUgc
in interfaceUGCRepository<T extends UGC>
- Parameters:
ugcId
- Id of the ugccontextId
- Context ID of the UGCs.- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByUserQuery
public Iterable<T> findByUserQuery(String contextId, String query, String sort, int start, int limit) throws org.craftercms.commons.mongo.MongoDataException Description copied from interface:UGCRepository
Finds Ugcs by the given user query. It assumes that the query has been sanitized for any security concerns- Specified by:
findByUserQuery
in interfaceUGCRepository<T extends UGC>
- Parameters:
contextId
- Context ID of the UGCs.query
- Query to execute.sort
- Sort query If null or empty it will be ignoredstart
- Where to startlimit
- How many results- Returns:
- A list of the Ugc that match the given query in the given order, empty if nothing is found.
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findChildren
public Iterable<T> findChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel) throws org.craftercms.commons.mongo.MongoDataException, UGCNotFound Description copied from interface:UGCRepository
Finds all the children of a given ugc.- Specified by:
findChildren
in interfaceUGCRepository<T extends UGC>
- Parameters:
ugcId
- Id of the ugc to find and its children.targetId
- Target Id which the ugs belongs to.contextId
- Context ID of the UGCs.start
- where to start.limit
- How many resultsupToLevel
- how many sub-children levels to lookup.- Returns:
- An iterable with the results.empty if nothing is found.
- Throws:
org.craftercms.commons.mongo.MongoDataException
UGCNotFound
-
findByTargetId
public Iterable<T> findByTargetId(String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel) throws org.craftercms.commons.mongo.MongoDataException - Specified by:
findByTargetId
in interfaceUGCRepository<T extends UGC>
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
countByTargetId
public long countByTargetId(String contextId, String threadId, int levels) throws org.craftercms.commons.mongo.MongoDataException - Specified by:
countByTargetId
in interfaceUGCRepository<T extends UGC>
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
countChildrenOf
public long countChildrenOf(String contextId, String ugcId) throws org.craftercms.commons.mongo.MongoDataException - Specified by:
countChildrenOf
in interfaceUGCRepository<T extends UGC>
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByModerationStatus
public Iterable<T> findByModerationStatus(ModerationStatus status, String targetId, String contextId, int start, int limit, List sortOrder) throws org.craftercms.commons.mongo.MongoDataException - Specified by:
findByModerationStatus
in interfaceUGCRepository<T extends UGC>
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
countFindByModerationStatus
public long countFindByModerationStatus(ModerationStatus status, String targetId, String contextId) throws org.craftercms.commons.mongo.MongoDataException - Specified by:
countFindByModerationStatus
in interfaceUGCRepository<T extends UGC>
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findAllFlagged
- Specified by:
findAllFlagged
in interfaceUGCRepository<T extends UGC>
-
countAllFlagged
- Specified by:
countAllFlagged
in interfaceUGCRepository<T extends UGC>
-
toUgcList
-
setTenantConfigurationServiceImpl
public void setTenantConfigurationServiceImpl(TenantConfigurationService tenantConfigurationService)
-