Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Regular Contributor
Posts: 163
Registered: ‎11-17-2015
Accepted Solution

GMSC Plugin - Run predefined query programatically

Hello,

How can I run a predefined query (created in GMSC Administrator) from a JAVA plugin?

Thank you!

Yohann.

Regular Contributor
Posts: 163
Registered: ‎11-17-2015

Re: GMSC Plugin - Run predefined query programatically

Hello, 

 

Anyone has an idea?

I can access list of predefinied searches and run one.

I get a SearchResult. How can I open a datagrid filled by this result?

 

 

Thank you!

Yohann.

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: GMSC Plugin - Run predefined query programatically

Hi Yohann,

 

so you are using already the SearchController to get the PredefinedSearch and executing it?

 

Regards,

Steve

 

 

Regular Contributor
Posts: 163
Registered: ‎11-17-2015

Re: GMSC Plugin - Run predefined query programatically

Hello Steve,

 

Yes, my code looks like this :

 

List<PredefinedSearch> searches = ApplicationContext.getProject().getFeatureByTitle("MyFeatureName").getPredefinedSearches();
Map<String, String> searchCriterias = new HashMap<String, String>();
SearchResult searchResult = searches.get(0).execute(searchCriterias, selectedElements);

 

Thank you.

Yohann.

 

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: GMSC Plugin - Run predefined query programatically

change it to:

 

SearchController searchController = ApplicationContext.getProject().getSearchController();

// use searchController.getAllSearchesForFeature(FeatureID) or searchController.getAllSearches() or searchController.getSearchForFeatureAndName(FeatureID, String) to get the PredefinedSearch

PredefinedSearch searchToExecute = ....


Map<String, String> searchCriterias = new HashMap<String, String>();

Object[] selectedElements = ApplicationContext.getBrowser().getMapSelectionCurator().getSelectedElements();

searchController.executeSearch(searchToExecute, searchCriterias, selectedElements; 

Please keep in mind, I didn't tested it ;-) Therefore it could be possible that you will find some Syntax-Errors.

Regular Contributor
Posts: 163
Registered: ‎11-17-2015

Re: GMSC Plugin - Run predefined query programatically

Perfect! 

Thank you Steve!

Yohann.

Frequent Contributor
Posts: 115
Registered: ‎04-05-2016

Re: GMSC Plugin - Run predefined query programatically

[ Edited ]

Hi,

 

I have a problem with executing a search in my plugin. The datagrid is not rendered correctly when I run the execute and the datagrid is not open yet. Only when I mouseover the datagrid the elements get rendered.

 

When the datagrid is already open or I run the method twice, it gets rendered correctly.

 

Maybe this is also connected with the method being called during a GeometryCaptureAdapter run method?

 

I think it has to do with the executeSearch method being async but I don't know how to resolve the problem. Any ideas?

 

Thanks

Frequent Contributor
Posts: 115
Registered: ‎04-05-2016

Re: GMSC Plugin - Run predefined query programatically

The problem was caused by a TableModelListener which fired events in itself when it shouldn't and caused a circular effect

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.