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.ItemField;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.config.ACTION_ON_ITEM;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.config.GcubeUserRole;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.config.RoleRights.OPERATION_TYPE;
|
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;
|
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;
|
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;
|
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
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
private Collection<GeoNaFormCardModel> orderedCards;
|
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;
|
|
|
|
|
|
|
|
private LoaderIcon loader = new LoaderIcon("Loading Application...");
|
2021-12-06 17:24:27 +01:00
|
|
|
|
|
|
|
private List<ItemField> displayFields = new ArrayList<ItemField>();
|
|
|
|
private List<ItemField> sortByFields = new ArrayList<ItemField>();
|
|
|
|
private List<ItemField> searchByFields = new ArrayList<ItemField>();
|
2021-11-26 16:05:05 +01:00
|
|
|
|
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);
|
|
|
|
|
2021-12-06 17:24:27 +01:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback<List<ItemField>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2021-12-07 17:14:03 +01:00
|
|
|
Window.alert(caught.getMessage());
|
2021-12-06 17:24:27 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<ItemField> result) {
|
|
|
|
|
|
|
|
|
|
|
|
for (ItemField itemField : result) {
|
|
|
|
if(itemField.isDisplayIntoTable()) {
|
|
|
|
displayFields.add(itemField);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(itemField.isSearchable()) {
|
|
|
|
searchByFields.add(itemField);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(itemField.isSortable()) {
|
|
|
|
sortByFields.add(itemField);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GWT.log("List display fields: "+result);
|
|
|
|
SearchingFilter initialSortFilter = new SearchingFilter();
|
|
|
|
initialSortFilter.setOrder(ORDER.ASC);
|
|
|
|
initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
|
|
|
|
|
|
|
|
displayFields = result;
|
|
|
|
mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter);
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", true);
|
|
|
|
|
|
|
|
geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus);
|
|
|
|
mainTabPanel.addFormPanel(geoNaMainForm);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback<UserRights>() {
|
2020-10-21 15:36:50 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2021-11-26 16:05:05 +01:00
|
|
|
String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support";
|
|
|
|
Alert alert = new Alert(errorMsg, AlertType.ERROR);
|
|
|
|
alert.setClose(false);
|
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).add(alert);
|
|
|
|
Window.alert(errorMsg);
|
|
|
|
|
2020-10-21 15:36:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-11-26 16:05:05 +01:00
|
|
|
public void onSuccess(UserRights result) {
|
|
|
|
try {
|
|
|
|
RootPanel.get(DIV_PORTLET_ID).remove(loader);
|
|
|
|
} catch (Exception e) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
}
|
2021-12-13 11:27:03 +01:00
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
myRights = result;
|
2021-12-13 11:27:03 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
2021-11-26 16:05:05 +01:00
|
|
|
RoleRights roleRights = myRights.getRoleRights();
|
|
|
|
boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT);
|
|
|
|
|
|
|
|
if (!canCreateNewItem) {
|
|
|
|
// removing Tab "Create New Project"
|
|
|
|
mainTabPanel.removeTab(0);
|
|
|
|
// activating Tab "List of Project"
|
|
|
|
mainTabPanel.setTabActive(0);
|
|
|
|
mainTabPanel.instanceAndShowListOfConcessioni();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Window.alert(
|
|
|
|
"Sorry, an error occurrend when loading configurations. Please, contact the support");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(GeonaISConfig result) {
|
|
|
|
|
|
|
|
if (result != null && result.getgRSecondaryType() != null
|
|
|
|
&& result.getScope() != null) {
|
|
|
|
callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType());
|
|
|
|
} else
|
|
|
|
Window.alert(
|
|
|
|
"Sorry, no configuration found in the context. Please, contact the support");
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-21 15:36:50 +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-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();
|
|
|
|
}-*/;
|
|
|
|
|
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
|
|
|
|
2020-10-21 15:36:50 +02:00
|
|
|
private void callGetMetadataProfiles(String scope, String secondaryType) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, secondaryType,
|
|
|
|
new AsyncCallback<List<MetaDataProfileBean>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
|
|
|
GWT.log("Returned " + result.size() + "profile/s");
|
|
|
|
orderedCards = setGeoNaFormsOrder(result);
|
|
|
|
// ordered values
|
|
|
|
buildNewCards(orderedCards);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
}
|
|
|
|
});
|
2020-10-08 15:09:25 +02:00
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-20 09:58:56 +02:00
|
|
|
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
|
2021-08-05 16:49:04 +02:00
|
|
|
projectSavedWithSuccess = false; // resetting state of saving
|
|
|
|
mainTabPanel.setLoaderVisible("Loading...", 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
|
|
|
|
// if(geonaForm.getFormCardTitle().equals(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE)){
|
|
|
|
|
|
|
|
GWT.log("Adding card: " + geonaForm.getFormCardTitle());
|
|
|
|
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()),
|
|
|
|
appManagerBus);
|
|
|
|
geonaForm.setMetadataForm(baseForm);
|
|
|
|
String key = geonaForm.getMetadataProfileBean().getType();
|
|
|
|
if (geonaForm.getFormCardTitle() != null) {
|
|
|
|
key = geonaForm.getFormCardTitle().getTitle();
|
|
|
|
}
|
|
|
|
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-12 13:04:01 +02:00
|
|
|
private Collection<GeoNaFormCardModel> setGeoNaFormsOrder(List<MetaDataProfileBean> listMetadataProfilesForGeona) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-12 13:04:01 +02:00
|
|
|
TreeMap<Integer, GeoNaFormCardModel> treemapOrderedGeoNaProfiles = new TreeMap<Integer, GeoNaFormCardModel>();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-12 16:46:17 +02:00
|
|
|
List<GeoNaFormCardModel> listUnknownType = new ArrayList<GeoNaFormCardModel>();
|
2020-10-12 13:04:01 +02:00
|
|
|
|
2020-10-09 16:34:23 +02:00
|
|
|
for (MetaDataProfileBean metaDataProfileBean : listMetadataProfilesForGeona) {
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-09 16:34:23 +02:00
|
|
|
String theMetaType = metaDataProfileBean.getType().toLowerCase();
|
2021-08-05 16:49:04 +02:00
|
|
|
GWT.log("Building form card for type: " + theMetaType);
|
2020-10-12 13:04:01 +02:00
|
|
|
GeoNaFormCardModel geonaForm = new GeoNaFormCardModel(metaDataProfileBean, null, null);
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
if (theMetaType.contains(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getKey().toLowerCase())) {
|
2020-10-13 11:52:50 +02:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO);
|
2021-08-05 16:49:04 +02:00
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.INFORMAZIONI_DI_PROGETTO.getOrder(),
|
|
|
|
geonaForm);
|
|
|
|
} else if (theMetaType
|
|
|
|
.contains(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
2021-01-15 15:08:38 +01:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO);
|
2021-08-05 16:49:04 +02:00
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.ABSTRACT_RELAZIONE_DI_SCAVO.getOrder(),
|
|
|
|
geonaForm);
|
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getKey().toLowerCase())) {
|
2020-10-20 11:49:23 +02:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO);
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.RELAZIONE_DI_SCAVO.getOrder(), geonaForm);
|
2021-08-05 16:49:04 +02:00
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getKey().toLowerCase())) {
|
2020-10-12 13:04:01 +02:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE);
|
2021-08-05 16:49:04 +02:00
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.IMMAGINI_RAPPRESENTATIVE.getOrder(),
|
|
|
|
geonaForm);
|
|
|
|
} else if (theMetaType
|
|
|
|
.contains(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getKey().toLowerCase())) {
|
2020-10-12 13:04:01 +02:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE);
|
2021-08-05 16:49:04 +02:00
|
|
|
treemapOrderedGeoNaProfiles
|
|
|
|
.put(ConcessioniFormCardTitle.POSIZIONAMENTO_DELL_AREA_DI_INDAGINE.getOrder(), geonaForm);
|
|
|
|
} else if (theMetaType.contains(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getKey().toLowerCase())) {
|
2020-10-12 13:04:01 +02:00
|
|
|
geonaForm.setFormCardTitle(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO);
|
|
|
|
treemapOrderedGeoNaProfiles.put(ConcessioniFormCardTitle.PIANTA_DI_FINE_SCAVO.getOrder(), geonaForm);
|
2021-08-05 16:49:04 +02:00
|
|
|
} else {
|
|
|
|
// adding to unknown list
|
2020-10-12 16:46:17 +02:00
|
|
|
listUnknownType.add(geonaForm);
|
2020-10-09 16:34:23 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
// adding unknown types
|
2020-10-12 16:46:17 +02:00
|
|
|
for (GeoNaFormCardModel geoNaFormCardModel : listUnknownType) {
|
|
|
|
Integer highestKey = treemapOrderedGeoNaProfiles.lastKey();
|
|
|
|
highestKey++;
|
|
|
|
treemapOrderedGeoNaProfiles.put(highestKey, geoNaFormCardModel);
|
|
|
|
}
|
2021-08-05 16:49:04 +02:00
|
|
|
|
|
|
|
GWT.log("Map size: " + treemapOrderedGeoNaProfiles.size());
|
2020-10-12 13:04:01 +02:00
|
|
|
return treemapOrderedGeoNaProfiles.values();
|
2021-08-05 16:49:04 +02:00
|
|
|
|
2020-10-09 16:34:23 +02:00
|
|
|
}
|
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) {
|
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) {
|
|
|
|
boolean confirm = Window.confirm(
|
|
|
|
"Creating a new project, the current project (is not saved) and will be lost, Confirm?");
|
|
|
|
if (confirm)
|
2020-10-20 09:58:56 +02:00
|
|
|
buildNewCards(orderedCards);
|
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
|
2020-11-06 12:24:37 +01:00
|
|
|
buildNewCards(orderedCards);
|
|
|
|
} else {
|
2021-08-05 16:49:04 +02:00
|
|
|
// means the project reported one ore more errors after the submit
|
2020-11-02 16:48:33 +01:00
|
|
|
boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?");
|
2020-11-06 12:24:37 +01:00
|
|
|
if (confirm)
|
2020-11-02 16:48:33 +01:00
|
|
|
buildNewCards(orderedCards);
|
|
|
|
}
|
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();
|
|
|
|
}
|
2021-12-06 17:24:27 +01:00
|
|
|
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, displayFields, sortFilter);
|
2021-08-05 16:49:04 +02:00
|
|
|
mainTabPanel.showListOfConcessioniView(grpw);
|
|
|
|
}
|
|
|
|
});
|
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,
|
|
|
|
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);
|
|
|
|
|
|
|
|
// Checking if the user is NOT authorized to perform this action in two ways:
|
|
|
|
// 1. the map of actions allowed for the user does not contain the action;
|
|
|
|
RoleRights roleRights = myRights.getRoleRights();
|
|
|
|
OPERATION_TYPE operationType = roleRights.getListPermessions().get(action);
|
|
|
|
boolean allowedOperationForUser = operationType != null? true:false;
|
|
|
|
if (!allowedOperationForUser) {
|
|
|
|
|
|
|
|
String msg = "You are not authorized to perform the action: "+ action.getLabel();
|
|
|
|
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), "Forbidden: "+action, msg, AlertType.WARNING);
|
|
|
|
modalW.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 2. the user cannot access to action (e.g. the user cannot write an item of another user)
|
|
|
|
// if so an error is shown
|
|
|
|
GcubeUserRole userRole = myRights.getRoleRights().getUserRole();
|
|
|
|
boolean allowedWriteActionOnItem = checkAccessToOperationType(userRole, operationType, concessione);
|
|
|
|
if (!allowedWriteActionOnItem) {
|
|
|
|
String title = "Forbidden: missing write access";
|
|
|
|
String msg = "You do not have write access to item: "+ concessione.getNome();
|
|
|
|
if(!userRole.isWriteOwn()) {
|
|
|
|
msg = "You do not have write access to item: "+ concessione.getNome();
|
|
|
|
}else if (!userRole.isWriteAny()){
|
|
|
|
title = "Forbidden: missing ownership";
|
|
|
|
msg = "You are not the creator of: "+ concessione.getNome() +". You cannot access to it";
|
|
|
|
}
|
|
|
|
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, AlertType.WARNING);
|
|
|
|
modalW.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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(
|
2021-08-06 16:23:17 +02:00
|
|
|
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
|
|
|
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
|
|
|
}
|
2021-11-26 16:05:05 +01:00
|
|
|
|
|
|
|
private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, ConcessioneDV concessione) {
|
|
|
|
|
|
|
|
boolean writeAnyAPassed = false;
|
|
|
|
boolean writeOwnPassed = false;
|
|
|
|
|
|
|
|
// Case ADMIN
|
|
|
|
if (userRole.isWriteAny()) {
|
|
|
|
writeAnyAPassed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Case EDITOR
|
|
|
|
// Going to check if the user can RW the record is owner of.
|
|
|
|
if (userRole.isWriteOwn()) {
|
|
|
|
String ownerUser = concessione.getCreationUser();
|
|
|
|
if (ownerUser == null || ownerUser.isEmpty()) {
|
|
|
|
writeOwnPassed = false;
|
|
|
|
}else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) {
|
|
|
|
// if my username is equal the owner of the concessione
|
|
|
|
writeOwnPassed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean operationAllowed = false;
|
|
|
|
switch (allowedAction) {
|
|
|
|
case READ:
|
|
|
|
//Access to READ operation is allowed to everyone
|
|
|
|
operationAllowed = true;
|
|
|
|
GWT.log(OPERATION_TYPE.READ+ " ALLOWED? "+operationAllowed);
|
|
|
|
break;
|
|
|
|
case READ_WRITE:
|
|
|
|
//Access to READ_WRITE operation
|
|
|
|
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
|
|
|
GWT.log(OPERATION_TYPE.READ_WRITE+ " ALLOWED? "+operationAllowed);
|
|
|
|
break;
|
|
|
|
case WRITE:
|
|
|
|
//Access to WRITE operation
|
|
|
|
operationAllowed = writeAnyAPassed || writeOwnPassed;
|
|
|
|
GWT.log(OPERATION_TYPE.WRITE+ " ALLOWED? "+operationAllowed);
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
operationAllowed = false;
|
|
|
|
GWT.log(OPERATION_TYPE.UNKNOWN+ " ALLOWED? "+operationAllowed);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return operationAllowed;
|
|
|
|
}
|
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
|
|
|
}
|