04-08-2009 06:08 PM
public class MyClass
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
NodeServicePolicies.OnDeleteChildAssociationPolicy {
// Dependencies
private NodeService nodeService;
private PolicyComponent policyComponent;
private ServiceRegistry serviceRegistry;
// Behaviours
private Behaviour onCreateNode;
private Behaviour onDeleteNode;
private Logger logger = Logger.getLogger(MyClass.class);
public void init() {
if (logger.isDebugEnabled()) logger.debug("Initializing behaviors");
// Create behaviours
this.onCreateNode = new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.TRANSACTION_COMMIT);
this.onDeleteNode = new JavaBehaviour(this, "onDeleteChildAssociation", NotificationFrequency.TRANSACTION_COMMIT);
// Bind behaviours to node policies
this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), QName.createQName(myModel.NAMESPACE_MY_CONTENT_MODEL, myModel.ASPECT_MY_COMPONIBILE), QName.createQName(myModel.NAMESPACE_MT_CONTENT_MODEL, myModel.ASSN_TIPO1), this.onCreateNode);
this.policyComponent.bindAssociationBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteChildAssociation"), QName.createQName(visiteIspettiveModel.NAMESPACE_VISIT_CONTENT_MODEL, myModel.ASPECT_MY_COMPONIBILE), QName.createQName(myModel.NAMESPACE_MY_CONTENT_MODEL, myModel.ASSN_TIPO1), this.onDeleteNode);
}
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean arg1) {
if (logger.isDebugEnabled()) logger.debug("Inside onCreateNode");
method(childAssocRef);
}
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) {
if (logger.isDebugEnabled()) logger.debug("Inside onDeleteNode");
method(childAssocRef);
}NodeRef mynode = nodeService.createNode(nodoContenitore, QName.createQName(myModel.NAMESPACE_MY_CONTENT_MODEL , myModel.ASSN_TIPO1) ,ContentModel.TYPE_CONTENT, QName.createQName(myModel.NAMESPACE_MY_CONTENT_MODEL , myModel.TYPE_MY_TYPE)).getChildRef();nodeService.removeChildAssociation(assRef);
<aspect name="my:aspectDefined">
<title>Title here</title>
<properties>
</properties>
<associations>
<child-association name="my:ass1">
<title></title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>my:mydocument</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</child-association>
</associations>
</aspect>05-12-2009 07:16 AM
05-12-2009 12:51 PM
if (assocRef.isPrimary())
{ NodeRef childNodeRef = assocRef.getChildRef();
// Delete the child node
this.deleteNode(childNodeRef);
// Done
return true;
}else
{
// Delete the association
invokeBeforeDeleteChildAssociation(childAssocRef);
nodeDaoService.deleteChildAssoc(assocId);
invokeOnDeleteChildAssociation(childAssocRef);
// Index
nodeIndexer.indexDeleteChildAssociation(childAssocRef);
// Done
return true;
}
if (assocRef.isPrimary())
{
NodeRef childNodeRef = assocRef.getChildRef();
[b]invokeBeforeDeleteChildAssociation(childAssocRef);[/b]
// Delete the child node
this.deleteNode(childNodeRef);
[b]invokeOnDeleteChildAssociation(childAssocRef);[/b]
// Done
return true;
}
else
{
// Delete the association
invokeBeforeDeleteChildAssociation(childAssocRef);
nodeDaoService.deleteChildAssoc(assocId);
invokeOnDeleteChildAssociation(childAssocRef);
// Index
nodeIndexer.indexDeleteChildAssociation(childAssocRef);
// Done
return true;
}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.