AnsweredAssumed Answered

Using categories as a constraint

Question asked by eddiem on Feb 2, 2010
Hi,
I have two requirements that I think I should be able to meet using categories and a custom constraint.

The first requirement is for a sys admin to be able to add a list of Products - this I think would be easiest if I create Products as a category and then Product 1, Product 2, etc as sub categories. Sys admin would then have a single interface for managing products and related documents, etc.

The second requirement is that when completing document metadata, users should be able to select a list of products to say that this document is relevant to Product 1, and Product 2, etc. As this list of products will be used on more than one place (related products, up sell, cross sell, etc) it seems more efficient if this was a constraint that could be reused within and across custom models.

My issue is I cannot think of the correct way to implement this custom constraint. I'm hoping it is possible just via the my custom model w/o the need for a Java class.

I was hoping something like the following would suffice. I'm saying the constraint is a list and the datasource is an xpath expression to retrieve all Products under the Products category.

 
<constraint name="acme:CategoryProductsList" type="LIST" ds="/cm:generalclassifiable/cm:Products/*">
               <title>Products</title>
               <type>d:category</type>
               <mandatory>false</mandatory>
               <multiple>true</multiple>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>true</stored>
                  <tokenised>true</tokenised>
               </index>
</constraint>

Now I'm suspecting that this will fail! Is it possible that using the
type="org.alfresco.sample.CodeLabelExtend.ListOfValuesQueryConstraint"
would work, if I passed the xPath expression as the datasource?

The other alternative is to do the following:

<property name="acme:pcbProducts">
               <title>Product(s)</title>
               <type>d:category</type>
               <mandatory>false</mandatory>
               <multiple>true</multiple>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>true</stored>
                  <tokenised>true</tokenised>
               </index>
</property>

But this UI control means
1) they have to click down into the categories to find Products
2) I have to add this code to each UI element rather than being able to reference a single constraint.

Anybody know either how to get the constraint to work or of a better way of achieving this?

Cheers,
Eddie

Outcomes