cancel
Showing results for 
Search instead for 
Did you mean: 

CMLAddChild: cannot get it work

fchevance
Champ in-the-making
Champ in-the-making
Hello,

I defined a custom child-association and I'd like to link a parent object with a child using the webservices.
I tried using CMLAddChild but I cannot get it work … I don't get any error message, all seems ok but the association is not done.

Is there the same kind of issue like in the move and copy in CML ?
(see http://www.alfresco.org/jira/browse/AR-794)

Thank you.

Fred

(I'm using Alfresco Community 1.3.0)
2 REPLIES 2

fchevance
Champ in-the-making
Champ in-the-making
I got it work in 1.4 RC1.

The code :


String relationName = "{my.model}my_relation";

ParentReference parentReference = new ParentReference(
      store,
      parentNode.getReference().getUuid(),
      null,
      relationName,
      relationName);

Reference referenceChild = childNode.getReference();
Predicate predicateChild = new Predicate(new Reference[]{referenceChild}, store, null);

CMLAddChild addChild = new CMLAddChild();
addChild.setTo(parentReference);
addChild.setWhere(predicateChild);

CML cml = new CML();
cml.setAddChild(new CMLAddChild[] {addChild});

UpdateResult[] results = repositoryService.update(cml);

viralshah
Champ in-the-making
Champ in-the-making
Hi,
Did this create a primary child relation for you ? i.e. will the child gete deleted when the parent gets deleted ? How to do that ?