本文整理汇总了Java中org.alfresco.service.cmr.repository.AssociationRef类的典型用法代码示例。如果您正苦于以下问题:Java AssociationRef类的具体用法?Java AssociationRef怎么用?Java AssociationRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssociationRef类属于org.alfresco.service.cmr.repository包,在下文中一共展示了AssociationRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssocs
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* Gets the current node associations
*
* @return associations
*/
public List<PeerAssociation> getAssocs(NodeRef nodeRef)
{
List<AssociationRef> refs = null;
try
{
refs = getNodeService().getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
}
catch (UnsupportedOperationException err)
{
// some stores do not support associations
// but we doesn't want NPE in code below
refs = new ArrayList<AssociationRef>();
}
List<PeerAssociation> assocs = new ArrayList<PeerAssociation>(refs.size());
for (AssociationRef ref : refs)
{
assocs.add(new PeerAssociation(ref.getTypeQName(), ref.getSourceRef(), ref.getTargetRef()));
}
return assocs;
}
示例2: updateAssociations
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Override
protected void updateAssociations(NodeService nodeService)
{
List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, assocQName);
for (AssociationRef assoc : existingAssocs)
{
if (assoc.getTargetRef().equals(targetNodeRef))
{
if (logger.isWarnEnabled())
{
logger.warn("Attempt to add existing association prevented. " + assoc);
}
return;
}
}
nodeService.createAssociation(sourceNodeRef, targetNodeRef, assocQName);
}
示例3: freezeAssociations
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* Freeze associations
*
* @param versionNodeRef the version node reference
* @param associations the list of associations
*
* @since 3.3 (Ent)
*/
private void freezeAssociations(NodeRef versionNodeRef, List<AssociationRef> associations)
{
for (AssociationRef targetAssocRef : associations)
{
HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>();
QName sourceTypeRef = nodeService.getType(targetAssocRef.getSourceRef());
NodeRef targetRef = targetAssocRef.getTargetRef();
// Set the reference property to point to the target node
properties.put(ContentModel.PROP_REFERENCE, targetRef);
properties.put(Version2Model.PROP_QNAME_ASSOC_DBID, targetAssocRef.getId());
// Create peer version reference
dbNodeService.createNode(
versionNodeRef,
Version2Model.CHILD_QNAME_VERSIONED_ASSOCS,
targetAssocRef.getTypeQName(),
sourceTypeRef,
properties);
}
}
示例4: testGetNull
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Test
public void testGetNull()
{
assertNull(tenantService.getName((NodeRef)null));
assertNull(tenantService.getName((String)null));
assertNull(tenantService.getName((StoreRef) null));
assertNull(tenantService.getName("", (StoreRef) null));
assertNull(tenantService.getName((ChildAssociationRef) null));
assertNull(tenantService.getName((AssociationRef) null));
assertNull(tenantService.getName((NodeRef)null,(NodeRef)null));
assertNull(tenantService.getBaseName((StoreRef) null));
assertNull(tenantService.getBaseName((AssociationRef) null));
assertNull(tenantService.getBaseName((ChildAssociationRef) null, false));
assertNull(tenantService.getBaseName((String)null, false));
tenantService.checkDomain((String)null);
}
示例5: listNodePeerAssocs
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
protected CollectionWithPagingInfo<Node> listNodePeerAssocs(List<AssociationRef> assocRefs, Parameters parameters, boolean returnTarget)
{
Map<QName, String> qnameMap = new HashMap<>(3);
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
List<String> includeParam = parameters.getInclude();
List<Node> collection = new ArrayList<Node>(assocRefs.size());
for (AssociationRef assocRef : assocRefs)
{
// minimal info by default (unless "include"d otherwise)
NodeRef nodeRef = (returnTarget ? assocRef.getTargetRef() : assocRef.getSourceRef());
Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo);
QName assocTypeQName = assocRef.getTypeQName();
if (! EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI()))
{
String assocType = qnameMap.get(assocTypeQName);
if (assocType == null)
{
assocType = assocTypeQName.toPrefixString(namespaceService);
qnameMap.put(assocTypeQName, assocType);
}
node.setAssociation(new Assoc(assocType));
collection.add(node);
}
}
return listPage(collection, parameters.getPaging());
}
示例6: testDuplicateAssociationDetection
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
public void testDuplicateAssociationDetection() throws Exception
{
AssociationRef assocRef = createAssociation();
NodeRef sourceRef = assocRef.getSourceRef();
NodeRef targetRef = assocRef.getTargetRef();
QName qname = assocRef.getTypeQName();
try
{
// attempt repeat
nodeService.createAssociation(sourceRef, targetRef, qname);
fail("Duplicate assocation not detected");
}
catch (AssociationExistsException e)
{
// expected
}
}
示例7: processExcludedSet
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* @param thisNode NodeRef
* @return Set<NodeRef>
*/
private Set<NodeRef> processExcludedSet(NodeRef thisNode)
{
Set<NodeRef> results = new HashSet<NodeRef>(89);
NodeService nodeService = serviceRegistry.getNodeService();
// Find any peer nodes (filtering as necessary)
List<AssociationRef> targets = nodeService.getTargetAssocs(thisNode, RegexQNamePattern.MATCH_ALL);
boolean filterPeers = !peerAssociationTypes.isEmpty();
for (AssociationRef target : targets)
{
if (!filterPeers || !peerAssociationTypes.contains(target.getTypeQName()))
{
results.add(target.getTargetRef());
}
}
return results;
}
示例8: getAssociations
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* Get associations
*
* @param classRef QName
*/
public List<AssociationRef> getAssociations(QName classRef)
{
List<AssociationRef> result = null;
if (classRef.equals(this.classRef) == true)
{
result = getAssociations();
}
else
{
AspectDetails aspectDetails = this.aspectCopyDetails.get(classRef);
if (aspectDetails != null)
{
result = aspectDetails.getAssociations();
}
}
return result;
}
示例9: policyBehaviour
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
public void policyBehaviour(AssociationRef assocRef)
{
final QName assocTypeQName = assocRef.getTypeQName();
if ( !excludedAssocTypes.contains(assocTypeQName))
{
NodeRef nodeRef = assocRef.getSourceRef();
if (nodeService.exists(nodeRef))
{
List<ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef parentAssocRef : parentsAssocRefs)
{
triggerRules(parentAssocRef.getParentRef(), nodeRef);
if (logger.isDebugEnabled() == true)
{
logger.debug(
"OnUpdateAssoc rule triggered (parent); " +
"nodeRef=" + parentAssocRef.getParentRef());
}
}
}
}
}
示例10: getTargetAssocs
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Override
public NodeRef getTargetAssocs(NodeRef nodeRef, QName associationQName)
{
List<AssociationRef> assocs = apiFacet.getNodeService().getTargetAssocs(nodeRef,
associationQName);
if (assocs != null && assocs.size() >= 1)
{
AssociationRef associationRef = assocs.get(0);
NodeRef targetRef = associationRef.getTargetRef();
return targetRef;
}
else
{
return null;
}
}
示例11: createAssociation
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Override
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName)
{
Reference targetReference = Reference.fromNodeRef(targetRef);
if (targetReference != null
&& getTrait().getType(materializeIfPossible(sourceRef)).equals(DownloadModel.TYPE_DOWNLOAD))
{
// NOTE : this is enables downloads of virtual structures
createDownloadAssociation(sourceRef,
targetRef);
AssociationRef assocRef = new AssociationRef(sourceRef,
assocTypeQName,
targetRef);
return assocRef;
}
else
{
return getTrait().createAssociation(materializeIfPossible(sourceRef),
materializeIfPossible(targetRef),
assocTypeQName);
}
}
示例12: getWorkingCopy
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Override
@Extend(traitAPI=CheckOutCheckInServiceTrait.class,extensionAPI=CheckOutCheckInServiceExtension.class)
public NodeRef getWorkingCopy(NodeRef nodeRef)
{
NodeRef workingCopy = null;
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_CHECKED_OUT))
{
List<AssociationRef> assocs = nodeService.getTargetAssocs(nodeRef, ContentModel.ASSOC_WORKING_COPY_LINK);
// It is a 1:1 relationship
if (assocs.size() == 0)
{
logger.warn("Found node with cm:checkedOut aspect but no association. Current node state: " + nodeService.getNodeStatus(nodeRef));
}
else if (assocs.size() > 1)
{
logger.warn("Found multiple " + ContentModel.ASSOC_WORKING_COPY_LINK + " association from node: " + nodeRef);
}
else
{
workingCopy = assocs.get(0).getTargetRef();
}
}
return workingCopy;
}
示例13: getCheckedOut
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
@Override
@Extend(traitAPI=CheckOutCheckInServiceTrait.class,extensionAPI=CheckOutCheckInServiceExtension.class)
public NodeRef getCheckedOut(NodeRef nodeRef)
{
NodeRef original = null;
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
{
List<AssociationRef> assocs = nodeService.getSourceAssocs(nodeRef, ContentModel.ASSOC_WORKING_COPY_LINK);
// It is a 1:1 relationship
if (assocs.size() == 0)
{
logger.warn("Found node with cm:workingcopy aspect but no association. Current node state: " + nodeService.getNodeStatus(nodeRef));
}
else if (assocs.size() > 1)
{
logger.warn("Found multiple " + ContentModel.ASSOC_WORKING_COPY_LINK + " association to node: " + nodeRef);
}
else
{
original = assocs.get(0).getSourceRef();
}
}
return original;
}
示例14: getAssocs
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* @return Target associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getAssocs()
{
if (this.targetAssocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getTargetAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.targetAssocs = new QNameMap<String, List<TemplateNode>>(this);
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.targetAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.targetAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getTargetRef(), this.services, this.imageResolver) );
}
}
return this.targetAssocs;
}
示例15: getSourceAssocs
import org.alfresco.service.cmr.repository.AssociationRef; //导入依赖的package包/类
/**
* @return Source associations for this Node. As a Map of assoc name to a List of TemplateNodes.
*/
public Map<String, List<TemplateNode>> getSourceAssocs()
{
if (this.sourceAssocs == null)
{
List<AssociationRef> refs = this.services.getNodeService().getSourceAssocs(this.nodeRef, RegexQNamePattern.MATCH_ALL);
this.sourceAssocs = new QNameMap<String, List<TemplateNode>>(this);
for (AssociationRef ref : refs)
{
String qname = ref.getTypeQName().toString();
List<TemplateNode> nodes = this.sourceAssocs.get(qname);
if (nodes == null)
{
// first access for the list for this qname
nodes = new ArrayList<TemplateNode>(4);
this.sourceAssocs.put(ref.getTypeQName().toString(), nodes);
}
nodes.add( new TemplateNode(ref.getSourceRef(), this.services, this.imageResolver) );
}
}
return this.sourceAssocs;
}