feature_22286 #6
|
@ -1,16 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry including="**/*.java" kind="src" output="target/geoportal-data-entry-app-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
|
@ -35,5 +30,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-2.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/geoportal-data-entry-app-2.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.1-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.1.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,8 +17,16 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-2.0.1-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-2.1.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +45,11 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -56,7 +68,11 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -75,7 +91,10 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
<dependent-module archiveName="geoportal-data-common-1.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -93,27 +112,16 @@
|
|||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -132,7 +140,11 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -151,7 +163,11 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,15 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v2.1.0-SNAPSHOT] - 2021-11-24
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#22455] Integrated with roles: (Data-Member as default), Data-Manager, Data-Editor
|
||||
- [#22287] Integrated with base search, ordering and filtering facility provided by MongoDB
|
||||
- [#22506] Re-engineered the common utilities
|
||||
|
||||
|
||||
## [v2.0.1] - 2021-11-17
|
||||
|
||||
- [#22369] Just to include the bug fix for Policy and LicenseID in the geoportal-common
|
||||
|
|
18
pom.xml
18
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>geoportal-data-entry-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.0.1</version>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<name>GeoPortal Data Entry App</name>
|
||||
<description>The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project</description>
|
||||
<scm>
|
||||
|
@ -209,6 +209,22 @@
|
|||
update them in DevMode -->
|
||||
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.csv</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
||||
<!-- <resource> -->
|
||||
<!-- <directory>src/main/resources</directory> -->
|
||||
<!-- <includes> -->
|
||||
<!-- <include>**/*.*</include> -->
|
||||
<!-- </includes> -->
|
||||
<!-- </resource> -->
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<!-- GWT Maven Plugin -->
|
||||
|
|
|
@ -17,8 +17,6 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
|
||||
public static final String HOURS_MINUTES_SEPARATOR = ConstantsMPFormBuilder.HOURS_MINUTES_SEPARATOR;
|
||||
|
||||
public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!";
|
||||
|
||||
/**
|
||||
* The Enum RECORD_TYPE.
|
||||
*
|
||||
|
@ -31,49 +29,13 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
}
|
||||
|
||||
/**
|
||||
* The Enum ACTION_ON_ITEM.
|
||||
* The Enum ACTION_PERFORMED_ON_ITEM.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public enum ACTION_ON_ITEM {
|
||||
SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, SHOW_EDIT_MODE, DELETE_RECORD, UPDATED_RECORD
|
||||
public enum ACTION_PERFORMED_ON_ITEM {
|
||||
UPDATED_PROJECT
|
||||
}
|
||||
|
||||
/**
|
||||
* The Enum RECORD_FIELD.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 2, 2021
|
||||
*/
|
||||
public static enum RECORD_FIELD {
|
||||
NAME("name", "Name"), INTRODUCTION("introduction", "Introduction"), AUTHOR("author", "Author/s"),
|
||||
PROJECT_START_END_DATE("", "Project Start/End Date"), RECORD_STATUS("recordStatus", "Published with"), CREATED("created", "Created"),
|
||||
CREATED_BY("createdBy", "Created by");
|
||||
|
||||
String jsonFieldName;
|
||||
String displayName;
|
||||
|
||||
/**
|
||||
* Instantiates a new record field.
|
||||
*
|
||||
* @param jsonFieldName the json field name
|
||||
* @param displayName the display name
|
||||
*/
|
||||
RECORD_FIELD(String jsonFieldName, String displayName) {
|
||||
this.jsonFieldName = jsonFieldName;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getJsonFieldName() {
|
||||
return jsonFieldName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,22 +8,32 @@ import java.util.List;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
||||
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
|
@ -35,10 +45,10 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_
|
|||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
|
@ -58,6 +68,7 @@ import com.google.gwt.user.client.Window;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
|
@ -82,7 +93,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>();
|
||||
|
||||
private GeonaDataEntryMainForm geoNaMainForm;
|
||||
private GeonaDataEntryMainForm geoNaMainForm = null;
|
||||
|
||||
private Collection<GeoNaFormCardModel> orderedCards;
|
||||
|
||||
|
@ -94,44 +105,245 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
private GeonaRecordsPaginatedView grpw = null;
|
||||
|
||||
private UserRights myRights = null;
|
||||
|
||||
private LoaderIcon loader = new LoaderIcon("Loading Application...");
|
||||
|
||||
private List<ItemField> displayFields = new ArrayList<ItemField>();
|
||||
private List<ItemField> sortByFields = new ArrayList<ItemField>();
|
||||
private List<ItemField> searchByFields = new ArrayList<ItemField>();
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
|
||||
RECORD_FIELD[] sortByOptions = new RECORD_FIELD[] { RECORD_FIELD.NAME, RECORD_FIELD.PROJECT_START_END_DATE,
|
||||
RECORD_FIELD.CREATED, RECORD_FIELD.CREATED_BY, RECORD_FIELD.RECORD_STATUS };
|
||||
RootPanel.get(DIV_PORTLET_ID).add(loader);
|
||||
|
||||
SortFilter initialSortFilter = new SortFilter(RECORD_FIELD.NAME, ORDER.ASC);
|
||||
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, sortByOptions, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
||||
/*GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback<List<ItemField>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
||||
Window.alert(caught.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GeonaISConfig result) {
|
||||
public void onSuccess(List<ItemField> result) {
|
||||
|
||||
if (result != null && result.getgRSecondaryType() != null && result.getScope() != null) {
|
||||
callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
|
||||
} else
|
||||
Window.alert(
|
||||
ConstantsGeoPortalDataEntryApp.ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT);
|
||||
for (ItemField itemField : result) {
|
||||
if(itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GWT.log("List display fields: "+result);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
||||
|
||||
displayFields = result;
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().readDataViewerConfig(new AsyncCallback<GNADataEntryExtConfigProfile>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
|
||||
Alert alert = new Alert(errorMsg, AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
RootPanel.get(DIV_PORTLET_ID).add(alert);
|
||||
Window.alert(errorMsg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) {
|
||||
|
||||
try {
|
||||
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
List<ItemField> itemFields = gNADataEntryConfig.getListItemFields();
|
||||
|
||||
for (ItemField itemField : itemFields) {
|
||||
if(itemField.isDisplayAsResult()) {
|
||||
displayFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSearchable()) {
|
||||
searchByFields.add(itemField);
|
||||
}
|
||||
|
||||
if(itemField.isSortable()) {
|
||||
sortByFields.add(itemField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GWT.log("List display fields: "+itemFields);
|
||||
SearchingFilter initialSortFilter = new SearchingFilter();
|
||||
initialSortFilter.setOrder(ORDER.ASC);
|
||||
initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
||||
|
||||
displayFields = itemFields;
|
||||
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter);
|
||||
mainTabPanel.setLoaderVisible("Loading...", true);
|
||||
|
||||
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
|
||||
//PERMISSIONS
|
||||
myRights = gNADataEntryConfig.getUserRights();
|
||||
initGUI();
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
String msg = "Logged in as ";
|
||||
if(userRole != null && userRole.getName()!=null) {
|
||||
msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length());
|
||||
}else
|
||||
msg+="Member";
|
||||
|
||||
mainTabPanel.setRoleLabel(msg);
|
||||
|
||||
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT);
|
||||
|
||||
if (!canCreateNewItem) {
|
||||
// removing Tab "Create New Project"
|
||||
mainTabPanel.removeTab(0);
|
||||
// activating Tab "List of Project"
|
||||
mainTabPanel.setTabActive(0);
|
||||
mainTabPanel.instanceAndShowListOfConcessioni();
|
||||
return;
|
||||
}
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(
|
||||
"Sorry, an error occurrend when loading configurations. Please, contact the support");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GeonaISConfig result) {
|
||||
|
||||
if (result != null && result.getGenericResourceSecondaryType() != null
|
||||
&& result.getScope() != null) {
|
||||
callGetMetadataProfiles(result.getScope(), result.getGenericResourceSecondaryType());
|
||||
} else
|
||||
Window.alert(
|
||||
"Sorry, no configuration found in the context. Please, contact the support");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
bindEvents();
|
||||
mainTabPanel.addFormPanel(geoNaMainForm);
|
||||
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
||||
|
||||
|
||||
// GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback<UserRights>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
|
||||
// Alert alert = new Alert(errorMsg, AlertType.ERROR);
|
||||
// alert.setClose(false);
|
||||
// try {
|
||||
// RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// RootPanel.get(DIV_PORTLET_ID).add(alert);
|
||||
// Window.alert(errorMsg);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(UserRights result) {
|
||||
// try {
|
||||
// RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// myRights = result;
|
||||
// initGUI();
|
||||
// GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
// String msg = "Logged in as ";
|
||||
// if(userRole != null && userRole.getName()!=null) {
|
||||
// msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length());
|
||||
// }else
|
||||
// msg+="Member";
|
||||
//
|
||||
// mainTabPanel.setRoleLabel(msg);
|
||||
//
|
||||
//
|
||||
// RoleRights roleRights = myRights.getRoleRights();
|
||||
// boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT);
|
||||
//
|
||||
// if (!canCreateNewItem) {
|
||||
// // removing Tab "Create New Project"
|
||||
// mainTabPanel.removeTab(0);
|
||||
// // activating Tab "List of Project"
|
||||
// mainTabPanel.setTabActive(0);
|
||||
// mainTabPanel.instanceAndShowListOfConcessioni();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// Window.alert(
|
||||
// "Sorry, an error occurrend when loading configurations. Please, contact the support");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(GeonaISConfig result) {
|
||||
//
|
||||
// if (result != null && result.getgRSecondaryType() != null
|
||||
// && result.getScope() != null) {
|
||||
// callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
|
||||
// } else
|
||||
// Window.alert(
|
||||
// "Sorry, no configuration found in the context. Please, contact the support");
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
bindEvents();
|
||||
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
||||
Window.addResizeHandler(new ResizeHandler() {
|
||||
@Override
|
||||
public void onResize(ResizeEvent event) {
|
||||
|
@ -143,21 +355,29 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
updateSize();
|
||||
}
|
||||
|
||||
private static native void click(Element element)/*-{
|
||||
element.click();
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Update window size
|
||||
*/
|
||||
public void updateSize() {
|
||||
|
||||
RootPanel workspace = RootPanel.get(DIV_PORTLET_ID);
|
||||
int topBorder = workspace.getAbsoluteTop();
|
||||
int footer = 85; // footer is bottombar + sponsor
|
||||
int headerSize = 90;
|
||||
// int headerSize = 30;
|
||||
int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer ==
|
||||
// null)?0:(footer.getOffsetHeight()-15));
|
||||
try {
|
||||
RootPanel workspace = RootPanel.get(DIV_PORTLET_ID);
|
||||
int topBorder = workspace.getAbsoluteTop();
|
||||
int footer = 85; // footer is bottombar + sponsor
|
||||
int headerSize = 90;
|
||||
// int headerSize = 30;
|
||||
int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer ==
|
||||
// null)?0:(footer.getOffsetHeight()-15));
|
||||
|
||||
GWT.log("New workspace dimension Height: " + rootHeight);
|
||||
mainTabPanel.setInternalHeight(rootHeight);
|
||||
GWT.log("New workspace dimension Height: " + rootHeight);
|
||||
mainTabPanel.setInternalHeight(rootHeight);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
// appController.getMainPanel().setHeight(rootHeight);
|
||||
// appController.getMainPanel().setWidth(rootWidth);
|
||||
|
||||
|
@ -429,15 +649,55 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
@Override
|
||||
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
|
||||
|
||||
SortFilter sortFilter = getListOfRecordsEvent.getSortFilter();
|
||||
if(sortFilter==null){
|
||||
SearchingFilter sortFilter = getListOfRecordsEvent.getSortFilter();
|
||||
if (sortFilter == null) {
|
||||
sortFilter = mainTabPanel.getCurrentSortFilter();
|
||||
}
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null,
|
||||
sortFilter);
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, displayFields, sortFilter);
|
||||
mainTabPanel.showListOfConcessioniView(grpw);
|
||||
}
|
||||
});
|
||||
|
||||
appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T extends RecordDV> void onDoActionPerformedFired(
|
||||
ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent) {
|
||||
if (actionPerformedOnItemEvent != null) {
|
||||
|
||||
ACTION_PERFORMED_ON_ITEM action = actionPerformedOnItemEvent.getAction();
|
||||
List<T> items = actionPerformedOnItemEvent.getSelectItems();
|
||||
|
||||
if (items == null) {
|
||||
if (grpw != null) {
|
||||
items = (List<T>) grpw.getSelectItems();
|
||||
}
|
||||
}
|
||||
|
||||
if (items == null || items.size() == 0) {
|
||||
Window.alert("No item selected");
|
||||
return;
|
||||
}
|
||||
|
||||
T item = items.get(0);
|
||||
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
if (item instanceof ConcessioneDV) {
|
||||
final ConcessioneDV concessione = (ConcessioneDV) item;
|
||||
GWT.log("onDoActionPerformedFired item: " + concessione);
|
||||
switch (action) {
|
||||
case UPDATED_PROJECT:
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
mainTabPanel.getCurrentSortFilter()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
||||
|
||||
|
@ -470,10 +730,41 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
if (item instanceof ConcessioneDV) {
|
||||
|
||||
final ConcessioneDV concessione = (ConcessioneDV) item;
|
||||
GWT.log("ActionOnItemEvente item: " + concessione);
|
||||
GWT.log("onDoActionFired item: " + concessione);
|
||||
|
||||
// Checking if the user is NOT authorized to perform this action in two ways:
|
||||
// 1. the map of actions allowed for the user does not contain the action;
|
||||
RoleRights roleRights = myRights.getRoleRights();
|
||||
OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
|
||||
boolean allowedOperationForUser = operationType != null? true:false;
|
||||
if (!allowedOperationForUser) {
|
||||
|
||||
String msg = "You are not authorized to perform the action: "+ action.getLabel();
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), "Forbidden: "+action, msg, AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
// 2. the user cannot access to action (e.g. the user cannot write an item of another user)
|
||||
// if so an error is shown
|
||||
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
||||
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, concessione);
|
||||
if (!allowedWriteActionOnItem) {
|
||||
String title = "Forbidden: missing write access";
|
||||
String msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
if(!userRole.isWriteOwn()) {
|
||||
msg = "You do not have write access to item: "+ concessione.getNome();
|
||||
}else if (!userRole.isWriteAny()){
|
||||
title = "Forbidden: missing ownership";
|
||||
msg = "You are not the creator of: "+ concessione.getNome() +". You cannot access to it";
|
||||
}
|
||||
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, AlertType.WARNING);
|
||||
modalW.show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (action) {
|
||||
case SHOW_ON_MAP:
|
||||
case VIEW_ON_MAP:
|
||||
final Modal modal = new Modal(true, true);
|
||||
modal.setCloseVisible(true);
|
||||
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
||||
|
@ -508,10 +799,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
break;
|
||||
|
||||
case SHOW_REPORT:
|
||||
case VIEW_REPORT:
|
||||
|
||||
final Modal modal2 = new Modal(true, true);
|
||||
modal2.setTitle("<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>" + concessione.getNome()
|
||||
+ "</span></span>");
|
||||
modal2.setTitle(
|
||||
"<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
|
||||
+ concessione.getNome() + "</span></span>");
|
||||
modal2.setWidth(800);
|
||||
modal2.setCloseVisible(true);
|
||||
if (concessione.getValidationReport() == null) {
|
||||
|
@ -525,10 +818,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
break;
|
||||
|
||||
case SHOW_EDIT_MODE:
|
||||
case EDIT_PROJECT:
|
||||
final Modal modal3 = new Modal(true, true);
|
||||
modal3.setTitle("<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>" + concessione.getNome()
|
||||
+ "</span></span>");
|
||||
modal3.setTitle(
|
||||
"<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
|
||||
+ concessione.getNome() + "</span></span>");
|
||||
modal3.setWidth(950);
|
||||
modal3.setHeight("700px");
|
||||
modal3.setCloseVisible(true);
|
||||
|
@ -540,12 +834,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
modal3.show();
|
||||
break;
|
||||
|
||||
case UPDATED_RECORD:
|
||||
appManagerBus.fireEvent(
|
||||
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
mainTabPanel.getCurrentSortFilter()));
|
||||
break;
|
||||
case DELETE_RECORD:
|
||||
// case UPDATED_PROJECT:
|
||||
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// mainTabPanel.getCurrentSortFilter()));
|
||||
// break;
|
||||
case DELETE_PROJECT:
|
||||
|
||||
String htmlMsg = "Going to delete the project with:";
|
||||
htmlMsg += "<ul>";
|
||||
|
@ -614,6 +907,56 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, ConcessioneDV concessione) {
|
||||
|
||||
boolean writeAnyAPassed = false;
|
||||
boolean writeOwnPassed = false;
|
||||
|
||||
// Case ADMIN
|
||||
if (userRole.isWriteAny()) {
|
||||
writeAnyAPassed = true;
|
||||
}
|
||||
|
||||
// Case EDITOR
|
||||
// Going to check if the user can RW the record is owner of.
|
||||
if (userRole.isWriteOwn()) {
|
||||
String ownerUser = concessione.getCreationUser();
|
||||
if (ownerUser == null || ownerUser.isEmpty()) {
|
||||
writeOwnPassed = false;
|
||||
}else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
||||
// if my username is equal the owner of the concessione
|
||||
writeOwnPassed = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean operationAllowed = false;
|
||||
switch (allowedAction) {
|
||||
case READ:
|
||||
//Access to READ operation is allowed to everyone
|
||||
operationAllowed = true;
|
||||
GWT.log(OPERATION_TYPE.READ+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case READ_WRITE:
|
||||
//Access to READ_WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.READ_WRITE+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case WRITE:
|
||||
//Access to WRITE operation
|
||||
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
||||
GWT.log(OPERATION_TYPE.WRITE+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
operationAllowed = false;
|
||||
GWT.log(OPERATION_TYPE.UNKNOWN+ " ALLOWED? "+operationAllowed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return operationAllowed;
|
||||
}
|
||||
|
||||
private void purgeFileUploaded() {
|
||||
|
||||
|
|
|
@ -3,15 +3,16 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -63,7 +64,7 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter,
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception;
|
||||
|
||||
/**
|
||||
|
@ -118,13 +119,24 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
/**
|
||||
* Update record.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param jsonUpdate the json update
|
||||
* @param recordType the record type
|
||||
* @param itemId the item id
|
||||
* @param recordType the record type
|
||||
* @param section the section
|
||||
* @param pathIndex the path index
|
||||
* @param keepCurrentContent the keep current content
|
||||
* @param gDBean the g D bean
|
||||
* @return the updated JSON string representing the itemId
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean) throws Exception;
|
||||
|
||||
/**
|
||||
* Read data viewer config.
|
||||
*
|
||||
* @return the GNA data entry ext config profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -3,75 +3,64 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface GeoportalDataEntryServiceAsync
|
||||
{
|
||||
public interface GeoportalDataEntryServiceAsync {
|
||||
|
||||
/**
|
||||
* Utility class to get the RPC Async interface from client-side code
|
||||
*/
|
||||
public static final class Util
|
||||
{
|
||||
private static GeoportalDataEntryServiceAsync instance;
|
||||
/**
|
||||
* Utility class to get the RPC Async interface from client-side code
|
||||
*/
|
||||
public static final class Util {
|
||||
private static GeoportalDataEntryServiceAsync instance;
|
||||
|
||||
public static final GeoportalDataEntryServiceAsync getInstance()
|
||||
{
|
||||
if ( instance == null )
|
||||
{
|
||||
instance = (GeoportalDataEntryServiceAsync) GWT.create( GeoportalDataEntryService.class );
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Util()
|
||||
{
|
||||
// Utility class should not be instantiated
|
||||
}
|
||||
}
|
||||
public static final GeoportalDataEntryServiceAsync getInstance() {
|
||||
if (instance == null) {
|
||||
instance = (GeoportalDataEntryServiceAsync) GWT.create(GeoportalDataEntryService.class);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Util() {
|
||||
// Utility class should not be instantiated
|
||||
}
|
||||
}
|
||||
|
||||
void saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects, AsyncCallback<CommitReport> callback);
|
||||
|
||||
|
||||
void getGeonaInitConfig(AsyncCallback<GeonaISConfig> callback);
|
||||
|
||||
|
||||
void getLinksFor(String itemId, RECORD_TYPE recordType, AsyncCallback<GeoNaItemRef> callback);
|
||||
|
||||
|
||||
void getListConcessioni(Integer start, Integer limit, SortFilter filter, boolean reloadFromService,
|
||||
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
|
||||
void deleteRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<Boolean> callback);
|
||||
|
||||
|
||||
void getJSONRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<String> callback);
|
||||
|
||||
|
||||
void updateRecord(String itemId, String jsonUpdate, RECORD_TYPE recordType, AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
|
||||
void readFileSetPaths(AsyncCallback<FileSetPathsDV> callback);
|
||||
|
||||
|
||||
void getRecord(String itemId, RECORD_TYPE recordType, AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
|
||||
void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex,
|
||||
List<WorkspaceContentDV> keepCurrentContent, GenericDatasetBean gDBean,
|
||||
AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.portlets.user.geoportaldataentry.client.events;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ActionOnItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Sep 15, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ActionPerformedOnItemEvent<T extends RecordDV> extends GwtEvent<ActionPerformedOnItemEventHandler> {
|
||||
public static Type<ActionPerformedOnItemEventHandler> TYPE = new Type<ActionPerformedOnItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
private ACTION_PERFORMED_ON_ITEM action;
|
||||
|
||||
/**
|
||||
* Instantiates a new action performed on item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
* @param doAction the do action
|
||||
*/
|
||||
public ActionPerformedOnItemEvent(List<T> selectItems, ACTION_PERFORMED_ON_ITEM doAction) {
|
||||
this.selectItems = selectItems;
|
||||
this.action = doAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ActionPerformedOnItemEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ActionPerformedOnItemEventHandler handler) {
|
||||
handler.onDoActionPerformedFired(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the action.
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
public ACTION_PERFORMED_ON_ITEM getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ActionPerformedOnItemEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 25, 2021
|
||||
*/
|
||||
public interface ActionPerformedOnItemEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On do action performed fired.
|
||||
* @param <T>
|
||||
*
|
||||
* @param actionPerformedOnItemEvent the action performed on item event
|
||||
*/
|
||||
<T extends RecordDV> void onDoActionPerformedFired(ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent);
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
@ -18,12 +18,12 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
/** The type. */
|
||||
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
|
||||
private RECORD_TYPE recordType;
|
||||
private SortFilter sortFilter;
|
||||
private SearchingFilter sortFilter;
|
||||
|
||||
/**
|
||||
* Instantiates a new cancel upload event.
|
||||
*/
|
||||
public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType, SortFilter sortFilter) {
|
||||
public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType, SearchingFilter sortFilter) {
|
||||
this.recordType = recordType;
|
||||
this.sortFilter = sortFilter;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler
|
|||
return recordType;
|
||||
}
|
||||
|
||||
public SortFilter getSortFilter() {
|
||||
public SearchingFilter getSortFilter() {
|
||||
return sortFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,4 +10,7 @@ public interface Images extends ClientBundle {
|
|||
|
||||
@Source("loading.gif")
|
||||
ImageResource loading();
|
||||
|
||||
@Source("access_denied.png")
|
||||
ImageResource accessDenied();
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 962 B |
|
@ -1,31 +1,46 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.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;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
@ -42,6 +57,8 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
private static final String LABEL_FILTER_SEPARATOR = " - ";
|
||||
|
||||
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
|
||||
|
||||
private static GeonaMainTabPanelUiBinder uiBinder = GWT.create(GeonaMainTabPanelUiBinder.class);
|
||||
|
||||
/**
|
||||
|
@ -78,6 +95,9 @@ public class GeonaMainTabPanel extends Composite {
|
|||
@UiField
|
||||
NavLink buttonReloadConcessioni;
|
||||
|
||||
@UiField
|
||||
TabPanel tabPanel;
|
||||
|
||||
@UiField
|
||||
Tab tabNewProject;
|
||||
|
||||
|
@ -88,7 +108,13 @@ public class GeonaMainTabPanel extends Composite {
|
|||
Dropdown dropdownSortBy;
|
||||
|
||||
@UiField
|
||||
TextBox textBoxSortBy;
|
||||
Dropdown dropdownSearchFor;
|
||||
|
||||
@UiField
|
||||
Alert alertSortBy;
|
||||
|
||||
@UiField
|
||||
Alert alertSearchFor;
|
||||
|
||||
@UiField
|
||||
NavLink navShowOnMap;
|
||||
|
@ -102,14 +128,27 @@ public class GeonaMainTabPanel extends Composite {
|
|||
@UiField
|
||||
NavLink navDelete;
|
||||
|
||||
@UiField
|
||||
TextBox searchField;
|
||||
|
||||
@UiField
|
||||
Button resetSearch;
|
||||
|
||||
@UiField
|
||||
Label roleLabel;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
private RECORD_FIELD[] sortByFields;
|
||||
private List<ItemField> sortByFields;
|
||||
|
||||
private SortFilter currentSortFilter;
|
||||
private List<ItemField> searchForFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
private GeonaRecordsPaginatedView grpw = null;
|
||||
|
||||
private List<ItemField> displayFields;
|
||||
|
||||
/**
|
||||
* Instantiates a new geona main tab panel.
|
||||
*
|
||||
|
@ -117,13 +156,27 @@ public class GeonaMainTabPanel extends Composite {
|
|||
* @param sortByFields the sort by fields
|
||||
* @param initialSortFilter
|
||||
*/
|
||||
public GeonaMainTabPanel(HandlerManager appManagerBus, RECORD_FIELD[] sortByFields, SortFilter initialSortFilter) {
|
||||
public GeonaMainTabPanel(HandlerManager appManagerBus, List<ItemField> displayFields, List<ItemField> sortByFields,
|
||||
List<ItemField> searchForFields, SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.appManagerBus = appManagerBus;
|
||||
this.sortByFields = sortByFields;
|
||||
setCurrentSortFilter(initialSortFilter);
|
||||
bindEvents();
|
||||
this.displayFields = displayFields;
|
||||
this.currentSortFilter = initialSortFilter;
|
||||
this.searchForFields = searchForFields;
|
||||
|
||||
alertSortBy.setType(AlertType.INFO);
|
||||
alertSortBy.setClose(false);
|
||||
|
||||
alertSearchFor.setType(AlertType.INFO);
|
||||
alertSearchFor.setClose(false);
|
||||
|
||||
alertSearchFor.setText(searchForFields.get(0).getDisplayName());
|
||||
alertSortBy.setText(toLabelFilter((initialSortFilter.getOrderByFields().get(0)), initialSortFilter.getOrder()));
|
||||
|
||||
bindEvents();
|
||||
resetSearch.setIconSize(IconSize.TWO_TIMES);
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
}
|
||||
|
||||
public void setInternalHeight(int height) {
|
||||
|
@ -159,17 +212,17 @@ public class GeonaMainTabPanel extends Composite {
|
|||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null, currentSortFilter);
|
||||
showListOfConcessioniView(grpw);
|
||||
|
||||
instanceAndShowListOfConcessioni();
|
||||
}
|
||||
});
|
||||
|
||||
for (RECORD_FIELD record_FIELD : sortByFields) {
|
||||
for (ItemField record_FIELD : sortByFields) {
|
||||
|
||||
// if (record_FIELD.equals(RECORD_FIELD.RECORD_STATUS))
|
||||
// continue;
|
||||
|
||||
// ASC
|
||||
SortFilter sortFilter = new SortFilter(record_FIELD, ORDER.ASC);
|
||||
String labelASC = toLabelFilter(sortFilter);
|
||||
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
NavLink nav = new NavLink(labelASC);
|
||||
dropdownSortBy.add(nav);
|
||||
|
||||
|
@ -177,29 +230,45 @@ public class GeonaMainTabPanel extends Composite {
|
|||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GWT.log("Sort by: " + sortFilter);
|
||||
setCurrentSortFilter(sortFilter);
|
||||
alertSortBy.setText(labelASC);
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
}
|
||||
});
|
||||
|
||||
// //DESC
|
||||
SortFilter sortFilter2 = new SortFilter(record_FIELD, ORDER.DESC);
|
||||
String labelASC2 = toLabelFilter(sortFilter2);
|
||||
NavLink nav2 = new NavLink(labelASC2);
|
||||
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
NavLink nav2 = new NavLink(labelDESC);
|
||||
dropdownSortBy.add(nav2);
|
||||
|
||||
nav2.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GWT.log("Sort by: " + sortFilter2);
|
||||
setCurrentSortFilter(sortFilter2);
|
||||
alertSortBy.setText(labelDESC);
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (ItemField 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());
|
||||
|
||||
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
navShowOnMap.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -209,7 +278,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_ON_MAP));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP));
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -223,7 +292,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_REPORT));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.VIEW_REPORT));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -237,7 +306,7 @@ public class GeonaMainTabPanel extends Composite {
|
|||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_EDIT_MODE));
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.EDIT_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -249,11 +318,54 @@ public class GeonaMainTabPanel extends Composite {
|
|||
if (grpw != null && grpw.getSelectItems() != null) {
|
||||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus
|
||||
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.DELETE_RECORD));
|
||||
appManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.DELETE_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
GWT.log("CHAR CODE: " + event.getCharCode());
|
||||
if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
GWT.log(searchField.getText());
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
resetSearch.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchField.setText("");
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
resetSearch.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setRoleLabel(String msg) {
|
||||
roleLabel.setText(msg);
|
||||
}
|
||||
|
||||
private void doSearchEvent() {
|
||||
String searchText = searchField.getText();
|
||||
if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
|
||||
Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters");
|
||||
return;
|
||||
}
|
||||
|
||||
resetSearch.setVisible(true);
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter()));
|
||||
}
|
||||
|
||||
private String toLabelFilter(ItemField itemField, ORDER direction) {
|
||||
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
return labelFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,49 +402,74 @@ public class GeonaMainTabPanel extends Composite {
|
|||
loader.setVisible(visible);
|
||||
}
|
||||
|
||||
private void setCurrentSortFilter(SortFilter sortFilter) {
|
||||
this.currentSortFilter = sortFilter;
|
||||
this.textBoxSortBy.setText(toLabelFilter(sortFilter));
|
||||
public SearchingFilter toSortFilter(String labelFilter) {
|
||||
GWT.log("toSortFilter for label " + labelFilter);
|
||||
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
|
||||
SearchingFilter sortFilter = null;
|
||||
try {
|
||||
ItemField recordField = null;
|
||||
for (ItemField value : sortByFields) {
|
||||
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
recordField = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ORDER orderField = ORDER.valueOf(array[1]);
|
||||
sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
GWT.log("toSortFilter Got " + sortFilter);
|
||||
return sortFilter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To label filter.
|
||||
*
|
||||
* @param sortFilter the sort filter
|
||||
* @return the string
|
||||
*/
|
||||
public String toLabelFilter(SortFilter sortFilter) {
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(alertSortBy.getText());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
String labelFilter = sortFilter.getOrderByField().getDisplayName() + LABEL_FILTER_SEPARATOR
|
||||
+ sortFilter.getOrder().name();
|
||||
GWT.log("Got " + sortFilter);
|
||||
return labelFilter;
|
||||
String searchForField = "";
|
||||
|
||||
for (ItemField recordField : searchForFields) {
|
||||
if (recordField.getDisplayName().equals(alertSearchFor.getText())) {
|
||||
searchForField = recordField.getJsonFields().get(0);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
searchInto.put(searchForField, searchText);
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
searchingFilter.setConditions(Arrays.asList(where));
|
||||
}
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* To sort filter.
|
||||
*
|
||||
* @param labelFilter the label filter
|
||||
* @return the sort filter
|
||||
*/
|
||||
/*
|
||||
* public SortFilter toSortFilter(String labelFilter) {
|
||||
*
|
||||
* String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
*
|
||||
* SortFilter sortFilter = null; try { RECORD_FIELD recordField =
|
||||
* RECORD_FIELD.valueOf(array[0]); ORDER orderField = ORDER.valueOf(array[1]);
|
||||
* sortFilter = new SortFilter(recordField, orderField); } catch (Exception e) {
|
||||
*
|
||||
* }
|
||||
*
|
||||
* GWT.log("Got " + sortFilter); return sortFilter;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
public SortFilter getCurrentSortFilter() {
|
||||
public SearchingFilter getCurrentSortFilter() {
|
||||
currentSortFilter = builtSearchingFilter();
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
return currentSortFilter;
|
||||
}
|
||||
|
||||
public void removeTab(int index) {
|
||||
tabPanel.remove(index);
|
||||
}
|
||||
|
||||
public void setTabActive(int index) {
|
||||
tabPanel.selectTab(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dirty solution. I created this one because I had problem on firing click
|
||||
* event for Tab element
|
||||
*
|
||||
*/
|
||||
public void instanceAndShowListOfConcessioni() {
|
||||
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, displayFields, currentSortFilter);
|
||||
showListOfConcessioniView(grpw);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,23 +32,34 @@
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
.display-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.max-height-300 {
|
||||
max-height: auto;
|
||||
}
|
||||
|
||||
.margin-botttom-5 {
|
||||
.margin-bottom-5 {
|
||||
margin-bottom: 5px !important;
|
||||
}
|
||||
|
||||
.search-field {
|
||||
padding-top: 6px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:PageHeader subtext="data entry facility"
|
||||
styleName="{style.custom-page-header}">GeoNa</b:PageHeader>
|
||||
styleName="{style.custom-page-header}">GNA</b:PageHeader>
|
||||
<g:Label ui:field="roleLabel"
|
||||
addStyleNames="{style.display-right}"></g:Label>
|
||||
<b:TabPanel tabPosition="above" ui:field="tabPanel">
|
||||
<b:Tab icon="FILE_TEXT" heading="New Project" active="true"
|
||||
ui:field="tabNewProject">
|
||||
<g:ScrollPanel>
|
||||
<g:HTMLPanel ui:field="contTabNewProject">
|
||||
<b:Navbar addStyleNames="{style.margin-botttom-5}">
|
||||
<b:Navbar addStyleNames="{style.margin-bottom-5}">
|
||||
<b:Brand addStyleNames="{style.margin-top-5}">New Project</b:Brand>
|
||||
<b:Nav>
|
||||
<b:NavLink ui:field="buttCreateNewProject"
|
||||
|
@ -85,20 +96,37 @@
|
|||
</g:FlowPanel>
|
||||
<g:ScrollPanel>
|
||||
<g:HTMLPanel ui:field="contTabGetListOfProjects">
|
||||
<b:Navbar addStyleNames="{style.margin-botttom-5}">
|
||||
<b:Brand addStyleNames="{style.margin-top-5}">List of Projects</b:Brand>
|
||||
<b:Navbar addStyleNames="nav-toolbar-style">
|
||||
<b:Brand>List of Projects</b:Brand>
|
||||
<b:Nav>
|
||||
<b:Dropdown text="Sort by" ui:field="dropdownSortBy">
|
||||
</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>
|
||||
|
||||
<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}">
|
||||
|
|
|
@ -2,15 +2,15 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
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.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.SortedCellTable;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
|
@ -47,10 +47,10 @@ public class GeonaRecordsPaginatedView {
|
|||
private MyCustomDataProvider<ConcessioneDV> dataProvider = new MyCustomDataProvider<ConcessioneDV>();
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
private LoaderIcon loadingPanel = new LoaderIcon("Loading data...");
|
||||
private int serverStartIndex;
|
||||
//private int serverStartIndex;
|
||||
private HandlerManager eventBus;
|
||||
private RECORD_TYPE recordType;
|
||||
private SortFilter currentSortFilter;
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
/**
|
||||
* Instantiates a new geona records paginated view.
|
||||
|
@ -61,12 +61,12 @@ public class GeonaRecordsPaginatedView {
|
|||
* @param currentSortFilter the sort by field
|
||||
*/
|
||||
public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType,
|
||||
RECORD_FIELD[] displayFields, SortFilter currentSortFilter) {
|
||||
List<ItemField> displayFields, SearchingFilter currentSortFilter) {
|
||||
this.recordType = recordType;
|
||||
this.currentSortFilter = currentSortFilter;
|
||||
this.initClassFirstRangeChanged = true;
|
||||
this.eventBus = eventbus;
|
||||
itemsTable = new ItemsTable<ConcessioneDV>(eventbus, displayFields, currentSortFilter);
|
||||
itemsTable = new ItemsTable<ConcessioneDV>(eventbus, displayFields);
|
||||
itemsTable.initTable(null, null, dataProvider);
|
||||
|
||||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
|
@ -120,7 +120,7 @@ public class GeonaRecordsPaginatedView {
|
|||
* @param invalidCache the invalid cache
|
||||
*/
|
||||
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore,
|
||||
final SortFilter currentSortFilter, final boolean invalidCache) {
|
||||
final SearchingFilter currentSortFilter, final boolean invalidCache) {
|
||||
// initFirstRangeChanged = resetStore;
|
||||
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
|
@ -131,12 +131,12 @@ public class GeonaRecordsPaginatedView {
|
|||
if (resetStore) {
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
serverStartIndex = 0;
|
||||
//serverStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: " + newStartIndex);
|
||||
getTableDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
loadConcessioni(newStartIndex, limit, serverStartIndex, currentSortFilter, invalidCache);
|
||||
loadConcessioni(newStartIndex, limit, currentSortFilter, invalidCache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ public class GeonaRecordsPaginatedView {
|
|||
*/
|
||||
private void setNewPageResult(ResultSetPaginatedData result) {
|
||||
GWT.log("setNewPageResult: " + result);
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
//serverStartIndex = result.getServerEndIndex();
|
||||
SelectionModel<? super ConcessioneDV> sm = getCellTable().getSelectionModel();
|
||||
|
||||
if (sm instanceof SingleSelectionModel) {
|
||||
|
@ -197,12 +197,11 @@ public class GeonaRecordsPaginatedView {
|
|||
* @param limit the limit
|
||||
* @param serverIndex the server index
|
||||
*/
|
||||
private <T> void loadConcessioni(int newStartIndex, int limit, int serverIndex, SortFilter sortFilter,
|
||||
private <T> void loadConcessioni(int newStartIndex, int limit, SearchingFilter sortFilter,
|
||||
boolean invalidCache) {
|
||||
showLoading(true);
|
||||
|
||||
GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit
|
||||
+ ", serverIndex:" + serverIndex + ", sortFilter: " + sortFilter + "]");
|
||||
GWT.log("calling loadItemsForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit+ ", sortFilter: " + sortFilter + "]");
|
||||
GeoPortalDataEntryApp.geoportalDataEntryService.getListConcessioni(newStartIndex, limit, sortFilter, invalidCache,
|
||||
new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
public class ModalWindow {
|
||||
|
||||
private HorizontalPanel hp = new HorizontalPanel();
|
||||
private Modal modal;
|
||||
|
||||
public ModalWindow(Image icon, String title, String msg, AlertType alertType) {
|
||||
|
||||
modal = new Modal(true,true);
|
||||
modal.hide(false);
|
||||
modal.setTitle(title);
|
||||
modal.setCloseVisible(true);
|
||||
|
||||
|
||||
Alert alert = new Alert();
|
||||
alert.setType(alertType);
|
||||
alert.setClose(false);
|
||||
alert.setText(msg);
|
||||
alert.getElement().getStyle().setMarginLeft(10, Unit.PX);
|
||||
|
||||
|
||||
if (icon != null)
|
||||
hp.add(icon);
|
||||
hp.add(alert);
|
||||
|
||||
ModalFooter modalFooter = new ModalFooter();
|
||||
final Button buttClose = new Button("Close");
|
||||
modalFooter.add(buttClose);
|
||||
|
||||
buttClose.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
modal.hide();
|
||||
}
|
||||
});
|
||||
|
||||
modal.add(hp);
|
||||
modal.add(modalFooter);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
modal.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -7,11 +7,11 @@ import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
|||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
|
@ -66,7 +66,7 @@ public class EditModeRecord extends Composite {
|
|||
private JSONEditorWrapper jsEditor;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
|
||||
private final HandlerManager editorManagerBus = new HandlerManager(null);
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@ public class EditModeRecord extends Composite {
|
|||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
|
||||
buttonJSONUpdate.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -181,8 +181,8 @@ public class EditModeRecord extends Composite {
|
|||
// TODO: handle exception
|
||||
}
|
||||
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(null, ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
editorManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(null,
|
||||
ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
|
||||
}
|
||||
|
||||
|
@ -195,38 +195,38 @@ public class EditModeRecord extends Composite {
|
|||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
||||
DialogInform di = new DialogInform(null, "Project updated!", "Project '" + result.getNome() + "' updated correctly");
|
||||
|
||||
DialogInform di = new DialogInform(null, "Project updated!",
|
||||
"Project '" + result.getNome() + "' updated correctly");
|
||||
di.setZIndex(100000);
|
||||
di.center();
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(Arrays.asList(result), ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
editorManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(
|
||||
Arrays.asList(result), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editorManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
||||
|
||||
editorManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
||||
|
||||
@Override
|
||||
public <T extends RecordDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
|
||||
|
||||
ACTION_ON_ITEM action = showItemEvent.getAction();
|
||||
List<T> items = showItemEvent.getSelectItems();
|
||||
|
||||
if(items!=null) {
|
||||
public <T extends RecordDV> void onDoActionPerformedFired(
|
||||
ActionPerformedOnItemEvent<T> actionPerformedOnItemEvent) {
|
||||
ACTION_PERFORMED_ON_ITEM action = actionPerformedOnItemEvent.getAction();
|
||||
List<T> items = actionPerformedOnItemEvent.getSelectItems();
|
||||
|
||||
if (items != null) {
|
||||
selectedConcessione = (BaseConcessioneDV) items.get(0);
|
||||
instanceJSONEditor();
|
||||
|
||||
if(action.equals(ACTION_ON_ITEM.UPDATED_RECORD)) {
|
||||
appManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>((List<ConcessioneDV>) items, ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
|
||||
if (action.equals(ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT)) {
|
||||
appManagerBus.fireEvent(new ActionPerformedOnItemEvent<ConcessioneDV>(
|
||||
(List<ConcessioneDV>) items, ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
|
|||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.StringUtil;
|
||||
|
@ -262,7 +262,7 @@ public class UpdateFileset extends Composite {
|
|||
buttonUpdate.setEnabled(true);
|
||||
showUploadFileGUI();
|
||||
editorManagerBus.fireEvent(
|
||||
new ActionOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_ON_ITEM.UPDATED_RECORD));
|
||||
new ActionPerformedOnItemEvent<ConcessioneDV>(Arrays.asList(fullConcessione), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT));
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,22 +5,18 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV.ValidationStatus;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.ButtonCell;
|
||||
import com.github.gwtbootstrap.client.ui.Pagination;
|
||||
import com.google.gwt.cell.client.Cell.Context;
|
||||
import com.google.gwt.cell.client.DateCell;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
|
@ -53,22 +49,10 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
|
||||
private static final int ITEMS_PER_PAGE = 10;
|
||||
private static final String NO_DATA = "No data";
|
||||
private TextColumn<T> name;
|
||||
private TextColumn<T> introduction;
|
||||
private TextColumn<T> author;
|
||||
public static DateTimeFormat dtformat = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT);
|
||||
|
||||
private AbstractDataProvider<T> dataProvider;
|
||||
|
||||
private List<RECORD_FIELD> displayFields;
|
||||
private TextColumn<T> startEndProjectColumn;
|
||||
private TextColumn<T> statusColumn;
|
||||
// private Column<T, Date> startProjectDateColumn;
|
||||
// private Column<T, Date> endProjectDateColumn;
|
||||
private List<ItemField> displayFields;
|
||||
private boolean isAsyncronusTable;
|
||||
private TextColumn<T> insertedBy;
|
||||
private Column<T, Date> createdColumn;
|
||||
private SortFilter currentSortFilter;
|
||||
|
||||
/**
|
||||
* Instantiates a new items table.
|
||||
|
@ -77,10 +61,9 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
* @param displayFields the display fields
|
||||
* @param startSortByColumn the start sort by column
|
||||
*/
|
||||
public ItemsTable(HandlerManager eventBus, RECORD_FIELD[] displayFields, SortFilter currentSortFilter) {
|
||||
public ItemsTable(HandlerManager eventBus, List<ItemField> displayFields) {
|
||||
this.eventBus = eventBus;
|
||||
this.currentSortFilter = currentSortFilter;
|
||||
setDisplayFields(displayFields);
|
||||
this.displayFields = displayFields;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,15 +92,66 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
|
||||
setEmptyTableMessage(NO_DATA);
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.NAME)) {
|
||||
int i = 0;
|
||||
|
||||
for (ItemField itemField : displayFields) {
|
||||
String displayName = itemField.getDisplayName();
|
||||
// NAME
|
||||
name = new TextColumn<T>() {
|
||||
TextColumn<T> col = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
|
||||
if (object == null)
|
||||
return "";
|
||||
return ((ConcessioneDV) object).getNome();
|
||||
|
||||
if (displayName.equalsIgnoreCase("Name")) {
|
||||
return ((ConcessioneDV) object).getNome();
|
||||
} else if (displayName.equalsIgnoreCase("Introduction")) {
|
||||
return ((ConcessioneDV) object).getIntroduzione();
|
||||
} else if (displayName.equalsIgnoreCase("Author/s")) {
|
||||
|
||||
String toDisplay = "";
|
||||
if (object.getAuthors() != null) {
|
||||
toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
|
||||
}
|
||||
return toDisplay;
|
||||
} else if (displayName.equalsIgnoreCase("Project Start/End Date")) {
|
||||
|
||||
Date dS = null;
|
||||
Date dE = null;
|
||||
if (object.getDataInizioProgetto() != null) {
|
||||
dS = (((ConcessioneDV) object).getDataInizioProgetto());
|
||||
}
|
||||
|
||||
if (object.getDataFineProgetto() != null) {
|
||||
dE = (((ConcessioneDV) object).getDataFineProgetto());
|
||||
}
|
||||
|
||||
String dateFormat = "";
|
||||
if (dS != null) {
|
||||
dateFormat += dtformat.format(dS);
|
||||
}
|
||||
|
||||
dateFormat += " / ";
|
||||
|
||||
if (dE != null) {
|
||||
dateFormat += dtformat.format(dE);
|
||||
}
|
||||
|
||||
return dateFormat;
|
||||
} else if (displayName.equalsIgnoreCase("Published with")) {
|
||||
ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport();
|
||||
if (vr != null && vr.getStatus() != null)
|
||||
return vr.getStatus().getLabel();
|
||||
return "";
|
||||
} else if (displayName.equalsIgnoreCase("Created")) {
|
||||
Date cd = ((ConcessioneDV) object).getCreationTime();
|
||||
return dtformat.format(cd);
|
||||
} else if (displayName.equalsIgnoreCase("Created by")) {
|
||||
return ((ConcessioneDV) object).getCreationUser();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// ADDING TOOLTIP
|
||||
|
@ -125,304 +159,224 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
|
||||
if (object == null)
|
||||
return;
|
||||
sb.appendHtmlConstant("<div introduction=\"" + ((ConcessioneDV) object).getNome() + "\">");
|
||||
super.render(context, object, sb);
|
||||
sb.appendHtmlConstant("</div>");
|
||||
|
||||
if (displayName.equalsIgnoreCase("Published with")) {
|
||||
String value = getValue(object);
|
||||
String color = "#000";
|
||||
if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) {
|
||||
color = "#32CD32";
|
||||
} else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) {
|
||||
color = "#FF8000";
|
||||
} else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) {
|
||||
color = "red";
|
||||
}
|
||||
sb.appendHtmlConstant("<span style=\"color:" + color + "\";>");
|
||||
super.render(context, object, sb);
|
||||
sb.appendHtmlConstant("</span>");
|
||||
} else
|
||||
super.render(context, object, sb);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return ((ConcessioneDV) o1).getNome().compareTo(((ConcessioneDV) o2).getNome());
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.setComparator(name, c);
|
||||
if(i==0) {
|
||||
//name
|
||||
sortedCellTable.setColumnWidth(col, 20, Unit.PCT);
|
||||
}else if (i == 1) {
|
||||
// intro
|
||||
sortedCellTable.setColumnWidth(col, 30, Unit.PCT);
|
||||
} else if (i == 2) {
|
||||
sortedCellTable.setColumnWidth(col, 15, Unit.PCT);
|
||||
}else if(i==displayFields.size()-1) {
|
||||
sortedCellTable.setColumnWidth(col, 120, Unit.PX);
|
||||
}
|
||||
|
||||
sortedCellTable.addColumn(col, itemField.getDisplayName(), true);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
|
||||
|
||||
introduction = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
return ((ConcessioneDV) object).getIntroduzione() != null
|
||||
? ((ConcessioneDV) object).getIntroduzione()
|
||||
: "";
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(introduction, RECORD_FIELD.INTRODUCTION.getDisplayName(), true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return ((ConcessioneDV) o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione());
|
||||
}
|
||||
};
|
||||
sortedCellTable.setComparator(introduction, c);
|
||||
}
|
||||
|
||||
// sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
|
||||
|
||||
author = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
|
||||
return toDisplay;
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(), true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
String toDisplay1 = toDisplayAuthors(((ConcessioneDV) o1).getAuthors());
|
||||
String toDisplay2 = toDisplayAuthors(((ConcessioneDV) o2).getAuthors());
|
||||
return toDisplay1.compareTo(toDisplay2);
|
||||
}
|
||||
};
|
||||
sortedCellTable.setComparator(author, c);
|
||||
}
|
||||
|
||||
sortedCellTable.setColumnWidth(author, 220, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) {
|
||||
|
||||
startEndProjectColumn = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
Date dS = (((ConcessioneDV) object).getDataInizioProgetto());
|
||||
Date dE = (((ConcessioneDV) object).getDataFineProgetto());
|
||||
return dtformat.format(dS) + " / " + dtformat.format(dE);
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(startEndProjectColumn, RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(),
|
||||
false);
|
||||
sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.CREATED)) {
|
||||
|
||||
DateCell date = new DateCell(DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT+" "+ConvertToDataViewModel.TIME_FORMAT));
|
||||
createdColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if (object == null)
|
||||
return null;
|
||||
|
||||
return (((ConcessioneDV) object).getCreationTime());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(createdColumn, RECORD_FIELD.CREATED.getDisplayName(), true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
if (o1 == null)
|
||||
return -1;
|
||||
|
||||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Date d1 = (((ConcessioneDV) o1).getCreationTime());
|
||||
Date d2 = (((ConcessioneDV) o2).getCreationTime());
|
||||
|
||||
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
|
||||
if (d1.after(d2))
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
GWT.log("date colum sortable");
|
||||
sortedCellTable.setComparator(createdColumn, c);
|
||||
}
|
||||
|
||||
sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) {
|
||||
|
||||
// NAME
|
||||
insertedBy = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
return ((ConcessioneDV) object).getCreationUser();
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(insertedBy, RECORD_FIELD.CREATED_BY.getDisplayName(), true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return ((ConcessioneDV) o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser());
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.setComparator(insertedBy, c);
|
||||
}
|
||||
sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX);
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(RECORD_FIELD.RECORD_STATUS)) {
|
||||
|
||||
statusColumn = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport();
|
||||
if (vr != null && vr.getStatus() != null)
|
||||
return vr.getStatus().getLabel();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Context context, T object, SafeHtmlBuilder sb) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
String value = getValue(object);
|
||||
String color = "#000";
|
||||
if (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) {
|
||||
color = "#32CD32";
|
||||
} else if (value.compareTo(ValidationStatus.WARNING.getLabel()) == 0) {
|
||||
color = "#FF8000";
|
||||
} else if (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) {
|
||||
color = "red";
|
||||
}
|
||||
sb.appendHtmlConstant("<span style=\"color:" + color + "\";>");
|
||||
super.render(context, object, sb);
|
||||
sb.appendHtmlConstant("</span>");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(statusColumn, RECORD_FIELD.RECORD_STATUS.getDisplayName(), false);
|
||||
sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
// ButtonCell showOnMapButton = new ButtonCell();
|
||||
// showOnMapButton.setIcon(IconType.MAP_MARKER);
|
||||
//
|
||||
// MyToolTipColumn<T, String> showOnMapColumn = new MyToolTipColumn<T, String>(showOnMapButton, "Show on Map") {
|
||||
//
|
||||
// @Override
|
||||
// public String getValue(T object) {
|
||||
// return "";
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// showOnMapColumn.setFieldUpdater(new FieldUpdater<T, String>() {
|
||||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
// GWT.log("clicked show");
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_ON_MAP));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(showOnMapColumn);
|
||||
// sortedCellTable.setColumnWidth(showOnMapColumn, 50, Unit.PX);
|
||||
//
|
||||
// ButtonCell showReportRecordButton = new ButtonCell();
|
||||
// showReportRecordButton.setIcon(IconType.FILE_TEXT_ALT);
|
||||
// MyToolTipColumn<T, String> showReportRecordColumn = new MyToolTipColumn<T, String>(showReportRecordButton,
|
||||
// "Show Publication Report") {
|
||||
// public String getValue(T object) {
|
||||
// return "";
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// showReportRecordColumn.setFieldUpdater(new FieldUpdater<T, String>() {
|
||||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
//
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.SHOW_REPORT));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(showReportRecordColumn);
|
||||
// sortedCellTable.setColumnWidth(showReportRecordColumn, 50, Unit.PX);
|
||||
//
|
||||
// ButtonCell deleteRecordButton = new ButtonCell();
|
||||
// deleteRecordButton.setIcon(IconType.TRASH);
|
||||
// MyToolTipColumn<T, String> deleteRecordColumn = new MyToolTipColumn<T, String>(deleteRecordButton,
|
||||
// "Delete Project") {
|
||||
// public String getValue(T object) {
|
||||
// return "";
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// deleteRecordColumn.setFieldUpdater(new FieldUpdater<T, String>() {
|
||||
// @Override
|
||||
// public void update(int index, T object, String value) {
|
||||
//
|
||||
// eventBus.fireEvent(new ActionOnItemEvent<T>(Arrays.asList(object), ACTION_ON_ITEM.DELETE_RECORD));
|
||||
// }
|
||||
// });
|
||||
// sortedCellTable.addColumn(deleteRecordColumn);
|
||||
// sortedCellTable.setColumnWidth(deleteRecordColumn, 50, Unit.PX);
|
||||
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
|
||||
if (currentSortFilter != null)
|
||||
switch (currentSortFilter.getOrderByField()) {
|
||||
case NAME:
|
||||
if (this.displayFields.contains(RECORD_FIELD.NAME)) {
|
||||
sortedCellTable.setInitialSortColumn(name);
|
||||
}
|
||||
break;
|
||||
case INTRODUCTION:
|
||||
if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
|
||||
sortedCellTable.setInitialSortColumn(introduction);
|
||||
}
|
||||
break;
|
||||
case AUTHOR:
|
||||
if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
|
||||
sortedCellTable.setInitialSortColumn(author);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.NAME)) {
|
||||
*
|
||||
* // NAME name = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
* return ((ConcessioneDV) object).getNome(); }
|
||||
*
|
||||
* // ADDING TOOLTIP
|
||||
*
|
||||
* @Override public void render(com.google.gwt.cell.client.Cell.Context context,
|
||||
* T object, SafeHtmlBuilder sb) { if (object == null) return;
|
||||
* sb.appendHtmlConstant("<div introduction=\"" + ((ConcessioneDV)
|
||||
* object).getNome() + "\">"); super.render(context, object, sb);
|
||||
* sb.appendHtmlConstant("</div>"); }; };
|
||||
*
|
||||
* sortedCellTable.addColumn(name, RECORD_FIELD.NAME.getDisplayName(), true);
|
||||
*
|
||||
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
|
||||
*
|
||||
* @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
|
||||
* o1).getNome().compareTo(((ConcessioneDV) o2).getNome()); } };
|
||||
*
|
||||
* sortedCellTable.setComparator(name, c); }
|
||||
*
|
||||
* }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.INTRODUCTION)) {
|
||||
*
|
||||
* introduction = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
* return ((ConcessioneDV) object).getIntroduzione() != null ? ((ConcessioneDV)
|
||||
* object).getIntroduzione() : ""; } };
|
||||
*
|
||||
* sortedCellTable.addColumn(introduction,
|
||||
* RECORD_FIELD.INTRODUCTION.getDisplayName(), true);
|
||||
*
|
||||
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
|
||||
*
|
||||
* @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
|
||||
* o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione()); } };
|
||||
* sortedCellTable.setComparator(introduction, c); }
|
||||
*
|
||||
* // sortedCellTable.setColumnWidth(introduction, 100, Unit.PCT);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.AUTHOR)) {
|
||||
*
|
||||
* author = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
*
|
||||
* String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
|
||||
* return toDisplay; } };
|
||||
*
|
||||
* sortedCellTable.addColumn(author, RECORD_FIELD.AUTHOR.getDisplayName(),
|
||||
* true);
|
||||
*
|
||||
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
|
||||
*
|
||||
* @Override public int compare(T o1, T o2) { String toDisplay1 =
|
||||
* toDisplayAuthors(((ConcessioneDV) o1).getAuthors()); String toDisplay2 =
|
||||
* toDisplayAuthors(((ConcessioneDV) o2).getAuthors()); return
|
||||
* toDisplay1.compareTo(toDisplay2); } }; sortedCellTable.setComparator(author,
|
||||
* c); }
|
||||
*
|
||||
* sortedCellTable.setColumnWidth(author, 220, Unit.PX);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.PROJECT_START_END_DATE)) {
|
||||
*
|
||||
* startEndProjectColumn = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
*
|
||||
* Date dS = null; Date dE = null; if(object.getDataInizioProgetto()!=null) { dS
|
||||
* = (((ConcessioneDV) object).getDataInizioProgetto()); }
|
||||
*
|
||||
* if(object.getDataFineProgetto()!=null) { dE = (((ConcessioneDV)
|
||||
* object).getDataFineProgetto()); }
|
||||
*
|
||||
* String dateFormat = ""; if(dS!=null) { dateFormat+=dtformat.format(dS); }
|
||||
*
|
||||
* dateFormat+=" / ";
|
||||
*
|
||||
* if(dE!=null) { dateFormat+=dtformat.format(dE); }
|
||||
*
|
||||
* return dateFormat; } };
|
||||
*
|
||||
* sortedCellTable.addColumn(startEndProjectColumn,
|
||||
* RECORD_FIELD.PROJECT_START_END_DATE.getDisplayName(), false);
|
||||
* sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.CREATED)) {
|
||||
*
|
||||
* DateCell date = new
|
||||
* DateCell(DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT+" "
|
||||
* +ConvertToDataViewModel.TIME_FORMAT)); createdColumn = new Column<T,
|
||||
* Date>(date) {
|
||||
*
|
||||
* @Override public Date getValue(T object) { if (object == null) return null;
|
||||
*
|
||||
* return (((ConcessioneDV) object).getCreationTime()); } };
|
||||
* sortedCellTable.addColumn(createdColumn,
|
||||
* RECORD_FIELD.CREATED.getDisplayName(), true);
|
||||
*
|
||||
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
|
||||
*
|
||||
* @Override public int compare(T o1, T o2) { if (o1 == null) return -1;
|
||||
*
|
||||
* if (o2 == null) return 1;
|
||||
*
|
||||
* Date d1 = (((ConcessioneDV) o1).getCreationTime()); Date d2 =
|
||||
* (((ConcessioneDV) o2).getCreationTime());
|
||||
*
|
||||
* // GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
*
|
||||
* if (d1.after(d2)) return 1; else return -1; } };
|
||||
* GWT.log("date colum sortable"); sortedCellTable.setComparator(createdColumn,
|
||||
* c); }
|
||||
*
|
||||
* sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX);
|
||||
*
|
||||
* }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.CREATED_BY)) {
|
||||
*
|
||||
* // NAME insertedBy = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
* return ((ConcessioneDV) object).getCreationUser(); } };
|
||||
*
|
||||
* sortedCellTable.addColumn(insertedBy,
|
||||
* RECORD_FIELD.CREATED_BY.getDisplayName(), true);
|
||||
*
|
||||
* if (!isAsyncronusTable) { Comparator<T> c = new Comparator<T>() {
|
||||
*
|
||||
* @Override public int compare(T o1, T o2) { return ((ConcessioneDV)
|
||||
* o1).getCreationUser().compareTo(((ConcessioneDV) o2).getCreationUser()); } };
|
||||
*
|
||||
* sortedCellTable.setComparator(insertedBy, c); }
|
||||
* sortedCellTable.setColumnWidth(insertedBy, 220, Unit.PX); }
|
||||
*
|
||||
* if (this.displayFields.contains(RECORD_FIELD.RECORD_STATUS)) {
|
||||
*
|
||||
* statusColumn = new TextColumn<T>() {
|
||||
*
|
||||
* @Override public String getValue(T object) { if (object == null) return "";
|
||||
*
|
||||
* ValidationReportDV vr = ((ConcessioneDV) object).getValidationReport(); if
|
||||
* (vr != null && vr.getStatus() != null) return vr.getStatus().getLabel();
|
||||
* return ""; }
|
||||
*
|
||||
* @Override public void render(Context context, T object, SafeHtmlBuilder sb) {
|
||||
* // TODO Auto-generated method stub
|
||||
*
|
||||
* String value = getValue(object); String color = "#000"; if
|
||||
* (value.compareTo(ValidationStatus.PASSED.getLabel()) == 0) { color =
|
||||
* "#32CD32"; } else if (value.compareTo(ValidationStatus.WARNING.getLabel()) ==
|
||||
* 0) { color = "#FF8000"; } else if
|
||||
* (value.compareTo(ValidationStatus.ERROR.getLabel()) == 0) { color = "red"; }
|
||||
* sb.appendHtmlConstant("<span style=\"color:" + color + "\";>");
|
||||
* super.render(context, object, sb); sb.appendHtmlConstant("</span>");
|
||||
*
|
||||
* } };
|
||||
*
|
||||
* sortedCellTable.addColumn(statusColumn,
|
||||
* RECORD_FIELD.RECORD_STATUS.getDisplayName(), false);
|
||||
* sortedCellTable.setColumnWidth(statusColumn, 120, Unit.PX);
|
||||
*
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void enableWriteOperations() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,15 +419,15 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display fields.
|
||||
*
|
||||
* @param fields the new display fields
|
||||
*/
|
||||
public void setDisplayFields(RECORD_FIELD[] fields) {
|
||||
this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields)
|
||||
: Arrays.asList(RECORD_FIELD.values());
|
||||
}
|
||||
// /**
|
||||
// * Sets the display fields.
|
||||
// *
|
||||
// * @param fields the new display fields
|
||||
// */
|
||||
// public void setDisplayFields(List<ItemField> fields) {
|
||||
// this.displayFields = fields != null && fields.size() > 0 ? Arrays.asList(fields)
|
||||
// : Arrays.asList(RECORD_FIELD.values());
|
||||
// }
|
||||
|
||||
/**
|
||||
* Reset columns table.
|
||||
|
@ -491,7 +445,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
*
|
||||
* @return the displayFields
|
||||
*/
|
||||
public List<RECORD_FIELD> getDisplayFields() {
|
||||
public List<ItemField> getDisplayFields() {
|
||||
return displayFields;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -19,25 +17,37 @@ import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
|||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
||||
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.exception.GNAConfigException;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.MongoServiceUtil.ConcessioneValidationReportStatusComparator;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.ResultSetPaginatedData;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SortFilter.ORDER;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -57,6 +67,29 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE";
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class);
|
||||
|
||||
/**
|
||||
* Gets the GNA data entry config profile.
|
||||
*
|
||||
* @return the GNA data entry config profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private GNADataEntryConfigProfile getGNADataEntryConfigProfile() throws Exception {
|
||||
|
||||
GNADataEntryConfigProfile profile = SessionUtil.getGNADataEntryConfigProfile(getThreadLocalRequest());
|
||||
if (profile == null) {
|
||||
LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " is null, loading configurations from IS");
|
||||
//to be sure
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
GeoportalCommon gCommon = new GeoportalCommon();
|
||||
profile = gCommon.readGNADataEntryConfig();
|
||||
SessionUtil.setGNADataEntryConfigProfile(getThreadLocalRequest(), profile);
|
||||
} else {
|
||||
LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " read from session");
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save geona data forms.
|
||||
*
|
||||
|
@ -362,8 +395,9 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
try {
|
||||
theSecondaryType = this.getServletContext().getInitParameter(GEONA_GENERIC_RESOURCE_SECONDARY_TYPE);
|
||||
} catch (Exception e) {
|
||||
LOG.error("I cannot read the init parameter for: " + GEONA_GENERIC_RESOURCE_SECONDARY_TYPE, e);
|
||||
LOG.warn("I cannot read the init parameter for: " + GEONA_GENERIC_RESOURCE_SECONDARY_TYPE, e);
|
||||
theSecondaryType = "GeoNaMetadata";
|
||||
LOG.warn("Using default SecondaryType: " + theSecondaryType);
|
||||
}
|
||||
|
||||
// LOG.warn("\n\n\nHARD-CABLING THE SCOPE, PLEASE REMOTE IT!!!!\n\n\n");
|
||||
|
@ -387,7 +421,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
LOG.info("getLinksFor called");
|
||||
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
GeoNaDataViewerProfile grViewerProfile = SessionUtil.getGeportalViewerResourceProfile(getThreadLocalRequest());
|
||||
GNADataViewerConfigProfile grViewerProfile = SessionUtil
|
||||
.getGeportalViewerResourceProfile(getThreadLocalRequest());
|
||||
GeoportalCommon gc = new GeoportalCommon(grViewerProfile);
|
||||
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toString().toLowerCase());
|
||||
item = gc.getPublicLinksFor(item, false);
|
||||
|
@ -406,147 +441,26 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SortFilter filter,
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception {
|
||||
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
|
||||
|
||||
try {
|
||||
|
||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
MongoServiceCommon serviceCommon = new MongoServiceCommon();
|
||||
|
||||
// TODO MUST BE REPLACED BY COUNT
|
||||
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
|
||||
reloadFromService);
|
||||
int listConcessioniSize = listOfConcessioni.size();
|
||||
|
||||
List<Concessione> toReturn = new ArrayList<Concessione>();
|
||||
int startIndex;
|
||||
int limitIndex = 0;
|
||||
if (start == null && limit == null) {
|
||||
startIndex = 0;
|
||||
limitIndex = listConcessioniSize;
|
||||
} else {
|
||||
startIndex = start;
|
||||
limitIndex = start + limit;
|
||||
if (limitIndex > listConcessioniSize) {
|
||||
limitIndex = listConcessioniSize;
|
||||
}
|
||||
}
|
||||
|
||||
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, startIndex, false);
|
||||
searchedData.setTotalItems(listConcessioniSize);
|
||||
|
||||
RECORD_FIELD orderBy = null;
|
||||
ORDER order = null;
|
||||
ConcessioneValidationReportStatusComparator statusComparator = null;
|
||||
|
||||
if (filter == null) {
|
||||
// unsorted list of records
|
||||
toReturn = listOfConcessioni.subList(startIndex, limitIndex);
|
||||
} else {
|
||||
|
||||
orderBy = filter.getOrderByField();
|
||||
order = filter.getOrder();
|
||||
|
||||
if (orderBy == null)
|
||||
orderBy = RECORD_FIELD.NAME;
|
||||
|
||||
if (order == null)
|
||||
order = ORDER.ASC;
|
||||
|
||||
// CASE INSENSITIVE COMPARATOR
|
||||
Comparator<Concessione> comparator = null;
|
||||
|
||||
switch (orderBy) {
|
||||
case NAME:
|
||||
if (order.equals(ORDER.ASC)) {
|
||||
comparator = Comparator.comparing(Concessione::getNome,
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
|
||||
} else {
|
||||
comparator = Comparator
|
||||
.comparing(Concessione::getNome, Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER))
|
||||
.reversed();
|
||||
}
|
||||
|
||||
break;
|
||||
case CREATED:
|
||||
if (order.equals(ORDER.ASC)) {
|
||||
comparator = Comparator.comparing(Concessione::getCreationTime,
|
||||
Comparator.nullsLast(Comparator.naturalOrder()));
|
||||
} else {
|
||||
comparator = Comparator.comparing(Concessione::getCreationTime,
|
||||
Comparator.nullsLast(Comparator.naturalOrder())).reversed();
|
||||
}
|
||||
break;
|
||||
|
||||
case CREATED_BY:
|
||||
if (order.equals(ORDER.ASC)) {
|
||||
comparator = Comparator.comparing(Concessione::getCreationUser,
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
|
||||
} else {
|
||||
comparator = Comparator.comparing(Concessione::getCreationUser,
|
||||
Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).reversed();
|
||||
}
|
||||
break;
|
||||
|
||||
// TODO is buggy must be performed by service
|
||||
case PROJECT_START_END_DATE:
|
||||
if (order.equals(ORDER.ASC)) {
|
||||
comparator = Comparator.comparing(Concessione::getDataInizioProgetto,
|
||||
Comparator.nullsLast(Comparator.naturalOrder()));
|
||||
} else {
|
||||
comparator = Comparator.comparing(Concessione::getDataInizioProgetto,
|
||||
Comparator.nullsLast(Comparator.naturalOrder())).reversed();
|
||||
}
|
||||
break;
|
||||
|
||||
case RECORD_STATUS:
|
||||
statusComparator = new ConcessioneValidationReportStatusComparator();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// sorting with nullsLast
|
||||
if (comparator != null)
|
||||
listOfConcessioni.sort(Comparator.nullsLast(comparator));
|
||||
|
||||
// solution quick&dirty
|
||||
try {
|
||||
if (statusComparator != null) {
|
||||
if (order.equals(ORDER.ASC)) {
|
||||
listOfConcessioni.sort(Comparator.nullsLast(statusComparator));
|
||||
} else {
|
||||
Collections.sort(listOfConcessioni, Comparator.nullsLast(
|
||||
Collections.reverseOrder(new ConcessioneValidationReportStatusComparator())));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn("comparator Exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
LOG.trace("sorted list: " + listOfConcessioni);
|
||||
// pagination
|
||||
toReturn = listOfConcessioni.subList(startIndex, limitIndex);
|
||||
}
|
||||
|
||||
List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size());
|
||||
|
||||
for (Concessione concessione : toReturn) {
|
||||
ConcessioneDV concessioneDV = ConvertToDataViewModel.toMetadataConcessione(concessione, true);
|
||||
toReturnList.add(concessioneDV);
|
||||
}
|
||||
|
||||
searchedData.setData(toReturnList);
|
||||
|
||||
if (listConcessioniSize == limit || listConcessioniSize == 0) {
|
||||
LOG.debug("Page completed returning " + listConcessioniSize + " items");
|
||||
int newOffset = startIndex + start;
|
||||
searchedData.setServerSearchFinished(newOffset > listConcessioniSize || listConcessioniSize == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
LOG.debug("Returning: " + toReturnList);
|
||||
LOG.info("Returning list of concessioni with size: " + toReturnList.size());
|
||||
ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
|
||||
"concessione");
|
||||
return searchedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading list of concessioni: ", e);
|
||||
LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
|
||||
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -760,19 +674,19 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
String toEditPath = null;
|
||||
AddSectionToConcessioneRequest request = null;
|
||||
List<TempFile> files = new ArrayList<TempFile>();
|
||||
|
||||
|
||||
// Managing files already present as current content and kept by user
|
||||
List<TempFile> keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent);
|
||||
if (keepFiles != null) {
|
||||
files.addAll(keepFiles);
|
||||
LOG.debug(keepFiles.size() +" current corrent file/s has/have been added to list of files");
|
||||
LOG.debug(keepFiles.size() + " current corrent file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// Managing new files uploaded by user
|
||||
List<TempFile> newFiles = serviceUtil.toTemFiles(gDBean.getFilesUploaded());
|
||||
if (newFiles != null) {
|
||||
files.addAll(newFiles);
|
||||
LOG.debug(newFiles.size() +" new file/s has/have been added to list of files");
|
||||
LOG.debug(newFiles.size() + " new file/s has/have been added to list of files");
|
||||
}
|
||||
|
||||
// if (files == null || files.isEmpty())
|
||||
|
@ -808,21 +722,21 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
Concessione concessione = clientMongo.cleanFileSet(itemId, toEditPath);
|
||||
|
||||
LOG.debug("Sending new Fileset ..");
|
||||
if(files.size()>0) {
|
||||
if (files.size() > 0) {
|
||||
// StorageUtils storage=new StorageUtils();
|
||||
// Building TempFile
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath + " and: "
|
||||
+ files.size() + " file/s");
|
||||
LOG.info("Registering FileSet into recordId " + itemId + " with request path: " + toEditPath
|
||||
+ " and: " + files.size() + " file/s");
|
||||
concessione = clientMongo.registerFileSet(itemId, request);
|
||||
}else {
|
||||
} else {
|
||||
LOG.info("Fileset is empty, skipping registerFileSet");
|
||||
}
|
||||
|
||||
LOG.info("Publishings itemId: "+itemId);
|
||||
|
||||
LOG.info("Publishings itemId: " + itemId);
|
||||
concessione = clientMongo.publish(itemId);
|
||||
|
||||
LOG.debug("returning concessione: "+concessione);
|
||||
|
||||
LOG.debug("returning concessione: " + concessione);
|
||||
return ConvertToDataViewModel.toConcessione(concessione);
|
||||
}
|
||||
|
||||
|
@ -834,5 +748,94 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
"Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception {
|
||||
LOG.info("readDataViewerConfig called");
|
||||
|
||||
GCubeUser user = null;
|
||||
GNADataEntryExtConfigProfile gnaDEExtConfig = new GNADataEntryExtConfigProfile();
|
||||
try {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
user = pContext.getCurrentUser(this.getThreadLocalRequest());
|
||||
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
|
||||
GNADataEntryConfigProfile config = getGNADataEntryConfigProfile();
|
||||
List<RoleRights> listUserRightsForRole = config.getPermissionsForRole();
|
||||
gnaDEExtConfig.setListItemFields(config.getListItemFields());
|
||||
gnaDEExtConfig.setPermissionsForRole(listUserRightsForRole);
|
||||
|
||||
// DEV MODE
|
||||
if (!SessionUtil.isIntoPortal()) {
|
||||
LOG.warn("OUT OF PORTAL - DEV MODE detected");
|
||||
GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR;
|
||||
|
||||
for (RoleRights roleRight : listUserRightsForRole) {
|
||||
if (roleRight.getUserRole().equals(myRole)) {
|
||||
UserRights userRights = new UserRights(user.getUsername(), roleRight);
|
||||
LOG.warn("DEV MODE returning: " + userRights);
|
||||
gnaDEExtConfig.setUserRights(userRights);
|
||||
return gnaDEExtConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
|
||||
|
||||
if (user == null || scope == null) {
|
||||
LOG.warn("called getMyRightsInTheContext with invalid parameter user: " + user + ", in the scope: "
|
||||
+ scope, ", returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
LOG.info("reading GcubeUserRole for user: " + user.getUsername() + ", in the scope: " + scope);
|
||||
// The following snippet should pass in the service-side
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(user.getUserId(), groupId);
|
||||
List<GcubeUserRole> listMyRoles = new ArrayList<GcubeUserRole>();
|
||||
for (GCubeRole gCubeRole : roles) {
|
||||
if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_EDITOR.getName())) {
|
||||
listMyRoles.add(GcubeUserRole.DATA_EDITOR);
|
||||
}
|
||||
if (gCubeRole.getRoleName().equalsIgnoreCase(GcubeUserRole.DATA_MANAGER.getName())) {
|
||||
listMyRoles.add(GcubeUserRole.DATA_MANAGER);
|
||||
}
|
||||
}
|
||||
|
||||
// Mapping to roles "known"
|
||||
LOG.info(
|
||||
"For user: " + user.getUsername() + " in the scope: " + scope + " read the role/s: " + listMyRoles);
|
||||
|
||||
GcubeUserRole myRole = null;
|
||||
if (listMyRoles.contains(GcubeUserRole.DATA_MANAGER))
|
||||
myRole = GcubeUserRole.DATA_MANAGER;
|
||||
else if (listMyRoles.contains(GcubeUserRole.DATA_EDITOR))
|
||||
myRole = GcubeUserRole.DATA_EDITOR;
|
||||
else
|
||||
myRole = GcubeUserRole.DATA_MEMBER;
|
||||
|
||||
LOG.info("using highest role: " + myRole);
|
||||
|
||||
RoleRights toRoleRight = null;
|
||||
for (RoleRights roleRight : listUserRightsForRole) {
|
||||
if (roleRight.getUserRole().equals(myRole)) {
|
||||
toRoleRight = roleRight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UserRights userRights = new UserRights(user.getUsername(), toRoleRight);
|
||||
LOG.info("returning: " + userRights);
|
||||
gnaDEExtConfig.setUserRights(userRights);
|
||||
return gnaDEExtConfig;
|
||||
} catch (UserRetrievalFault | GroupRetrievalFault | GNAConfigException e) {
|
||||
LOG.error("An error occurred during getMyRightsInTheContext: " + user, e);
|
||||
|
||||
Map<ACTION_ON_ITEM, OPERATION_TYPE> permissions = new HashMap<ACTION_ON_ITEM, RoleRights.OPERATION_TYPE>();
|
||||
RoleRights roleRights = new RoleRights(permissions, GcubeUserRole.DATA_MEMBER);
|
||||
UserRights ur = new UserRights(user.getUsername(), roleRights);
|
||||
LOG.warn("Returning default user rights: " + ur);
|
||||
gnaDEExtConfig.setUserRights(ur);
|
||||
return gnaDEExtConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class MongoServiceUtil.
|
||||
* The Class MongoServiceCommon.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
|
|
|
@ -13,7 +13,8 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -38,6 +39,8 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
*/
|
||||
public class SessionUtil {
|
||||
|
||||
private static final String GNA_DATAENTRY_CONFIG_PROFILE = "GNA_DATAENTRY_CONFIG_PROFILE";
|
||||
private static final String LATEST_RESULT_SET_SORTED = "LATEST_RESULT_SET_SORTED";
|
||||
private static final String GEONA_DATAVIEWER_PROFILE = "GEONA_DATAVIEWER_PROFILE";
|
||||
private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI";
|
||||
/** The log. */
|
||||
|
@ -173,15 +176,15 @@ public class SessionUtil {
|
|||
* @return the geportal viewer resource profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static GeoNaDataViewerProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest)
|
||||
public static GNADataViewerConfigProfile getGeportalViewerResourceProfile(HttpServletRequest httpServletRequest)
|
||||
throws Exception {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
GeoNaDataViewerProfile geoNaDataViewerProfile = (GeoNaDataViewerProfile) session
|
||||
GNADataViewerConfigProfile geoNaDataViewerProfile = (GNADataViewerConfigProfile) session
|
||||
.getAttribute(GEONA_DATAVIEWER_PROFILE);
|
||||
|
||||
if (geoNaDataViewerProfile == null) {
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
geoNaDataViewerProfile = gc.getGeoNaDataViewProfile(null);
|
||||
geoNaDataViewerProfile = gc.readGNADataViewerConfig(null);
|
||||
session.setAttribute(GEONA_DATAVIEWER_PROFILE, geoNaDataViewerProfile);
|
||||
}
|
||||
|
||||
|
@ -197,18 +200,41 @@ public class SessionUtil {
|
|||
*/
|
||||
public static ResultSetSorted getLatestResultSetSorted(HttpServletRequest httpServletRequest) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
return (ResultSetSorted) session.getAttribute("LATEST_RESULT_SET_SORTED");
|
||||
return (ResultSetSorted) session.getAttribute(LATEST_RESULT_SET_SORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the latest sort filter.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param rsSorted the rs sorted
|
||||
* @return the latest sort filter
|
||||
*/
|
||||
public static void setLatestResultSetSorted(HttpServletRequest httpServletRequest, ResultSetSorted rsSorted) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute("LATEST_RESULT_SET_SORTED", rsSorted);
|
||||
session.setAttribute(LATEST_RESULT_SET_SORTED, rsSorted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GNA data entry config profile.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @return the GNA data entry config profile
|
||||
*/
|
||||
public static GNADataEntryConfigProfile getGNADataEntryConfigProfile(HttpServletRequest httpServletRequest) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
return (GNADataEntryConfigProfile) session.getAttribute(GNA_DATAENTRY_CONFIG_PROFILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GNA data entry config profile.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param gNADEConfigProfile the g NADE config profile
|
||||
*/
|
||||
public static void setGNADataEntryConfigProfile(HttpServletRequest httpServletRequest,
|
||||
GNADataEntryConfigProfile gNADEConfigProfile) {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
session.setAttribute(GNA_DATAENTRY_CONFIG_PROFILE, gNADEConfigProfile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
|
||||
|
||||
/**
|
||||
* The Class GNADataEntryExtConfigProfile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 21, 2021
|
||||
*/
|
||||
public class GNADataEntryExtConfigProfile extends GNADataEntryConfigProfile implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3185317083819447952L;
|
||||
private UserRights userRights = null;
|
||||
|
||||
/**
|
||||
* Instantiates a new GNA data entry config profile.
|
||||
*/
|
||||
public GNADataEntryExtConfigProfile() {
|
||||
|
||||
}
|
||||
|
||||
public UserRights getUserRights() {
|
||||
return userRights;
|
||||
}
|
||||
|
||||
public void setUserRights(UserRights userRights) {
|
||||
this.userRights = userRights;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GNADataEntryExtConfigProfile [userRights=");
|
||||
builder.append(userRights);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,39 +2,73 @@ package org.gcube.portlets.user.geoportaldataentry.shared;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GeonaISConfig implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeonaISConfig.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 22, 2021
|
||||
*/
|
||||
public class GeonaISConfig implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6700506811708315617L;
|
||||
|
||||
String gRSecondaryType;
|
||||
String scope;
|
||||
|
||||
private static final long serialVersionUID = 4187839053354198268L;
|
||||
private String genericResSecondaryType;
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* Instantiates a new geona IS config.
|
||||
*/
|
||||
public GeonaISConfig() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new geona IS config.
|
||||
*
|
||||
* @param gRSecondaryType the g R secondary type
|
||||
* @param scope the scope
|
||||
*/
|
||||
public GeonaISConfig(String gRSecondaryType, String scope) {
|
||||
super();
|
||||
this.gRSecondaryType = gRSecondaryType;
|
||||
this.genericResSecondaryType = gRSecondaryType;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
|
||||
public String getgRSecondaryType() {
|
||||
return gRSecondaryType;
|
||||
/**
|
||||
* Gets the generic resource secondary type.
|
||||
*
|
||||
* @return the generic resource secondary type
|
||||
*/
|
||||
public String getGenericResourceSecondaryType() {
|
||||
return genericResSecondaryType;
|
||||
}
|
||||
|
||||
public void setgRSecondaryType(String gRSecondaryType) {
|
||||
this.gRSecondaryType = gRSecondaryType;
|
||||
/**
|
||||
* Sets the generic resource secondary type.
|
||||
*
|
||||
* @param gRSecondaryType the new generic resource secondary type
|
||||
*/
|
||||
public void setGenericResourceSecondaryType(String gRSecondaryType) {
|
||||
this.genericResSecondaryType = gRSecondaryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scope.
|
||||
*
|
||||
* @param scope the new scope
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
@ -42,14 +76,12 @@ public class GeonaISConfig implements Serializable{
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeonaISConfig [gRSecondaryType=");
|
||||
builder.append(gRSecondaryType);
|
||||
builder.append("GeonaISConfig [genericResSecondaryType=");
|
||||
builder.append(genericResSecondaryType);
|
||||
builder.append(", scope=");
|
||||
builder.append(scope);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
|
||||
|
||||
/**
|
||||
* The Class ResultSetPaginatedData.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
*/
|
||||
public class ResultSetPaginatedData implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6800997954077785719L;
|
||||
private List<ConcessioneDV> data;
|
||||
private int clientStartIndex = 0;
|
||||
private int limit;
|
||||
private int serverEndIndex = 0;
|
||||
private boolean isServerSearchFinished = false;
|
||||
private long totalItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new searched folder.
|
||||
*/
|
||||
public ResultSetPaginatedData() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new result set paginated data.
|
||||
*
|
||||
* @param clientStartIndex the client start index
|
||||
* @param limit the limit
|
||||
* @param serverEndIndex the server end index
|
||||
* @param isServerSearchFinished the is server search finished
|
||||
*/
|
||||
public ResultSetPaginatedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) {
|
||||
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
this.limit = limit;
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public List<ConcessioneDV> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client start index.
|
||||
*
|
||||
* @return the client start index
|
||||
*/
|
||||
public int getClientStartIndex() {
|
||||
return clientStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the limit.
|
||||
*
|
||||
* @return the limit
|
||||
*/
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server end index.
|
||||
*
|
||||
* @return the server end index
|
||||
*/
|
||||
public int getServerEndIndex() {
|
||||
return serverEndIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is server search finished.
|
||||
*
|
||||
* @return true, if is server search finished
|
||||
*/
|
||||
public boolean isServerSearchFinished() {
|
||||
return isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data the new data
|
||||
*/
|
||||
public void setData(List<ConcessioneDV> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client start index.
|
||||
*
|
||||
* @param clientStartIndex the new client start index
|
||||
*/
|
||||
public void setClientStartIndex(int clientStartIndex) {
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the limit.
|
||||
*
|
||||
* @param limit the new limit
|
||||
*/
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server end index.
|
||||
*
|
||||
* @param serverEndIndex the new server end index
|
||||
*/
|
||||
public void setServerEndIndex(int serverEndIndex) {
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server search finished.
|
||||
*
|
||||
* @param isServerSearchFinished the new server search finished
|
||||
*/
|
||||
public void setServerSearchFinished(boolean isServerSearchFinished) {
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total items.
|
||||
*
|
||||
* @return the total items
|
||||
*/
|
||||
public long getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total items.
|
||||
*
|
||||
* @param totalItems the new total items
|
||||
*/
|
||||
public void setTotalItems(long totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ResultSetPaginatedData [data=");
|
||||
builder.append(data);
|
||||
builder.append(", clientStartIndex=");
|
||||
builder.append(clientStartIndex);
|
||||
builder.append(", limit=");
|
||||
builder.append(limit);
|
||||
builder.append(", serverEndIndex=");
|
||||
builder.append(serverEndIndex);
|
||||
builder.append(", isServerSearchFinished=");
|
||||
builder.append(isServerSearchFinished);
|
||||
builder.append(", totalItems=");
|
||||
builder.append(totalItems);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
|
||||
public class ResultSetSorted implements Serializable {
|
||||
|
||||
|
@ -12,7 +13,7 @@ public class ResultSetSorted implements Serializable {
|
|||
*/
|
||||
private static final long serialVersionUID = 889420364685643758L;
|
||||
|
||||
private SortFilter searchFilter;
|
||||
private SearchingFilter searchFilter;
|
||||
|
||||
private List<Concessione> data;
|
||||
|
||||
|
@ -20,13 +21,13 @@ public class ResultSetSorted implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public ResultSetSorted(SortFilter searchFilter, List<Concessione> data) {
|
||||
public ResultSetSorted(SearchingFilter searchFilter, List<Concessione> data) {
|
||||
super();
|
||||
this.searchFilter = searchFilter;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public SortFilter getSearchFilter() {
|
||||
public SearchingFilter getSearchFilter() {
|
||||
return searchFilter;
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,7 @@ public class ResultSetSorted implements Serializable {
|
|||
return data;
|
||||
}
|
||||
|
||||
public void setSearchFilter(SortFilter searchFilter) {
|
||||
public void setSearchFilter(SearchingFilter searchFilter) {
|
||||
this.searchFilter = searchFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_FIELD;
|
||||
|
||||
/**
|
||||
* The Class SortFilter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
*/
|
||||
public class SortFilter implements Serializable {
|
||||
|
||||
/**
|
||||
* The Enum ORDER.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 6, 2021
|
||||
*/
|
||||
public static enum ORDER {
|
||||
ASC("ASCENDING"), DESC("DESCENDING");
|
||||
|
||||
String label;
|
||||
|
||||
ORDER(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4004094263090373626L;
|
||||
|
||||
private RECORD_FIELD orderByField;
|
||||
|
||||
private ORDER order;
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*/
|
||||
public SortFilter() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new sort filter.
|
||||
*
|
||||
* @param orderByField the order by field
|
||||
* @param order the order
|
||||
*/
|
||||
public SortFilter(RECORD_FIELD orderByField, ORDER order) {
|
||||
this.orderByField = orderByField;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order by field.
|
||||
*
|
||||
* @return the order by field
|
||||
*/
|
||||
public RECORD_FIELD getOrderByField() {
|
||||
return orderByField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the order.
|
||||
*
|
||||
* @return the order
|
||||
*/
|
||||
public ORDER getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order by field.
|
||||
*
|
||||
* @param orderByField the new order by field
|
||||
*/
|
||||
public void setOrderByField(RECORD_FIELD orderByField) {
|
||||
this.orderByField = orderByField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the order.
|
||||
*
|
||||
* @param order the new order
|
||||
*/
|
||||
public void setOrder(ORDER order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SortFilter [orderByField=");
|
||||
builder.append(orderByField);
|
||||
builder.append(", order=");
|
||||
builder.append(order);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
||||
|
||||
/**
|
||||
* The Class UserRights.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Nov 24, 2021
|
||||
*/
|
||||
public class UserRights implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -304157165851633221L;
|
||||
|
||||
private String myUsername;
|
||||
|
||||
private RoleRights roleRights;
|
||||
|
||||
/**
|
||||
* Instantiates a new user rights.
|
||||
*/
|
||||
public UserRights() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UserRights(String myUsername, RoleRights roleRights) {
|
||||
super();
|
||||
this.myUsername = myUsername;
|
||||
this.roleRights = roleRights;
|
||||
}
|
||||
|
||||
public String getMyUsername() {
|
||||
return myUsername;
|
||||
}
|
||||
|
||||
public RoleRights getRoleRights() {
|
||||
return roleRights;
|
||||
}
|
||||
|
||||
public void setMyUsername(String myUsername) {
|
||||
this.myUsername = myUsername;
|
||||
}
|
||||
|
||||
public void setRoleRights(RoleRights roleRights) {
|
||||
this.roleRights = roleRights;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UserRights [myUsername=");
|
||||
builder.append(myUsername);
|
||||
builder.append(", roleRights=");
|
||||
builder.append(roleRights);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -119,3 +119,30 @@ h1 {
|
|||
margin-left: 10px;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.nav-toolbar-style {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.nav-toolbar-style .container {
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.search-textbox {
|
||||
padding: 4px 14px !important;
|
||||
margin-bottom: 0 !important;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
||||
font-size: 13px !important;
|
||||
font-weight: normal !important;
|
||||
-webkit-border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px !important;
|
||||
width: 250px !important;
|
||||
margin-top: 8px !important;
|
||||
}
|
||||
|
||||
.alert_box_nav {
|
||||
padding: 4px 10px !important;
|
||||
margin-top: 8px !important;
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
|
|
|
@ -3,42 +3,40 @@ package org.gcube.portlets.user.geoportaldataentry.client;
|
|||
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.PagedRequest;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.BasicDBObjectBuilder;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
|
||||
private static String TOKEN = "";
|
||||
private static String CONTEXT ="/gcube/devsec/devVRE";
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
private static String USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
//@Before
|
||||
public void init() {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
||||
// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
|
||||
// System.out.println(ldt.toString());
|
||||
//
|
||||
// String latitudine = "-899.2986";
|
||||
// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// String longitude = "0";
|
||||
// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
|
||||
// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString());
|
||||
|
||||
getListOfConcessioni();
|
||||
|
||||
}
|
||||
|
||||
public static void getListOfConcessioni() throws Exception {
|
||||
// @Test
|
||||
public void getListConcessioniTest() throws Exception {
|
||||
MongoConcessioni clientMongo = mongoConcessioni().build();
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
List<Concessione> listOfConcessioni = new ArrayList<Concessione>();
|
||||
|
@ -46,13 +44,138 @@ public class TestClass {
|
|||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (Concessione concessione : listOfConcessioni) {
|
||||
System.out.println(++i+" "+concessione);
|
||||
System.out.println(++i + " " + concessione);
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void queryConcessioniTest() throws Exception {
|
||||
try {
|
||||
MongoConcessioni clientMongo = mongoConcessioni().build();
|
||||
int offsetIndex = 0;
|
||||
int limitIndex = 25;
|
||||
Direction sDirection = Direction.ASCENDING;
|
||||
List<String> orderByFields = Arrays.asList("nome");
|
||||
|
||||
Map<String, Object> searchFields = new HashMap<String, Object>();
|
||||
searchFields.put("nome", "test");
|
||||
searchFields.put("authors", "fra");
|
||||
|
||||
QueryRequest request = new QueryRequest();
|
||||
PagedRequest paging = new PagedRequest();
|
||||
paging.setOffset(offsetIndex);
|
||||
paging.setLimit(limitIndex);
|
||||
request.setPaging(paging);
|
||||
|
||||
OrderedRequest ordering = new OrderedRequest();
|
||||
|
||||
ordering.setDirection(sDirection);
|
||||
|
||||
ordering.setFields(orderByFields);
|
||||
request.setOrdering(ordering);
|
||||
|
||||
Document query = null;
|
||||
|
||||
if (searchFields != null) {
|
||||
|
||||
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
|
||||
|
||||
query = new Document();
|
||||
|
||||
for (String key : searchFields.keySet()) {
|
||||
// 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);
|
||||
System.out.println("Search for: " + query);
|
||||
System.out.println("Search for Query to JSON: " + query.toJson());
|
||||
|
||||
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()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
System.out.println(concessione.getNome());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void readUserRights() throws Exception {
|
||||
// new GNARoleRitghtsConfigReader();
|
||||
// List<RoleRights> listUserRights = GNARoleRitghtsConfigReader.readRoleRightsConfig();
|
||||
// System.out.println(listUserRights);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue