Create node with mandatory associations

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2014 08:23 PM
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
I've included the basic code, model, and error message for reference. Thanks for your assistance.
Christy
Java:
Model:
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
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.
Christy
Java:
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
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2014 04:07 AM
This is a known issue (https://issues.alfresco.com/jira/browse/MNT-12367). Even though you set
<blockcode>
<mandatory enforced="false">true</mandatory>
</blockcode>
the association is enforced <strong>on node creation</strong>. You don't get a chance to set the association.
Don't use a mandatory association until this bug is fixed in Alfresco.
<blockcode>
<mandatory enforced="false">true</mandatory>
</blockcode>
the association is enforced <strong>on node creation</strong>. You don't get a chance to set the association.
Don't use a mandatory association until this bug is fixed in Alfresco.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2014 01:13 PM
This an existing client model that cannot be changed, as is usually the case in these forums. Answers like 'Don't use a mandatory association until this bug is fixed in Alfresco' are not helpful or productive. Thank you however, for the JIRA link.
Anyone else come up with a workaround? Thanks.
Anyone else come up with a workaround? Thanks.
