cancel
Showing results for 
Search instead for 
Did you mean: 

fetching associations using the alfresco WS api

timv
Champ in-the-making
Champ in-the-making
How can I fetch associations using the alfresco WS api?

Reference node = new Reference(STORE, null, nodepath);
Association[] assoc = {new Association("my:association", AssociationDirectionEnum.source)};
QueryResult queryAssoc = repositoryService.queryAssociated(node, assoc);
ResultSet resultSetAssoc = queryAssoc.getResultSet();

It gives me no results, although the node clearly has an association which is called my:association.
I think there's something wrong with the creation of the Association object. I did not found any documentation of it.. can someone tell me whether the assiocationType is used is correct, and explane me how the AssociationDirectionEnum works?

Thanks.
2 REPLIES 2

timv
Champ in-the-making
Champ in-the-making
my association looks like this

         <associations>
            <child-association name="my:association">
               <source>
                  <mandatory>true</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>my:associatedimage</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
               <duplicate>false</duplicate>
            </child-association>
         </associations>

fchevance
Champ in-the-making
Champ in-the-making
Hi,

I have same problem, did you succeeded ?

You can try this:

QueryResult queryAssoc = repositoryService.queryChildren(node);
and iterate the results to do some "manual" checks since it's not possible to give the association type.

Fred