cancel
Showing results for 
Search instead for 
Did you mean: 

Remove associations

agey
Champ in-the-making
Champ in-the-making
Hi all,

I have defined an association that relates a 'DocsAdmin' type content to 'Invoice' type content:



<type name="inv:DocsAdmin">
         <title>Admin Documents</title>
         <parent>cm:content</parent>
         <properties>
       <property name="inv:date">
            <title>Fecha</title>
            <type>d:date</type>
            </property>
      <property name="inv:type">
            <title>Tipo</title>
            <type>d:text</type>
            </property>
       </properties>
      <mandatory-aspects>
         <aspect>inv:docsAssocs</aspect>
      </mandatory-aspects>

      </type>   


                       <aspect name="inv:docsAssocs">
            <associations>
               <association name="inv:relatedInvoices">
                  <title>Facturas relacionadas</title>
                  <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
                  </source>
                  <target>
                  <class>inv:invoice</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
                  </target>
               </association>
            </associations>
         </aspect>

I have created a custom dialog to create and remove relationships of this association. Basically, the dialog retrieves all 'inv:relatedInvoices' associations of a document for display to the user and saves new associations that user sets.

This is the code used to save associations:


//associationsIni = list of retrived associations of the document
     for(NodeRef assocFile: this.associations){
         if(!this.associationsIni.contains(assocFile)){
           this.getNodeService().createAssociation(this.editableNode.getNodeRef(), assocFile, ASSOC_FRAS);
         }
      }
//associations = list of associations set by user     
      for(NodeRef assocFile: this.associationsIni){
         if(!this.associations.contains(assocFile)){
            this.getNodeService().removeAssociation(this.editableNode.getNodeRef(), assocFile, ASSOC_FRAS);
         }
      }


Well, it´s work fine. I have a custom action for each invoice type content to show all documents associated with it. That is, retrieve documents related to the inverse of the following way:

List<AssociationRef> associationRefList=
               this.getNodeService().getSourceAssocs(this.currentNode.getNodeRef(), Constants.ASSOC_INVOICE);

This action shows the associations created. The problem is when the user deletes one of them, the action continues to show the relationship removed. Why is this? The association is defined for the 'DocsAdmin' type. If the user deletes the association of a document of the 'DocsAdmin' type, should not be completely removed? Should we also remove the relationship in the other document of 'Invoice' type?

Thanks a lot in advance
4 REPLIES 4

agey
Champ in-the-making
Champ in-the-making
Can anybody point me something about this issue?

alfteam
Champ in-the-making
Champ in-the-making
I have almost the same issue. Did you find solution?

agey
Champ in-the-making
Champ in-the-making
I haven´t any solution yet for this issue.

mirko79
Champ in-the-making
Champ in-the-making
I haven´t any solution yet for this issue.

hi agey,

have you found a solution? How a user deletes the association?
The user deletes the 'DocsAdmin' or 'Invoice' node, doesn't he? If so, i think that the deleted node's spacesStore changes in "archive://", that is the trash. I think If you wanto to delete the association you have to do it programmatically, perhaps with a custom behaviours.