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.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-08-08 17:43:13 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
2022-09-01 12:44:00 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
2022-03-17 18:08:58 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
2022-08-11 12:07:07 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
2021-11-26 16:05:05 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_PERFORMED_ON_ITEM;
|
2022-08-31 12:45:01 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalClientCaches.CacheSearchingFilterParametersFromConfig;
|
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;
|
2022-07-05 15:51:43 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEventHandler;
|
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;
|
2022-09-01 12:44:00 +02: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-08-04 17:11:46 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
2022-09-01 12:44:00 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.LifecycleInformationPanel;
|
2022-09-01 16:43:25 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
2022-07-05 15:51:43 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.NodeItem;
|
2022-07-01 15:39:27 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.TreeItemPanel;
|
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;
|
2022-09-01 17:11:04 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ModalConfirm;
|
2022-09-01 12:44:00 +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;
|
2022-07-08 16:38:45 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node;
|
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;
|
2022-07-07 18:21:34 +02:00
|
|
|
import com.google.gwt.core.client.Scheduler;
|
|
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
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;
|
2022-07-05 15:51:43 +02:00
|
|
|
import com.google.gwt.user.client.ui.TreeItem;
|
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.";
|
|
|
|
|
2022-07-04 16:34:15 +02:00
|
|
|
public static final String DIV_PORTLET_ID = "geoportal-data-entry";
|
2020-10-08 15:09:25 +02:00
|
|
|
|
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-08-08 17:43:13 +02:00
|
|
|
// private Collection<GeoNaFormCardModel> orderedCards = new
|
|
|
|
// ArrayList<GeoNaFormCardModel>();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
private GeonaMainTabPanel mainTabPanel;
|
|
|
|
|
2022-07-08 16:38:45 +02:00
|
|
|
private LinkedHashMap<String, Tree_Node<GeoNaFormDataObject>> savedMap = new LinkedHashMap<String, Tree_Node<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-09-01 16:43:25 +02:00
|
|
|
private LoaderIcon loaderApplication = new LoaderIcon("Step 1 of 2. Loading Application facilities, please wait");
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-09-01 16:43:25 +02:00
|
|
|
private LoaderIcon loaderConfigurations = new LoaderIcon("Step 2 of 2. Loading Configurations, please wait");
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
private GeonaISConfig geonaISConfig;
|
2022-08-08 17:43:13 +02:00
|
|
|
|
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-08-31 12:45:01 +02:00
|
|
|
// private List<UseCaseDescriptorDV> listUCDescriptors;
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
private boolean dataEntryProjectCreated = false;
|
|
|
|
|
2022-07-07 12:36:08 +02:00
|
|
|
private TreeItemPanel treeItemPanel;
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
private GeoPortalClientCaches geoportalCaches;
|
|
|
|
|
2020-10-08 15:09:25 +02:00
|
|
|
/**
|
|
|
|
* This is the entry point method.
|
|
|
|
*/
|
|
|
|
public void onModuleLoad() {
|
2022-07-04 16:34:15 +02:00
|
|
|
/*
|
2022-07-05 15:51:43 +02:00
|
|
|
* ArrayList<GeoNaFormCardModel> gnaCardsModels = new
|
|
|
|
* ArrayList<GeoNaFormCardModel>(10); GcubeProfileDV gprofile = new
|
|
|
|
* GcubeProfileDV(); gprofile.setParentName("$.");
|
|
|
|
* gprofile.setSectionTitle("Istruzione"); GeoNaFormCardModel fcm = new
|
|
|
|
* GeoNaFormCardModel(); fcm.setGcubeProfile(gprofile); gnaCardsModels.add(fcm);
|
|
|
|
*
|
|
|
|
* for (int i = 0; i < 2; i++) { GcubeProfileDV gprofile1 = new
|
|
|
|
* GcubeProfileDV(); gprofile1.setParentName("$.livello1");
|
|
|
|
* gprofile1.setSectionTitle("Secondaria Superiore "+i); GeoNaFormCardModel fcm1
|
|
|
|
* = new GeoNaFormCardModel(); fcm1.setGcubeProfile(gprofile1);
|
|
|
|
* gnaCardsModels.add(fcm1); }
|
|
|
|
*
|
|
|
|
* for (int i = 0; i < 3; i++) { GcubeProfileDV gprofile2 = new
|
|
|
|
* GcubeProfileDV(); gprofile2.setParentName("$.livello1.livello2");
|
|
|
|
* gprofile2.setSectionTitle("Alberghiero di Pisa "+i); GeoNaFormCardModel fcm2
|
|
|
|
* = new GeoNaFormCardModel(); fcm2.setGcubeProfile(gprofile2);
|
|
|
|
* gnaCardsModels.add(fcm2); }
|
|
|
|
*
|
|
|
|
* TreeItemPanel tip = new TreeItemPanel("Concessione", gnaCardsModels);
|
|
|
|
* RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree());
|
|
|
|
*/
|
2022-08-31 12:45:01 +02:00
|
|
|
geoportalCaches = new GeoPortalClientCaches();
|
|
|
|
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(loaderApplication);
|
2021-11-26 16:05:05 +01:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
mainTabPanel = new GeonaMainTabPanel(appManagerBus);
|
|
|
|
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
|
|
|
mainTabPanel.addFormPanel(geoNaMainForm);
|
|
|
|
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(mainTabPanel);
|
2022-07-05 15:51:43 +02:00
|
|
|
|
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 {
|
2022-08-31 12:45:01 +02:00
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication);
|
2022-03-03 18:44:21 +01:00
|
|
|
} 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 {
|
2022-08-31 12:45:01 +02:00
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication);
|
2022-03-04 14:40:43 +01:00
|
|
|
} 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) {
|
2022-08-31 12:45:01 +02:00
|
|
|
GWT.log(GNADataEntryExtConfigProfile.class.getSimpleName() + " loaded: " + gNADataEntryConfig);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
// 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);
|
2022-08-31 12:45:01 +02:00
|
|
|
mainTabPanel.instanceAndShowListOfProjects();
|
2022-03-04 14:40:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loaderApplication);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:51:56 +01:00
|
|
|
}
|
2022-07-04 16:34:15 +02: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-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-08-08 17:43:13 +02:00
|
|
|
// orderedCards = new ArrayList<GeoNaFormCardModel>();
|
2022-08-31 12:45:01 +02:00
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).insert(loaderConfigurations, 0);
|
|
|
|
} catch (Exception e) {
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
}
|
2022-08-08 17:43:13 +02:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getListUseCaseDescriptors(
|
|
|
|
ConstantsGeoPortalDataEntryApp.HANDLERS_IDS, new AsyncCallback<List<UseCaseDescriptorDV>>() {
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2022-08-31 12:45:01 +02:00
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
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) {
|
2022-08-31 12:45:01 +02:00
|
|
|
GWT.log("ListUseCaseDescriptors loaded: " + 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-08-31 12:45:01 +02:00
|
|
|
initDataEntryAppForListUseCaseDescriptors(result);
|
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loaderConfigurations);
|
|
|
|
} catch (Exception e) {
|
2022-08-08 17:43:13 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
}
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
private void initDataEntryAppForListUseCaseDescriptors(List<UseCaseDescriptorDV> listUCDescriptors) {
|
|
|
|
GWT.log("initDataEntryAppForListUseCaseDescriptors with size: " + listUCDescriptors.size());
|
|
|
|
ConstantsGeoPortalDataEntryApp.printUCDs(listUCDescriptors);
|
2022-03-03 18:44:21 +01:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
mainTabPanel.initMainAccordingToListUseCaseDescriptors(listUCDescriptors);
|
2022-08-08 17:43:13 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
for (UseCaseDescriptorDV ucdDV : listUCDescriptors) {
|
2022-08-08 17:43:13 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
List<ConfigurationDV<?>> listConfigurations = geoportalCaches
|
|
|
|
.getHandlerConfigurationsForProfileId(ucdDV.getProfileID());
|
2022-08-08 17:43:13 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
if (listConfigurations == null) {
|
|
|
|
listConfigurations = new ArrayList<ConfigurationDV<?>>();
|
|
|
|
}
|
2022-08-08 17:43:13 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
for (HandlerDeclarationDV handler : ucdDV.getHandlers()) {
|
|
|
|
ConfigurationDV<?> config = handler.getConfiguration();
|
|
|
|
listConfigurations.add(config);
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
2022-08-31 12:45:01 +02:00
|
|
|
|
|
|
|
geoportalCaches.putHandlerConfigurationsForProfileId(ucdDV.getProfileID(), listConfigurations);
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
2022-08-31 12:45:01 +02:00
|
|
|
|
|
|
|
geoportalCaches.printCacheHandlerConfigurations();
|
|
|
|
|
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-05-20 12:31:58 +02:00
|
|
|
private void createNewDataEntyFor(String profileID, HandlerDeclarationDV handlerDeclarationDV,
|
|
|
|
List<GcubeProfileDV> listGPs) {
|
2022-03-04 14:40:43 +01:00
|
|
|
dataEntryProjectCreated = true;
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
2022-08-08 17:43:13 +02:00
|
|
|
// orderedCards.clear();
|
2022-03-04 14:40:43 +01:00
|
|
|
resetUI();
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
List<GeoNaFormCardModel> cardsPerIT = geoportalCaches
|
|
|
|
.getGcubeProfilePerItemType(handlerDeclarationDV.getItemType());
|
2022-03-17 18:08:58 +01:00
|
|
|
mainTabPanel.setPageHeader(handlerDeclarationDV);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
if (cardsPerIT != null) {
|
2022-08-08 17:43:13 +02:00
|
|
|
GWT.log("Profiles/Cards per Item Type are: " + cardsPerIT);
|
|
|
|
// orderedCards.addAll(cardsPerIT);
|
2022-08-08 09:54:49 +02:00
|
|
|
buildNewCards(profileID, handlerDeclarationDV.getItemType(), new ArrayList<GeoNaFormCardModel>(cardsPerIT));
|
2022-03-04 14:40:43 +01:00
|
|
|
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-07-05 15:51:43 +02:00
|
|
|
GcubeProfileDV gcubeProfile = listGPs.get(i);
|
2022-03-04 14:40:43 +01:00
|
|
|
final int order = i;
|
2022-07-05 15:51:43 +02:00
|
|
|
GWT.log("calling getProfilesInTheScope for secondaryType: " + gcubeProfile.getGcubeSecondaryType()
|
|
|
|
+ ", name: " + gcubeProfile.getGcubeName());
|
2022-03-04 14:40:43 +01:00
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScopeForName(
|
2022-07-05 15:51:43 +02:00
|
|
|
geonaISConfig.getScope(), gcubeProfile.getGcubeSecondaryType(), gcubeProfile.getGcubeName(),
|
2022-03-04 14:40:43 +01:00
|
|
|
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);
|
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
GeoNaFormCardModel geonaForm = buildNewFormCardModelFromProfile(gcubeProfile, order,
|
|
|
|
metaDataProfileBean, OPERATION.UPDATE);
|
2022-03-04 14:40:43 +01:00
|
|
|
|
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-08-08 09:54:49 +02:00
|
|
|
GWT.log("TreeMap values: " + gnaCardsModels);
|
2022-08-31 12:45:01 +02:00
|
|
|
geoportalCaches.putGcubeProfilePerItemType(handlerDeclarationDV.getItemType(),
|
2022-08-08 09:54:49 +02:00
|
|
|
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
2022-08-08 17:43:13 +02:00
|
|
|
// orderedCards.addAll(new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
|
|
|
buildNewCards(profileID, handlerDeclarationDV.getItemType(),
|
|
|
|
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
2022-03-04 14:40:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", false);
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
/**
|
|
|
|
* Builds the new form card model from profile.
|
|
|
|
*
|
|
|
|
* @param gcubeProfile the gcube profile
|
|
|
|
* @param order the order
|
|
|
|
* @param metaDataProfileBean the meta data profile bean
|
|
|
|
* @param operation the operation
|
|
|
|
* @return the geo na form card model
|
|
|
|
*/
|
|
|
|
private GeoNaFormCardModel buildNewFormCardModelFromProfile(GcubeProfileDV gcubeProfile, int order,
|
|
|
|
MetaDataProfileBean metaDataProfileBean, OPERATION operation) {
|
2022-07-07 12:36:08 +02:00
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
// Managing Forms repeatability
|
|
|
|
int minOccurs = gcubeProfile.getMinOccurs();
|
|
|
|
minOccurs = minOccurs <= 0 ? 0 : minOccurs;
|
|
|
|
int maxOccurs = gcubeProfile.getMaxOccurs();
|
|
|
|
maxOccurs = maxOccurs <= 0 ? Integer.MAX_VALUE : maxOccurs;
|
|
|
|
|
|
|
|
// TODO MUST BE MANAGED MIN_OCCURS
|
|
|
|
ProjectFormCard cct = new ProjectFormCard(gcubeProfile.getSectionName(), gcubeProfile.getSectionTitle(), order,
|
|
|
|
maxOccurs > 1, minOccurs, maxOccurs);
|
|
|
|
|
|
|
|
GeoNaFormCardModel geoNaFormCardModel = new GeoNaFormCardModel(metaDataProfileBean, null, cct, gcubeProfile);
|
|
|
|
|
|
|
|
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geoNaFormCardModel.getMetadataProfileBean()),
|
|
|
|
appManagerBus, operation);
|
|
|
|
geoNaFormCardModel.setMetadataForm(baseForm);
|
|
|
|
|
|
|
|
return geoNaFormCardModel;
|
|
|
|
}
|
|
|
|
|
2022-07-06 11:06:35 +02:00
|
|
|
private void buildNewCards(String profileID, String itemTypeTitle, Collection<GeoNaFormCardModel> orderedCards) {
|
2022-07-07 12:36:08 +02:00
|
|
|
|
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();
|
2020-12-11 09:56:17 +01:00
|
|
|
geoNaMainForm.enableButtonSave(true);
|
2021-08-05 16:49:04 +02:00
|
|
|
mainTabPanel.setLoaderVisible("", false);
|
2022-07-05 15:51:43 +02:00
|
|
|
|
2022-07-07 12:36:08 +02:00
|
|
|
treeItemPanel = new TreeItemPanel(profileID, itemTypeTitle, orderedCards, appManagerBus);
|
|
|
|
geoNaMainForm.addTree(treeItemPanel);
|
2022-07-08 11:44:48 +02:00
|
|
|
|
2022-07-07 18:21:34 +02:00
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
2022-07-08 11:44:48 +02:00
|
|
|
|
2022-07-07 18:21:34 +02:00
|
|
|
@Override
|
|
|
|
public void execute() {
|
|
|
|
TreeItem firstChild = treeItemPanel.getRoot().getChild(0);
|
|
|
|
treeItemPanel.getTree().setSelectedItem(firstChild, true);
|
|
|
|
}
|
|
|
|
});
|
2022-07-08 11:44:48 +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
|
|
|
private void resetUI() {
|
2022-07-06 11:06:35 +02:00
|
|
|
geoNaMainForm.resetUI();
|
2022-08-08 17:43:13 +02:00
|
|
|
// geoNaMainForm.remeTree(treeItemPanel);
|
2020-10-20 09:58:56 +02:00
|
|
|
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
|
|
|
|
2022-07-08 16:38:45 +02:00
|
|
|
if (saveGeonaDataFormsEvent.getTreeNode() != null) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
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(
|
2022-07-08 16:38:45 +02:00
|
|
|
saveGeonaDataFormsEvent.getProfileID(), saveGeonaDataFormsEvent.getTreeNode(),
|
2022-05-20 12:31:58 +02:00
|
|
|
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);
|
2022-05-20 12:31:58 +02:00
|
|
|
|
|
|
|
LifecycleInformationDV lcDV = result.getLifecycleInformation();
|
|
|
|
|
|
|
|
switch (lcDV.getLastOperationStatus()) {
|
|
|
|
case OK: {
|
2021-08-05 16:49:04 +02:00
|
|
|
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
|
|
|
"SUCCESS");
|
2022-05-20 12:31:58 +02:00
|
|
|
String msg = lcDV.getLastInvokedStep() + "terminated with: " + success;
|
2021-08-05 16:49:04 +02:00
|
|
|
projectSavedWithSuccess = true;
|
|
|
|
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
|
|
|
purgeFileUploaded();
|
|
|
|
break;
|
2022-05-20 12:31:58 +02:00
|
|
|
}
|
|
|
|
case WARNING: {
|
2021-08-05 16:49:04 +02:00
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
break;
|
2022-05-20 12:31:58 +02:00
|
|
|
}
|
|
|
|
case ERROR: {
|
2021-08-05 16:49:04 +02:00
|
|
|
geoNaMainForm.enableButtonSave(true);
|
|
|
|
break;
|
2022-05-20 12:31:58 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-09-01 12:44:00 +02:00
|
|
|
LifecycleInformationPanel lip = new LifecycleInformationPanel(result.getProjectID(),
|
|
|
|
result.getProfileID(), result.getProjectAsJSON(), lcDV, true);
|
|
|
|
|
|
|
|
modalContainerPanel.add(lip);
|
|
|
|
|
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
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
appManagerBus.addHandler(TreeItemEvent.TYPE, new TreeItemEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTreeItemEvent(TreeItemEvent treeItemEvent) {
|
|
|
|
|
2022-07-06 11:06:35 +02:00
|
|
|
TreeItem selectedItem = treeItemEvent.getSelectItem();
|
|
|
|
NodeItem selectedNode = treeItemEvent.selectedAsNodeItem();
|
|
|
|
|
|
|
|
if (selectedItem == null) {
|
|
|
|
selectedItem = geoNaMainForm.getTreeItemPanel().getSelectItem();
|
|
|
|
|
|
|
|
if (selectedItem == null)
|
2022-07-05 15:51:43 +02:00
|
|
|
return;
|
2022-07-06 11:06:35 +02:00
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
selectedNode = (NodeItem) selectedItem.getWidget();
|
|
|
|
}
|
2022-08-08 17:43:13 +02:00
|
|
|
|
|
|
|
GWT.log("TreeItemEvent selected node is: " + selectedNode);
|
|
|
|
|
|
|
|
if (selectedNode.isRoot()) {
|
2022-07-08 16:54:52 +02:00
|
|
|
return;
|
|
|
|
}
|
2022-07-05 15:51:43 +02:00
|
|
|
|
|
|
|
GeoNaFormCardModel nodeCard = selectedNode.getGeoNaFormCardModel();
|
2022-07-06 11:06:35 +02:00
|
|
|
|
2022-07-05 15:51:43 +02:00
|
|
|
switch (treeItemEvent.getActionPerformed()) {
|
2022-07-06 11:06:35 +02:00
|
|
|
case SELECTED: {
|
2022-07-05 15:51:43 +02:00
|
|
|
geoNaMainForm.enableButtonRemoveSection(false);
|
|
|
|
geoNaMainForm.enableButtonDuplicateSection(false);
|
|
|
|
geoNaMainForm.setSelectedForm(nodeCard.getMetadataForm());
|
2022-07-06 11:06:35 +02:00
|
|
|
|
|
|
|
// if(nodeCount>1) {
|
|
|
|
// geoNaMainForm.enableButtonRemoveSection(true);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
if (nodeCard.getFormCard().isInternalRepeatibleForm()) {
|
2022-07-05 15:51:43 +02:00
|
|
|
geoNaMainForm.enableButtonDuplicateSection(true);
|
|
|
|
}
|
|
|
|
|
2022-07-06 11:06:35 +02:00
|
|
|
if (selectedNode.isCanBeDeleted()) {
|
|
|
|
geoNaMainForm.enableButtonRemoveSection(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DELETE: {
|
2022-07-06 17:12:55 +02:00
|
|
|
|
|
|
|
geoNaMainForm.getTreeItemPanel().removeChild(selectedItem.getParentItem(), selectedItem,
|
|
|
|
selectedNode.getJsonSectionFullPath());
|
2022-07-06 11:06:35 +02:00
|
|
|
geoNaMainForm.resetInputPanel();
|
2022-07-05 15:51:43 +02:00
|
|
|
break;
|
2022-07-06 11:06:35 +02:00
|
|
|
}
|
2022-07-05 15:51:43 +02:00
|
|
|
|
2022-07-06 11:06:35 +02:00
|
|
|
case DUPLICATE: {
|
2022-07-05 15:51:43 +02:00
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
GWT.log("DUPLICATING node: " + selectedNode.getHtmlNode());
|
2022-07-05 15:51:43 +02:00
|
|
|
|
2022-07-06 11:06:35 +02:00
|
|
|
int nodeCountPerJSONFullPAth = geoNaMainForm.getTreeItemPanel()
|
|
|
|
.countNodeForFullPath(selectedNode.getJsonSectionFullPath());
|
|
|
|
|
|
|
|
if (nodeCountPerJSONFullPAth >= nodeCard.getFormCard().getMaxFormRepeatability()) {
|
|
|
|
|
|
|
|
DialogInform di = new DialogInform(new Image(Images.ICONS.accessDenied()), "Maximun reached",
|
|
|
|
"Maximun number of data reached for " + nodeCard.getFormCard().getTitle());
|
|
|
|
di.center();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
TreeItem newSubTree = cloneSubTreeItems(selectedItem);
|
2022-08-08 17:43:13 +02:00
|
|
|
// TO DEBUG
|
|
|
|
// TreeVisitUtil.postOrderVisit(newSubTree);
|
2022-07-08 11:44:48 +02:00
|
|
|
TreeItem parentItem = selectedItem.getParentItem();
|
|
|
|
int nextSiblingIndex = -1;
|
|
|
|
if (parentItem != null) {
|
|
|
|
nextSiblingIndex = parentItem.getChildIndex(selectedItem);
|
|
|
|
nextSiblingIndex++;
|
|
|
|
}
|
2022-08-08 17:43:13 +02:00
|
|
|
geoNaMainForm.getTreeItemPanel().addChild(selectedItem.getParentItem(), nextSiblingIndex,
|
|
|
|
newSubTree);
|
2022-07-05 15:51:43 +02:00
|
|
|
break;
|
2022-07-06 11:06:35 +02:00
|
|
|
}
|
2022-07-05 15:51:43 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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-05-20 12:31:58 +02:00
|
|
|
GWT.log("Create new project");
|
2022-03-04 14:40:43 +01:00
|
|
|
if (!dataEntryProjectCreated) {
|
2022-05-20 12:31:58 +02:00
|
|
|
createNewDataEntyFor(newProjectEvent.getProfileID(), 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-09-01 16:51:12 +02:00
|
|
|
ModalConfirm confirm = new ModalConfirm(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-08-08 17:43:13 +02:00
|
|
|
|
|
|
|
// TODO QUA
|
|
|
|
|
2022-05-20 12:31:58 +02:00
|
|
|
createNewDataEntyFor(newProjectEvent.getProfileID(), 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-09-01 16:43:25 +02:00
|
|
|
confirm.show();
|
2022-03-04 14:40:43 +01:00
|
|
|
|
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-08-08 17:43:13 +02:00
|
|
|
|
|
|
|
// TODO HERE
|
2022-05-20 12:31:58 +02:00
|
|
|
createNewDataEntyFor(newProjectEvent.getProfileID(), 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-09-01 16:51:12 +02:00
|
|
|
ModalConfirm confirm = new ModalConfirm(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-08-08 09:54:49 +02:00
|
|
|
|
2022-08-08 17:43:13 +02:00
|
|
|
// TODO HERE
|
|
|
|
// List<GeoNaFormCardModel> cardsPerIT =
|
|
|
|
// mapGcubeProfilePerItemType.get(newProjectEvent.getHandler().getItemType());
|
|
|
|
|
2022-05-20 12:31:58 +02:00
|
|
|
createNewDataEntyFor(newProjectEvent.getProfileID(), newProjectEvent.getHandler(),
|
|
|
|
newProjectEvent.getListGcubeProfiles());
|
2022-03-04 14:40:43 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2022-09-01 16:43:25 +02:00
|
|
|
confirm.show();
|
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) {
|
2022-08-31 12:45:01 +02:00
|
|
|
GWT.log("Fired: " + getListOfRecordsEvent);
|
|
|
|
SearchingFilter searchingFilter = getListOfRecordsEvent.getSearchingFilter();
|
2022-09-01 12:44:00 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
CacheSearchingFilterParametersFromConfig seachingFilterParameters = geoportalCaches
|
|
|
|
.getFilterParametersForProfileId(getListOfRecordsEvent.getProfileID());
|
2022-09-01 12:44:00 +02:00
|
|
|
|
|
|
|
if (searchingFilter == null || getListOfRecordsEvent.isOnApplicationInit()
|
|
|
|
|| getListOfRecordsEvent.isReloadFilteringParameters()) {
|
2022-08-31 12:45:01 +02:00
|
|
|
mainTabPanel.setFilteringParameters(seachingFilterParameters);
|
|
|
|
searchingFilter = mainTabPanel.getCurrentSearchingFilter();
|
|
|
|
}
|
2022-09-01 12:44:00 +02:00
|
|
|
|
|
|
|
// TODO MUST MANAGE getListOfRecordsEvent.isReloadFilteringParameters()
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
searchingFilter.setProjection(seachingFilterParameters.getProjection());
|
2022-08-09 16:37:09 +02:00
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
List<ItemFieldDV> displayFields = seachingFilterParameters.getDisplayFields();
|
2022-08-09 16:37:09 +02:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
grpw = new GeonaRecordsPaginatedView(appManagerBus, profileID, displayFields, searchingFilter);
|
2022-03-17 18:08:58 +01:00
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
mainTabPanel.showListOfConcessioniView(grpw);
|
2022-08-09 16:37:09 +02:00
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
}
|
|
|
|
});
|
2022-03-04 14:40:43 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
2022-08-08 17:43:13 +02:00
|
|
|
public <T extends DocumentDV> void onDoActionPerformedFired(
|
2021-11-26 16:05:05 +01:00
|
|
|
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;
|
|
|
|
|
2022-08-08 17:43:13 +02:00
|
|
|
if (item instanceof DocumentDV) {
|
|
|
|
final DocumentDV concessione = (DocumentDV) item;
|
2021-11-26 16:05:05 +01:00
|
|
|
GWT.log("onDoActionPerformedFired item: " + concessione);
|
|
|
|
switch (action) {
|
|
|
|
case UPDATED_PROJECT:
|
2022-08-08 17:43:13 +02:00
|
|
|
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
|
|
|
// actionPerformedOnItemEvent.getProfileID(), null,
|
|
|
|
// mainTabPanel.getCurrentSortFilter()));
|
|
|
|
|
2022-08-31 12:45:01 +02:00
|
|
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, null, grpw.getProfileID(),
|
|
|
|
mainTabPanel.getCurrentSearchingFilter(), false));
|
2021-11-26 16:05:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
appManagerBus.addHandler(ActionOnItemEvent.TYPE, new ActionOnItemEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
2022-08-08 17:43:13 +02:00
|
|
|
public <T extends DocumentDV> void onDoActionFired(ActionOnItemEvent<T> showItemEvent) {
|
2021-09-15 16:14:27 +02:00
|
|
|
|
|
|
|
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) {
|
2022-05-20 12:31:58 +02:00
|
|
|
DialogInform di = new DialogInform(null, "No selection",
|
|
|
|
"You must select a record in the table");
|
|
|
|
di.center();
|
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;
|
|
|
|
|
2022-09-01 12:44:00 +02:00
|
|
|
if (item instanceof ResultDocumentDV) {
|
2022-08-09 16:37:09 +02:00
|
|
|
|
2022-09-01 12:44:00 +02:00
|
|
|
final ResultDocumentDV resultDocumentDV = (ResultDocumentDV) item;
|
|
|
|
GWT.log("onDoActionFired item: " + resultDocumentDV);
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
String creatorUsername = "";
|
|
|
|
try {
|
|
|
|
creatorUsername = resultDocumentDV.getPublicationInfoDV().getCreationInfo().getUsername();
|
|
|
|
} catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
}
|
|
|
|
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType,
|
|
|
|
creatorUsername);
|
|
|
|
if (!allowedWriteActionOnItem) {
|
|
|
|
String title = "Forbidden: missing write access";
|
|
|
|
String msg = "You do not have write access to item: " + resultDocumentDV.getId();
|
|
|
|
if (!userRole.isWriteOwn()) {
|
|
|
|
msg = "You do not have write access to item: " + resultDocumentDV.getId();
|
|
|
|
} else if (!userRole.isWriteAny()) {
|
|
|
|
title = "Forbidden: missing ownership";
|
|
|
|
msg = "You are not the creator of: " + resultDocumentDV.getId()
|
|
|
|
+ ". You cannot access to it";
|
|
|
|
}
|
|
|
|
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg,
|
|
|
|
AlertType.WARNING);
|
|
|
|
modalW.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case VIEW_ON_MAP: {
|
2022-09-01 16:43:25 +02:00
|
|
|
|
2022-09-01 12:44:00 +02:00
|
|
|
final Modal modal = new Modal(true, true);
|
|
|
|
modal.setCloseVisible(true);
|
|
|
|
final HorizontalPanel hpGetLink = new HorizontalPanel();
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Just moment getting link...");
|
|
|
|
hpGetLink.add(lc);
|
|
|
|
modal.add(hpGetLink);
|
|
|
|
|
|
|
|
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", "_blank", "");
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(resultDocumentDV.getId(),
|
|
|
|
resultDocumentDV.getProfileID(), 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();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-09-01 16:43:25 +02:00
|
|
|
case VIEW_REPORT: {
|
2022-09-01 12:44:00 +02:00
|
|
|
|
|
|
|
final Modal modal2 = new Modal(true, true);
|
|
|
|
modal2.setTitle(
|
2022-09-01 17:11:04 +02:00
|
|
|
"<span style='font-size:20px;'>Publication Report for Project ID: <span style='color:#555; font-size:20px;'>"
|
2022-09-01 12:44:00 +02:00
|
|
|
+ resultDocumentDV.getId() + "</span></span>");
|
|
|
|
modal2.setWidth(800);
|
|
|
|
modal2.setCloseVisible(true);
|
|
|
|
final LoaderIcon lc = new LoaderIcon("Just moment loading lifecycle info...");
|
|
|
|
modal2.add(lc);
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getLifecycleInfoForProjectId(
|
|
|
|
resultDocumentDV.getProfileID(), resultDocumentDV.getId(),
|
|
|
|
new AsyncCallback<LifecycleInformationDV>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
lc.setVisible(false);
|
|
|
|
modal2.add(
|
|
|
|
new HTML("No report available for: " + resultDocumentDV.getId()));
|
|
|
|
modal2.add(new Alert(caught.getMessage(), AlertType.ERROR));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(LifecycleInformationDV result) {
|
|
|
|
lc.setVisible(false);
|
|
|
|
LifecycleInformationPanel lip = new LifecycleInformationPanel(
|
|
|
|
resultDocumentDV.getId(), resultDocumentDV.getProfileID(),
|
|
|
|
resultDocumentDV.getDocumentAsJSON(), result, false);
|
|
|
|
modal2.add(lip);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
modal2.show();
|
|
|
|
|
|
|
|
break;
|
2022-09-01 16:43:25 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2022-08-08 17:43:13 +02:00
|
|
|
// 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.setWidth(950);
|
|
|
|
// modal3.setHeight("700px");
|
|
|
|
// modal3.setCloseVisible(true);
|
|
|
|
// ((Element) modal3.getElement().getChildNodes().getItem(1))
|
|
|
|
// .addClassName("modal-body-custom");
|
|
|
|
// EditModeRecord emr = new EditModeRecord(appManagerBus, concessione,
|
|
|
|
// RECORD_TYPE.CONCESSIONE);
|
|
|
|
// modal3.add(emr);
|
|
|
|
// modal3.show();
|
|
|
|
// break;
|
2022-09-01 12:44:00 +02:00
|
|
|
|
|
|
|
// case UPDATED_PROJECT:
|
|
|
|
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
|
|
|
// mainTabPanel.getCurrentSortFilter()));
|
|
|
|
// break;
|
2022-09-01 16:43:25 +02:00
|
|
|
case DELETE_PROJECT: {
|
|
|
|
|
|
|
|
String htmlMsg = "Going to delete the project with:";
|
|
|
|
htmlMsg += "<ul>";
|
|
|
|
htmlMsg += "<li>id: " + resultDocumentDV.getId() + "</li>";
|
|
|
|
htmlMsg += "<li>profile: " + resultDocumentDV.getProfileID() + "</li>";
|
|
|
|
htmlMsg += "</ul>";
|
|
|
|
htmlMsg += "<br>";
|
|
|
|
htmlMsg += "This operation cannot be undone. Would you like to proceed?";
|
|
|
|
|
2022-09-01 16:51:12 +02:00
|
|
|
final ModalConfirm dialog = new ModalConfirm(null, "Delete Confirm?", htmlMsg);
|
2022-09-01 16:43:25 +02:00
|
|
|
dialog.addToCenterPanel(
|
|
|
|
new ReportTemplateToHTML("Project", resultDocumentDV.getDocumentAsJSON(), false));
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
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().deleteProject(
|
|
|
|
resultDocumentDV.getProfileID(), resultDocumentDV.getId(),
|
|
|
|
new AsyncCallback<Boolean>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
hp.clear();
|
|
|
|
modal.setTitle("Error");
|
|
|
|
Alert alert = new Alert("Sorry, I cannot delete the Project with id '"
|
|
|
|
+ resultDocumentDV.getId() + "' Refresh an try again. Error: "+caught.getMessage(),
|
|
|
|
AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean result) {
|
|
|
|
hp.clear();
|
|
|
|
if (result) {
|
|
|
|
modal.setTitle("Project deleted");
|
|
|
|
Alert alert = new Alert("Project with id '"
|
|
|
|
+ resultDocumentDV.getId() + "' deleted correclty",
|
|
|
|
AlertType.INFO);
|
|
|
|
alert.setClose(false);
|
|
|
|
hp.add(alert);
|
|
|
|
|
|
|
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(false, null,
|
|
|
|
resultDocumentDV.getProfileID(),
|
|
|
|
mainTabPanel.getCurrentSearchingFilter(), false));
|
|
|
|
}else {
|
|
|
|
modal.setTitle("Error");
|
|
|
|
Alert alert = new Alert("Sorry, I cannot delete the Project with id '"
|
|
|
|
+ resultDocumentDV.getId() + "' Refresh an try again",
|
|
|
|
AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
hp.add(alert);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
modal.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
2022-09-01 12:44:00 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-08-09 16:37:09 +02:00
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
private TreeItem cloneSubTreeItems(TreeItem root) {
|
|
|
|
GWT.log("cloneSubTreeItems called");
|
2022-07-06 17:47:39 +02:00
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
if (root == null) {
|
|
|
|
GWT.log("cloneSubTreeItems returns, node is null");
|
|
|
|
return null;
|
|
|
|
}
|
2022-07-06 17:47:39 +02:00
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
GWT.log("cloneSubTreeItems called on: " + root.getText());
|
2022-07-06 17:47:39 +02:00
|
|
|
|
2022-07-06 17:12:55 +02:00
|
|
|
// Cloning
|
|
|
|
NodeItem theRootNode = (NodeItem) root.getWidget();
|
|
|
|
GeoNaFormCardModel nodeCard = theRootNode.getGeoNaFormCardModel();
|
|
|
|
GeoNaFormCardModel newNodeFormCard = buildNewFormCardModelFromProfile(nodeCard.getGcubeProfile(), -1,
|
|
|
|
nodeCard.getMetadataProfileBean(), OPERATION.UPDATE);
|
|
|
|
|
|
|
|
// create a new node with the same data as the root node
|
|
|
|
boolean canBeDuplicated = newNodeFormCard.getFormCard().isInternalRepeatibleForm();
|
|
|
|
// geoNaMainForm.getTreeItemPanel().createAndAddChild(theRootNode.getParentTreeItem(), newNodeFormCard,
|
|
|
|
// canBeDuplicated, true, theRootNode.getJsonSectionFullPath());
|
|
|
|
|
2022-07-07 12:36:08 +02:00
|
|
|
TreeItem newTreeItem = new TreeItem(
|
|
|
|
new NodeItem(root.getParentItem(), nodeCard.getGcubeProfile().getSectionTitle(), newNodeFormCard,
|
|
|
|
canBeDuplicated, true, theRootNode.getJsonSectionFullPath()));
|
2022-07-06 17:47:39 +02:00
|
|
|
String parentText = root.getParentItem() != null ? root.getParentItem().getText() : null;
|
|
|
|
GWT.log("newTreeItem created: " + newTreeItem.getText() + ", parent is: " + parentText);
|
2022-07-06 17:12:55 +02:00
|
|
|
|
|
|
|
// Total children count
|
|
|
|
int total = root.getChildCount();
|
|
|
|
// All the children
|
|
|
|
for (int i = 0; i < total; i++) {
|
|
|
|
TreeItem childCloned = cloneSubTreeItems(root.getChild(i));
|
|
|
|
newTreeItem.addItem(childCloned);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newTreeItem;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-03-04 14:40:43 +01:00
|
|
|
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction,
|
2022-09-01 12:44:00 +02:00
|
|
|
String creatorUsername) {
|
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()) {
|
2022-09-01 12:44:00 +02:00
|
|
|
String ownerUser = creatorUsername;
|
2021-11-26 16:05:05 +01:00
|
|
|
if (ownerUser == null || ownerUser.isEmpty()) {
|
|
|
|
writeOwnPassed = false;
|
2022-03-04 14:40:43 +01:00
|
|
|
} else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
2022-09-01 12:44:00 +02:00
|
|
|
// if my username is equal the owner of the project
|
2021-11-26 16:05:05 +01:00
|
|
|
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
|
|
|
}
|