collection query retrieval redundancy fix;
native jsonnode mapping of request values for query function;
resource interface usage for secured resources;
class specification for resource mapping;
auditable annotation extension to class (untested)
general refactoring in security module
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQuery.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQuery.java
index cb04f90..5cdd28c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQuery.java
@@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Multiset;
import java.io.IOException;
import java.util.*;
@@ -101,14 +102,17 @@
}
// fixme: map can only have one key/value pair. thus,
- // text class can only be added once. Multiple types are not possible!
+ // fixme: text class can only be added once. Multiple types are not possible!
public CollectionQuery addMetaFilter(String queries) {
Multimap<String, String> m = resEq(queries);
boolean multypes = m.keys().size() > 1;
String def_key = null;
- if (!multypes)
- def_key = m.keys().toArray(new String[0])[0];
+
+ if (!multypes){
+ Multiset<String> keys = m.keys();
+ def_key = keys.toArray(new String[keys.size()])[0];
+ }
List value = this.createValue(m);
// todo: missing: - takes only one resource, but resources can be chained!
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index e6ffbe6..6e8fb62 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -105,13 +105,11 @@
* @param outFile The file to which the serialization is written
* @param query The query string
* @param queryLanguage The query language. As of 13/11/20, this must be either 'poliqarp' or 'poliqarpplus'. Some extra maven stuff needs to done to support CosmasII ('cosmas') [that maven stuff would be to tell maven how to build the cosmas grammar and where to find the classes]
- * @throws JsonGenerationException
- * @throws JsonMappingException
* @throws IOException
* @throws QueryException
*/
public void run(String query, String queryLanguage, String outFile)
- throws JsonGenerationException, JsonMappingException, IOException, QueryException {
+ throws IOException, QueryException {
if (queryLanguage.equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
} else if (queryLanguage.toLowerCase().equals("cosmas2")) {
@@ -125,7 +123,7 @@
mapper.writeValue(new File(outFile), requestMap);
}
- public String buildQuery(String query, String ql, List<String> parents,
+ public String buildQuery(String query, String ql, String collection,
String cli, String cri, int cls, int crs,
int num, int page, boolean cutoff)
throws QueryException {
@@ -146,8 +144,6 @@
}
Map<String, Object> requestMap = ast.getRequestMap();
- CollectionQuery collectionQuery = new CollectionQuery();
- collectionQuery.addResources(parents);
MetaQuery meta = new MetaQuery();
meta.addContext(cls, cli, crs, cri);
@@ -155,19 +151,12 @@
meta.addEntry("startPage", page);
meta.addEntry("count", num);
- try
-
- {
- requestMap.put("collections", collectionQuery.raw());
+ try {
+ requestMap.put("collections", collection);
requestMap.put("meta", meta.raw());
return mapper.writeValueAsString(requestMap);
- } catch (
- IOException e
- )
-
- {
+ } catch (IOException e){
return "";
}
-
}
}