cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple property constraint

trakhan
Champ in-the-making
Champ in-the-making
Hello everyone.

I have content model with multiple specific properties. I need to create constraint (or another restriction) which will enforce uniqueness to some of my properties, so there will be no other two documents with the same property value. This is quite simple with utilizing lucene search in constraint evaluation. Problem is, I have a pair of properties logically bound together, which are only unique together. For example if property A has value X then there can be another document with the same value only if it differs in value of property B.

Basically I need something I call multiple property constraint, a constraint which would evaluate multiple properties together. Another solution would be to get the value of property B from constraint of property A, but so far it seems impossible without changes to some of the alfresco core components.

Does anybody have a hint, how to do this? What would be your solution for this problem?

Thanks for any responses.
1 REPLY 1

trakhan
Champ in-the-making
Champ in-the-making
If anyone had the same problem as me - I found out a solution to this problem. Actual Node can be injected to constraint from ComponentGenerator. Solution to this can be found on Jean Barmash's blog.

My note to injecting constraint from ComponentGenerator is, that this works correctly only when ComponentGenerator is called before the constraint e.g. when user is editing properties. However constraint can be called without ComponentGenerator e. g. when accessing nodes and its properties from Javascript API. Then the Node is not injected (and old value of node from previous call can be set there).

So it's vital to set internal node variable to null at every end of evaluateSingleValue, to avoid problems with old values.
And check whether node is really set to any value and respond accordingly.