/** * Helper method to fetch the association reference */ public AssociationRef getAssociationRef(QNameDAO qnameDAO) { QName assocTypeQName = qnameDAO.getQName(typeQNameId).getSecond(); AssociationRef assocRef = new AssociationRef( id, sourceNode.getNodeRef(), assocTypeQName, targetNode.getNodeRef()); return assocRef; }
/** * Helper method to fetch the association reference */ public AssociationRef getAssociationRef(QNameDAO qnameDAO) { QName assocTypeQName = qnameDAO.getQName(typeQNameId).getSecond(); AssociationRef assocRef = new AssociationRef( id, sourceNode.getNodeRef(), assocTypeQName, targetNode.getNodeRef()); return assocRef; }
AssociationRef assocRef = new AssociationRef(sourceNodeRef, DownloadModel.ASSOC_REQUESTED_NODES, targetRef);
AssociationRef assocRef = new AssociationRef(sourceNodeRef, DownloadModel.ASSOC_REQUESTED_NODES, targetRef);
/** * @throws UnsupportedOperationException always */ public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) { // Get the child assocs from the version store List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs( VersionUtil.convertNodeRef(sourceRef), RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSIONED_ASSOCS); List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { // Get the assoc reference NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode) == true) { // get the qualified type name of the frozen child association and filter out unwanted names QName qName = (QName)this.dbNodeService.getProperty(childRef, PROP_QNAME_ASSOC_TYPE_QNAME); if (qnamePattern.isMatch(qName) == true) { AssociationRef newAssocRef = new AssociationRef(null, sourceRef, qName, referencedNode); result.add(newAssocRef); } } } return result; }
/** * @throws UnsupportedOperationException always */ public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) { // Get the child assocs from the version store List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs( VersionUtil.convertNodeRef(sourceRef), RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSIONED_ASSOCS); List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { // Get the assoc reference NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode) == true) { // get the qualified type name of the frozen child association and filter out unwanted names QName qName = (QName)this.dbNodeService.getProperty(childRef, PROP_QNAME_ASSOC_TYPE_QNAME); if (qnamePattern.isMatch(qName) == true) { AssociationRef newAssocRef = new AssociationRef(null, sourceRef, qName, referencedNode); result.add(newAssocRef); } } } return result; }
AssociationRef newAssocRef = new AssociationRef( assocDbId, sourceRef,
@Override public AssociationRef getName(AssociationRef assocRef) { if (assocRef == null) { return null; } return new AssociationRef(assocRef.getId(), getName(assocRef.getSourceRef()), assocRef.getTypeQName(), getName(assocRef.getTargetRef())); }
@Override public AssociationRef getBaseName(AssociationRef assocRef) { if (assocRef == null) { return null; } return new AssociationRef(assocRef.getId(), getBaseName(assocRef.getSourceRef()), assocRef.getTypeQName(), getBaseName(assocRef.getTargetRef())); }
@Override public AssociationRef getName(AssociationRef assocRef) { if (assocRef == null) { return null; } return new AssociationRef(assocRef.getId(), getName(assocRef.getSourceRef()), assocRef.getTypeQName(), getName(assocRef.getTargetRef())); }
@Override public AssociationRef getBaseName(AssociationRef assocRef) { if (assocRef == null) { return null; } return new AssociationRef(assocRef.getId(), getBaseName(assocRef.getSourceRef()), assocRef.getTypeQName(), getBaseName(assocRef.getTargetRef())); }
private void associatePeers(TransferManifestNormalNode source, TransferManifestNormalNode target) { List<AssociationRef> currentReferencedPeers = source.getTargetAssocs(); if (currentReferencedPeers == null) { currentReferencedPeers = new ArrayList<AssociationRef>(); source.setTargetAssocs(currentReferencedPeers); } List<AssociationRef> currentRefereePeers = target.getSourceAssocs(); if (currentRefereePeers == null) { currentRefereePeers = new ArrayList<AssociationRef>(); target.setSourceAssocs(currentRefereePeers); } Set<QName> aspects = source.getAspects(); if (aspects == null) { aspects = new HashSet<QName>(); source.setAspects(aspects); } aspects.add(ContentModel.ASPECT_ATTACHABLE); AssociationRef newAssoc = new AssociationRef(null, source.getNodeRef(), ContentModel.ASSOC_ATTACHMENTS, target .getNodeRef()); currentRefereePeers.add(newAssoc); currentReferencedPeers.add(newAssoc); }
reference .execute(new GetParentReferenceMethod())); AssociationRef virtualAssocRef = new AssociationRef(associationRef.getId(), sourceReference.toNodeRef(), associationRef.getTypeQName(),
@Override @Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException, AssociationExistsException { // The node(s) involved may not be pending deletion checkPendingDelete(sourceRef); checkPendingDelete(targetRef); Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef); long sourceNodeId = sourceNodePair.getFirst(); Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef); long targetNodeId = targetNodePair.getFirst(); // we are sure that the association doesn't exist - make it Long assocId = nodeDAO.newNodeAssoc(sourceNodeId, targetNodeId, assocTypeQName, -1); AssociationRef assocRef = new AssociationRef(assocId, sourceRef, assocTypeQName, targetRef); // Invoke policy behaviours invokeOnCreateAssociation(assocRef); // Add missing aspects addAspectsAndPropertiesAssoc(sourceNodePair, assocTypeQName, null, null, null, null, false); return assocRef; }
@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); } }
@Override @Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException, AssociationExistsException { // The node(s) involved may not be pending deletion checkPendingDelete(sourceRef); checkPendingDelete(targetRef); Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef); long sourceNodeId = sourceNodePair.getFirst(); Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef); long targetNodeId = targetNodePair.getFirst(); // we are sure that the association doesn't exist - make it Long assocId = nodeDAO.newNodeAssoc(sourceNodeId, targetNodeId, assocTypeQName, -1); AssociationRef assocRef = new AssociationRef(assocId, sourceRef, assocTypeQName, targetRef); // Invoke policy behaviours invokeOnCreateAssociation(assocRef); // Add missing aspects addAspectsAndPropertiesAssoc(sourceNodePair, assocTypeQName, null, null, null, null, false); return assocRef; }
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException { // The node(s) involved may not be pending deletion checkPendingDelete(sourceRef); checkPendingDelete(targetRef); Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef); Long sourceNodeId = sourceNodePair.getFirst(); Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef); Long targetNodeId = targetNodePair.getFirst(); AssociationRef assocRef = new AssociationRef(sourceRef, assocTypeQName, targetRef); // Invoke policy behaviours invokeBeforeDeleteAssociation(assocRef); // delete it int assocsDeleted = nodeDAO.removeNodeAssoc(sourceNodeId, targetNodeId, assocTypeQName); if (assocsDeleted > 0) { // Invoke policy behaviours invokeOnDeleteAssociation(assocRef); } }
@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); } }
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public void removeAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) throws InvalidNodeRefException { // The node(s) involved may not be pending deletion checkPendingDelete(sourceRef); checkPendingDelete(targetRef); Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef); Long sourceNodeId = sourceNodePair.getFirst(); Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef); Long targetNodeId = targetNodePair.getFirst(); AssociationRef assocRef = new AssociationRef(sourceRef, assocTypeQName, targetRef); // Invoke policy behaviours invokeBeforeDeleteAssociation(assocRef); // delete it int assocsDeleted = nodeDAO.removeNodeAssoc(sourceNodeId, targetNodeId, assocTypeQName); if (assocsDeleted > 0) { // Invoke policy behaviours invokeOnDeleteAssociation(assocRef); } }
TENANT_STORE_REF = new StoreRef(PROTOCOL, addDomainToId(IDENTIFIER, DOMAIN)); TENANT_QNAME = QName.createQName(addDomainToId(NAMESPACE_URI, DOMAIN), LOCAL_NAME); tenantAssocRef = new AssociationRef(TENANT_NODE_REF, QNAME, TENANT_NODE_REF); childAssocRef = new ChildAssociationRef(QNAME, NODE_REF, QNAME, NODE_REF); tenantChildAssocRef = new ChildAssociationRef(QNAME, TENANT_NODE_REF, QNAME, TENANT_NODE_REF);