本文整理汇总了Java中org.alfresco.service.cmr.repository.ChildAssociationRef类的典型用法代码示例。如果您正苦于以下问题:Java ChildAssociationRef类的具体用法?Java ChildAssociationRef怎么用?Java ChildAssociationRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChildAssociationRef类属于org.alfresco.service.cmr.repository包,在下文中一共展示了ChildAssociationRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDuplicateChildAssocCleanup
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
public void testDuplicateChildAssocCleanup() throws Exception
{
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
// Recreate the association from n1 to n3 i.e. duplicate it
QName assocQName = QName.createQName(BaseNodeServiceTest.NAMESPACE, "dup");
ChildAssociationRef dup1 = nodeService.addChild(
n1pn3Ref.getParentRef(),
n1pn3Ref.getChildRef(),
n1pn3Ref.getTypeQName(),
assocQName);
ChildAssociationRef dup2 = nodeService.addChild(
n1pn3Ref.getParentRef(),
n1pn3Ref.getChildRef(),
n1pn3Ref.getTypeQName(),
assocQName);
assertEquals("Duplicate not created", dup1, dup2);
List<ChildAssociationRef> dupAssocs = nodeService.getChildAssocs(n1pn3Ref.getParentRef(), n1pn3Ref.getTypeQName(), assocQName);
assertEquals("Expected duplicates", 2, dupAssocs.size());
// Now delete the specific association
nodeService.removeChildAssociation(dup1);
setComplete();
endTransaction();
}
示例2: invokeOnCreateNode
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* @see NodeServicePolicies.OnCreateNodePolicy#onCreateNode(ChildAssociationRef)
*/
protected void invokeOnCreateNode(ChildAssociationRef childAssocRef)
{
NodeRef childNodeRef = childAssocRef.getChildRef();
if (ignorePolicy(childNodeRef))
{
return;
}
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(childNodeRef);
// execute policy for node type and aspects
NodeServicePolicies.OnCreateNodePolicy policy = onCreateNodeDelegate.get(childNodeRef, qnames);
policy.onCreateNode(childAssocRef);
}
示例3: getValue
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
public Serializable getValue(Map<String, Argument> args, FunctionEvaluationContext context)
{
Argument selectorArgument = args.get(ARG_SELECTOR);
String selectorName = DefaultTypeConverter.INSTANCE.convert(String.class, selectorArgument.getValue(context));
Argument parentArgument = args.get(ARG_PARENT);
NodeRef parent = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, parentArgument.getValue(context));
NodeRef child = context.getNodeRefs().get(selectorName);
for (ChildAssociationRef car : context.getNodeService().getParentAssocs(child))
{
if (car.getParentRef().equals(parent))
{
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
示例4: findOrCreatePackagesFolder
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Finds the system folder in which all packages are stored. If this folder
* has not been created yet then this method creates a new packages folder.
*
* @return The system folder containing all workflow packages.
*/
private NodeRef findOrCreatePackagesFolder()
{
// create simple folder in workflow system folder
NodeRef system = getSystemWorkflowContainer();
// TODO: Consider structuring this folder, if number of children becomes
// an issue
List<NodeRef> packageFolders = searchService.selectNodes(system, "./" + NamespaceService.CONTENT_MODEL_PREFIX
+ ":" + PACKAGE_FOLDER, null, namespaceService, false);
if (packageFolders.size() > 0)
{
return packageFolders.get(0); // Return folder if exists.
}
else
// Create new package folder
{
QName packageFolderName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, PACKAGE_FOLDER);
ChildAssociationRef packageFolderAssoc = nodeService.createNode(system, ContentModel.ASSOC_CHILDREN,
packageFolderName, ContentModel.TYPE_SYSTEM_FOLDER);
return packageFolderAssoc.getChildRef();
}
}
示例5: getSourceNode
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
public ChildAssociationRef getSourceNode(NodeRef renditionNode)
{
// In normal circumstances only a node which is itself a rendition can have
// a source node - as linked by the rn:rendition association.
//
// However there are some circumstances where a node which is not
// technically a rendition can still have a source. One such example is the case
// of thumbnail nodes created in a pre-3.3 Alfresco which have not been patched
// to have the correct rendition aspect applied.
// This will also occur *during* execution of the webscript patch and so the
// decision was made not to throw an exception or log a warning if such a
// situation is encountered.
// A rendition node should have 1 and only 1 source node.
List<ChildAssociationRef> parents = nodeService.getParentAssocs(renditionNode,
RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL);
if (parents.size() > 1)
{
StringBuilder msg = new StringBuilder();
msg.append("NodeRef ")
.append(renditionNode)
.append(" unexpectedly has ")
.append(parents.size())
.append(" rendition parents.");
if (log.isWarnEnabled())
{
log.warn(msg.toString());
}
throw new RenditionServiceException(msg.toString());
}
else
{
return parents.isEmpty() ? null : parents.get(0);
}
}
示例6: invokeBeforeMoveNode
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* @see NodeServicePolicies.BeforeMoveNodePolicy#beforeMoveNode(ChildAssociationRef, NodeRef)
*/
protected void invokeBeforeMoveNode(ChildAssociationRef oldChildAssocRef, NodeRef newParentRef)
{
NodeRef childNodeRef = oldChildAssocRef.getChildRef();
if (ignorePolicy(childNodeRef))
{
return;
}
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(childNodeRef);
// execute policy for node type and aspects
NodeServicePolicies.BeforeMoveNodePolicy policy = beforeMoveNodeDelegate.get(childNodeRef, qnames);
policy.beforeMoveNode(oldChildAssocRef, newParentRef);
}
示例7: getComments
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Returns all comment nodes for a given node.
* @return an array of comments.
*/
public static List<ChildAssociationRef> getComments(NodeRef node, ServiceRegistry services)
{
List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>();
NodeRef commentsFolder = getCommentsFolder(node, services);
if (commentsFolder != null)
{
List<ChildAssociationRef> children = services.getNodeService().getChildAssocs(commentsFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
if (!children.isEmpty())
{
result = children;
}
}
return result;
}
示例8: setPropertiesCommonWork
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Performs additional tasks associated with setting a property.
*
* @return Returns <tt>true</tt> if any work was done by this method
*/
private boolean setPropertiesCommonWork(Pair<Long, NodeRef> nodePair, Map<QName, Serializable> properties)
{
Long nodeId = nodePair.getFirst();
boolean changed = false;
// cm:name special handling
if (properties.containsKey(ContentModel.PROP_NAME))
{
String name = extractNameProperty(properties);
Pair<Long, ChildAssociationRef> primaryParentAssocPair = nodeDAO.getPrimaryParentAssoc(nodeId);
if (primaryParentAssocPair != null)
{
String oldName = extractNameProperty(nodeDAO.getNodeProperties(nodeId));
String newName = DefaultTypeConverter.INSTANCE.convert(String.class, name);
changed = setChildNameUnique(nodePair, newName, oldName);
}
}
// Done
return changed;
}
示例9: testVersionTypeIsSet
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Check that the version type property is actually set when creating a new version.
*
* @see https://issues.alfresco.com/jira/browse/MNT-14681
*/
public void testVersionTypeIsSet()
{
ChildAssociationRef childAssociation = nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN,
QName.createQName("http://www.alfresco.org/test/versiontypeissettest/1.0", "versionTypeIsSetTest"), TEST_TYPE_QNAME);
NodeRef newNode = childAssociation.getChildRef();
assertNull(nodeService.getProperty(newNode, ContentModel.PROP_VERSION_TYPE));
Map<String, Serializable> versionProps = new HashMap<String, Serializable>(1);
versionProps.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
versionService.createVersion(newNode, versionProps);
Serializable versionTypeProperty = nodeService.getProperty(newNode, ContentModel.PROP_VERSION_TYPE);
assertNotNull(versionTypeProperty);
assertTrue(versionTypeProperty.toString().equals(VersionType.MINOR.toString()));
}
示例10: getInheritedAcl
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
public Long getInheritedAcl(NodeRef nodeRef)
{
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(nodeRef);
if (nodePair == null)
{
return null;
}
Pair<Long, ChildAssociationRef> parentAssocRefPair = nodeDAO.getPrimaryParentAssoc(nodePair.getFirst());
if (parentAssocRefPair == null || parentAssocRefPair.getSecond().getParentRef() == null)
{
return null;
}
Acl acl = getAccessControlList(parentAssocRefPair.getSecond().getParentRef());
if (acl != null)
{
return acl.getId();
}
else
{
return null;
}
}
示例11: getCommentsFolder
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Returns the folder that contains all the comments.
*
* We currently use the fm:discussable aspect where we
* add a "Comments" topic to it.
*/
public static NodeRef getCommentsFolder(NodeRef node, ServiceRegistry services)
{
//FIXME These methods are from the original JavaScript. Should use the (soon to arrive) CommentService.
NodeRef result = null;
if (services.getNodeService().hasAspect(node, ForumModel.ASPECT_DISCUSSABLE))
{
List<ChildAssociationRef> forumFolders = services.getNodeService().getChildAssocs(node, ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL);
// The JavaScript was retrieving the first child under this child-assoc so we'll do the same.
NodeRef forumFolder = forumFolders.get(0).getChildRef();
List<ChildAssociationRef> topicFolder = services.getNodeService().getChildAssocs(forumFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, COMMENTS_TOPIC_NAME));
result = topicFolder.isEmpty() ? null : topicFolder.get(0).getChildRef();
}
return result;
}
示例12: getChildAssocsByPropertyValue
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
@Override
public List<ChildAssociationRef> getChildAssocsByPropertyValue(Reference parentReference, QName propertyQName,
Serializable value)
{
List<ChildAssociationRef> allAssociations = getChildAssocs(parentReference,
RegexQNamePattern.MATCH_ALL,
RegexQNamePattern.MATCH_ALL,
Integer.MAX_VALUE,
false);
List<ChildAssociationRef> associations = new LinkedList<>();
for (ChildAssociationRef childAssociationRef : allAssociations)
{
Serializable propertyValue = environment.getProperty(childAssociationRef.getChildRef(),
propertyQName);
if ((value == null && propertyValue == null) || (value != null && value.equals(propertyValue)))
{
associations.add(childAssociationRef);
}
}
return associations;
}
示例13: removeChildAssociation
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
@Override
public boolean removeChildAssociation(ChildAssociationRef childAssocRef)
{
NodeServiceTrait theTrait = getTrait();
NodeRef childRef = childAssocRef.getChildRef();
if (Reference.fromNodeRef(childRef) != null)
{
List<ChildAssociationRef> assocsToRemove = revertVirtualAssociation(childAssocRef,
theTrait,
childRef);
boolean removed = false;
if (!assocsToRemove.isEmpty())
{
for (ChildAssociationRef assoc : assocsToRemove)
{
removed = removed || theTrait.removeChildAssociation(assoc);
}
}
return removed;
}
else
{
return theTrait.removeChildAssociation(childAssocRef);
}
}
示例14: testCreateWithTooLongPathLocalname
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
public void testCreateWithTooLongPathLocalname() throws Exception
{
try
{
ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("Recognize that VSEPR theory states that nonbonded electrons (lone "
+ "pairs) exert strong electrostatic repulsive forces against the bonded pairs "
+ "of electrons and, as a result, the electron pairs arrange themselves as far "
+ "apart as possible in order to minimize the repulsive forces"),
ContentModel.TYPE_CONTAINER);
fail("Expected too-long QName localname to have been kicked out as illegal argument.");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
示例15: getSystemContainer
import org.alfresco.service.cmr.repository.ChildAssociationRef; //导入依赖的package包/类
/**
* Returns the System Container for the current tenant
*/
public static NodeRef getSystemContainer(final NodeService nodeService, final Repository repositoryHelper)
{
// Grab the root of the repository, for the current tennant
final NodeRef root = repositoryHelper.getRootHome();
// Locate the system folder, in the root
List<ChildAssociationRef> sysRefs = nodeService.getChildAssocs(
root, ContentModel.ASSOC_CHILDREN, SYSTEM_FOLDER_QNAME);
if (sysRefs.size() != 1)
{
throw new IllegalStateException("System folder missing / duplicated! Found " + sysRefs);
}
final NodeRef system = sysRefs.get(0).getChildRef();
return system;
}