mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix to export of associations (AWC-1754)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7762 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -29,6 +29,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -454,11 +455,11 @@ public class ExporterComponent
|
|||||||
// Export node children
|
// Export node children
|
||||||
if (parameters.isCrawlChildNodes())
|
if (parameters.isCrawlChildNodes())
|
||||||
{
|
{
|
||||||
exporter.startAssocs(nodeRef);
|
// sort associations into assoc type buckets filtering out unneccessary associations
|
||||||
|
Map<QName, List<ChildAssociationRef>> assocTypes = new HashMap<QName, List<ChildAssociationRef>>();
|
||||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
||||||
for (int i = 0; i < childAssocs.size(); i++)
|
for (ChildAssociationRef childAssoc : childAssocs)
|
||||||
{
|
{
|
||||||
ChildAssociationRef childAssoc = childAssocs.get(i);
|
|
||||||
QName childAssocType = childAssoc.getTypeQName();
|
QName childAssocType = childAssoc.getTypeQName();
|
||||||
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssocType.getNamespaceURI()))
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssocType.getNamespaceURI()))
|
||||||
{
|
{
|
||||||
@@ -469,20 +470,39 @@ public class ExporterComponent
|
|||||||
nodesWithSecondaryLinks.put(nodeRef, nodeRef);
|
nodesWithSecondaryLinks.put(nodeRef, nodeRef);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false)
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssoc.getQName().getNamespaceURI()))
|
||||||
{
|
{
|
||||||
exporter.startAssoc(nodeRef, childAssocType);
|
continue;
|
||||||
}
|
|
||||||
if (!isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssoc.getQName().getNamespaceURI()))
|
|
||||||
{
|
|
||||||
walkNode(childAssoc.getChildRef(), parameters, exporter, false);
|
|
||||||
}
|
|
||||||
if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false)
|
|
||||||
{
|
|
||||||
exporter.endAssoc(nodeRef, childAssocType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ChildAssociationRef> assocRefs = assocTypes.get(childAssocType);
|
||||||
|
if (assocRefs == null)
|
||||||
|
{
|
||||||
|
assocRefs = new ArrayList<ChildAssociationRef>();
|
||||||
|
assocTypes.put(childAssocType, assocRefs);
|
||||||
|
}
|
||||||
|
assocRefs.add(childAssoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// output each association type bucket
|
||||||
|
if (assocTypes.size() > 0)
|
||||||
|
{
|
||||||
|
exporter.startAssocs(nodeRef);
|
||||||
|
for (Map.Entry<QName, List<ChildAssociationRef>> assocType : assocTypes.entrySet())
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> assocRefs = assocType.getValue();
|
||||||
|
if (assocRefs.size() > 0)
|
||||||
|
{
|
||||||
|
exporter.startAssoc(nodeRef, assocType.getKey());
|
||||||
|
for (ChildAssociationRef assocRef : assocRefs)
|
||||||
|
{
|
||||||
|
walkNode(assocRef.getChildRef(), parameters, exporter, false);
|
||||||
|
}
|
||||||
|
exporter.endAssoc(nodeRef, assocType.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exporter.endAssocs(nodeRef);
|
||||||
}
|
}
|
||||||
exporter.endAssocs(nodeRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export node associations
|
// Export node associations
|
||||||
@@ -592,13 +612,11 @@ public class ExporterComponent
|
|||||||
*/
|
*/
|
||||||
private void walkNodeSecondaryLinks(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
private void walkNodeSecondaryLinks(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
||||||
{
|
{
|
||||||
exporter.startReference(nodeRef, null);
|
// sort associations into assoc type buckets filtering out unneccessary associations
|
||||||
exporter.startAssocs(nodeRef);
|
Map<QName, List<ChildAssociationRef>> assocTypes = new HashMap<QName, List<ChildAssociationRef>>();
|
||||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
|
||||||
for (int i = 0; i < childAssocs.size(); i++)
|
for (ChildAssociationRef childAssoc : childAssocs)
|
||||||
{
|
{
|
||||||
ChildAssociationRef childAssoc = childAssocs.get(i);
|
|
||||||
|
|
||||||
// determine if child association should be exported
|
// determine if child association should be exported
|
||||||
QName childAssocType = childAssoc.getTypeQName();
|
QName childAssocType = childAssoc.getTypeQName();
|
||||||
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssocType.getNamespaceURI()))
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssocType.getNamespaceURI()))
|
||||||
@@ -614,24 +632,37 @@ public class ExporterComponent
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export the association
|
List<ChildAssociationRef> assocRefs = assocTypes.get(childAssocType);
|
||||||
if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false)
|
if (assocRefs == null)
|
||||||
{
|
{
|
||||||
exporter.startAssoc(nodeRef, childAssocType);
|
assocRefs = new ArrayList<ChildAssociationRef>();
|
||||||
}
|
assocTypes.put(childAssocType, assocRefs);
|
||||||
QName childName = childAssoc.getQName();
|
}
|
||||||
if (!isExcludedURI(parameters.getExcludeNamespaceURIs(), childName.getNamespaceURI()))
|
assocRefs.add(childAssoc);
|
||||||
{
|
}
|
||||||
exporter.startReference(childAssoc.getChildRef(), childName);
|
|
||||||
exporter.endReference(childAssoc.getChildRef());
|
// output each association type bucket
|
||||||
}
|
if (assocTypes.size() > 0)
|
||||||
if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false)
|
{
|
||||||
{
|
exporter.startReference(nodeRef, null);
|
||||||
exporter.endAssoc(nodeRef, childAssocType);
|
exporter.startAssocs(nodeRef);
|
||||||
}
|
for (Map.Entry<QName, List<ChildAssociationRef>> assocType : assocTypes.entrySet())
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> assocRefs = assocType.getValue();
|
||||||
|
if (assocRefs.size() > 0)
|
||||||
|
{
|
||||||
|
exporter.startAssoc(nodeRef, assocType.getKey());
|
||||||
|
for (ChildAssociationRef assocRef : assocRefs)
|
||||||
|
{
|
||||||
|
exporter.startReference(assocRef.getChildRef(), assocRef.getQName());
|
||||||
|
exporter.endReference(assocRef.getChildRef());
|
||||||
|
}
|
||||||
|
exporter.endAssoc(nodeRef, assocType.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exporter.endAssocs(nodeRef);
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
}
|
}
|
||||||
exporter.endAssocs(nodeRef);
|
|
||||||
exporter.endReference(nodeRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -643,14 +674,11 @@ public class ExporterComponent
|
|||||||
*/
|
*/
|
||||||
private void walkNodeAssociations(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
private void walkNodeAssociations(NodeRef nodeRef, ExporterCrawlerParameters parameters, Exporter exporter)
|
||||||
{
|
{
|
||||||
exporter.startReference(nodeRef, null);
|
// sort associations into assoc type buckets filtering out unneccessary associations
|
||||||
exporter.startAssocs(nodeRef);
|
Map<QName, List<AssociationRef>> assocTypes = new HashMap<QName, List<AssociationRef>>();
|
||||||
List<AssociationRef> assocs = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
|
List<AssociationRef> assocs = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
|
||||||
for (int i = 0; i < assocs.size(); i++)
|
for (AssociationRef assoc : assocs)
|
||||||
{
|
{
|
||||||
AssociationRef assoc = assocs.get(i);
|
|
||||||
|
|
||||||
// determine if association should be exported
|
|
||||||
QName assocType = assoc.getTypeQName();
|
QName assocType = assoc.getTypeQName();
|
||||||
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), assocType.getNamespaceURI()))
|
if (isExcludedURI(parameters.getExcludeNamespaceURIs(), assocType.getNamespaceURI()))
|
||||||
{
|
{
|
||||||
@@ -660,21 +688,38 @@ public class ExporterComponent
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export the association
|
List<AssociationRef> assocRefs = assocTypes.get(assocType);
|
||||||
if (i == 0 || assocs.get(i - 1).getTypeQName().equals(assocType) == false)
|
if (assocRefs == null)
|
||||||
{
|
{
|
||||||
exporter.startAssoc(nodeRef, assocType);
|
assocRefs = new ArrayList<AssociationRef>();
|
||||||
}
|
assocTypes.put(assocType, assocRefs);
|
||||||
exporter.startReference(assoc.getTargetRef(), null);
|
}
|
||||||
exporter.endReference(assoc.getTargetRef());
|
assocRefs.add(assoc);
|
||||||
if (i == assocs.size() - 1 || assocs.get(i + 1).getTypeQName().equals(assocType) == false)
|
}
|
||||||
{
|
|
||||||
exporter.endAssoc(nodeRef, assocType);
|
// output each association type bucket
|
||||||
}
|
if (assocTypes.size() > 0)
|
||||||
|
{
|
||||||
|
exporter.startReference(nodeRef, null);
|
||||||
|
exporter.startAssocs(nodeRef);
|
||||||
|
for (Map.Entry<QName, List<AssociationRef>> assocType : assocTypes.entrySet())
|
||||||
|
{
|
||||||
|
List<AssociationRef> assocRefs = assocType.getValue();
|
||||||
|
if (assocRefs.size() > 0)
|
||||||
|
{
|
||||||
|
exporter.startAssoc(nodeRef, assocType.getKey());
|
||||||
|
for (AssociationRef assocRef : assocRefs)
|
||||||
|
{
|
||||||
|
exporter.startReference(assocRef.getTargetRef(), null);
|
||||||
|
exporter.endReference(assocRef.getTargetRef());
|
||||||
|
}
|
||||||
|
exporter.endAssoc(nodeRef, assocType.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exporter.endAssocs(nodeRef);
|
||||||
|
exporter.endReference(nodeRef);
|
||||||
}
|
}
|
||||||
exporter.endAssocs(nodeRef);
|
|
||||||
exporter.endReference(nodeRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user