2020-10-07 17:04:13 +02:00
|
|
|
package org.gcube.portlets.user.geoportaldataentry.client;
|
|
|
|
|
2020-10-12 16:46:17 +02:00
|
|
|
import java.util.ArrayList;
|
2020-10-08 16:06:58 +02:00
|
|
|
import java.util.Arrays;
|
2020-10-12 13:04:01 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.LinkedHashMap;
|
2020-10-08 16:06:58 +02:00
|
|
|
import java.util.List;
|
2020-10-09 16:34:23 +02:00
|
|
|
import java.util.TreeMap;
|
2020-10-08 16:06:58 +02:00
|
|
|
|
2020-12-01 18:15:13 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
2021-12-06 17:24:27 +01:00
|
|
|
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;
|
2022-03-17 18:08:58 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.HandlerDeclarationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.UseCaseDescriptorDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
2021-08-05 16:49:04 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
2021-09-15 16:14:27 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
2021-09-14 13:08:55 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.ValidationReportDV;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
2021-08-04 17:11:46 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
2021-08-05 16:49:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler;
|
2020-10-20 09:58:56 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
|
2021-08-04 17:11:46 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler;
|
2020-10-20 09:58:56 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.resource.Images;
|
2021-08-05 16:49:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
|
2021-08-04 17:11:46 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow;
|
2020-10-12 13:04:01 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
2021-09-20 18:08:43 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord;
|
2021-08-04 17:11:46 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
2021-09-14 13:08:55 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.BuildValidationReport;
|
2021-01-26 12:52:49 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
2021-08-05 16:49:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogConfirm;
|
2022-03-17 18:08:58 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
|
2021-01-26 12:52:49 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
|
2020-10-20 09:58:56 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
2021-08-05 16:49:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.NewBrowserWindow;
|
2020-10-21 16:52:07 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
2021-12-21 16:51:56 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile;
|
2020-11-02 16:48:33 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
2020-10-21 15:36:50 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.UserRights;
|
2020-10-08 16:06:58 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderServiceAsync;
|
2020-10-08 15:09:25 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
2022-03-03 18:44:21 +01:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
2020-10-08 16:06:58 +02:00
|
|
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
2020-10-07 17:04:13 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Alert;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Modal;
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
2020-10-07 17:04:13 +02:00
|
|
|
import com.google.gwt.core.client.EntryPoint;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
2021-09-22 11:38:52 +02:00
|
|
|
import com.google.gwt.dom.client.Element;
|
2021-08-05 16:49:04 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2021-09-15 16:14:27 +02:00
|
|
|
import com.google.gwt.event.logical.shared.ResizeEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.ResizeHandler;
|
2020-10-08 15:09:25 +02:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2020-10-20 09:58:56 +02:00
|
|
|
import com.google.gwt.user.client.Window;
|
2020-10-08 16:06:58 +02:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2020-12-01 18:15:13 +01:00
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2020-11-06 12:24:37 +01:00
|
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
2021-11-26 16:05:05 +01:00
|
|
|
import com.google.gwt.user.client.ui.Image;
|
2020-10-07 17:04:13 +02:00
|
|
|
import com.google.gwt.user.client.ui.RootPanel;
|
2021-01-26 12:52:49 +01:00
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
2020-10-07 17:04:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Entry point classes define <code>onModuleLoad()</code>.
|
|
|
|
*/
|
|
|
|
public class GeoPortalDataEntryApp implements EntryPoint {
|
2020-10-21 15:36:50 +02:00
|
|
|
|
2020-10-08 15:09:25 +02:00
|
|
|
/**
|
|
|
|
* The message displayed to the user when the server cannot be reached or
|
|
|
|
* returns an error.
|
|
|
|
*/
|
|
|
|
private static final String SERVER_ERROR = "An error occurred while "
|
|
|
|
+ "attempting to contact the server. Please check your network " + "connection and try again.";
|
|
|
|
|
|
|
|
private static final String DIV_PORTLET_ID = "geoportal-data-entry";
|
|
|
|
|
2021-09-27 15:28:36 +02:00
|
|
|
public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT
|
|
|
|
.create(GeoportalDataEntryService.class);
|
2020-10-08 15:09:25 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
private final HandlerManager appManagerBus = new HandlerManager(null);
|
2020-10-09 16:34:23 +02:00
|
|
|
|
2020-10-12 16:46:17 +02:00
|
|
|
private LinkedHashMap<String, GeoNaFormCardModel> mapForms = new LinkedHashMap<String, GeoNaFormCardModel>();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
private GeonaDataEntryMainForm geoNaMainForm = null;
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
private Collection<GeoNaFormCardModel> orderedCards = new ArrayList<GeoNaFormCardModel>();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
private GeonaMainTabPanel mainTabPanel;
|
|
|
|
|
2021-07-30 11:53:12 +02:00
|
|
|
private LinkedHashMap<String, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<String, List<GeoNaFormDataObject>>();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-11-06 12:24:37 +01:00
|
|
|
private boolean projectSavedWithSuccess;
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-09-15 16:14:27 +02:00
|
|
|
private GeonaRecordsPaginatedView grpw = null;
|
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
private UserRights myRights = null;
|
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
private LoaderIcon loader = new LoaderIcon("Loading Application... please wait");
|
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
private List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
|
|
|
|
private List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
|
|
|
|
private List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
private GeonaISConfig geonaISConfig;
|
|
|
|
|
|
|
|
private TreeMap<String, List<GeoNaFormCardModel>> mapGcubeProfilePerItemType = new TreeMap<String, List<GeoNaFormCardModel>>();
|
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
private int numberOfCards = 0;
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
private int expectedCards = 0;
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
private synchronized void incrementNumberOfCards() {
|
|
|
|
numberOfCards++;
|
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
private synchronized int getNumberOfCards() {
|
|
|
|
return numberOfCards;
|
|
|
|
}
|
2021-11-26 16:05:05 +01:00
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
private List<UseCaseDescriptorDV> listUCDescriptors;
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
private boolean dataEntryProjectCreated = false;
|
|
|
|
|
2020-10-08 15:09:25 +02:00
|
|
|
/**
|
|
|
|
* This is the entry point method.
|
|
|
|
*/
|
|
|
|
public void onModuleLoad() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(loader);
|
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
2021-12-06 17:24:27 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2022-03-03 18:44:21 +01:00
|
|
|
String errorMsg = "Sorry, an error occurrend when loading configurations. 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);
|
2021-12-06 17:24:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-03-03 18:44:21 +01:00
|
|
|
public void onSuccess(GeonaISConfig result) {
|
2022-03-04 14:40:43 +01:00
|
|
|
geonaISConfig = result;
|
2021-12-06 17:24:27 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
if (result != null && result.getScope() != null) {
|
|
|
|
|
|
|
|
loadGeoportalConfigs(result.getScope());
|
2022-03-03 18:44:21 +01:00
|
|
|
} else
|
2022-03-04 14:40:43 +01:00
|
|
|
Window.alert("Sorry, no scope found in the session. Re-login and try again");
|
2021-12-06 17:24:27 +01:00
|
|
|
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
});
|
2020-10-21 15:36:50 +02:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance()
|
|
|
|
.readDataViewerConfig(new AsyncCallback<GNADataEntryExtConfigProfile>() {
|
2021-11-26 16:05:05 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
@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) {
|
2020-10-21 15:36:50 +02:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(alert);
|
|
|
|
Window.alert(errorMsg);
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-12-21 16:51:56 +01:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
List<ItemFieldDV> itemFields = gNADataEntryConfig.getListItemFields();
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
for (ItemFieldDV itemField : itemFields) {
|
2022-03-04 14:40:43 +01:00
|
|
|
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(
|
2022-03-17 18:08:58 +01:00
|
|
|
Arrays.asList(new ItemFieldDV("Name", Arrays.asList("name"), null, true, true, true)));
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
displayFields = itemFields;
|
|
|
|
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields,
|
|
|
|
initialSortFilter);
|
|
|
|
|
|
|
|
// TWICE BECAUSE THE MAIN PANEL COULD BE NULL BEFORE
|
2022-03-17 18:08:58 +01:00
|
|
|
setListUseCaseDescriptors(listUCDescriptors);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:51:56 +01:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
});
|
2021-11-26 16:05:05 +01:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
private void initGUI() {
|
2020-10-21 15:36:50 +02:00
|
|
|
bindEvents();
|
2021-08-05 16:49:04 +02:00
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
2021-09-15 16:14:27 +02:00
|
|
|
Window.addResizeHandler(new ResizeHandler() {
|
|
|
|
@Override
|
|
|
|
public void onResize(ResizeEvent event) {
|
|
|
|
GWT.log("onWindowResized width: " + event.getWidth() + " height: " + event.getHeight());
|
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
private static native void click(Element element)/*-{
|
|
|
|
element.click();
|
|
|
|
}-*/;
|
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
private void loadGeoportalConfigs(final String scope) {
|
|
|
|
GWT.log("loading GeoportalConfigsAndBuildCards in the scope: " + scope);
|
2022-03-03 18:44:21 +01:00
|
|
|
orderedCards = new ArrayList<GeoNaFormCardModel>();
|
2022-03-17 18:08:58 +01:00
|
|
|
// // TODO PASS THE RIGHT ID
|
|
|
|
// GeoportalDataEntryServiceAsync.Util.getInstance().getListDocumentConfigurationForId("id",
|
|
|
|
// new AsyncCallback<List<DocumentConfigDV>>() {
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onFailure(Throwable caught) {
|
|
|
|
// GWT.log("caught: " + caught);
|
|
|
|
// Window.alert(caught.toString());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public void onSuccess(List<DocumentConfigDV> result) {
|
|
|
|
// listUCDescriptors = result;
|
|
|
|
// GWT.log("List<DocumentConfigDV>: " + result);
|
|
|
|
//
|
|
|
|
// if (result == null || result.size() == 0) {
|
|
|
|
// Window.alert("No Configuration found in this scope. Please contact the support");
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// setListDocumentConfig(listUCDescriptors);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(null,
|
|
|
|
new AsyncCallback<List<UseCaseDescriptorDV>>() {
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
GWT.log("caught: " + caught);
|
|
|
|
Window.alert(caught.toString());
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
@Override
|
2022-03-17 18:08:58 +01:00
|
|
|
public void onSuccess(List<UseCaseDescriptorDV> result) {
|
|
|
|
listUCDescriptors = result;
|
|
|
|
GWT.log("List<UseCaseDescriptorDV>: " + listUCDescriptors);
|
|
|
|
listUCDescriptors = result;
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log("List<DocumentConfigDV>: " + result);
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
if (result == null || result.size() == 0) {
|
|
|
|
Window.alert("No Configuration found in this scope. Please contact the support");
|
|
|
|
return;
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
setListUseCaseDescriptors(listUCDescriptors);
|
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
private synchronized void setListUseCaseDescriptors(List<UseCaseDescriptorDV> listUCDescriptors) {
|
|
|
|
GWT.log("Setting listUCDescriptors: " + listUCDescriptors);
|
|
|
|
if (listUCDescriptors != null) {
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
if (mainTabPanel != null) {
|
2022-03-17 18:08:58 +01:00
|
|
|
// Just to be sure that its set once
|
|
|
|
if (mainTabPanel.getListUCDescriptors() == null) {
|
|
|
|
mainTabPanel.setListUseCaseDescriptors(listUCDescriptors);
|
2022-03-04 16:44:51 +01:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-09-15 16:14:27 +02:00
|
|
|
/**
|
|
|
|
* Update window size
|
|
|
|
*/
|
|
|
|
public void updateSize() {
|
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
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);
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
}
|
2021-09-15 16:14:27 +02:00
|
|
|
// appController.getMainPanel().setHeight(rootHeight);
|
|
|
|
// appController.getMainPanel().setWidth(rootWidth);
|
|
|
|
|
2020-10-21 15:36:50 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
private void createNewDataEntyFor(HandlerDeclarationDV handlerDeclarationDV, List<GcubeProfileDV> listGPs) {
|
2022-03-04 14:40:43 +01:00
|
|
|
dataEntryProjectCreated = true;
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
|
|
|
orderedCards.clear();
|
|
|
|
resetUI();
|
|
|
|
|
2022-03-17 18:08:58 +01:00
|
|
|
List<GeoNaFormCardModel> cardsPerIT = mapGcubeProfilePerItemType.get(handlerDeclarationDV.getItemType());
|
|
|
|
mainTabPanel.setPageHeader(handlerDeclarationDV);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
if (cardsPerIT != null) {
|
|
|
|
orderedCards.addAll(cardsPerIT);
|
|
|
|
buildNewCards(orderedCards, OPERATION.NEW);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
numberOfCards = 0;
|
2022-03-17 18:08:58 +01:00
|
|
|
expectedCards = listGPs.size();
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log("expectedCards are: " + expectedCards);
|
2022-03-04 16:44:51 +01:00
|
|
|
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGNAProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < expectedCards; i++) {
|
2022-03-17 18:08:58 +01:00
|
|
|
GcubeProfileDV gcubeProfiles = listGPs.get(i);
|
2022-03-04 14:40:43 +01:00
|
|
|
final int order = i;
|
|
|
|
GWT.log("calling getProfilesInTheScope for secondaryType: " + gcubeProfiles.getGcubeSecondaryType()
|
|
|
|
+ ", name: " + gcubeProfiles.getGcubeName());
|
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScopeForName(
|
|
|
|
geonaISConfig.getScope(), gcubeProfiles.getGcubeSecondaryType(), gcubeProfiles.getGcubeName(),
|
|
|
|
new AsyncCallback<List<MetaDataProfileBean>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
|
|
|
|
|
|
|
incrementNumberOfCards();
|
|
|
|
GWT.log("loaded " + getNumberOfCards() + " of " + expectedCards + " card/s");
|
|
|
|
GWT.log("Returned " + result.size() + " profile/s");
|
|
|
|
// orderedCards = setGeoNaFormsOrder(result);
|
|
|
|
for (MetaDataProfileBean metaDataProfileBean : result) {
|
|
|
|
|
|
|
|
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
|
|
|
GWT.log("Building form card for type: " + theMetaType);
|
|
|
|
|
|
|
|
// Managing Forms repeatability
|
|
|
|
int minOccurs = gcubeProfiles.getMinOccurs();
|
|
|
|
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
|
|
|
|
int maxOccurs = gcubeProfiles.getMaxOccurs();
|
|
|
|
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
|
|
|
|
|
|
|
|
// TODO MUST BE MANAGED MIN_OCCURS
|
2022-03-17 18:08:58 +01:00
|
|
|
ProjectFormCard cct = new ProjectFormCard(gcubeProfiles.getSectionName(),
|
|
|
|
gcubeProfiles.getSectionTitle(), order, maxOccurs > 1, minOccurs, maxOccurs);
|
2022-03-04 14:40:43 +01:00
|
|
|
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, cct,
|
|
|
|
gcubeProfiles);
|
|
|
|
|
2022-03-04 16:44:51 +01:00
|
|
|
treemapOrderedGNAProfiles.put(order, geonaForm);
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
|
2022-03-07 17:48:32 +01:00
|
|
|
if (getNumberOfCards() >= expectedCards) {
|
2022-03-04 14:40:43 +01:00
|
|
|
mainTabPanel.setLoaderVisible("Loading...", false);
|
|
|
|
// ordered values
|
2022-03-04 16:44:51 +01:00
|
|
|
Collection<GeoNaFormCardModel> gnaCardsModels = treemapOrderedGNAProfiles.values();
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log("TreMap values: " + gnaCardsModels);
|
|
|
|
orderedCards.addAll(gnaCardsModels);
|
2022-03-17 18:08:58 +01:00
|
|
|
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
|
2022-03-04 14:40:43 +01:00
|
|
|
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
|
|
|
buildNewCards(orderedCards, OPERATION.UPDATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", false);
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-03-03 18:44:21 +01:00
|
|
|
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards, OPERATION operation) {
|
2021-08-05 16:49:04 +02:00
|
|
|
projectSavedWithSuccess = false; // resetting state of saving
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
2022-03-04 14:40:43 +01:00
|
|
|
geoNaMainForm.setVisibleFormActions(true);
|
2020-10-20 09:58:56 +02:00
|
|
|
resetUI();
|
2021-08-05 16:49:04 +02:00
|
|
|
// ordered values
|
2020-10-20 09:58:56 +02:00
|
|
|
for (GeoNaFormCardModel geonaForm : orderedCards) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
// TODO TO TEST
|
2022-03-04 16:44:51 +01:00
|
|
|
// if(geonaForm.getFormCardTitle().equals(ProjectFormCard.IMMAGINI_RAPPRESENTATIVE)){
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-03-04 16:44:51 +01:00
|
|
|
GWT.log("Adding card: " + geonaForm.getFormCard());
|
2021-08-05 16:49:04 +02:00
|
|
|
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),
|
2022-03-03 18:44:21 +01:00
|
|
|
appManagerBus, operation);
|
2021-08-05 16:49:04 +02:00
|
|
|
geonaForm.setMetadataForm(baseForm);
|
|
|
|
String key = geonaForm.getMetadataProfileBean().getType();
|
2022-03-04 16:44:51 +01:00
|
|
|
if (geonaForm.getFormCard() != null) {
|
|
|
|
key = geonaForm.getFormCard().getTitle();
|
2021-08-05 16:49:04 +02:00
|
|
|
}
|
|
|
|
geoNaMainForm.addForm(key, geonaForm);
|
|
|
|
mapForms.put(key, geonaForm);
|
|
|
|
|
|
|
|
// }
|
2020-10-20 09:58:56 +02:00
|
|
|
}
|
2020-12-11 09:56:17 +01:00
|
|
|
geoNaMainForm.enableButtonSave(true);
|
2021-08-05 16:49:04 +02:00
|
|
|
mainTabPanel.setLoaderVisible("", false);
|
2020-10-20 09:58:56 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
private void resetUI() {
|
|
|
|
geoNaMainForm.reset();
|
|
|
|
mapForms.clear();
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
private void bindEvents() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
appManagerBus.addHandler(SaveGeonaDataFormsEvent.TYPE, new SaveGeonaDataFormsHandler() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
@Override
|
2020-11-02 16:48:33 +01:00
|
|
|
public void onSave(final SaveGeonaDataFormsEvent saveGeonaDataFormsEvent) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-21 16:16:53 +02:00
|
|
|
geoNaMainForm.enableButtonSave(false);
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
if (saveGeonaDataFormsEvent.getListGeonaDataForms() != null) {
|
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
final Modal modal = new Modal(true);
|
|
|
|
modal.setCloseVisible(false);
|
2020-11-06 12:24:37 +01:00
|
|
|
modal.setTitle("Saving project...");
|
|
|
|
modal.hide(false);
|
2021-01-26 14:56:47 +01:00
|
|
|
modal.setWidth(800);
|
2021-01-26 12:52:49 +01:00
|
|
|
modal.setMaxHeigth("650px");
|
|
|
|
final VerticalPanel modalContainerPanel = new VerticalPanel();
|
2020-10-20 09:58:56 +02:00
|
|
|
final LoaderIcon loader = new LoaderIcon();
|
|
|
|
loader.setText("Trying to save the data, please wait...");
|
2020-11-06 12:24:37 +01:00
|
|
|
modalContainerPanel.add(loader);
|
|
|
|
modal.add(modalContainerPanel);
|
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(
|
|
|
|
saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() {
|
2020-10-20 09:58:56 +02:00
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
try {
|
|
|
|
modal.remove(loader);
|
|
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
|
|
Alert alert = new Alert(caught.getMessage());
|
|
|
|
alert.setType(AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
modal.add(alert);
|
|
|
|
// resetUI();
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
2020-12-01 18:15:13 +01:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(CommitReport result) {
|
|
|
|
modalContainerPanel.clear();
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
HTML recordPublished = new HTML();
|
2021-09-14 13:08:55 +02:00
|
|
|
ValidationReportDV vr = result.getValidationReportDV();
|
|
|
|
switch (vr.getStatus()) {
|
|
|
|
case PASSED:
|
2021-08-05 16:49:04 +02:00
|
|
|
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
|
|
|
"SUCCESS");
|
|
|
|
recordPublished.setHTML("Record Published with " + success);
|
|
|
|
projectSavedWithSuccess = true;
|
2021-09-14 13:08:55 +02:00
|
|
|
String msg = "Record published with success";
|
2021-08-05 16:49:04 +02:00
|
|
|
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
|
|
|
purgeFileUploaded();
|
|
|
|
break;
|
2021-09-14 13:08:55 +02:00
|
|
|
case WARNING:
|
2021-08-05 16:49:04 +02:00
|
|
|
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
|
|
|
|
"WARNING");
|
|
|
|
recordPublished.setHTML("Record Published with " + warning);
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
break;
|
|
|
|
case ERROR:
|
|
|
|
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
|
|
|
|
"ERROR");
|
|
|
|
recordPublished.setHTML(error + " on publishing the Record");
|
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
modalContainerPanel.add(recordPublished);
|
|
|
|
|
|
|
|
if (result.getMongoId() != null) {
|
|
|
|
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
|
|
|
|
|
|
|
try {
|
|
|
|
savedMap.put(result.getMongoId(),
|
|
|
|
saveGeonaDataFormsEvent.getListGeonaDataForms());
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
}
|
|
|
|
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Get link...");
|
|
|
|
hpGetLink.add(lc);
|
|
|
|
modalContainerPanel.add(hpGetLink);
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(
|
|
|
|
result.getMongoId(), RECORD_TYPE.CONCESSIONE,
|
|
|
|
new AsyncCallback<GeoNaItemRef>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
hpGetLink.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(GeoNaItemRef result) {
|
|
|
|
hpGetLink.clear();
|
|
|
|
String theURL = result.getRestrictedLink().getShortURL() != null
|
|
|
|
? result.getRestrictedLink().getShortURL()
|
|
|
|
: result.getRestrictedLink().getCompleteURL();
|
|
|
|
String htmlLink = "<div>Go to record: <a href=" + theURL
|
|
|
|
+ " target=\"_blank\">" + theURL + "</a></div>";
|
|
|
|
HTML html = new HTML(htmlLink);
|
|
|
|
hpGetLink.add(html);
|
|
|
|
// modal.add(html);
|
|
|
|
}
|
|
|
|
});
|
2021-01-26 12:52:49 +01:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
// geoNaMainForm.enableButtonSave(true);
|
|
|
|
// resetUI();
|
|
|
|
|
2021-09-14 13:08:55 +02:00
|
|
|
if (vr.getAsJSONString() != null) {
|
2021-09-30 13:06:14 +02:00
|
|
|
modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false));
|
2021-01-26 12:52:49 +01:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-10-20 11:49:23 +02:00
|
|
|
modal.show();
|
2021-08-05 16:49:04 +02:00
|
|
|
} else
|
2020-10-21 16:16:53 +02:00
|
|
|
geoNaMainForm.enableButtonSave(true);
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
}
|
|
|
|
});
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
appManagerBus.addHandler(CreateNewProjectEvent.TYPE, new CreateNewProjectEventHandler() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
@Override
|
|
|
|
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log("Crate new project");
|
|
|
|
if (!dataEntryProjectCreated) {
|
2022-03-17 18:08:58 +01:00
|
|
|
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles());
|
2022-03-04 14:40:43 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-11-06 12:24:37 +01:00
|
|
|
// means the form was not submitted
|
|
|
|
if (savedMap.size() == 0) {
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-04 16:44:51 +01:00
|
|
|
DialogConfirm confirm = new DialogConfirm(null, "Creating New Project...",
|
2022-03-04 14:40:43 +01:00
|
|
|
"The current project (is not saved) and will be lost. Confirm?");
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
confirm.getYesButton().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
confirm.hide();
|
2022-03-17 18:08:58 +01:00
|
|
|
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles());
|
2022-03-04 14:40:43 +01:00
|
|
|
// buildNewCards(orderedCards, OPERATION.NEW);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
confirm.center();
|
|
|
|
|
2020-11-06 12:24:37 +01:00
|
|
|
} else if (projectSavedWithSuccess) {
|
2021-08-05 16:49:04 +02:00
|
|
|
// means the project has been saved
|
2022-03-17 18:08:58 +01:00
|
|
|
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles());
|
2022-03-04 14:40:43 +01:00
|
|
|
// buildNewCards(orderedCards, OPERATION.NEW);
|
2020-11-06 12:24:37 +01:00
|
|
|
} else {
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-03-04 16:44:51 +01:00
|
|
|
DialogConfirm confirm = new DialogConfirm(null, "Creating New Project...",
|
2022-03-04 14:40:43 +01:00
|
|
|
"The data entry form/s will be cleaned. Confirm?");
|
|
|
|
|
|
|
|
confirm.getYesButton().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
confirm.hide();
|
2022-03-17 18:08:58 +01:00
|
|
|
createNewDataEntyFor(newProjectEvent.getHandler(), newProjectEvent.getListGcubeProfiles());
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
confirm.center();
|
2020-11-02 16:48:33 +01:00
|
|
|
}
|
2020-11-06 12:24:37 +01:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
}
|
|
|
|
});
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-08-04 17:11:46 +02:00
|
|
|
appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-08-04 17:11:46 +02:00
|
|
|
@Override
|
|
|
|
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-12-01 11:54:39 +01:00
|
|
|
SearchingFilter sortFilter = getListOfRecordsEvent.getSortFilter();
|
2021-11-26 16:05:05 +01:00
|
|
|
if (sortFilter == null) {
|
2021-09-27 15:28:36 +02:00
|
|
|
sortFilter = mainTabPanel.getCurrentSortFilter();
|
|
|
|
}
|
2022-03-17 18:08:58 +01:00
|
|
|
String profileID = getListOfRecordsEvent.getProfileID();
|
|
|
|
if (profileID == null) {
|
|
|
|
new DialogInform(null, "Error", "No user case descriptor selected").center();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, sortFilter);
|
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
mainTabPanel.showListOfConcessioniView(grpw);
|
|
|
|
}
|
|
|
|
});
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
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,
|
2022-03-17 18:08:58 +01:00
|
|
|
actionPerformedOnItemEvent.getProfileID(), null,
|
2021-11-26 16:05:05 +01:00
|
|
|
mainTabPanel.getCurrentSortFilter()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
2021-09-15 16:14:27 +02:00
|
|
|
public <T extends RecordDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
|
|
|
|
|
|
|
|
GWT.log("Fired event: " + showItemEvent);
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
if (showItemEvent != null) {
|
|
|
|
|
|
|
|
ACTION_ON_ITEM action = showItemEvent.getAction();
|
|
|
|
List<T> items = showItemEvent.getSelectItems();
|
|
|
|
|
2021-09-15 16:14:27 +02:00
|
|
|
if (items == null) {
|
|
|
|
if (grpw != null) {
|
|
|
|
items = (List<T>) grpw.getSelectItems();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (items == null || items.size() == 0) {
|
|
|
|
Window.alert("You must select a record in the table");
|
2021-08-05 16:49:04 +02:00
|
|
|
return;
|
2021-09-15 16:14:27 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
T item = items.get(0);
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (item instanceof ConcessioneDV) {
|
|
|
|
|
|
|
|
final ConcessioneDV concessione = (ConcessioneDV) item;
|
2021-11-26 16:05:05 +01:00
|
|
|
GWT.log("onDoActionFired item: " + concessione);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
// 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);
|
2022-03-04 14:40:43 +01:00
|
|
|
boolean allowedOperationForUser = operationType != null ? true : false;
|
2021-11-26 16:05:05 +01:00
|
|
|
if (!allowedOperationForUser) {
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
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);
|
2021-11-26 16:05:05 +01:00
|
|
|
modalW.show();
|
|
|
|
return;
|
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
// 2. the user cannot access to action (e.g. the user cannot write an item of
|
|
|
|
// another user)
|
2021-11-26 16:05:05 +01:00
|
|
|
// if so an error is shown
|
|
|
|
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
2022-03-04 14:40:43 +01:00
|
|
|
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType,
|
|
|
|
concessione);
|
2021-11-26 16:05:05 +01:00
|
|
|
if (!allowedWriteActionOnItem) {
|
|
|
|
String title = "Forbidden: missing write access";
|
2022-03-04 14:40:43 +01:00
|
|
|
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()) {
|
2021-11-26 16:05:05 +01:00
|
|
|
title = "Forbidden: missing ownership";
|
2022-03-04 14:40:43 +01:00
|
|
|
msg = "You are not the creator of: " + concessione.getNome()
|
|
|
|
+ ". You cannot access to it";
|
2021-11-26 16:05:05 +01:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg,
|
|
|
|
AlertType.WARNING);
|
2021-11-26 16:05:05 +01:00
|
|
|
modalW.show();
|
|
|
|
return;
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
switch (action) {
|
2021-11-26 16:05:05 +01:00
|
|
|
case VIEW_ON_MAP:
|
2021-08-05 16:49:04 +02:00
|
|
|
final Modal modal = new Modal(true, true);
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
2021-09-14 13:08:55 +02:00
|
|
|
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
|
2021-08-05 16:49:04 +02:00
|
|
|
hpGetLink.add(lc);
|
|
|
|
modal.add(hpGetLink);
|
2021-09-14 17:51:20 +02:00
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(concessione.getItemId(),
|
|
|
|
RECORD_TYPE.CONCESSIONE, new AsyncCallback<GeoNaItemRef>() {
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
hpGetLink.clear();
|
|
|
|
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
hpGetLink.add(alert);
|
|
|
|
newBrowserWindow.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(GeoNaItemRef result) {
|
|
|
|
String theURL = result.getRestrictedLink().getShortURL() != null
|
|
|
|
? result.getRestrictedLink().getShortURL()
|
|
|
|
: result.getRestrictedLink().getCompleteURL();
|
|
|
|
newBrowserWindow.setUrl(theURL);
|
|
|
|
modal.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
modal.show();
|
|
|
|
|
2021-09-14 13:08:55 +02:00
|
|
|
break;
|
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
case VIEW_REPORT:
|
|
|
|
|
2021-09-14 13:08:55 +02:00
|
|
|
final Modal modal2 = new Modal(true, true);
|
2021-11-26 16:05:05 +01:00
|
|
|
modal2.setTitle(
|
|
|
|
"<span style='font-size:20px;'>Report: <span style='color:#555; font-size:20px;'>"
|
|
|
|
+ concessione.getNome() + "</span></span>");
|
2021-09-14 13:08:55 +02:00
|
|
|
modal2.setWidth(800);
|
|
|
|
modal2.setCloseVisible(true);
|
|
|
|
if (concessione.getValidationReport() == null) {
|
2021-09-14 17:51:20 +02:00
|
|
|
modal2.add(new HTML("No report available for: " + concessione.getNome()));
|
2021-09-14 13:08:55 +02:00
|
|
|
} else {
|
|
|
|
BuildValidationReport buildValidationReport = new BuildValidationReport(
|
|
|
|
concessione.getValidationReport());
|
|
|
|
modal2.add(buildValidationReport);
|
|
|
|
}
|
|
|
|
modal2.show();
|
|
|
|
|
2021-09-15 16:33:24 +02:00
|
|
|
break;
|
2021-09-27 15:28:36 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
case EDIT_PROJECT:
|
2021-09-15 16:33:24 +02:00
|
|
|
final Modal modal3 = new Modal(true, true);
|
2021-11-26 16:05:05 +01:00
|
|
|
modal3.setTitle(
|
|
|
|
"<span style='font-size:20px;'>Edit: <span style='color:#555; font-size:20px;'>"
|
|
|
|
+ concessione.getNome() + "</span></span>");
|
2021-09-20 18:08:43 +02:00
|
|
|
modal3.setWidth(950);
|
|
|
|
modal3.setHeight("700px");
|
2021-09-15 16:33:24 +02:00
|
|
|
modal3.setCloseVisible(true);
|
2021-09-27 15:28:36 +02:00
|
|
|
((Element) modal3.getElement().getChildNodes().getItem(1))
|
|
|
|
.addClassName("modal-body-custom");
|
|
|
|
EditModeRecord emr = new EditModeRecord(appManagerBus, concessione,
|
|
|
|
RECORD_TYPE.CONCESSIONE);
|
2021-09-20 18:08:43 +02:00
|
|
|
modal3.add(emr);
|
2021-09-15 16:33:24 +02:00
|
|
|
modal3.show();
|
2021-08-05 16:49:04 +02:00
|
|
|
break;
|
2021-09-27 15:28:36 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
// case UPDATED_PROJECT:
|
|
|
|
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
|
|
|
// mainTabPanel.getCurrentSortFilter()));
|
|
|
|
// break;
|
|
|
|
case DELETE_PROJECT:
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
String htmlMsg = "Going to delete the project with:";
|
|
|
|
htmlMsg += "<ul>";
|
|
|
|
htmlMsg += "<li>id: " + concessione.getItemId() + "</li>";
|
|
|
|
htmlMsg += "<li>name: " + concessione.getNome() + "</li>";
|
|
|
|
htmlMsg += "</ul>";
|
|
|
|
htmlMsg += "<br>";
|
|
|
|
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
|
|
|
|
|
|
|
|
final DialogConfirm dialog = new DialogConfirm(null, "Delete Confirm?", htmlMsg);
|
|
|
|
dialog.center();
|
|
|
|
|
|
|
|
dialog.getYesButton().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
dialog.hide();
|
|
|
|
final Modal modal = new Modal(true, true);
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
final HorizontalPanel hp = new HorizontalPanel();
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Deleting Project...");
|
|
|
|
hp.add(lc);
|
|
|
|
modal.add(hp);
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().deleteRecord(
|
|
|
|
concessione.getItemId(), RECORD_TYPE.CONCESSIONE,
|
|
|
|
new AsyncCallback<Boolean>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
hp.clear();
|
|
|
|
Alert alert = new Alert(caught.getMessage(), AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
if (result) {
|
|
|
|
hp.clear();
|
|
|
|
Alert alert = new Alert("Project '" + concessione.getNome()
|
|
|
|
+ "' deleted correclty", AlertType.INFO);
|
|
|
|
alert.setClose(false);
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
appManagerBus.fireEvent(
|
2022-03-17 18:08:58 +01:00
|
|
|
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,grpw.getProfileID(),null,
|
2021-08-06 16:23:17 +02:00
|
|
|
mainTabPanel.getCurrentSortFilter()));
|
2021-08-05 16:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
modal.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-04 17:11:46 +02:00
|
|
|
}
|
2021-09-15 16:14:27 +02:00
|
|
|
|
2021-08-04 17:11:46 +02:00
|
|
|
});
|
2020-10-20 09:58:56 +02:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction,
|
|
|
|
ConcessioneDV concessione) {
|
2021-11-26 16:05:05 +01:00
|
|
|
|
|
|
|
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;
|
2022-03-04 14:40:43 +01:00
|
|
|
} else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
2021-11-26 16:05:05 +01:00
|
|
|
// if my username is equal the owner of the concessione
|
|
|
|
writeOwnPassed = true;
|
|
|
|
}
|
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
boolean operationAllowed = false;
|
|
|
|
switch (allowedAction) {
|
|
|
|
case READ:
|
2022-03-04 14:40:43 +01:00
|
|
|
// Access to READ operation is allowed to everyone
|
2021-11-26 16:05:05 +01:00
|
|
|
operationAllowed = true;
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log(OPERATION_TYPE.READ + " ALLOWED? " + operationAllowed);
|
2021-11-26 16:05:05 +01:00
|
|
|
break;
|
|
|
|
case READ_WRITE:
|
2022-03-04 14:40:43 +01:00
|
|
|
// Access to READ_WRITE operation
|
2021-11-26 16:05:05 +01:00
|
|
|
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log(OPERATION_TYPE.READ_WRITE + " ALLOWED? " + operationAllowed);
|
2021-11-26 16:05:05 +01:00
|
|
|
break;
|
|
|
|
case WRITE:
|
2022-03-04 14:40:43 +01:00
|
|
|
// Access to WRITE operation
|
2021-11-26 16:05:05 +01:00
|
|
|
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log(OPERATION_TYPE.WRITE + " ALLOWED? " + operationAllowed);
|
2021-11-26 16:05:05 +01:00
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
operationAllowed = false;
|
2022-03-04 14:40:43 +01:00
|
|
|
GWT.log(OPERATION_TYPE.UNKNOWN + " ALLOWED? " + operationAllowed);
|
2021-11-26 16:05:05 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
return operationAllowed;
|
|
|
|
}
|
2021-01-26 12:52:49 +01:00
|
|
|
|
2020-10-22 15:31:59 +02:00
|
|
|
private void purgeFileUploaded() {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-22 15:31:59 +02:00
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().purgeFilesUploaded(new AsyncCallback<Integer>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2021-08-05 16:49:04 +02:00
|
|
|
// silent
|
|
|
|
|
2020-10-22 15:31:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Integer result) {
|
2021-08-05 16:49:04 +02:00
|
|
|
GWT.log("Purged " + result + " file/s uploaded");
|
|
|
|
|
2020-10-22 15:31:59 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-09 16:34:23 +02:00
|
|
|
|
2020-10-07 17:04:13 +02:00
|
|
|
}
|