cancel
Showing results for 
Search instead for 
Did you mean: 

Get property constraints

joblo
Champ in-the-making
Champ in-the-making
Hi,

Im trying to get all the constraints from my Alfresco data-model in Java. Right now I'm able to get the maxLength of a String property. In the Alfresco data-model is it also possible to put the minLength of a d:text. In the openCMIS PropertyStringDefinition interface there is only a function to get the maxLength. My question is: how can I get the minLength in Java?

Same for regular expressions. Is it possible to get them?


PropertyStringDefinition propDefString = (PropertyStringDefinition) propDef;
if (propDefString.getMaxLength() != null) {
    // Do something
}



<property name="ex:example">
    <title>Example</title>
    <description></description>
    <type>d:text</type>
    <mandatory>true</mandatory>
    <constraints>
        <constraint type="LENGTH">
            <parameter name="minLength">
          <value>5</value>
      </parameter>
      <parameter name="maxLength">
          <value>5</value>
      </parameter>
        </constraint>
    </constraints>
</property>


Thanks in advance
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
I don't think constraints are part of the spec because they are repository specific. You'll have to write an extension or use a web script to retrieve that.

Jeff

joblo
Champ in-the-making
Champ in-the-making
OK thanks for the response. I'll try to get it on another way then.

xkahn
Champ in-the-making
Champ in-the-making
<blockquote>I don't think constraints are part of the spec because they are repository specific. You'll have to write an extension or use a web script to retrieve that.</blockquote>

Okay. Is there such an extension for Alfresco? Lets say I have a property that I've added: sc:status which is a string with a constraint of Red, Yellow, or Green. Using CMIS, I get the following from Alfresco on a document with the property applied:

<cmisSmiley TongueropertyString propertyDefinitionId="sc:status" displayName="Status" queryName="sc:status"><cmis:value>Red</cmis:value></cmisSmiley TongueropertyString>

How can I see what the possible values are?

jpotts
World-Class Innovator
World-Class Innovator
For a list constraint, no extension is necessary. CMIS sees that as a "closed list" and there are calls defined by the spec to get the "choices" available for the constraint from the Dictionary Service.

The OpenCMIS Workbench is a spec-compliant client that knows how to fetch these values. In the attached screenshot, I'm showing the Workbench Types inspector which is currently opened on the sc:marketingDoc type from the SomeCo examples. That type has a constraint called sc:campaignList, which is a list constraint that defines three possible values. The sc:campaign property is constrained by the sc:compaignList constraint, so you can use the dictionary service to ask for the allowed values.

Jeff