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
  • Constructor Details

    • UGCRepositoryImpl

      public UGCRepositoryImpl() throws Exception
      Creates a instance of a Jongo Repository.
      Throws:
      Exception
  • Method Details

    • findAll

      public Iterable<UGC> findAll() throws org.craftercms.commons.mongo.MongoDataException
      Specified by:
      findAll in interface org.craftercms.commons.mongo.CrudRepository<T extends UGC>
      Overrides:
      findAll in class org.craftercms.commons.mongo.AbstractJongoRepository
      Throws:
      org.craftercms.commons.mongo.MongoDataException
    • 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 interface UGCRepository<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

      public UGC findById(String id) throws org.craftercms.commons.mongo.MongoDataException
      Specified by:
      findById in interface org.craftercms.commons.mongo.CrudRepository<T extends UGC>
      Overrides:
      findById in class org.craftercms.commons.mongo.AbstractJongoRepository
      Throws:
      org.craftercms.commons.mongo.MongoDataException
    • 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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<T extends UGC>
      Parameters:
      ugcId - Id of the ugc
      contextId - 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 interface UGCRepository<T extends UGC>
      Parameters:
      contextId - Context ID of the UGCs.
      query - Query to execute.
      sort - Sort query If null or empty it will be ignored
      start - Where to start
      limit - 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 interface UGCRepository<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 results
      upToLevel - 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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<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 interface UGCRepository<T extends UGC>
      Throws:
      org.craftercms.commons.mongo.MongoDataException
    • findAllFlagged

      public Iterable<T> findAllFlagged(String context, int start, int pageSize, List sortOrder)
      Specified by:
      findAllFlagged in interface UGCRepository<T extends UGC>
    • countAllFlagged

      public long countAllFlagged(String context, int start, int pageSize, List sortOrder)
      Specified by:
      countAllFlagged in interface UGCRepository<T extends UGC>
    • toUgcList

      protected List<T> toUgcList(List<BaseTreeUgc> as)
    • setTenantConfigurationServiceImpl

      public void setTenantConfigurationServiceImpl(TenantConfigurationService tenantConfigurationService)