feature_22286 #6
|
@ -47,7 +47,7 @@ public class ConstantsGeoPortalDataEntryApp {
|
||||||
* Sep 2, 2021
|
* Sep 2, 2021
|
||||||
*/
|
*/
|
||||||
public static enum RECORD_FIELD {
|
public static enum RECORD_FIELD {
|
||||||
NAME("nome", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"),
|
NAME("nome", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("authors", "Author/s"),
|
||||||
PROJECT_START_END_DATE("", "Project Start/End Date"), RECORD_STATUS("recordStatus", "Published with"), CREATED("creationTime", "Created"),
|
PROJECT_START_END_DATE("", "Project Start/End Date"), RECORD_STATUS("recordStatus", "Published with"), CREATED("creationTime", "Created"),
|
||||||
CREATED_BY("creationUser", "Created by");
|
CREATED_BY("creationUser", "Created by");
|
||||||
|
|
||||||
|
|
|
@ -118,9 +118,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
|
|
||||||
SearchingFilter initialSortFilter = new SearchingFilter(RECORD_FIELD.NAME, ORDER.ASC);
|
SearchingFilter initialSortFilter = new SearchingFilter(RECORD_FIELD.NAME, ORDER.ASC);
|
||||||
|
|
||||||
|
RECORD_FIELD[] searchForFields = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.AUTHOR};
|
||||||
|
|
||||||
RootPanel.get(DIV_PORTLET_ID).add(loader);
|
RootPanel.get(DIV_PORTLET_ID).add(loader);
|
||||||
|
|
||||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, initialSortFilter);
|
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, searchForFields, initialSortFilter);
|
||||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||||
|
|
||||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||||
|
|
|
@ -16,12 +16,14 @@ import org.gcube.portlets.user.geoportaldataentry.shared.ACTION_ON_ITEM;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchingFilter;
|
import org.gcube.portlets.user.geoportaldataentry.shared.SearchingFilter;
|
||||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchingFilter.ORDER;
|
import org.gcube.portlets.user.geoportaldataentry.shared.SearchingFilter.ORDER;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||||
import com.github.gwtbootstrap.client.ui.Tab;
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -102,7 +104,13 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
Dropdown dropdownSortBy;
|
Dropdown dropdownSortBy;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
TextBox textBoxSortBy;
|
Dropdown dropdownSearchFor;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Alert alertSortBy;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Alert alertSearchFor;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
NavLink navShowOnMap;
|
NavLink navShowOnMap;
|
||||||
|
@ -126,6 +134,8 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
|
|
||||||
private RECORD_FIELD[] sortByFields;
|
private RECORD_FIELD[] sortByFields;
|
||||||
|
|
||||||
|
private RECORD_FIELD[] searchForFields;
|
||||||
|
|
||||||
private SearchingFilter currentSortFilter;
|
private SearchingFilter currentSortFilter;
|
||||||
|
|
||||||
private GeonaRecordsPaginatedView grpw = null;
|
private GeonaRecordsPaginatedView grpw = null;
|
||||||
|
@ -137,13 +147,22 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
* @param sortByFields the sort by fields
|
* @param sortByFields the sort by fields
|
||||||
* @param initialSortFilter
|
* @param initialSortFilter
|
||||||
*/
|
*/
|
||||||
public GeonaMainTabPanel(HandlerManager appManagerBus, RECORD_FIELD[] sortByFields,
|
public GeonaMainTabPanel(HandlerManager appManagerBus, RECORD_FIELD[] sortByFields, RECORD_FIELD[] searchForFields,
|
||||||
SearchingFilter initialSortFilter) {
|
SearchingFilter initialSortFilter) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
this.appManagerBus = appManagerBus;
|
this.appManagerBus = appManagerBus;
|
||||||
this.sortByFields = sortByFields;
|
this.sortByFields = sortByFields;
|
||||||
this.currentSortFilter = initialSortFilter;
|
this.currentSortFilter = initialSortFilter;
|
||||||
textBoxSortBy.setText(toLabelFilter(initialSortFilter.getOrderByField(), initialSortFilter.getOrder()));
|
this.searchForFields = searchForFields;
|
||||||
|
|
||||||
|
alertSortBy.setType(AlertType.INFO);
|
||||||
|
alertSortBy.setClose(false);
|
||||||
|
|
||||||
|
alertSearchFor.setType(AlertType.INFO);
|
||||||
|
alertSearchFor.setClose(false);
|
||||||
|
|
||||||
|
alertSearchFor.setText(searchForFields[0].getDisplayName());
|
||||||
|
alertSortBy.setText(toLabelFilter(initialSortFilter.getOrderByField(), initialSortFilter.getOrder()));
|
||||||
bindEvents();
|
bindEvents();
|
||||||
resetSearch.setIconSize(IconSize.TWO_TIMES);
|
resetSearch.setIconSize(IconSize.TWO_TIMES);
|
||||||
resetSearch.setType(ButtonType.LINK);
|
resetSearch.setType(ButtonType.LINK);
|
||||||
|
@ -200,7 +219,7 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
textBoxSortBy.setText(labelASC);
|
alertSortBy.setText(labelASC);
|
||||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -214,12 +233,27 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
textBoxSortBy.setText(labelDESC);
|
alertSortBy.setText(labelDESC);
|
||||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (RECORD_FIELD record_FIELD : searchForFields) {
|
||||||
|
|
||||||
|
NavLink nav = new NavLink(record_FIELD.getDisplayName());
|
||||||
|
dropdownSearchFor.add(nav);
|
||||||
|
|
||||||
|
nav.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
alertSearchFor.setText(record_FIELD.getDisplayName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
navShowOnMap.addClickHandler(new ClickHandler() {
|
navShowOnMap.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -369,11 +403,20 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchingFilter builtSearchingFilter() {
|
private SearchingFilter builtSearchingFilter() {
|
||||||
SearchingFilter searchingFilter = toSortFilter(this.textBoxSortBy.getText());
|
SearchingFilter searchingFilter = toSortFilter(alertSortBy.getText());
|
||||||
String searchText = searchField.getText();
|
String searchText = searchField.getText();
|
||||||
if (searchText != null && !searchText.isEmpty()) {
|
if (searchText != null && !searchText.isEmpty()) {
|
||||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||||
searchInto.put(RECORD_FIELD.NAME.getJsonFieldName(), searchText);
|
|
||||||
|
String searchForField = RECORD_FIELD.NAME.getJsonFieldName();
|
||||||
|
|
||||||
|
for (RECORD_FIELD recordField : searchForFields) {
|
||||||
|
if(recordField.getDisplayName().equals(alertSearchFor.getText())) {
|
||||||
|
searchForField = recordField.getJsonFieldName();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
searchInto.put(searchForField, searchText);
|
||||||
searchingFilter.setSearchInto(searchInto);
|
searchingFilter.setSearchInto(searchInto);
|
||||||
}
|
}
|
||||||
return searchingFilter;
|
return searchingFilter;
|
||||||
|
|
|
@ -101,19 +101,30 @@
|
||||||
</b:Dropdown>
|
</b:Dropdown>
|
||||||
</b:Nav>
|
</b:Nav>
|
||||||
<b:Nav>
|
<b:Nav>
|
||||||
<b:TextBox ui:field="textBoxSortBy" readOnly="true"
|
<b:Alert ui:field="alertSortBy"
|
||||||
addStyleNames="{style.margin-top-8}"></b:TextBox>
|
addStyleNames="alert_box_nav"></b:Alert>
|
||||||
</b:Nav>
|
</b:Nav>
|
||||||
<b:Nav>
|
<b:Nav>
|
||||||
<b:NavLink ui:field="buttonReloadConcessioni"
|
<b:NavLink ui:field="buttonReloadConcessioni"
|
||||||
title="Create a new Project" icon="ROTATE_RIGHT">Reload Projects</b:NavLink>
|
title="Create a new Project" icon="ROTATE_RIGHT">Reload Projects</b:NavLink>
|
||||||
</b:Nav>
|
</b:Nav>
|
||||||
|
|
||||||
<b:TextBox ui:field="searchField"
|
<g:HTMLPanel addStyleNames="{style.display-right}">
|
||||||
addStyleNames="search-textbox" placeholder="Search"></b:TextBox>
|
<b:Nav>
|
||||||
<b:Button addStyleNames="{style.display-right}"
|
<b:Dropdown text="Search for"
|
||||||
icon="REMOVE_CIRCLE" ui:field="resetSearch"
|
ui:field="dropdownSearchFor">
|
||||||
title="Reset the search" visible="false"></b:Button>
|
</b:Dropdown>
|
||||||
|
</b:Nav>
|
||||||
|
<b:Nav>
|
||||||
|
<b:Alert ui:field="alertSearchFor"
|
||||||
|
addStyleNames="alert_box_nav"></b:Alert>
|
||||||
|
</b:Nav>
|
||||||
|
|
||||||
|
<b:TextBox ui:field="searchField"
|
||||||
|
addStyleNames="search-textbox" placeholder="type a text..."></b:TextBox>
|
||||||
|
<b:Button icon="REMOVE_CIRCLE" ui:field="resetSearch"
|
||||||
|
title="Reset the search" visible="false"></b:Button>
|
||||||
|
</g:HTMLPanel>
|
||||||
</b:Navbar>
|
</b:Navbar>
|
||||||
|
|
||||||
<g:HTMLPanel addStyleNames="{style.float-right}">
|
<g:HTMLPanel addStyleNames="{style.float-right}">
|
||||||
|
|
|
@ -137,7 +137,12 @@ h1 {
|
||||||
-webkit-border-radius: 15px;
|
-webkit-border-radius: 15px;
|
||||||
-moz-border-radius: 15px;
|
-moz-border-radius: 15px;
|
||||||
border-radius: 15px !important;
|
border-radius: 15px !important;
|
||||||
float: right !important;
|
|
||||||
width: 250px !important;
|
width: 250px !important;
|
||||||
margin-top: 8px !important;
|
margin-top: 8px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert_box_nav {
|
||||||
|
padding: 4px 10px !important;
|
||||||
|
margin-top: 8px !important;
|
||||||
|
margin-bottom: 10px !important;
|
||||||
|
}
|
||||||
|
|
|
@ -23,11 +23,13 @@ import org.gcube.portlets.user.geoportaldataentry.shared.RoleRights;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBList;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
|
import com.mongodb.BasicDBObjectBuilder;
|
||||||
|
|
||||||
public class TestClass {
|
public class TestClass {
|
||||||
|
|
||||||
private static String TOKEN = "8e74a17c-92f1-405a-b591-3a6090066248-98187548";
|
private static String TOKEN = "";
|
||||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||||
private static String USERNAME = "francesco.mangiacrapa";
|
private static String USERNAME = "francesco.mangiacrapa";
|
||||||
|
|
||||||
|
@ -64,11 +66,9 @@ public class TestClass {
|
||||||
Direction sDirection = Direction.ASCENDING;
|
Direction sDirection = Direction.ASCENDING;
|
||||||
List<String> orderByFields = Arrays.asList("nome");
|
List<String> orderByFields = Arrays.asList("nome");
|
||||||
|
|
||||||
String searchByField = "nome";
|
|
||||||
String serchValue = "mock";
|
|
||||||
|
|
||||||
Map<String, Object> searchFields = new HashMap<String, Object>();
|
Map<String, Object> searchFields = new HashMap<String, Object>();
|
||||||
searchFields.put(searchByField, serchValue);
|
searchFields.put("nome", "test");
|
||||||
|
searchFields.put("authors", "fra");
|
||||||
|
|
||||||
|
|
||||||
QueryRequest request = new QueryRequest();
|
QueryRequest request = new QueryRequest();
|
||||||
|
@ -88,29 +88,84 @@ public class TestClass {
|
||||||
|
|
||||||
if(searchFields!=null) {
|
if(searchFields!=null) {
|
||||||
|
|
||||||
// BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
||||||
// BasicDBObject bs = null;
|
|
||||||
// query = new Document();
|
|
||||||
//
|
|
||||||
// for (String key : searchFields.keySet()) {
|
|
||||||
// //builder.append(key, new BasicDBObject("$eq", searchFields.get(key)));
|
|
||||||
// //query.put(key, new BasicDBObject("$eq", searchFields.get(key)));
|
|
||||||
// query = new Document(key, searchFields.get(key));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// request.setFilter(query);
|
|
||||||
|
|
||||||
query = new Document();
|
query = new Document();
|
||||||
|
|
||||||
for (String key : searchFields.keySet()) {
|
for (String key : searchFields.keySet()) {
|
||||||
//query.put(key, searchFields.get(key));
|
//builder.append(key, new BasicDBObject("$eq", searchFields.get(key)));
|
||||||
query.put(key, new BasicDBObject("$eq", searchFields.get(key)));
|
BasicDBObject bs = new BasicDBObject();
|
||||||
|
bs.append("$regex", searchFields.get(key));
|
||||||
|
bs.append("$options", "i");
|
||||||
|
builder.append(key, bs);
|
||||||
|
//query.put(key, new BasicDBObject("$eq", searchFields.get(key)));
|
||||||
|
//query = new Document(key, searchFields.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// query.putAll(builder.get().toMap());
|
||||||
|
// request.setFilter(query);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BasicDBList list = new BasicDBList();
|
||||||
|
list.add(builder.get().toMap());
|
||||||
|
query.put("$or", list);
|
||||||
|
//or(query);
|
||||||
request.setFilter(query);
|
request.setFilter(query);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//************************************************ AND
|
||||||
|
// query = new Document();
|
||||||
|
// for (String key : searchFields.keySet()) {
|
||||||
|
// //AND
|
||||||
|
// BasicDBObject bs = new BasicDBObject();
|
||||||
|
// bs.append("$regex", searchFields.get(key));
|
||||||
|
// bs.append("$options", "i");
|
||||||
|
// query.put(key, bs);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// request.setFilter(query);
|
||||||
|
//******************************************** END AND
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//OR
|
||||||
|
/*query = new Document();
|
||||||
|
BasicDBObject container = new BasicDBObject();
|
||||||
|
BsonArray bArray = new BsonArray();
|
||||||
|
for (String key : searchFields.keySet()) {
|
||||||
|
//AND
|
||||||
|
BasicDBObject bs = new BasicDBObject();
|
||||||
|
bs.append("$regex", searchFields.get(key));
|
||||||
|
bs.append("$options", "i");
|
||||||
|
query.put(key, bs);
|
||||||
|
|
||||||
|
//container.put(key, bs);
|
||||||
|
|
||||||
|
|
||||||
|
// BasicDBObject bs2 = new BasicDBObject();
|
||||||
|
// bs2.append("$regex", searchFields.get(key));
|
||||||
|
// bs2.append("$options", "i");
|
||||||
|
// BsonDocument bsK = new BsonDocument();
|
||||||
|
// bsK.append(key, new BsonString(bs2.toJson()));
|
||||||
|
// bArray.add(bsK);
|
||||||
|
|
||||||
|
}
|
||||||
|
// query.put("$or", bArray);
|
||||||
|
|
||||||
|
BasicDBList list = new BasicDBList();
|
||||||
|
list.add(query);
|
||||||
|
|
||||||
|
Document orDocument = new Document();
|
||||||
|
orDocument.put("$or", list);
|
||||||
|
//
|
||||||
|
query = orDocument;
|
||||||
|
request.setFilter(query);*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
|
System.out.println("Paging offset: " + offsetIndex + ", limit: " + limitIndex);
|
||||||
System.out.println("Direction: " + sDirection);
|
System.out.println("Direction: " + sDirection);
|
||||||
System.out.println("Order by Fields: " + orderByFields);
|
System.out.println("Order by Fields: " + orderByFields);
|
||||||
|
@ -119,6 +174,10 @@ public class TestClass {
|
||||||
|
|
||||||
Iterator<Concessione> concessioni = clientMongo.query(request);
|
Iterator<Concessione> concessioni = clientMongo.query(request);
|
||||||
|
|
||||||
|
if(concessioni.hasNext()) {
|
||||||
|
System.out.println("Found concessioni, printing them...");
|
||||||
|
}else
|
||||||
|
System.out.println("No concessione found");
|
||||||
|
|
||||||
if (concessioni != null) {
|
if (concessioni != null) {
|
||||||
while (concessioni.hasNext()) {
|
while (concessioni.hasNext()) {
|
||||||
|
|
Loading…
Reference in New Issue