It's all about the answers!

Ask a question

query in a custom policy


Darrell Schrag (62) | asked Apr 08 '10, 8:01 p.m.
I need to query for another asset as part of a custom policy. I noticed there is the AssetManager class that accepts a String text query. What is the format of the query?

I essentially need the query to look like this (using SQL-like syntax)

select * from assets where (type="TypeA") and (community="CommunityA") and (Category="Domain.SuperCat.SubCat") and (Category="Team.SuperTeam.SubTeam")

So essentially I need to find an asset of a certain type and of a certain community that has 2 different particular Category Schema values.

3 answers



permanent link
Gili Mendel (1.8k56) | answered Apr 09 '10, 9:34 a.m.
JAZZ DEVELOPER
Use the Web UI to do the search with your filters, and then click on search shortcut icon (on to the right of the search box with a little maginfying glass).... it will give you the search shortcut for the current query.


permanent link
Darrell Schrag (62) | answered Apr 09 '10, 11:41 a.m.
I have tried everything but nothing works. I have tried every permutation of the query string I can think of such as replacing %2c with a comma, removing the ramSearch prefix, etc. and nothing works. Actually, the string as it exists from the search page causes the policy to throw an exception. Always returns zero assets.

Here is my snippet:

AssetManager am = AssetManager.getInstance();

String query = "ramSearch:(1fType%2Cmapping)";
SearchResults sr;
try {
sr = am.searchAssets(user, query, false, false);
} catch (InvalidQueryException e) {
String message = (new StringBuilder("Unable to search for mapping asset")).toString();
result.setMessage(message);
result.setReturnCode(ResultDetail.ERROR);
return result;
}

AbstractSearchAsset assets[] = sr.getAssets();
if (assets.length < 1) {
String message = (new StringBuilder("Search for mapping asset did not return a result")).toString();
result.setMessage(message);
result.setReturnCode(ResultDetail.ERROR);
return result;
}

permanent link
Gili Mendel (1.8k56) | answered Apr 12 '10, 3:23 p.m.
JAZZ DEVELOPER
The am.searchAssets(user, query, false, false); is an internal API and may be removed in the near future.

Your answer


Register or to post your answer.