tsgrp / ActiveWizard

OpenContent Dynamic Forms and Workflow
http://www.tsgrp.com/products/opencontentforms/
4 stars 0 forks source link

Cannot Edit Form That Contains Supporting Doc #269

Closed dhartman25 closed 9 years ago

dhartman25 commented 9 years ago

When editing a form that contains a supporting document, the form will not finish in Alfresco because it errs on the addRelation call. This is Alfresco specific - the form will finish correctly in a Documentum environment.

gsteimer commented 9 years ago

This was working fine before the two big merges yesterday. Could this have something to do with the addRelation updates that were part of the hotdocs merge?

gsteimer commented 9 years ago

Here's the error:

09:12:57,231 ERROR [com.tsgrp.opencontent.alfresco.core.EmbeddedAlfrescoAdvice] [ajp-apr-8009-exec-2] Unhandled exception around OC method class: interface com.tsgrp.opencontent.core.content.IContent| name: addRelation
org.alfresco.service.cmr.repository.AssociationExistsException
    at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.newNodeAssoc(AbstractNodeDAOImpl.java:2883)
    at org.alfresco.repo.node.db.DbNodeServiceImpl.createAssociation(DbNodeServiceImpl.java:2015)
    at sun.reflect.GeneratedMethodAccessor954.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)

Based on the error, is the problem that the code is trying to attach the supporting document again?

@mikeblum

gsteimer commented 9 years ago

Update - I think the problem is definitely that the code is not correctly realizing that the document is already attached. If I edit the form, remove the supporting doc and add a new one, it works perfectly fine.

mikeblum commented 9 years ago

Yes, for some reason, even though the relation already exists from looking at the node browser:

attachedDocType=aw:attached_doc supportingDocRelationName={http://www.activewizard.com/model/content/1.0}supportingDocument

and tested the /getChildRelations endpoint and the attached doc comes back correctly. For some reason, this line here:

//valid and in relationship, continue
if(getRelatedSupportingDocs.contains(supportingDocId) &&
getValidSupportingDocsFromPageSetInstance.contains(supportingDocId)){
                continue;
}

is failing when simply resubmitting a form with a suppporting doc. This code works properly in DCTM.

mikeblum commented 9 years ago

It appears in DCTM we are adding dual supporting doc relations upon save:

3700000680000adb aw_rel_supporting_document 0900000680002b34 0900000680002b23 3700000680000ae9 aw_rel_supporting_document 0900000680002b34 0900000680002b23

We need to look into the logic responsible for removing the relation or not.

Looking deeper at it, the suppoirting document is getting re-added to the form as its versioned, so 0.1 has one copy, 0.2 has three copies:

3700000680000af4 aw_rel_supporting_document 0900000680002b52 0900000680002b44 3700000680000afc aw_rel_supporting_document 0900000680002b52 0900000680002b44 3700000680000afd aw_rel_supporting_document 0900000680002b52 0900000680002b44

The actual logic for deciding when to relate, un-relate, or delete the document appears to be sound. I think the crux of the problem is with how we're creating the relation:

addRelationRequest.setParentId(psiId);
addRelationRequest.setChildIds(supportingDocIds);
addRelationRequest.setRelationType(WizardContext.getLegacyWizardConfig().getSupportingDocRelationName());
addRelationRequest.setTicket(ticket);
addRelationRequest.setPermanent(true);

should the relationship setPermenant be set to true for supporting docs?

It appears that dctm doesn't care about duplicate relationships but alfresco does.

DQL queries to investigate this on monday: select * from dm_relation where parent_id = '0900000680002b58';

select * from aw_psi (all) where i_chronicle_id = '0900000680002b45'

mikeblum commented 9 years ago

r12857 | mblum | 2015-10-19 10:25:21 -0500 (Mon, 19 Oct 2015) | 1 line

Merging in fix for Supporting Documents in Wizard: https://github.com/tsgrp/ActiveWizard/issues/269