cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle datamodel associations?

csabee
Champ in-the-making
Champ in-the-making
Hi there,

I have an extended datalist, with the following association:
<association name="dl:assignee">
               <title>Assignee</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:person</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>

And I have a java backed webscript, that gets http get parameters, and does a lucene query to find matching documents. Then, it gets some properties from the documents.
I would like, to return the user name from the field above. How do I do this?

I have the following objects defined and instantiated for this:

ServiceRegistry registry;
String    strStoreRef      = StoreRef.PROTOCOL_WORKSPACE + StoreRef.URI_FILLER + "SpacesStore";
StoreRef storeRef = new StoreRef(strStoreRef);
SearchService search    = registry.getSearchService();
NodeService nodeSvc = registry.getNodeService();

I get the required property values through the nodeService:
nodeSvc.getProperty(row.getNodeRef(), myProperty);

So, please help me, how can I get the value stored in "dl:assignee"?
And how can I get the values, if I make it a multivalue field?

Thank you!
3 REPLIES 3

csabee
Champ in-the-making
Champ in-the-making
Any ideas?

Thank you

csabee
Champ in-the-making
Champ in-the-making
Any ideas?

Thank you

shmoula
Champ in-the-making
Champ in-the-making
Hi Csabee, try something like this:

QName qName = QName.createQName("your.dl.model", "assignee");
List<AssociationRef> list = nodeService.getTargetAssocs(nodeRef, qName);
if(list.size()>0)
  assignee = list.get(0).getTargetRef();