|
|
|
@ -1,25 +1,32 @@
|
|
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.ItemField;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.GetListOfRecordsEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Alert;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
|
|
|
|
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.IconType;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
|
|
|
@ -75,6 +82,8 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
private HandlerManager appManagerBus;
|
|
|
|
|
|
|
|
|
|
private static final String LABEL_FILTER_SEPARATOR = " - ";
|
|
|
|
|
|
|
|
|
|
private ResultSetPaginatedData latestResult;
|
|
|
|
|
|
|
|
|
|
interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
|
|
|
|
}
|
|
|
|
@ -106,32 +115,35 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
|
|
for (ItemField record_FIELD : sortByFields) {
|
|
|
|
|
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
|
|
|
|
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
|
|
|
|
listBoxSortBy.addItem(labelASC);
|
|
|
|
|
listBoxSortBy.addItem(labelDESC);
|
|
|
|
|
if(record_FIELD.isSortable()) {
|
|
|
|
|
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
|
|
|
|
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
|
|
|
|
listBoxSortBy.addItem(labelASC);
|
|
|
|
|
listBoxSortBy.addItem(labelDESC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
|
|
|
|
|
|
|
|
|
if(latestResult!=null && latestResult.getData().size()>0) {
|
|
|
|
|
doSearchEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (ItemField record_FIELD : searchForFields) {
|
|
|
|
|
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
|
|
|
|
GWT.log("search for: "+record_FIELD);
|
|
|
|
|
if(record_FIELD.isSearchable()) {
|
|
|
|
|
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
|
|
|
|
|
// alertSearchFor.setText(listBoxSearchFor.getSelectedValue());
|
|
|
|
|
|
|
|
|
|
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
|
|
|
|
doSearchEvent();
|
|
|
|
|
}
|
|
|
|
@ -182,8 +194,10 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
searchField.setText("");
|
|
|
|
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
|
|
|
|
//appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
|
|
|
|
resetSearch.setVisible(false);
|
|
|
|
|
panelResults.clear();
|
|
|
|
|
latestResult = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -192,19 +206,30 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
private void searchConcessioni() {
|
|
|
|
|
|
|
|
|
|
SearchingFilter filter = getCurrentSortFilter();
|
|
|
|
|
|
|
|
|
|
panelResults.clear();
|
|
|
|
|
panelResults.add(new HTML("<hr>"));
|
|
|
|
|
panelResults.add(new LoaderIcon("Searching..."));
|
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
|
|
|
|
new AsyncCallback<ResultSetPaginatedData>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
// showLoading(false);
|
|
|
|
|
// Window.alert(caught.getMessage());
|
|
|
|
|
|
|
|
|
|
panelResults.clear();
|
|
|
|
|
panelResults.add(new HTML("<hr>"));
|
|
|
|
|
Alert alert = new Alert("Error on searching. Please, refresh or change it");
|
|
|
|
|
alert.setType(AlertType.ERROR);
|
|
|
|
|
alert.setClose(false);
|
|
|
|
|
panelResults.add(alert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(ResultSetPaginatedData result) {
|
|
|
|
|
|
|
|
|
|
latestResult = result;
|
|
|
|
|
|
|
|
|
|
panelResults.clear();
|
|
|
|
|
panelResults.add(new HTML("<hr>"));
|
|
|
|
@ -216,20 +241,24 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
|
|
|
|
|
FlexTable ft = new FlexTable();
|
|
|
|
|
ft.getElement().setClassName("table-results");
|
|
|
|
|
int i = 0;
|
|
|
|
|
int i = 1;
|
|
|
|
|
ft.setWidget(0, i, new HTML("Name"));
|
|
|
|
|
|
|
|
|
|
String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
|
|
|
|
|
|
|
|
|
boolean addIntroduction = false;
|
|
|
|
|
if(selValue.startsWith("name")) {
|
|
|
|
|
if(selValue.startsWith("name") || selValue.startsWith("any")) {
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Introduction"));
|
|
|
|
|
addIntroduction = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean addStaff = false;
|
|
|
|
|
if(selValue.startsWith("staff")) {
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Staff"));
|
|
|
|
|
if(selValue.startsWith("direttore")) {
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Authors"));
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Responsabile"));
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Editore"));
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Titolari"));
|
|
|
|
|
ft.setWidget(0, ++i, new HTML("Contributore"));
|
|
|
|
|
addStaff = true;
|
|
|
|
|
}
|
|
|
|
|
boolean addParole = false;
|
|
|
|
@ -242,12 +271,35 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
i = 1;
|
|
|
|
|
for (ConcessioneDV concessione : result.getData()) {
|
|
|
|
|
int j = -1;
|
|
|
|
|
|
|
|
|
|
NavLink locateOnMap = new NavLink("Show");
|
|
|
|
|
locateOnMap.setTitle("Locate on the Map and show details");
|
|
|
|
|
locateOnMap.setIcon(IconType.MAP_MARKER);
|
|
|
|
|
|
|
|
|
|
locateOnMap.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
|
|
|
|
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
|
|
|
|
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ft.setWidget(i, ++j, locateOnMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
|
|
|
|
if(addIntroduction)
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 100)));
|
|
|
|
|
|
|
|
|
|
if(addStaff) {
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
|
|
|
|
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addParole) {
|
|
|
|
@ -276,7 +328,7 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
// if (!imagePreviewFound) {
|
|
|
|
|
// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -346,15 +398,22 @@ public class SearchFacilityUI extends Composite {
|
|
|
|
|
if (searchText != null && !searchText.isEmpty()) {
|
|
|
|
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
String searchForField = "";
|
|
|
|
|
List<String> listOfSeachingFields = new ArrayList<String>();
|
|
|
|
|
|
|
|
|
|
for (ItemField recordField : searchForFields) {
|
|
|
|
|
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
|
|
|
|
searchForField = recordField.getJsonFields().get(0);
|
|
|
|
|
listOfSeachingFields = recordField.getJsonFields();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
searchInto.put(searchForField, searchText);
|
|
|
|
|
|
|
|
|
|
if(listOfSeachingFields.size()==0) {
|
|
|
|
|
listOfSeachingFields.add("nome");
|
|
|
|
|
}
|
|
|
|
|
for (String fieldname : listOfSeachingFields) {
|
|
|
|
|
searchInto.put(fieldname, searchText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchingFilter.setSearchInto(searchInto);
|
|
|
|
|
}
|
|
|
|
|
return searchingFilter;
|
|
|
|
|