2

I trying to use this method in groovy,

groupedDocs = reader.selectGroupedDocs(last_update_date.toString()).get();

And this is my java code part for "selectGroupedDocs" method,

private List<Map<String, String>> selectGroupedDocs(String lastUpdateDate) {
            logger.warn("START :: selectGroupedDocs");
            String query = prepareQuery(SELECT_ALL_GROUPED_DOCES_BY_DATE, lastUpdateDate);

            DataStoreQuery.QueryResult result = dataStoreQuery.executeQuery(CMT_GROUPED_DOCS, query);

            List<Map<String, String>> resultMaps = result.getSelectResultAsMapRows().orElse(new ArrayList<>());
            logger.warn("Result Maps :: " + resultMaps);

            logger.warn("END :: selectGroupedDocs");

            return resultMaps;
        }

when I run it I get the following error,

groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.get() is applicable for argument types: () values: []
Possible solutions: get(int), get(int), set(int, java.lang.Object), set(int, java.lang.Object), grep(), grep()
    at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:138)
    at org.webharvest.runtime.processors.ScriptProcessor.execute(ScriptProcessor.java:74)
    at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
    at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
    at org.webharvest.runtime.Scraper.execute(Scraper.java:182)

What am I doing wrong?

1 Answers1

0

If you want the list to be assigned to groupedDocs, Remove the .get() from the below line

groupedDocs = reader.selectGroupedDocs(last_update_date.toString()).get();

The get method in the list expects an argument. If you are trying to assign a particular value in the list to groupedDocs you need to pass in an index in the get method in order to retrieve it.

Eg. groupedDocs = reader.selectGroupedDocs(last_update_date.toString()).get(1);

Shubham Saraswat
  • 559
  • 4
  • 11