cancel
Showing results for 
Search instead for 
Did you mean: 

Validating values of custom aspects with a dynamic constrain

theorbix
Confirmed Champ
Confirmed Champ
I need to define a custom Aspect that can have a list of allowed values.

If the list of allowed values is fixed, this can be done easily by modifying the customModel.xml file and adding a <constraint> tag, as show below:


  <constraints>
      <constraint name="custom:VerticalMarketAllowedValuesList" type="LIST">
       <parameter name="allowedValues">
          <list>
             <value>Telco</value>
             <value>Finance</value>
             <value>Insurance</value>
             <value>Government</value>
          </list>
       </parameter>
      </constraint>
     </constraints>
   <types>

              <property name="custom:VerticalMarket">
                  <title>Settore</title>
                  <type>d:text</type>
                  <mandatory>true</mandatory>
                  <constraints>
                    <constraint ref="custom:VerticalMarketAllowedValuesList"/>
                  </constraints>
               </property>


So far, so good… but is there an easy way to dynamically retrieve the list of valid contstrain values from an external source (for instance a database table, via JDBC)?

Has anyone done something similar, and can post a description of how this can be done?

Does this require the development of a custom Java component?
6 REPLIES 6

richard_im
Champ in-the-making
Champ in-the-making

theorbix
Confirmed Champ
Confirmed Champ

alex--70
Champ in-the-making
Champ in-the-making
The code is ok, but the list is static , i must restart the alfresco to reload the record from database. Have you suggestion for resolve this ?

Thank you
Alex–70

gilles
Champ in-the-making
Champ in-the-making
If one could found a solution for dynamically load the constraints values/labels, it would be a solution to solve the lack of multilingualism for constraints.
I would like the constraints lists to be localized. Any idea?
Another solution to my problem would be that the categories could be multilingual like a simple cm:mltext. Meaning that the category applied to a node would be shown (in CRUD) by its translated label and not by its (unilingual) value. Engineers please help!
Thanks in advance.
Gilles

mabayona
Champ on-the-rise
Champ on-the-rise
Here is a sample with dynamic values and code (java):

http://blogs.alfresco.com/jbarmash/?p=6

the general idea is to create the values as nodes in a space and to have the code dynamically reading the values and showing them in the constraint. Very clever and very useful since it not only provides dynamic data. It also provides the possibility of data security and data filtering based on user roles and permissions.

venzia
Star Collaborator
Star Collaborator
Hi guys!, I guess I get a little outdated, but to complete this post, for those arriving now, I would like to mention that there is a component in Alfresco Addons that does this and more in a simple, intuitive and powerful way (Zero Code).
https://addons.alfresco.com/addons/alfresco-metadbconnector-component
I hope this helps the community.

Greetings!
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.