mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged 1.4 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4229 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4230 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4232 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4233 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4234 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4235 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4239 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4240 . svn resolved root\projects\web-client\source\java\org\alfresco\web\app\AlfrescoNavigationHandler.java svn resolved root\projects\web-client\source\web\WEB-INF\faces-config-beans.xml svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4241 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4242 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4243 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4244 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4244 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4245 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4245 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4246 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4247 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4248 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4248 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4249 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4250 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4251 . svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4251 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V1.4@4252 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4633 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -65,6 +65,7 @@ import org.alfresco.service.cmr.repository.NodeRef.Status;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNamePattern;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -1041,8 +1042,39 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
|
||||
{
|
||||
Node node = getNodeNotNull(nodeRef);
|
||||
// get the assocs pointing from it
|
||||
Collection<ChildAssociationRef> childAssocRefs = nodeDaoService.getChildAssocRefs(node);
|
||||
|
||||
Collection<ChildAssociationRef> childAssocRefs = null;
|
||||
// if the type is the wildcard type, and the qname is not a search, then use a shortcut query
|
||||
if (typeQNamePattern.equals(RegexQNamePattern.MATCH_ALL) && qnamePattern instanceof QName)
|
||||
{
|
||||
// get all child associations with the specific qualified name
|
||||
childAssocRefs = nodeDaoService.getChildAssocRefs(node, (QName)qnamePattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get all child associations
|
||||
childAssocRefs = nodeDaoService.getChildAssocRefs(node);
|
||||
// remove non-matching assocs
|
||||
Iterator<ChildAssociationRef> iterator = childAssocRefs.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ChildAssociationRef childAssocRef = iterator.next();
|
||||
// does the qname match the pattern?
|
||||
if (!qnamePattern.isMatch(childAssocRef.getQName()) || !typeQNamePattern.isMatch(childAssocRef.getTypeQName()))
|
||||
{
|
||||
// no match - remove
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
// sort the results
|
||||
List<ChildAssociationRef> orderedList = reorderChildAssocs(childAssocRefs);
|
||||
// done
|
||||
return orderedList;
|
||||
}
|
||||
|
||||
private List<ChildAssociationRef> reorderChildAssocs(Collection<ChildAssociationRef> childAssocRefs)
|
||||
{
|
||||
// shortcut if there are no assocs
|
||||
if (childAssocRefs.size() == 0)
|
||||
{
|
||||
@@ -1058,17 +1090,8 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
ChildAssociationRef childAssocRef = iterator.next();
|
||||
// does the qname match the pattern?
|
||||
if (!qnamePattern.isMatch(childAssocRef.getQName()) || !typeQNamePattern.isMatch(childAssocRef.getTypeQName()))
|
||||
{
|
||||
// no match - remove
|
||||
iterator.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
childAssocRef.setNthSibling(nthSibling);
|
||||
nthSibling++;
|
||||
}
|
||||
childAssocRef.setNthSibling(nthSibling);
|
||||
nthSibling++;
|
||||
}
|
||||
// done
|
||||
return orderedList;
|
||||
|
@@ -159,6 +159,14 @@ public interface NodeDaoService
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getChildAssocRefs(Node parentNode);
|
||||
|
||||
/**
|
||||
* Get a collection of all child association references for a given parent node.
|
||||
*
|
||||
* @param parentNode the parent node
|
||||
* @return Returns a collection of association references
|
||||
*/
|
||||
public Collection<ChildAssociationRef> getChildAssocRefs(Node parentNode, QName assocQName);
|
||||
|
||||
/**
|
||||
* @return Returns a matching association or null if one was not found
|
||||
*
|
||||
|
@@ -85,6 +85,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
private static final String QUERY_GET_CHILD_ASSOCS = "node.GetChildAssocs";
|
||||
private static final String QUERY_GET_CHILD_ASSOC_BY_TYPE_AND_NAME = "node.GetChildAssocByTypeAndName";
|
||||
private static final String QUERY_GET_CHILD_ASSOC_REFS = "node.GetChildAssocRefs";
|
||||
private static final String QUERY_GET_CHILD_ASSOC_REFS_BY_QNAME = "node.GetChildAssocRefsByQName";
|
||||
private static final String QUERY_GET_NODE_ASSOC = "node.GetNodeAssoc";
|
||||
private static final String QUERY_GET_NODE_ASSOCS_TO_AND_FROM = "node.GetNodeAssocsToAndFrom";
|
||||
private static final String QUERY_GET_TARGET_ASSOCS = "node.GetTargetAssocs";
|
||||
@@ -100,6 +101,9 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
private static TransactionAwareSingleton<Long> serverIdSingleton = new TransactionAwareSingleton<Long>();
|
||||
private final String ipAddress;
|
||||
|
||||
/** used for debugging */
|
||||
private Set<String> changeTxnIdSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -114,6 +118,8 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to get server IP address", e);
|
||||
}
|
||||
|
||||
changeTxnIdSet = new HashSet<String>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,17 +212,32 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
Serializable txnId = (Serializable) AlfrescoTransactionSupport.getResource(RESOURCE_KEY_TRANSACTION_ID);
|
||||
if (txnId == null)
|
||||
{
|
||||
String changeTxnId = AlfrescoTransactionSupport.getTransactionId();
|
||||
// no transaction instance has been bound to the transaction
|
||||
transaction = new TransactionImpl();
|
||||
transaction.setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
transaction.setChangeTxnId(changeTxnId);
|
||||
transaction.setServer(getServer());
|
||||
txnId = getHibernateTemplate().save(transaction);
|
||||
// bind the id
|
||||
AlfrescoTransactionSupport.bindResource(RESOURCE_KEY_TRANSACTION_ID, txnId);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
if (!changeTxnIdSet.add(changeTxnId))
|
||||
{
|
||||
// the txn id was already used!
|
||||
logger.error("Change transaction ID already used: " + transaction);
|
||||
}
|
||||
logger.debug("Created new transaction: " + transaction);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
transaction = (Transaction) getHibernateTemplate().get(TransactionImpl.class, txnId);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Using existing transaction: " + transaction);
|
||||
}
|
||||
}
|
||||
return transaction;
|
||||
}
|
||||
@@ -355,7 +376,9 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
}
|
||||
else
|
||||
{
|
||||
status.getTransaction().setChangeTxnId(AlfrescoTransactionSupport.getTransactionId());
|
||||
// make sure that the status has the latest transaction attached
|
||||
Transaction currentTxn = getCurrentTransaction();
|
||||
status.setTransaction(currentTxn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,6 +678,38 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
|
||||
}
|
||||
};
|
||||
List<Object[]> queryResults = (List<Object[]>) getHibernateTemplate().execute(callback);
|
||||
Collection<ChildAssociationRef> refs = convertToChildAssocRefs(parentNode, queryResults);
|
||||
// done
|
||||
return refs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<ChildAssociationRef> getChildAssocRefs(final Node parentNode, final QName assocQName)
|
||||
{
|
||||
HibernateCallback callback = new HibernateCallback()
|
||||
{
|
||||
public Object doInHibernate(Session session)
|
||||
{
|
||||
Query query = session
|
||||
.getNamedQuery(HibernateNodeDaoServiceImpl.QUERY_GET_CHILD_ASSOC_REFS_BY_QNAME)
|
||||
.setLong("parentId", parentNode.getId())
|
||||
.setParameter("childAssocQName", assocQName);
|
||||
return query.list();
|
||||
}
|
||||
};
|
||||
List<Object[]> queryResults = (List<Object[]>) getHibernateTemplate().execute(callback);
|
||||
Collection<ChildAssociationRef> refs = convertToChildAssocRefs(parentNode, queryResults);
|
||||
// done
|
||||
return refs;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* assocTypeQName, assocQName, assocIsPrimary, assocIndex, ?, childProtocol, childIdentifier, childUuid
|
||||
* </pre>
|
||||
*/
|
||||
private Collection<ChildAssociationRef> convertToChildAssocRefs(Node parentNode, List<Object[]> queryResults)
|
||||
{
|
||||
Collection<ChildAssociationRef> refs = new ArrayList<ChildAssociationRef>(queryResults.size());
|
||||
NodeRef parentNodeRef = parentNode.getNodeRef();
|
||||
for (Object[] row : queryResults)
|
||||
|
Reference in New Issue
Block a user