query in a custom policy
![]()
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
![]()
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.
|
![]()
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; } |
![]()
The am.searchAssets(user, query, false, false); is an internal API and may be removed in the near future.
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.