Hi all,I am trying to create a node using nodeService.createNode() in Java, but get an IntegrityException error because a mandatory association is not present. Anyone done this before? I've tried setting the association in property map and setting <mandatory enforced="false">true</mandatory>
in the content model. Currently using Alfresco 4.1.4 (super old I know - client requirement.)I've included the basic code, model, and error message for reference. Thanks for your assistance.ChristyJava:
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, id);
props.put(MyModel.PROP_ID, id);
props.put(MyModel.PROP_PERIOD, "period");
props.put(MyModel.ASSOC_BUSINESS, myBusinessNodeRef);
ChildAssociationRef createdNodeChildRef = nodeService.createNode(
parentFolderNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName((String) props.get(ContentModel.PROP_NAME)),
MyModel.TYPE_MY_FOLDER,
props
);
Model:
<association name="myModel:business">
<title>Business</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>myOtherModel:BusinessClient</class>
<mandatory enforced="false">true</mandatory>
<many>false</many>
</target>
</association>
Error:The association target multiplicity has been violated: Source Node: workspace://SpacesStore/386a0725-f46d-414b-8ee7-dbb80b1b256f Association: Association[ class=ClassDef[name={my.model}requestAttributes], name={my.model}business, target class={my.other.model}BusinessClient, source role=null, target role=null] Required target Multiplicity: 1..1 Actual target Multiplicity: 0