CMDBuild Forum

CQL Help

Hi

 

I have the following schema:

Class: Custom_Attribute

Domain Attribute2Attribute, Origin=Custom_Attribute, Destination=Custom_Attribute, 1:N

 

Class Custom_Attribute has an attribute (Parent, type REFERENCE, Domain Custom_Attribute, Filter: XXXXXXXX)

 

I have an extra Class: Item (with attribute UUID), and a Domain: ItemAttribute (Origin Item, Destination Custom_Attribute, Master/Detail yes, 1:N)

 

In different words, My Item Class can have multiple Custom_Attributes.  These can be linked in a tree structure via the Parent relationship.

 

My Problem: I cannot work out the Filter syntax on Custom_Attribute.Parent to only show Custom_Attributes related to the same Item.

 

I have tried as per the manual's examples with building and floor

 

from Custom_Attribute where [ItemAttribute].objects(Id=0{client.Custom_Attribute.Id}), which returns no Custom_Attributes

 

from Custom_Attribute where [ItemAttribute].objects(Id={client.Custom_Attribute.Id}), which returns all Custom_Attributes

 

Is there any CQL language reference, which can explain the syntax fully , or a SQL to CQL conversion guide?

If I understand well, you create a card of Custom_Attribute, you set the relation between this card and an Item and finally you want to fill the Parent attribute choosing among the custom_attributes related to that item. 
 
You can do this setting the following filter on the Parent attribute:
 
from Custom_Attribute
where Id in (/(
select "IdObj2"
from "Map_ItemAttribute"
where "IdObj1" = (
select "IdObj1"
from "Map_ItemAttribute"
where "IdObj2"={server:Id})
)/)
 
You can insert an sql query inside a cql query using the syntax (/( your_sql_query )/)
 
Best regards.
 
CMDBuild Team
 
 
 
Previously Chris wrote:

Hi

 

I have the following schema:

Class: Custom_Attribute

Domain Attribute2Attribute, Origin=Custom_Attribute, Destination=Custom_Attribute, 1:N

 

Class Custom_Attribute has an attribute (Parent, type REFERENCE, Domain Custom_Attribute, Filter: XXXXXXXX)

 

I have an extra Class: Item (with attribute UUID), and a Domain: ItemAttribute (Origin Item, Destination Custom_Attribute, Master/Detail yes, 1:N)

 

In different words, My Item Class can have multiple Custom_Attributes.  These can be linked in a tree structure via the Parent relationship.

 

My Problem: I cannot work out the Filter syntax on Custom_Attribute.Parent to only show Custom_Attributes related to the same Item.

 

I have tried as per the manual's examples with building and floor

 

from Custom_Attribute where [ItemAttribute].objects(Id=0{client.Custom_Attribute.Id}), which returns no Custom_Attributes

 

from Custom_Attribute where [ItemAttribute].objects(Id={client.Custom_Attribute.Id}), which returns all Custom_Attributes

 

Is there any CQL language reference, which can explain the syntax fully , or a SQL to CQL conversion guide?