mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.2 to HEAD
10963: Merged DEV/LARGE_COLLECTION_PROPERTIES_2.2.1 to V2.2 - PersonService: Lucene removal - Lucene optimizations (in progress) - Multi-valued and locale-specific properties persisted in alf_node_properties - Removal of unused AVM tables 10987: Oracle dialects and enhanced SQL patch support - Only support Alfresco's 9i and 10g dialects (with auto-switching) - SQL script patches can now apply selectively to ranges 11007: Test to check cached retrieval of QNames git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11206 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,6 +35,7 @@ import org.alfresco.repo.domain.NamespaceEntity;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Query;
|
||||
@@ -196,7 +197,7 @@ public class HibernateQNameDAOImpl extends HibernateDaoSupport implements QNameD
|
||||
qnameEntityCache.put(qname, -1L);
|
||||
}
|
||||
}
|
||||
else if(id == -1L)
|
||||
else if (id == -1L)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -228,6 +229,20 @@ public class HibernateQNameDAOImpl extends HibernateDaoSupport implements QNameD
|
||||
return result;
|
||||
}
|
||||
|
||||
public Pair<Long, QName> getOrCreateQNamePair(QName qname)
|
||||
{
|
||||
Long id = qnameEntityCache.get(qname);
|
||||
if (id == null)
|
||||
{
|
||||
// It is not cached
|
||||
QNameEntity qnameEntity = getOrCreateQNameEntity(qname);
|
||||
id = qnameEntity.getId();
|
||||
}
|
||||
Pair<Long, QName> qnamePair = new Pair<Long, QName>(id, qname);
|
||||
// Done
|
||||
return qnamePair;
|
||||
}
|
||||
|
||||
public QNameEntity newQNameEntity(QName qname)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -273,4 +288,42 @@ public class HibernateQNameDAOImpl extends HibernateDaoSupport implements QNameD
|
||||
}
|
||||
return qnameMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a set of IDs mapping to the QNames provided. If create is <tt>false</tt>
|
||||
* 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 <tt>true</tt>.
|
||||
*/
|
||||
public Set<Long> convertQNamesToIds(Set<QName> qnames, boolean create)
|
||||
{
|
||||
Set<Long> qnameIds = new HashSet<Long>(qnames.size(), 1.0F);
|
||||
for (QName qname : qnames)
|
||||
{
|
||||
Long qnameEntityId = null;
|
||||
if (create)
|
||||
{
|
||||
qnameEntityId = getOrCreateQNameEntity(qname).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
QNameEntity qnameEntity = getQNameEntity(qname);
|
||||
if (qnameEntity == null)
|
||||
{
|
||||
// No such qname and we are not creating one
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
qnameEntityId = qnameEntity.getId();
|
||||
}
|
||||
}
|
||||
if (qnameEntityId != null)
|
||||
{
|
||||
qnameIds.add(qnameEntityId);
|
||||
}
|
||||
}
|
||||
// Done
|
||||
return qnameIds;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user