Interface ItemDAO


public interface ItemDAO
  • Field Details

    • SORT_FIELD_MAP

      static final Map<String,String> SORT_FIELD_MAP
    • DETAILED_ITEM_SORT_FIELD_MAP

      static final Map<String,String> DETAILED_ITEM_SORT_FIELD_MAP
  • Method Details

    • getChildrenByPathTotal

      int getChildrenByPathTotal(@Param("siteId") Long siteId, @Param("path") String path, @Param("localeCode") String localeCode, @Param("keyword") String keyword, @Param("systemTypes") List<String> systemTypes, @Param("excludeSystemTypes") List<String> excludeSystemTypes, @Param("excludes") List<String> excludes)
      Get total number of children for given path
      Parameters:
      siteId - site identifier
      path - path to get children for
      localeCode - local code
      keyword - filter by keyword
      systemTypes - filter by type
      excludeSystemTypes - system types to exclude
      excludes - exclude items by path
      Returns:
      total number of children
    • getChildrenByPath

      List<Item> getChildrenByPath(@Param("siteId") Long siteId, @Param("path") String path, @Param("systemTypeFolder") String systemTypeFolder, @Param("localeCode") String localeCode, @Param("keyword") String keyword, @Param("systemTypes") List<String> systemTypes, @Param("excludeSystemTypes") List<String> excludeSystemTypes, @Param("excludes") List<String> excludes, @Param("sortStrategy") String sortStrategy, @Param("order") String order, @Param("offset") int offset, @Param("limit") int limit)
      Get children for given path from database
      Parameters:
      siteId - site identifier
      path - path to get children for
      systemTypeFolder - system type value for folder
      localeCode - locale code
      keyword - filter by keyword
      systemTypes - filter by type
      excludeSystemTypes - system types to exclude
      excludes - exclude items by path
      sortStrategy - sort strategy
      order - order of children
      offset - offset of the first record to return
      limit - number of children to return
      Returns:
      list of items (parent, level descriptor, children)
    • upsertEntry

      void upsertEntry(Item item)
      insert or update item
      Parameters:
      item - item to insert/update
    • getItemById

      DetailedItem getItemById(@Param("id") long id, @Param("siteId") String siteId, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment)
      Get item by id
      Parameters:
      id - item id
      siteId - site identifier
      systemTypeFolder - value for system type folder
      completedState - completed state
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      Returns:
      item identified by given id
    • getItemBySiteIdAndPath

      DetailedItem getItemBySiteIdAndPath(@Param("siteId") long siteId, @Param("path") String path, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment)
      Get item for given site and path
      Parameters:
      siteId - site identifier
      path - path of the item
      systemTypeFolder - value for system type folder
      completedState - completed state
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      Returns:
      item for given site and path
    • getItemBySiteIdAndPathPreferContent

      DetailedItem getItemBySiteIdAndPathPreferContent(@Param("siteId") long siteId, @Param("path") String path, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment)
      Get item with prefer content option for given site and path
      Parameters:
      siteId - site identifier
      path - path of the item
      systemTypeFolder - value for system type folder
      completedState - completed state
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      Returns:
      item for given site and path
    • updateItem

      void updateItem(Item item)
      Update item
      Parameters:
      item - item to update
    • deleteBySiteAndPath

      void deleteBySiteAndPath(@Param("siteId") long siteId, @Param("path") String path)
      Delete item
      Parameters:
      siteId - site identifier
      path - path of item to delete
    • setStatesBySiteAndPathBulk

      void setStatesBySiteAndPathBulk(@Param("siteId") long siteId, @Param("paths") List<String> paths, @Param("statesBitMap") long statesBitMap)
      Set items state
      Parameters:
      siteId - site identifier
      paths - paths of items
      statesBitMap - states bit map to be set
    • resetStatesBySiteAndPathBulk

      void resetStatesBySiteAndPathBulk(@Param("siteId") long siteId, @Param("paths") List<String> paths, @Param("statesBitMap") long statesBitMap)
      Reset items state
      Parameters:
      siteId - site identifier
      paths - paths of items
      statesBitMap - states bit map to be reset
    • updateStatesBySiteAndPathBulk

      void updateStatesBySiteAndPathBulk(@Param("siteId") long siteId, @Param("paths") Collection<String> paths, @Param("onStatesBitMap") long onStatesBitMap, @Param("offStatesBitMap") long offStatesBitMap)
      Update states to flip on list off states and flip off another list of states for items
      Parameters:
      siteId - site identifier
      paths - list of paths to update states for
      onStatesBitMap - state bitmap to flip on
      offStatesBitMap - state bitmap to flip off
    • updateStatesForSite

      void updateStatesForSite(@Param("siteId") long siteId, @Param("onStatesBitMap") long onStatesBitMap, @Param("offStatesBitMap") long offStatesBitMap)
      Update states to flip on list off states and flip off another list of states for items
      Parameters:
      siteId - site identifier
      onStatesBitMap - state bitmap to flip on
      offStatesBitMap - state bitmap to flip off
    • deleteItemsForSite

      void deleteItemsForSite(@Param("siteId") long siteId)
      Delete all items for site
      Parameters:
      siteId - site id
    • deleteBySiteAndPathForFolder

      void deleteBySiteAndPathForFolder(@Param("siteId") long siteId, @Param("folderPath") String path)
      Delete items for site and folder path
      Parameters:
      siteId - site id
      path - path of the folder
    • moveItem

      void moveItem(@Param("siteId") String siteId, @Param("oldPath") String oldPath, @Param("newPath") String newPath, @Param("parentId") Long parentId, @Param("oldPreviewUrl") String oldPreviewUrl, @Param("newPreviewUrl") String newPreviewUrl, @Param("label") String label, @Param("onStatesBitMap") long onStatesBitMap, @Param("offStatesBitMap") long offStatesBitMap)
      Move item
      Parameters:
      siteId - site identifier
      oldPath - old path
      newPath - new path
      parentId - new parent ID
      oldPreviewUrl - old preview url
      newPreviewUrl - new preview url
      label - the new label
      onStatesBitMap - state bitmap to flip on
      offStatesBitMap - state bitmap to flip off
    • getItemByPath

      DetailedItem getItemByPath(@Param("siteId") Long siteId, @Param("path") String path, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment)
      Get item for given path from database
      Parameters:
      siteId - site identifier
      path - path of the item
      systemTypeFolder - value for system type folder
      completedState - completed state
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      Returns:
      item
    • getDetailedItemsByStates

      List<DetailedItem> getDetailedItemsByStates(@Param("siteId") long siteId, @Param("statesBitMap") long statesBitMap, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("systemTypes") List<String> systemTypes, @Param("sortFields") List<org.craftercms.commons.rest.parameters.SortField> sortFields, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment, @Param("offset") int offset, @Param("limit") int limit)
      Get a list of DetailedItem for given site and filters (system_types, states)
      Parameters:
      siteId - site identifier
      statesBitMap - states bit map to filter by
      systemTypeFolder - value for system type folder
      completedState - completed state
      systemTypes - system types to filter by
      sortFields - sort fields
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      offset - offset for the first record in result set
      limit - number of records to return
      Returns:
      list of filtered DetailedItems
    • getItemByPathPreferContent

      DetailedItem getItemByPathPreferContent(@Param("siteId") Long siteId, @Param("path") String path, @Param("systemTypeFolder") String systemTypeFolder, @Param("completedState") String completedState, @Param("stagingEnvironment") String stagingEnvironment, @Param("liveEnvironment") String liveEnvironment)
      Get item with prefer content option for given path from database
      Parameters:
      siteId - site identifier
      path - path of the item
      systemTypeFolder - value for system type folder
      completedState - completed state
      stagingEnvironment - staging environment
      liveEnvironment - live environment
      Returns:
      item
    • getSandboxItemsByPath

      List<Item> getSandboxItemsByPath(@Param("siteId") Long siteId, @Param("paths") List<String> paths, @Param("systemTypeFolder") String systemTypeFolder, @Param("preferContent") boolean preferContent)
      Get sandbox items for given paths
      Parameters:
      siteId - site identifier
      paths - paths to get items for
      systemTypeFolder - value for system type folder
      preferContent - indicates if pages should be returned instead of folders when available
      Returns:
      list of items
    • getSandboxItemsByIdPreferContent

      List<Item> getSandboxItemsByIdPreferContent(@Param("itemIds") List<Long> itemIds, @Param("systemTypeFolder") String systemTypeFolder, @Param("sortFields") List<org.craftercms.commons.rest.parameters.SortField> sortFields)
      Get sandbox items for given ids with prefer content option
      Parameters:
      itemIds - item ids
      systemTypeFolder - value for system type folder
      sortFields -
      Returns:
      list of items
    • getSandboxItemsById

      List<Item> getSandboxItemsById(@Param("itemIds") List<Long> itemIds, @Param("systemTypeFolder") String systemTypeFolder, @Param("sortFields") List<org.craftercms.commons.rest.parameters.SortField> sortFields)
      Get sandbox items for given ids
      Parameters:
      itemIds - item ids
      systemTypeFolder - value for system type folder
      sortFields -
      Returns:
      list of items
    • getMandatoryParentsForPublishing

      List<String> getMandatoryParentsForPublishing(@Param("siteId") String siteId, @Param("possibleParents") List<String> possibleParents, @Param("newMask") long newMask, @Param("modifiedMask") long modifiedMask)
      Get mandatory parents for publishing
      Parameters:
      siteId - site identifier
      possibleParents - possible parents
      newMask - states mask for detecting new items
      modifiedMask - states mask for detecting modified items
      Returns:
      list of mandatory parents
    • getExistingRenamedChildrenOfMandatoryParentsForPublishing

      List<String> getExistingRenamedChildrenOfMandatoryParentsForPublishing(@Param("siteId") String siteId, @Param("parents") List<String> parents, @Param("newMask") long newMask, @Param("modifiedMask") long modifiedMask)
    • countAllContentItems

      int countAllContentItems(@Param("nonContentItemTypes") List<String> nonContentItemTypes)
      Count all content items in the system
      Returns:
      number of content items in the system
    • clearPreviousPath

      void clearPreviousPath(@Param("siteId") String siteId, @Param("path") String path)
      Clear previous path of the content
      Parameters:
      siteId - site identifier
      path - path of the content
    • getInProgressItems

      List<Item> getInProgressItems(@Param("siteId") String siteId, @Param("inProgressMask") long inProgressMask)
      Get in progress items from DB
      Parameters:
      siteId - site identifier
      inProgressMask - in progress states mask
      Returns:
      list of items
    • countPreviousPaths

      int countPreviousPaths(@Param("siteId") String siteId, @Param("previousPath") String previousPath, @Param("newMask") long newMask)
      Count non-new items having previous path property set to given path
      Parameters:
      siteId - site identifier
      previousPath - path to check
      Returns:
      number of items
    • updateCommitId

      void updateCommitId(@Param("siteId") String siteId, @Param("path") String path, @Param("commitId") String commitId)
      Update commit id for item
      Parameters:
      siteId - site identifier
      path - path of the item
      commitId - commit id
    • getChangeSetForSubtree

      List<String> getChangeSetForSubtree(@Param("siteId") String siteId, @Param("path") String path, @Param("likePath") String likePath, @Param("nonContentItemTypes") List<String> nonContentItemTypes, @Param("inProgressMask") long inProgressMask)
      Get change set for subtree
      Parameters:
      siteId - site identifier
      path - path of subtree root
      likePath - like path for query
      nonContentItemTypes - non content item types
      inProgressMask - in progress state mask
      Returns:
      list of items
    • updateLastPublishedOn

      void updateLastPublishedOn(@Param("siteId") String siteId, @Param("path") String path, @Param("lastPublishedOn") ZonedDateTime lastPublishedOn)
      Update last published date for item
      Parameters:
      siteId - site identifier
      path - path of the item
      lastPublishedOn - published date
    • getContentTypeUsages

      List<Item> getContentTypeUsages(@Param("siteId") String siteId, @Param("contentType") String contentType, @Param("scriptPath") String scriptPath)
      Finds all items related to a given content-type
      Parameters:
      siteId - the id of the site
      contentType - the id of the content-type
      scriptPath - the path of the controller script
      Returns:
      the list of items
    • lockItemByPath

      void lockItemByPath(@Param("siteId") String siteId, @Param("path") String path, @Param("lockOwnerId") long lockOwnerId, @Param("lockedBitOn") long lockedBitOn, @Param("systemTypeFolder") String systemTypeFolder)
      Lock item
      Parameters:
      siteId - site identifier
      path - path of the item
      lockOwnerId - lock owner
      lockedBitOn - state bit mask with LOCKED bit on
      systemTypeFolder - value for system type folder
    • unlockItemByPath

      void unlockItemByPath(@Param("siteId") String siteId, @Param("path") String path, @Param("lockedBitOff") long lockedBitOff)
      Lock item
      Parameters:
      siteId - site identifier
      path - path of the item
      lockedBitOff - state bit mask with LOCKED bit off
    • getItemStatesTotal

      int getItemStatesTotal(@Param("siteId") String siteId, @Param("path") String path, @Param("statesBitMap") Long states, @Param("systemTypes") List<String> systemTypes)
      Get total number of item states records for given filters by path regex and states mask
      Parameters:
      siteId - site identifier
      path - path regex to filter items
      states - states mask to filter items by state
      systemTypes - system types to filter items
      Returns:
      number of records
    • getItemStates

      List<Item> getItemStates(@Param("siteId") String siteId, @Param("path") String path, @Param("statesBitMap") Long states, @Param("systemTypes") List<String> systemTypes, @Param("sortFields") List<org.craftercms.commons.rest.parameters.SortField> sortFields, @Param("offset") int offset, @Param("limit") int limit)
      Get item states for given filters by path regex and states mask
      Parameters:
      siteId - site identifier
      path - path regex to filter items
      states - states mask to filter items by state
      systemTypes - system types to filter items
      sortFields - list of sort fields
      offset - offset for the first record in result set
      limit - number of item states records to return
      Returns:
      list of sandbox items
    • updateStatesByQuery

      void updateStatesByQuery(@Param("siteId") String siteId, @Param("path") String path, @Param("statesBitMap") Long states, @Param("onStatesBitMap") long setStatesMask, @Param("offStatesBitMap") long resetStatesMask)
      Update item state by query
      Parameters:
      siteId - site identifier
      path - path regex to filter items to be updated
      states - states bitmap mask to filter items to be updated
      setStatesMask - states bitmap mask to set states on
      resetStatesMask - states bitmap mask to set states off
    • getSubtreeForDelete

      List<String> getSubtreeForDelete(@Param("siteId") String siteId, @Param("likePath") String likePath)
      Get subtree for delete
      Parameters:
      siteId - site identifier
      likePath - like path for query
      Returns:
      list of items
    • updateNewPageChildren

      void updateNewPageChildren(@Param("siteId") String siteId, @Param("path") String folderPath)
      When creating a new page in an already existing folder, we need to update the children of the folder to become the children of the page. This method will find the direct children of the given folder, and update their parent id to be the id the new page (the item with path = folderPath + /index.xml).
      Parameters:
      siteId - site identifier
      folderPath - path of the folder