feature_22286 #6
|
@ -47,7 +47,7 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
* Sep 2, 2021
|
||||
*/
|
||||
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"),
|
||||
CREATED_BY("creationUser", "Created by");
|
||||
|
||||
|
|
|
@ -117,10 +117,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.RECORD_STATUS };
|
||||
|
||||
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);
|
||||
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, initialSortFilter);
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, searchForFields, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
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.ORDER;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Dropdown;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
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.IconSize;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -100,9 +102,15 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@UiField
|
||||
Dropdown dropdownSortBy;
|
||||
|
||||
@UiField
|
||||
Dropdown dropdownSearchFor;
|
||||
|
||||
@UiField
|
||||
TextBox textBoxSortBy;
|
||||
Alert alertSortBy;
|
||||
|
||||
@UiField
|
||||
Alert alertSearchFor;
|
||||
|
||||
@UiField
|
||||
NavLink navShowOnMap;
|
||||
|
@ -125,6 +133,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
private HandlerManager appManagerBus;
|
||||
|
||||
private RECORD_FIELD[] sortByFields;
|
||||
|
||||
private RECORD_FIELD[] searchForFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
|
@ -137,13 +147,22 @@ public class GeonaMainTabPanel extends Composite {
|
|||
* @param sortByFields the sort by fields
|
||||
* @param initialSortFilter
|
||||
*/
|
||||
public GeonaMainTabPanel(HandlerManager appManagerBus, RECORD_FIELD[] sortByFields,
|
||||
public GeonaMainTabPanel(HandlerManager appManagerBus, RECORD_FIELD[] sortByFields, RECORD_FIELD[] searchForFields,
|
||||
SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.appManagerBus = appManagerBus;
|
||||
this.sortByFields = sortByFields;
|
||||
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();
|
||||
resetSearch.setIconSize(IconSize.TWO_TIMES);
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
@ -200,7 +219,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
textBoxSortBy.setText(labelASC);
|
||||
alertSortBy.setText(labelASC);
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
}
|
||||
});
|
||||
|
@ -214,11 +233,26 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
textBoxSortBy.setText(labelDESC);
|
||||
alertSortBy.setText(labelDESC);
|
||||
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() {
|
||||
|
||||
|
@ -369,11 +403,20 @@ public class GeonaMainTabPanel extends Composite {
|
|||
}
|
||||
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(this.textBoxSortBy.getText());
|
||||
SearchingFilter searchingFilter = toSortFilter(alertSortBy.getText());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
return searchingFilter;
|
||||
|
|
|
@ -101,19 +101,30 @@
|
|||
</b:Dropdown>
|
||||
</b:Nav>
|
||||
<b:Nav>
|
||||
<b:TextBox ui:field="textBoxSortBy" readOnly="true"
|
||||
addStyleNames="{style.margin-top-8}"></b:TextBox>
|
||||
<b:Alert ui:field="alertSortBy"
|
||||
addStyleNames="alert_box_nav"></b:Alert>
|
||||
</b:Nav>
|
||||
<b:Nav>
|
||||
<b:NavLink ui:field="buttonReloadConcessioni"
|
||||
title="Create a new Project" icon="ROTATE_RIGHT">Reload Projects</b:NavLink>
|
||||
</b:Nav>
|
||||
|
||||
<b:TextBox ui:field="searchField"
|
||||
addStyleNames="search-textbox" placeholder="Search"></b:TextBox>
|
||||
<b:Button addStyleNames="{style.display-right}"
|
||||
icon="REMOVE_CIRCLE" ui:field="resetSearch"
|
||||
title="Reset the search" visible="false"></b:Button>
|
||||
<g:HTMLPanel addStyleNames="{style.display-right}">
|
||||
<b:Nav>
|
||||
<b:Dropdown text="Search for"
|
||||
ui:field="dropdownSearchFor">
|
||||
</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>
|
||||
|
||||
<g:HTMLPanel addStyleNames="{style.float-right}">
|
||||
|
|
|
@ -137,7 +137,12 @@ h1 {
|
|||
-webkit-border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px !important;
|
||||
float: right !important;
|
||||
width: 250px !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.Test;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.BasicDBObjectBuilder;
|
||||
|
||||
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 USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
|
@ -64,11 +66,9 @@ public class TestClass {
|
|||
Direction sDirection = Direction.ASCENDING;
|
||||
List<String> orderByFields = Arrays.asList("nome");
|
||||
|
||||
String searchByField = "nome";
|
||||
String serchValue = "mock";
|
||||
|
||||
Map<String, Object> searchFields = new HashMap<String, Object>();
|
||||
searchFields.put(searchByField, serchValue);
|
||||
searchFields.put("nome", "test");
|
||||
searchFields.put("authors", "fra");
|
||||
|
||||
|
||||
QueryRequest request = new QueryRequest();
|
||||
|
@ -88,29 +88,84 @@ public class TestClass {
|
|||
|
||||
if(searchFields!=null) {
|
||||
|
||||
// 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);
|
||||
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
||||
|
||||
|
||||
|
||||
query = new Document();
|
||||
|
||||
|
||||
for (String key : searchFields.keySet()) {
|
||||
//query.put(key, searchFields.get(key));
|
||||
query.put(key, new BasicDBObject("$eq", searchFields.get(key)));
|
||||
//builder.append(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);
|
||||
|
||||
|
||||
|
||||
//************************************************ 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("Direction: " + sDirection);
|
||||
System.out.println("Order by Fields: " + orderByFields);
|
||||
|
@ -119,6 +174,10 @@ public class TestClass {
|
|||
|
||||
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) {
|
||||
while (concessioni.hasNext()) {
|
||||
|
|
Loading…
Reference in New Issue