cancel
Showing results for 
Search instead for 
Did you mean: 

Property decorators with dynamic models

cgiuliano
Champ in-the-making
Champ in-the-making
Hi everybody,

I'm in the middle of testing dynamic model deployment, that sounds to be very easy for fast changes during the design and development phases!

I've found an issue about property decorators: I cannot add my decorated property to the list of category decorators, just because I don't know where to put my context file for that!

The following bean can be defined by placing its definition on the file system

<bean id="my.categoryPropertyDecorator" parent="categoryPropertyDecorator" class="org.alfresco.repo.jscript.app.CategoryPropertyDecorator">   
   <property name="propertyName" value="my:category" />   
</bean>
and it works.
But when I move the model definition to the Data Dictionary, the above context file will raise an error, because the bootstrapper does not know the specified namespace at the boot time.

Does anyone know how to have some bean definitions read after the dynamic models loading has been completed?

Thank you all!

Carlo
6 REPLIES 6

afaust
Legendary Innovator
Legendary Innovator
Hello,

there is currently no support for dynamic Spring configuration in Alfresco (except what is possible using subsystems).
You might want to check if <a href="https://addons.alfresco.com/addons/dynamic-extensions-alfresco">the Dynamic Extensions addon</a> can help you here. That would be the only potential way to go that I know of.

Regards
Axel

cgiuliano
Champ in-the-making
Champ in-the-making
Hi Axel,
That extension sounds interesting.

Actually I've worked the issue around by defining a minimal model in the file system (including just the namespace and the property to be decorated) and then extending it to the full model by uploading the full definition into the Data Dictionary.
I know it is a very unclean approach…, although it seems to be effective.

I'll have a look at the extension you mentioned.

Thanks a lot!
Regards,
Carlo

kaynezhang
World-Class Innovator
World-Class Innovator
Or you can bypass namespace check by implementing your own category property decorator.
You can do it like this
1. copy org.alfresco.repo.jscript.app.CategoryPropertyDecorator and rename it(for example MyCategoryPropertyDecorator)
2.override setPropertyName method like following

    @Override
    public void setPropertyName(String propertyName)
    {
        propertyNames = new HashSet<QName>(1);       
        propertyNames.add(QName.createQName(propertyName));
    }

3.config your MyCategoryPropertyDecorator in spring file.

<bean id="my.categoryPropertyDecorator" parent="categoryPropertyDecorator" class="**.MyCategoryPropertyDecorator" >
   <property name="propertyName" value="{http://www.example.org/model/content/1.0}category" />   
</bean>


But This is not an ideal solution.

cgiuliano
Champ in-the-making
Champ in-the-making
Kaynezhang,
thanks a lot for your suggestion.

If I got it well, it will perfectly run as long as I don't use the namespace prefix for the decorated property, won't it?
That sounds good!

Thank you,
Carlo

kaynezhang
World-Class Innovator
World-Class Innovator
The default implementation 's setPropertyName method's defination is like following(defined in setPropertyName.BasePropertyDecorator)

   public void setPropertyName(String propertyName)
    {
        propertyNames = new HashSet<QName>(1);       
        propertyNames.add(QName.createQName(propertyName, namespaceService));
    }

QName.createQName(propertyName, namespaceService) will call namespaceService to check and calculate namespace URI.

after override this method like following

    @Override

    public void setPropertyName(String propertyName)

    {

        propertyNames = new HashSet<QName>(1);       

        propertyNames.add(QName.createQName(propertyName));

    }
<bean id="my.categoryPropertyDecorator" parent="categoryPropertyDecorator" class="**.MyCategoryPropertyDecorator" >

   <property name="propertyName" value="{http://www.example.org/model/content/1.0}category" />   

</bean>

you will provide namespace URI directly to property decorator and bypass namespace URI check.

cgiuliano
Champ in-the-making
Champ in-the-making
Thanks again for the further clarification.

Rgeards,
Carlo