CMDBuild Forum

CQL missing in REST v3

Hello,

I can’t find any reference to the cql endpoint in the latest REST Web service documentation (v3). Also the cql endpoint responds 404. Has it been deprecated?

If so, what is the expected alternative to do JOIN operations on multiple tables using REST v3?

Thanks

hi,

clear cql has been deprecated to avioid exposing sql/query details. The replacement is ecql, which works in a different way (and uses the standard …/cards ws).

If you could share with us an example of your cql query (full ws call with parameters, please), we can provide you a replacement query for v3.

thank you, regards,
CMDBuild Team

Trying to retrieve all Maintenance Requests associated to a specific CI, identified by its Code in an unique request.

The following worked well with v2:

http://localhost/cmdbuild/services/rest/v2/cql?filter={CQL: "from MaintRequest where Id in (/(select mr.\"Id\" from \"MaintRequest\" as mr join \"CI\" ci on ci.\"Id\" = mr.\"CI\" where ci.\"Code\"='my CI Code')/)"}

@tecnoteca, I used 2 requests to perform the desired behavior.

Is there any documentation related to ecql?

1 Like

Hi,

this is what I figured out so far to create a filter against REST V3.

{“attribute”:{“simple”:{“attribute”:“Code”,“operator”:“EQUAL”,“value”:“your_value_here”}}}

Obviously you pass that as a URL parameter named “filter”.

You query against : YOUR_URL_HERE/services/rest/v3/classes/YOUR_CLASS_HERE/cards/

  1. The first attribute can be ‘and’,‘or’,‘simple’,‘not’ (if you want to create more complex filters)
  2. The second attribute is the attribute of the class you’re querying
  3. Operator can be [EQUAL, NOTEQUAL, ISNULL, ISNOTNULL, GREATER, LESS, BETWEEN, LIKE, CONTAIN, NOTCONTAIN, DESCRIPTION_CONTAINS, BEGIN, NOTBEGIN, END, NOTEND, IN, NET_CONTAINED, NET_CONTAINEDOREQUAL, NET_CONTAINS, NET_CONTAINSOREQUAL, NET_RELATION, FALSE]
  4. Value is self explaining.

HTH

Alex

Hello,
(I hope I’m not hijacking this thread :slight_smile:)

I’m also facing a similar (if not equal) problem as rokin.

I’m trying to make a filter that involves two classes:

let us say class A and class B.

They share a domain with relation 1:N (A:B).

(what is the HTTP-Get request I need to perform)
To list/select all the fields from both A and B,
where A.X>10 and B.Y > 5

Best regards,
André

PS: If I could have access to the ecql API/source code (which file @ bitbucket), I could try to solve this by myself :slight_smile: otherwise I’m stuck with guessing how to solve this.

PS2: I’m afraid that most of us (end-users) use CQL only to perform SQL queries. Without any “real” documentation it’s unrealistically challenging trying to learn CQL.

PS3: Don’t get me wrong, I do appreciate all the functionalities and capabilities of CMDBUILD (Openmaint) complete time saver (for me), allowing to deploy solutions much faster than before :slight_smile:

@alexweirig Alex,

do you have an example with two conditions connected with OR or AND?

For example, I counstructed a dictionary as

params = {
‘filter’: json.dumps({
“attribute”: {
‘and’: [
{
“attribute”:“PersonName”,
“operator”:“EQUAL”,
“value”:“Name”
},
{
“attribute”:“PersonSurname”,
“operator”:“EQUAL”,
“value”:“Surname”
}
]}
})
}

But it doesn’t work. Error message is:
(invalid top-level key, must be one of ‘and’,‘or’,‘simple’,‘not’)’}]}

Simple attribute works, but I don’t know how to construct multiple conditions.
I tried several approaches but with no succes.

Please provide dictionary format if you can.

Best regards.

I found it.

data = {
‘filter’: json.dumps(
{‘attribute’: {‘and’: [{‘simple’: {‘attribute’: ‘attribute1’,
‘operator’: ‘contain’,
‘value’: [‘value1’]}},
{‘simple’: {‘attribute’: ‘attribute2’,
‘operator’: ‘contain’,
‘value’: [‘value2’]}}]},
‘relation’: [{‘destination’: ‘class’,
‘direction’: ‘_1’,
‘domain’: ‘domain_name’,
‘source’: ‘source_class’,
‘type’: ‘any’}]}
)
}