cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic models and custom properties

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

My client has a requirement to add new Products on the fly without code changes or server restart. We already have a base custom content model where we have defined our products. But adding a new product to the system would require changes to the model and a technical person to do it.

With respect to this, I have been doing some research on Dynamic Content Model capabilities in Alfresco. It looked good to me and we were planning to create dynamic models on the fly based on user selections in the UI and then deploy it in Data Dictionary/Models space (contentModel.xml and web-client-config-custom.xml). But somehow I am not getting a comfort feeling on it as I find it very risky to play with the content model. In fact, I just faced an issue now where I deleted a dynamic model and was not able to create another one as it always complained about "Failed to validate model update - found deleted TYPE". Also, I noticed that if a dynamic model has to be deleted, then all the contents created on that model has to be deleted first. That seems to be little risky from the content perspective…

What are the other options I have? I do have a base custom content model from which all my new products would be inheriting. I was thinking about storing the new products in a custom database (MySQL, SQLServer etc) along with its custom properties. But the issue which I might face here is showing the custom properties in the "Advanced Search" page  as my custom properties are not in web-client-config-custom.xml file. Is there any way through which I can customize this? By extending Alfresco's Advanced Search???

Regards,
Jerry
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
As you have seen you can have "dynamic" models however as you have also seen how you handle existing data becomes tricky.   For example what happens if your new model says that something is mandatory but the old existing data does not have a mandatory property.   Or if a constraint says red or blue and the existing value is green?   

This is similar to the relational world where once you have data in your database tables you need to consider very carefully how to change those tables.   And its a fairly hard problem to solve.

I suspect that your products are not really that "dynamic".

Let's say that all your products have a price and a catalog number.   That's not going to change without causing havoc.     And you decide to stock lawnmowers and ice cream.    You could have a lawnmower aspect that has details about lawnmowers, such as the blade cutting width. And you could have an ice cream aspect that has details of the flavour etc.       The point is that you will never want to change a lawn mower into an ice cream since that's bonkers 😎     And let's say that you decide later that you need to store the ingredients for ice cream then you could add a new "ingredients aspect, or you could add ingredients to your existing ice cream aspect.    However what happens to the ice cream products that do not have ingredients.  

Perhaps a few concrete examples from you would help open up the discussion.

unknown-user
Champ on-the-rise
Champ on-the-rise
Thanks a lot for the quick response.

Let me ellaborate the scenario.

Currently, the system has been decided to support only one type of Product for which we defined a custom content model. It has its own properties and aspects. Now since the client foresees that there could be new products to be supported, we  are in the process of enhancing the App so that adding a new Product can be done by the end user who does not have any Alfresco knowledge.

The approach that we are thinking of is to generate the content model dynamically based on user selections on a custom UI - basically user will be able to define new Products through this UI and will have the ability to add specific properties for the new Product. Once the user is done with the selections, the content model will be generated automatically based on the selections. We were thinking of creating sepearate models for each Product (like new database tables in RDBMS world) with just one Type and the Specific Properties of that Product. This way the new Product is coupled only to its own model. The dynamically (on the fly) generated model xml and web-client-config-custom xml will be stored in Data Dictionary/Models folder programmatically and the user will manually reload the web-client-config through the Admin console.

The risk that we see here is the existing content getting corrupted due to dynamic creation of model.

Due to this risk, another approach that we are thinking of is to define a base type for the new Products which will have the standard properties and define the specific properties of the product in a custom database. While saving the content, these properties will be read from the DB and set on the content. But the issue we might face here is the search. We wont be able to display these properties in the out of the box Advanced Search page as they are not defined in the web-client-config.

Please let me know if I have not made myself clear

Thanks
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.