org.alfresco.repo.domain.qname
Class AbstractQNameDAOImpl

java.lang.Object
  extended by org.alfresco.repo.domain.qname.AbstractQNameDAOImpl
All Implemented Interfaces:
QNameDAO
Direct Known Subclasses:
QNameDAOImpl

public abstract class AbstractQNameDAOImpl
extends java.lang.Object
implements QNameDAO

Abstract implementation of the QName and Namespace DAO interface.

Since:
3.4

Constructor Summary
protected AbstractQNameDAOImpl()
          Default constructor.
 
Method Summary
 java.util.Map convertIdMapToQNameMap(java.util.Map idMap)
          Convenience method to convert map keys from QName IDs to QNames
 java.util.Set convertIdsToQNames(java.util.Set ids)
          Bulk-convert QName IDs into QNames
 java.util.Set convertQNamesToIds(java.util.Set qnames, boolean create)
          Bulk-convert QNames into QName IDs.
protected abstract  NamespaceEntity createNamespaceEntity(java.lang.String uri)
           
protected abstract  QNameEntity createQNameEntity(java.lang.Long nsId, java.lang.String localName)
           
protected abstract  NamespaceEntity findNamespaceEntityById(java.lang.Long id)
           
protected abstract  NamespaceEntity findNamespaceEntityByUri(java.lang.String uri)
           
protected abstract  QNameEntity findQNameEntityById(java.lang.Long id)
           
protected abstract  QNameEntity findQNameEntityByNamespaceAndLocalName(java.lang.Long nsId, java.lang.String localName)
           
 org.alfresco.util.Pair getNamespace(java.lang.Long id)
           
 org.alfresco.util.Pair getNamespace(java.lang.String namespaceUri)
           
 org.alfresco.util.Pair getOrCreateNamespace(java.lang.String namespaceUri)
          Get an existing instance matching the URI or create one if necessary.
 org.alfresco.util.Pair getOrCreateQName(org.alfresco.service.namespace.QName qname)
          Get an existing instance matching the QName or create one if necessary.
 org.alfresco.util.Pair getQName(java.lang.Long id)
           
 org.alfresco.util.Pair getQName(org.alfresco.service.namespace.QName qname)
           
 void setNamespaceCache(org.alfresco.repo.cache.SimpleCache namespaceCache)
          Set the cache that maintains the ID-Namespace mappings and vice-versa.
 void setQnameCache(org.alfresco.repo.cache.SimpleCache qnameCache)
          Set the cache that maintains the ID-Namespace mappings and vice-versa.
 void updateNamespace(java.lang.String oldNamespaceUri, java.lang.String newNamespaceUri)
          Modifies an existing namespace URI.
protected abstract  int updateNamespaceEntity(NamespaceEntity entity, java.lang.String uri)
           
 org.alfresco.util.Pair updateQName(org.alfresco.service.namespace.QName qnameOld, org.alfresco.service.namespace.QName qnameNew)
          Modify an existing QName.
protected abstract  int updateQNameEntity(QNameEntity entity, java.lang.Long nsId, java.lang.String localName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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 qnameCache)
Set the cache that maintains the ID-Namespace mappings and vice-versa.

Parameters:
qnameCache - the cache

getNamespace

public org.alfresco.util.Pair getNamespace(java.lang.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 getNamespace(java.lang.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 getOrCreateNamespace(java.lang.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(java.lang.String oldNamespaceUri,
                            java.lang.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(java.lang.Long id)

findNamespaceEntityByUri

protected abstract NamespaceEntity findNamespaceEntityByUri(java.lang.String uri)

createNamespaceEntity

protected abstract NamespaceEntity createNamespaceEntity(java.lang.String uri)

updateNamespaceEntity

protected abstract int updateNamespaceEntity(NamespaceEntity entity,
                                             java.lang.String uri)

getQName

public org.alfresco.util.Pair getQName(java.lang.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 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 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 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

findQNameEntityById

protected abstract QNameEntity findQNameEntityById(java.lang.Long id)

findQNameEntityByNamespaceAndLocalName

protected abstract QNameEntity findQNameEntityByNamespaceAndLocalName(java.lang.Long nsId,
                                                                      java.lang.String localName)

createQNameEntity

protected abstract QNameEntity createQNameEntity(java.lang.Long nsId,
                                                 java.lang.String localName)

updateQNameEntity

protected abstract int updateQNameEntity(QNameEntity entity,
                                         java.lang.Long nsId,
                                         java.lang.String localName)

convertIdsToQNames

public java.util.Set convertIdsToQNames(java.util.Set 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 java.util.Map convertIdMapToQNameMap(java.util.Map 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 java.util.Set convertQNamesToIds(java.util.Set 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.


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.