Class AbstractQNameDAOImpl

  • All Implemented Interfaces:
    QNameDAO
    Direct Known Subclasses:
    QNameDAOImpl

    public abstract class AbstractQNameDAOImpl
    extends Object
    implements QNameDAO
    Abstract implementation of the QName and Namespace DAO interface.
    Since:
    3.4
    Author:
    Derek Hulley
    • Constructor Detail

      • AbstractQNameDAOImpl

        protected AbstractQNameDAOImpl()
        Default constructor.

        This sets up the DAO accessors to bypass any caching to handle the case where the caches are not supplied in the setters.

    • Method Detail

      • setNamespaceCache

        public void setNamespaceCache​(org.alfresco.repo.cache.SimpleCache<Long,​String> namespaceCache)
        Set the cache that maintains the ID-Namespace mappings and vice-versa.
        Parameters:
        namespaceCache - the cache
      • setQnameCache

        public void setQnameCache​(org.alfresco.repo.cache.SimpleCache<Long,​org.alfresco.service.namespace.QName> qnameCache)
        Set the cache that maintains the ID-Namespace mappings and vice-versa.
        Parameters:
        qnameCache - the cache
      • getNamespace

        public org.alfresco.util.Pair<Long,​String> getNamespace​(Long id)
        Specified by:
        getNamespace in interface QNameDAO
        Parameters:
        id - the unique ID of the entity
        Returns:
        the namespace pair (id, uri)
      • getNamespace

        public org.alfresco.util.Pair<Long,​String> getNamespace​(String namespaceUri)
        Specified by:
        getNamespace in interface QNameDAO
        Parameters:
        namespaceUri - the namespace URI to query for
        Returns:
        the namespace pair (id, uri) or null if it doesn't exist
      • getOrCreateNamespace

        public org.alfresco.util.Pair<Long,​String> getOrCreateNamespace​(String namespaceUri)
        Description copied from interface: QNameDAO
        Get an existing instance matching the URI or create one if necessary. Note that this method should be treated as a write method and should not be used in the context of read-only or query methods.
        Specified by:
        getOrCreateNamespace in interface QNameDAO
        Parameters:
        namespaceUri - the namespace URI to create
        Returns:
        the existing namespace pair (id, uri) or a new one
      • updateNamespace

        public void updateNamespace​(String oldNamespaceUri,
                                    String newNamespaceUri)
        Description copied from interface: QNameDAO
        Modifies an existing namespace URI. If the new URI already exists, then no new entity is created.
        Specified by:
        updateNamespace in interface QNameDAO
        Parameters:
        oldNamespaceUri - the old namespace URI
        newNamespaceUri - the new namespace URI
      • findNamespaceEntityById

        protected abstract NamespaceEntity findNamespaceEntityById​(Long id)
      • updateNamespaceEntity

        protected abstract int updateNamespaceEntity​(NamespaceEntity entity,
                                                     String uri)
      • getQName

        public org.alfresco.util.Pair<Long,​org.alfresco.service.namespace.QName> getQName​(Long id)
        Specified by:
        getQName in interface QNameDAO
        Parameters:
        id - the unique ID of the entity
        Returns:
        the QName pair (id, qname) (never null)
      • getQName

        public org.alfresco.util.Pair<Long,​org.alfresco.service.namespace.QName> getQName​(org.alfresco.service.namespace.QName qname)
        Specified by:
        getQName in interface QNameDAO
        Parameters:
        qname - the QName to query for
        Returns:
        the QName pair (id, qname) or null if it doesn't exist
      • getOrCreateQName

        public org.alfresco.util.Pair<Long,​org.alfresco.service.namespace.QName> getOrCreateQName​(org.alfresco.service.namespace.QName qname)
        Description copied from interface: QNameDAO
        Get an existing instance matching the QName or create one if necessary. Note that this method should be treated as a write method and should not be used in the context of read-only or query methods.
        Specified by:
        getOrCreateQName in interface QNameDAO
        Parameters:
        qname - the QName to query for
        Returns:
        the QName pair (id, qname) or a new one
      • updateQName

        public org.alfresco.util.Pair<Long,​org.alfresco.service.namespace.QName> updateQName​(org.alfresco.service.namespace.QName qnameOld,
                                                                                                   org.alfresco.service.namespace.QName qnameNew)
        Description copied from interface: QNameDAO
        Modify an existing QName. The ID of the new QName will be the same as the old one i.e. the old QName will cease to exist and will become the new QName. This allows QName modification without affecting tables that reference the old QName.
        Specified by:
        updateQName in interface QNameDAO
        Parameters:
        qnameOld - the old QName, which must exist
        qnameNew - the new QName, which must not exist
        Returns:
        the QName pair (id, qname) with the ID unchanged from old to new
      • deleteQName

        public void deleteQName​(org.alfresco.service.namespace.QName qname)
        Description copied from interface: QNameDAO
        Delete a QName. This will work only if the QName is not in use e.g. by nodes, properties, etc
        Specified by:
        deleteQName in interface QNameDAO
      • findQNameEntityById

        protected abstract QNameEntity findQNameEntityById​(Long id)
      • findQNameEntityByNamespaceAndLocalName

        protected abstract QNameEntity findQNameEntityByNamespaceAndLocalName​(Long nsId,
                                                                              String localName)
      • updateQNameEntity

        protected abstract int updateQNameEntity​(QNameEntity entity,
                                                 Long nsId,
                                                 String localName)
      • deleteQNameEntity

        protected abstract int deleteQNameEntity​(QNameEntity entity)
      • convertIdsToQNames

        public Set<org.alfresco.service.namespace.QName> convertIdsToQNames​(Set<Long> ids)
        Description copied from interface: QNameDAO
        Bulk-convert QName IDs into QNames
        Specified by:
        convertIdsToQNames in interface QNameDAO
        Parameters:
        ids - the IDs
        Returns:
        the QNames for the IDs given, in the same order
      • convertIdMapToQNameMap

        public Map<org.alfresco.service.namespace.QName,​? extends Object> convertIdMapToQNameMap​(Map<Long,​? extends Object> idMap)
        Description copied from interface: QNameDAO
        Convenience method to convert map keys from QName IDs to QNames
        Specified by:
        convertIdMapToQNameMap in interface QNameDAO
        Parameters:
        idMap - a map of objects keyed by QName ID
        Returns:
        a map of the same objects keyed by the equivalent QNames
      • convertQNamesToIds

        public Set<Long> convertQNamesToIds​(Set<org.alfresco.service.namespace.QName> qnames,
                                            boolean create)
        Description copied from interface: QNameDAO
        Bulk-convert QNames into QName IDs. This is primarily used for generating SQL IN clause lists for other DAO queries.
        Specified by:
        convertQNamesToIds in interface QNameDAO
        Parameters:
        qnames - the QNames to convert
        create - true to create any missing QName entities
        Returns:
        Returns a set of IDs mapping to the QNames provided. If create is false then there will not be corresponding entries for the QNames that don't exist. So there is no guarantee that the returned set will be ordered the same or even contain the same number of elements as the original unless create is true.