feature_22506 #3
|
@ -23,6 +23,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBList;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
import com.mongodb.BasicDBObjectBuilder;
|
import com.mongodb.BasicDBObjectBuilder;
|
||||||
|
|
||||||
|
@ -178,8 +179,20 @@ public class MongoServiceCommon {
|
||||||
bs.append("$regex", searchFields.get(key));
|
bs.append("$regex", searchFields.get(key));
|
||||||
bs.append("$options", "i");
|
bs.append("$options", "i");
|
||||||
builder.append(key, bs);
|
builder.append(key, bs);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
query = new Document(builder.get().toMap());
|
//Building list of Document in OR clause
|
||||||
|
BasicDBList list = new BasicDBList();
|
||||||
|
Map map = builder.get().toMap();
|
||||||
|
for (Object key : map.keySet()) {
|
||||||
|
|
||||||
|
BasicDBObject value = (BasicDBObject) map.get(key);
|
||||||
|
Document doc = new Document((String) key, value);
|
||||||
|
list.add(doc);
|
||||||
|
}
|
||||||
|
query = new Document();
|
||||||
|
query.put("$or", list);
|
||||||
request.setFilter(query);
|
request.setFilter(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package org.gcube.application;
|
package org.gcube.application;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||||
import org.gcube.application.geoportalcommon.config.GNADataConfigProfileReader;
|
import org.gcube.application.geoportalcommon.config.GNADataConfigProfileReader;
|
||||||
|
@ -47,14 +50,18 @@ public class TestGNACommon {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
@Test
|
||||||
public void queryConcessioniTest() throws Exception {
|
public void queryConcessioniTest() throws Exception {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ScopeProvider.instance.set(CONTEXT);
|
ScopeProvider.instance.set(CONTEXT);
|
||||||
MongoServiceCommon msc = new MongoServiceCommon();
|
MongoServiceCommon msc = new MongoServiceCommon();
|
||||||
SearchingFilter filter = new SearchingFilter();
|
SearchingFilter filter = new SearchingFilter();
|
||||||
// filter.setSearchInto(new Se);
|
|
||||||
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||||
|
//searchInto.put("nome", "mock");
|
||||||
|
searchInto.put("authors", "annalisa");
|
||||||
|
filter.setSearchInto(searchInto);
|
||||||
ResultSetPaginatedData result = msc.queryOnMongo(30, 0, 30, filter, "concessione");
|
ResultSetPaginatedData result = msc.queryOnMongo(30, 0, 30, filter, "concessione");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
Loading…
Reference in New Issue