why contains keyword is not working on rally api query - api

I am trying to query on rally api by using below
req.Query = new Query("User.ObjectID", Query.Operator.Equals, loggedinUser.ToString()).And(new Query("Role", Query.Operator.Contains, Role).And(new Query("Workspace.ObjectID", Query.Operator.Contains, workspaceID)).And(new Query("Project.ObjectID", Query.Operator.Equals, projectObjectID)));
But it is throwing error as
The operator [ contains ] is not supported for this attribute type. The available operators are [ =, !=, >, <, >=, <=, in ]
is it contains key word is deprecated? please help me alternative in such case.

You can't use contains for an object id- that attribute is numeric. contains is reserved for strings and collections.
It's the Workspace.ObjectID specifically that's ruining your day. Change it to equals and you should be good to go.

As per
https://communities.ca.com/thread/241816885-why-contains-keyword-is-not-working-on-rally-api-query?et=watches.email.outcome
contains no longer supports in such type of queries but previously it is worked.
Its working when I replaced 'Contains' with 'Equals' as
req.Query = new Query("User.ObjectID", Query.Operator.Equals, loggedinUser.ToString()).And(new Query("Role", Query.Operator.Equals, Role).And(new Query("Workspace.ObjectID", Query.Operator.Equals, workspaceID)).And(new Query("Project.ObjectID", Query.Operator.Equals, projectObjectID)));

Related

Using filter operators (<, >, <=, >=, or) in Directus

I want to filter with these specific operators:
- "<", ">", "<=", ">=" for integer and date values.
- "or" for text fields.
PS: my question concerns the admin backend UI not the underlying API.
This has been added in the last major release of Directus (v7)

Population of a selection box base on the Other Selection Box

Good Day! I have a problem I am trying to populate a Selection box base on the selected data on the other selection box here is my code
.py
licensetype = fields.Many2one('hr.licensetype','License Type')
license = fields.Many2one('hr.license','License')
#api.one
#api.onchange('licensetype')
def getlicense(self):
if len(self.licensetype) > 0:
mdlLicense= self.env['hr.license'].search([('license_name', '=', int(self.licensetype[0]))])
#raise Warning(mdlLicense.ids)
self.license = mdlLicense.ids
but still it populate all license I want to populate the License based on the selected License type. This is in Odoo8
Domains
A domain is a list of criteria, each criteria being a triple (either a list or a tuple) of (field_name, operator, value).
Here,
field_name :
It's string type and must be from the current model or any relational traversal field through the Many2one/One2many field using membership (.) dot operator.
- operator : It's for comparing field's value with passed value.
Valid operator list (>, >=, <, <=, =, !=, =?, ilike, like =like, =ilike, not like, not ilike, childs_of, in, not in)
value : It's for comparing with field's value.
Multiple criteria can be joined with three logical operators.
Logical AND, logical OR, logical NOT.
Read more about domain
You can easily achieve this by defining domain for that field, no need to write any extra code.
Just put domain in your xml code.
<field name="licensetype" />
<field name="license" domain="[('licensetype','=',licensetype)]" />
Note :
Remember there must be relation between hr.license and hr.licensetype. licensetype must be Many2one in hr.license.
It will give the same effect as you want.

How to filter by dateHour on Google Analytics API?

I'm trying to retrieve results from the Google Analytics API that are between two specific dateHours. I tried to use the following filter:
'filters' => 'ga:dateHour>2013120101;ga:dateHour<2013120501'
But this doesn't work. What do I need to do? (I've used other filters before, and they work just fine).
First off, you're trying to use greater than and less than on a dimension which doesn't work. Dimension filters only allow ==, !=, =#, !#,=~, and !=.
So, if you want to get ga:dateHour, you'll have to use a regex filter:
ga:dateHour=~^2013120([1-4][0-2][0-9]|500)$;ga:dateHour!~^201312010[0-1]$
EDIT:
I wouldn't hesitate a second to learn RegEx, especially if you're a programmer. Here is a great SO post on learning regular expressions.
So, to break it down:
=~ looking to match the following regex
!= not looking to match the following regex
(check out GA's filter operators)
^ at the start of a string
2013120 since the entire dateHour range contained this string of numbers, look for that
([1-4][0-2][0-9]|500) match every number after 2013120, so the first [1-4] will match 20131201, 20131202, 20131203, and 20131204, then within those strings we want the next number to be [0-2] and likewise with [0-9]. So look at each [ ] as a placeholder for a range of digits.
| means or
500 says, we only want 500 and nothing more, so it's very specific.
The whole statement is wrapped in () so we can say he, match [1-4][0-2][0-9] OR 500, after 2013120.
Then, we end it with $ to signify the end of the string.
This probably isn't the most concise way to describe how this filter is working, but what I would do is use a website like regexpal or some other regex testing tool, and get the range you'd like to filter and start writing regex.
Best of luck!

SQL from where like with or statement

I have a SQL statement to search for an application by name.
def apps = Application.findAll("from Application as app where lower(app.name) like '%${params.query.toLowerCase()}%' ")
I want to not just be able to search by the applications name, but by different properties such as type and language. How would I add or statements to allow me to do this. Thanks!
It's not clear (to me) what framework you're using, or what specific RDBMS your database is on, but the overall thrust of SQL conditions is usually pretty simple.
Pretty much, like most other computer languages, you use and/or/not statements. Of course, in SQL you use the words, instead of (what are usually) symbols:
AND instead of &&
OR instead of ||
NOT instead of !
along with the standard comparison operators:
<, <=, =, <>, >, >=
Note that 'equals' is only a single = sign, and 'not equals' is usually opposed angle brackets <>.
So, given your current statement, if you wanted to only get those applications in the user's language, and exclude apps that are 'disabled', you could do something like the following:
def apps = Application.findAll("from Application as app
where lower(app.name) like '%${params.query.toLowerCase()}%'
and app.language = userLanguageParameter
and app.status <> inactiveAppStatus ");

Semantics of = and !=

In XQuery,
("foo", "bar") = ("foo", "bar")
yields the value true. That seems obvious. But I noticed that
("foo", "bar") != ("foo", "bar")
also yields true, which I found rather surprising. I know that I can negate = with not($x = $y) and I've noticed that = has some kind of set intersection semantics, but can anyone explains the semantics of !=, and/or provide a reference for it?
XQuery = and != are existential operators. They yield true if any element in the left set together with any element in the right set would return true for this operator (so actually same semantics for =, !=, >, ... - all the comparison operators without alphabetical characters).
("foo", "bar") != ("foo", "bar")
"foo" on the left side is != "bar" on the right side, so the whole comparison is true.
You probably want to use deep-equal for the equals-comparison and its negated version for the not-equals-comparison as you already proposed in your question.
This can be found in the documentation for XQuery under section "3.5.2 General Comparisons".
The following example contains two general comparisons, both of which
are true. This example illustrates the fact that the = and !=
operators are not inverses of each other.
(1, 2) = (2, 3)
(1, 2) != (2, 3)
Reading into the reasoning, it reads to me as if the rules of Atomization are to blame here. If the elements are untypedAtomic, then the parser is free to "guess" at how the comparison should be made which allows for the difference in operations based on the elements themselves rather than on any operator behavior.