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
ugcFactoryFields inherited from class org.craftercms.commons.mongo.AbstractJongoRepository
clazz, collectionName, gridfs, jongo, queries -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountAllFlagged(String context, int start, int pageSize, List sortOrder) longcountByTargetId(String contextId, String threadId, int levels) longcountChildrenOf(String contextId, String ugcId) longcountFindByModerationStatus(ModerationStatus status, String targetId, String contextId) voiddeleteAttribute(String ugcId, String contextId, String[] attributesName) Deletes an attribute Has to be full "dot notation" modevoidDeletes 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.voidsetAttributes(String ugcId, String contextId, Map attributes) Adds the given attributes to the ugc.voidsetTenantConfigurationServiceImpl(TenantConfigurationService tenantConfigurationService) toUgcList(List<BaseTreeUgc> as) Methods inherited from class org.craftercms.social.repositories.SocialJongoRepository
init, setUgcFactoryMethods 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, validateObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:UGCRepositoryFinds all the ugc and all its children.- Specified by:
findChildrenOfin 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:UGCRepositoryFinds all UGC's of a contextId that belongs to the given target-id.- Specified by:
findByTargetIdin 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:UGCRepositoryDeletes an attribute Has to be full "dot notation" mode- Specified by:
deleteAttributein 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:UGCRepositoryFinds a ugc with the given id and contextId.- Specified by:
findUGCin 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:UGCRepositoryAdds the given attributes to the ugc.- Specified by:
setAttributesin 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:UGCRepositoryDeletes the given UGC and All its children.- Specified by:
deleteUgcin 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:UGCRepositoryFinds Ugcs by the given user query. It assumes that the query has been sanitized for any security concerns- Specified by:
findByUserQueryin 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:UGCRepositoryFinds all the children of a given ugc.- Specified by:
findChildrenin 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.MongoDataExceptionUGCNotFound
-
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:
findByTargetIdin 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:
countByTargetIdin 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:
countChildrenOfin 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:
findByModerationStatusin 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:
countFindByModerationStatusin interfaceUGCRepository<T extends UGC>- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findAllFlagged
- Specified by:
findAllFlaggedin interfaceUGCRepository<T extends UGC>
-
countAllFlagged
- Specified by:
countAllFlaggedin interfaceUGCRepository<T extends UGC>
-
toUgcList
-
setTenantConfigurationServiceImpl
public void setTenantConfigurationServiceImpl(TenantConfigurationService tenantConfigurationService)
-