11-20-2012 07:05 AM
NodeRef node = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
node = nodeService.getChildByName(node, ContentModel.ASSOC_CONTAINS, "mi-fichero.pdf");
<type name="dt:tipo1">
<title>Mi tipo</title>
<parent>cm:content</parent>
<properties>
<property name="dt:propiedad1">
<title>Propiedad 1</title>
<description>Propiedad 1.</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
</properties>
<associations>
<association name="dt:associacion1">
<title>Documentos asociados</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>dt:tipo2</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="dt:tipo2">
<title>Mi tipo 2</title>
<parent>cm:content</parent>
<properties>
<property name="dt:propiedad1">
<title>Propiedad 2</title>
<description>Propiedad 2.</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
</properties>
</type>
var assocs = node.assocs["associacion1"];
for (var i = 0; i < assocs.length; i++)
{
var assoc = assocs[i];
}
11-29-2012 04:52 AM
// Process the collections
NodeRef srcCollection = nodeService.getChildByName(
sourceSection, ContentModel.ASSOC_CONTAINS, "collections"
);
NodeRef dstCollection = nodeService.getChildByName(
newSection, ContentModel.ASSOC_CONTAINS, "collections"
);
if(srcCollection != null && dstCollection != null)
{
// Copy each child of the collection in turn
for(ChildAssociationRef ref :nodeService.getChildAssocs(srcCollection))
{
if(ref.isPrimary())
{
String name = (String)nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME);
if(nodeService.getChildByName(dstCollection, ref.getTypeQName(), name) != null)
{
// There's already something in the destination collection
// with this name. Assume it's deliberate, and don't copy
}
else
{
// Copy the resource over
NodeRef copy = copyService.copy(
ref.getChildRef(),
dstCollection,
ref.getTypeQName(),
ref.getQName(),
true
);
nodeService.setProperty(copy, ContentModel.PROP_NAME, name);
}
}
else
{
// Don't copy non primary associations
// Note: If it's a static asset collection, we may in future want to try to
// identify the equivalent translated assets, ask Brian R for details…
}
}
}
else
{
// This shouldn't happen - aspect behaviour should have already triggered
log.warn("Missing collections on WCM Section! Unable to migrate assets");
}
NodeRef srcCollection = nodeService.getChildByName(
sourceSection, ContentModel.ASSOC_CONTAINS, "collections"
);
for(ChildAssociationRef ref :nodeService.getChildAssocs(srcCollection))
{
if(ref.isPrimary())
{
String name = (String)nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME);
if(nodeService.getChildByName(dstCollection, ref.getTypeQName(), name) != null)
{
// There's already something in the destination collection
// with this name. Assume it's deliberate, and don't copy
}
else
{
…
12-18-2012 09:54 AM
String ASSOC_URL = "la-url-que-tengamos-en-el-modelo";
NodeRef node = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
node = nodeService.getChildByName(node, ContentModel.ASSOC_CONTAINS, "mi-fichero.pdf");
QName asociacionQName = QName.createQName(ASSOC_URL, "asociacion1")
List<AssociationRef> assocNodeRefs = nodeService.getTargetAssocs(node, asociacionQName);
for(int i=0; i< assocNodeRefs.size(); i++)
{
NodeRef assocNodeRef = assocNodeRefs.get(i).getTargetRef();
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.