CMDBuild Forum

Unique attribute in Superclass

Hi!

 

I would like to define a superclass, for instance machine, and derive a server and blade subclasses. However I would like to make sure that these will not have repeated serial numbers or hostnames. 

However, the unique option is grayed out in a superclass. How can I solve this problem.

 

Thank you in advance.

Regards,

 

Nuno Jordão

I have the exact same question. I would like to have globally unique values that span multiple super-classes as well for serial numbers, asset tag values, IP addresses, etc.

Hope someone can shed some light on this!


NFJ wrote:

Hi!

 

I would like to define a superclass, for instance machine, and drifts and blade servers subclasses. However I would like to make sure That These repeated will not have serial numbers or hostnames. 

However, the unique option is grayed out in a superclass. How can I solve this problem.

 

Thank you in advance.

Regards,

 

Nuno Jordão

 

Hi Rich,

 
CMDBuild uses the native PostgreSQL inheritance and constraint systems. Unfortunately the database does not enforce unique constraints on superclasses [1], so it was disabled in CMDBuild as well. You can put a trigger on every leaf of the class hierarchy of that superclass. The trigger should be run on every insert or update (if the value changes) and it should raise an exception if it can find a row with that value querying the superclass.
 
Hope it helps.
 
Paolo
 
Notes:
[1] http://www.postgresql.org/docs/9.1/static/ddl-inherit.html#DDL-INHERIT-CAVEATS