cancel
Showing results for 
Search instead for 
Did you mean: 

Searchable associations

grk
Champ in-the-making
Champ in-the-making
I have implemented my own custom model, and I have a question about associations.
I have searched and found that associations are not searchable by Lucene, for performance issues. Yet, consider the following scenario:
<ul><li>A list of contacts in a data list <li>A document that needs to be associated with one of those contacts</ul>

In order for the user to be able to search documents that have been received from that contact, the association needs to be searchable.
So far, I have added a d:text property, that holds the name of the contact, and it is filled when associated with a datalist object. Yet, this entails a variety of issues.

Synchronization is one such major problem. The association needs to be 2-way, so as for the datalist object to be able to notify all documents that are linked to it, that for example the name of the contact has changed. And this is just a way to bypass the problem for a particular datalist. What if for example, I want to associate documents with one another (like in the use of a case of documents)?

Is it more efficient to be implement this in a different way other than string property and a rule for update?
Can someone guide me for an Alfresco SDK implementation of this scenario?
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
This is a bit of a slippery slope. There are ways to work around the problem, as you've observed, but if you get carried away you will have a big mess on your hands. Alfresco simply isn't a relational database so the more you try to treat it like one the more pain you will encounter.

With that said, one option to consider is writing a behavior to sync the data between the nodes. That is a much better approach than using a rule because it happens at a lower level. So, for example, you have a behavior that binds to the onUpdateNode policy of your specific data list type. When it is triggered, it traverses the associations to update the data it needs to update on the related documents.

Hope that helps,

Jeff

grk
Champ in-the-making
Champ in-the-making
Thank you very much for your help, Jeff.

So, from what I am given to understand I have to implement a <a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html" >custom behavior</a> in every datalist type that I might use? Can I develop a behavior where the name of the associated person is loaded on display of the document, rather than implementing an update one?

But putting that aside, is this the correct way to implement a dynamic list? I mean, the very first reason I wanted to do this, was a request for a constraint of values, but not defined in the .xml; instead, we wanted a dynamic list that we can maintain. Is this the best way? Because as I mentioned, I also want to implement content modelling for related documents that are part of an office "case", etc. So, are associations the way to do this?

jpotts
World-Class Innovator
World-Class Innovator
Tony Parzgnat did an excellent lightning talk at last year's Alfresco Summit on using data list values for constraints. The recording of that lightning talk session is here: http://summit.alfresco.com/boston/sessions/lightning-talks-2

I believe he intends to open source that code but he has not done that yet to my knowledge.

You don't need associations to do constraints implemented in data lists. I don't really see a reason to maintain that relationship between the selected value and the thing that defines that value. If you want to change the value when the data list value changes, you can do a query to find all documents with the old value, then change it to the new value.

Jeff

angelborroy
Community Manager Community Manager
Community Manager
Take a look at https://github.com/keensoft/alfresco-datalist-constraints

You can find a sample implementation for constraints based on datalists.
Hyland Developer Evangelist
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.