From eb6a8ff58711ce3ae282ce04308a75c4c0ad1b8d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 24 May 2022 18:33:33 +0200 Subject: [PATCH 1/7] #23390 Implementing facility: "Clone Project" --- .classpath | 4 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 28 +- CHANGELOG.md | 6 + pom.xml | 28 +- .../client/GeoPortalDataEntryApp.java | 367 ++++++++++-------- .../client/ui/GeonaMainTabPanel.java | 23 +- .../client/ui/GeonaMainTabPanel.ui.xml | 2 + 8 files changed, 274 insertions(+), 186 deletions(-) diff --git a/.classpath b/.classpath index d8296e1..15db912 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -30,5 +30,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 876328d..0a87b1c 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 jarsExcludedFromWebInfLib= -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.1.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-entry-app/target/geoportal-data-entry-app-2.2.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 98ea8c3..c37aa99 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + @@ -22,8 +22,10 @@ - - + + + + @@ -47,7 +49,8 @@ - + + @@ -71,7 +74,8 @@ - + + @@ -95,10 +99,11 @@ - + uses - + + @@ -122,7 +127,8 @@ - + + @@ -146,7 +152,8 @@ - + + @@ -170,7 +177,8 @@ - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index a69f535..77bb3e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.2.0-SNAPSHOT] - 2022-05-25 + +#### Enhancements + +- [#23390] Implemented facility: "Clone Project" + ## [v2.1.0] - 2021-11-24 #### Enhancements diff --git a/pom.xml b/pom.xml index d855017..f4dd68c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 2.1.0 + 2.2.0-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to GeoNa project @@ -25,7 +25,7 @@ - 2.9.0 + 2.8.2 ${project.build.directory}/${project.build.finalName} UTF-8 @@ -98,6 +98,9 @@ gwt-bootstrap compile + + + org.gcube.portlets.widgets metadata-profile-form-builder-widget @@ -136,16 +139,31 @@ [1.0.0, 2.0.0-SNAPSHOT) compile + + + + + org.gcube.application + geoportal-common + [1.0.0,1.0.8-SNAPSHOT) + + + + org.gcube.common + metadata-profile-discovery + [1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT) + + org.gcube.application geoportal-data-common - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT) compile org.gcube.application geoportal-client - [1.0.0, 2.0.0-SNAPSHOT) + [1.0.0, 1.0.7-SNAPSHOT) compile @@ -154,6 +172,8 @@ + + org.gcube.portlets.user gcube-widgets diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 6afcf8c..7db1a3f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -108,7 +108,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { private UserRights myRights = null; private LoaderIcon loader = new LoaderIcon("Loading Application..."); - + private List displayFields = new ArrayList(); private List sortByFields = new ArrayList(); private List searchByFields = new ArrayList(); @@ -120,152 +120,148 @@ public class GeoPortalDataEntryApp implements EntryPoint { RootPanel.get(DIV_PORTLET_ID).add(loader); - /*GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new AsyncCallback>() { + /* + * GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new + * AsyncCallback>() { + * + * @Override public void onFailure(Throwable caught) { + * Window.alert(caught.getMessage()); + * + * } + * + * @Override public void onSuccess(List result) { + * + * for (ItemField itemField : result) { if(itemField.isDisplayAsResult()) { + * displayFields.add(itemField); } + * + * if(itemField.isSearchable()) { searchByFields.add(itemField); } + * + * if(itemField.isSortable()) { sortByFields.add(itemField); } } + * + * + * GWT.log("List display fields: "+result); SearchingFilter initialSortFilter = + * new SearchingFilter(); initialSortFilter.setOrder(ORDER.ASC); + * initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", + * Arrays.asList("name"), true, true, true))); + * + * displayFields = result; mainTabPanel = new GeonaMainTabPanel(appManagerBus, + * displayFields, sortByFields, searchByFields, initialSortFilter); + * mainTabPanel.setLoaderVisible("Loading...", true); + * + * geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); + * mainTabPanel.addFormPanel(geoNaMainForm); + * + * } }); + */ - @Override - public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); - - } - - @Override - public void onSuccess(List result) { - - for (ItemField itemField : result) { - if(itemField.isDisplayAsResult()) { - displayFields.add(itemField); - } - - if(itemField.isSearchable()) { - searchByFields.add(itemField); - } - - if(itemField.isSortable()) { - sortByFields.add(itemField); - } - } - - - GWT.log("List display fields: "+result); - SearchingFilter initialSortFilter = new SearchingFilter(); - initialSortFilter.setOrder(ORDER.ASC); - initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); - - displayFields = result; - mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter); - mainTabPanel.setLoaderVisible("Loading...", true); - - geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); - mainTabPanel.addFormPanel(geoNaMainForm); - - } - });*/ - - GeoportalDataEntryServiceAsync.Util.getInstance().readDataViewerConfig(new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support"; - Alert alert = new Alert(errorMsg, AlertType.ERROR); - alert.setClose(false); - try { - RootPanel.get(DIV_PORTLET_ID).remove(loader); - } catch (Exception e) { - - } - RootPanel.get(DIV_PORTLET_ID).add(alert); - Window.alert(errorMsg); - - } - - @Override - public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) { - - try { - RootPanel.get(DIV_PORTLET_ID).remove(loader); - } catch (Exception e) { - - } - - List itemFields = gNADataEntryConfig.getListItemFields(); - - for (ItemField itemField : itemFields) { - if(itemField.isDisplayAsResult()) { - displayFields.add(itemField); - } - - if(itemField.isSearchable()) { - searchByFields.add(itemField); - } - - if(itemField.isSortable()) { - sortByFields.add(itemField); - } - } - - - GWT.log("List display fields: "+itemFields); - SearchingFilter initialSortFilter = new SearchingFilter(); - initialSortFilter.setOrder(ORDER.ASC); - initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); - - displayFields = itemFields; - mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, initialSortFilter); - mainTabPanel.setLoaderVisible("Loading...", true); - - geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); - mainTabPanel.addFormPanel(geoNaMainForm); - - //PERMISSIONS - myRights = gNADataEntryConfig.getUserRights(); - initGUI(); - GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); - String msg = "Logged in as "; - if(userRole != null && userRole.getName()!=null) { - msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length()); - }else - msg+="Member"; - - mainTabPanel.setRoleLabel(msg); - - - RoleRights roleRights = myRights.getRoleRights(); - boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT); - - if (!canCreateNewItem) { - // removing Tab "Create New Project" - mainTabPanel.removeTab(0); - // activating Tab "List of Project" - mainTabPanel.setTabActive(0); - mainTabPanel.instanceAndShowListOfConcessioni(); - return; - } - - GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { + GeoportalDataEntryServiceAsync.Util.getInstance() + .readDataViewerConfig(new AsyncCallback() { @Override public void onFailure(Throwable caught) { - Window.alert( - "Sorry, an error occurrend when loading configurations. Please, contact the support"); + String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support"; + Alert alert = new Alert(errorMsg, AlertType.ERROR); + alert.setClose(false); + try { + RootPanel.get(DIV_PORTLET_ID).remove(loader); + } catch (Exception e) { + + } + RootPanel.get(DIV_PORTLET_ID).add(alert); + Window.alert(errorMsg); + } @Override - public void onSuccess(GeonaISConfig result) { + public void onSuccess(GNADataEntryExtConfigProfile gNADataEntryConfig) { - if (result != null && result.getGenericResourceSecondaryType() != null - && result.getScope() != null) { - callGetMetadataProfiles(result.getScope(), result.getGenericResourceSecondaryType()); + try { + RootPanel.get(DIV_PORTLET_ID).remove(loader); + } catch (Exception e) { + + } + + List itemFields = gNADataEntryConfig.getListItemFields(); + + for (ItemField itemField : itemFields) { + if (itemField.isDisplayAsResult()) { + displayFields.add(itemField); + } + + if (itemField.isSearchable()) { + searchByFields.add(itemField); + } + + if (itemField.isSortable()) { + sortByFields.add(itemField); + } + } + + GWT.log("List display fields: " + itemFields); + SearchingFilter initialSortFilter = new SearchingFilter(); + initialSortFilter.setOrder(ORDER.ASC); + initialSortFilter.setOrderByFields( + Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); + + displayFields = itemFields; + mainTabPanel = new GeonaMainTabPanel(appManagerBus, displayFields, sortByFields, searchByFields, + initialSortFilter); + mainTabPanel.setLoaderVisible("Loading...", true); + + geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); + mainTabPanel.addFormPanel(geoNaMainForm); + + // PERMISSIONS + myRights = gNADataEntryConfig.getUserRights(); + initGUI(); + GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); + String msg = "Logged in as "; + if (userRole != null && userRole.getName() != null) { + msg += userRole.getName().substring(userRole.getName().indexOf("-") + 1, + userRole.getName().length()); } else - Window.alert( - "Sorry, no configuration found in the context. Please, contact the support"); + msg += "Member"; + + mainTabPanel.setRoleLabel(msg); + + RoleRights roleRights = myRights.getRoleRights(); + boolean canCreateNewItem = roleRights.getListPermessions().keySet() + .contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT); + + if (!canCreateNewItem) { + // removing Tab "Create New Project" + mainTabPanel.removeTab(0); + // activating Tab "List of Project" + mainTabPanel.setTabActive(0); + mainTabPanel.instanceAndShowListOfConcessioni(); + return; + } + + GeoportalDataEntryServiceAsync.Util.getInstance() + .getGeonaInitConfig(new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + Window.alert( + "Sorry, an error occurrend when loading configurations. Please, contact the support"); + } + + @Override + public void onSuccess(GeonaISConfig result) { + + if (result != null && result.getGenericResourceSecondaryType() != null + && result.getScope() != null) { + callGetMetadataProfiles(result.getScope(), + result.getGenericResourceSecondaryType()); + } else + Window.alert( + "Sorry, no configuration found in the context. Please, contact the support"); + + } + }); } }); - - } - }); - - // GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback() { // @@ -657,7 +653,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { mainTabPanel.showListOfConcessioniView(grpw); } }); - + appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() { @Override @@ -731,40 +727,44 @@ public class GeoPortalDataEntryApp implements EntryPoint { final ConcessioneDV concessione = (ConcessioneDV) item; 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; + 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); + + 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) + // 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); + 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()){ + 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"; + 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); + ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), title, msg, + AlertType.WARNING); modalW.show(); return; } - switch (action) { - case VIEW_ON_MAP: + case VIEW_ON_MAP: { final Modal modal = new Modal(true, true); modal.setCloseVisible(true); final HorizontalPanel hpGetLink = new HorizontalPanel(); @@ -798,8 +798,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.show(); break; + } - case VIEW_REPORT: + case VIEW_REPORT: { final Modal modal2 = new Modal(true, true); modal2.setTitle( @@ -817,8 +818,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal2.show(); break; + } - case EDIT_PROJECT: + case EDIT_PROJECT: { final Modal modal3 = new Modal(true, true); modal3.setTitle( "Edit: " @@ -833,12 +835,43 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal3.add(emr); modal3.show(); break; + } // case UPDATED_PROJECT: // appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, // mainTabPanel.getCurrentSortFilter())); // break; - case DELETE_PROJECT: + + case CLONE_PROJECT: { + + String htmlMsg = "Going to create a copy of the project with:"; + htmlMsg += "
    "; + htmlMsg += "
  • id: " + concessione.getItemId() + "
  • "; + htmlMsg += "
  • name: " + concessione.getNome() + "
  • "; + htmlMsg += "
"; + htmlMsg += "
"; + htmlMsg += "Would you like to proceed?"; + + final DialogConfirm dialog = new DialogConfirm(null, "Cloning 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("Creating a copy of the project..."); + hp.add(lc); + modal.add(hp); + + } + }); + break; + } + case DELETE_PROJECT: { String htmlMsg = "Going to delete the project with:"; htmlMsg += "
    "; @@ -895,6 +928,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { modal.show(); } }); + } default: break; @@ -907,8 +941,9 @@ public class GeoPortalDataEntryApp implements EntryPoint { }); } - - private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, ConcessioneDV concessione) { + + private boolean checkAccessToOperationType(GcubeUserRole userRole, OPERATION_TYPE allowedAction, + ConcessioneDV concessione) { boolean writeAnyAPassed = false; boolean writeOwnPassed = false; @@ -924,37 +959,37 @@ public class GeoPortalDataEntryApp implements EntryPoint { String ownerUser = concessione.getCreationUser(); if (ownerUser == null || ownerUser.isEmpty()) { writeOwnPassed = false; - }else if (ownerUser.compareTo(myRights.getMyUsername()) == 0) { + } 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 + // Access to READ operation is allowed to everyone operationAllowed = true; - GWT.log(OPERATION_TYPE.READ+ " ALLOWED? "+operationAllowed); + GWT.log(OPERATION_TYPE.READ + " ALLOWED? " + operationAllowed); break; case READ_WRITE: - //Access to READ_WRITE operation + // Access to READ_WRITE operation operationAllowed = writeAnyAPassed || writeOwnPassed; - GWT.log(OPERATION_TYPE.READ_WRITE+ " ALLOWED? "+operationAllowed); + GWT.log(OPERATION_TYPE.READ_WRITE + " ALLOWED? " + operationAllowed); break; case WRITE: - //Access to WRITE operation + // Access to WRITE operation operationAllowed = writeAnyAPassed || writeOwnPassed; - GWT.log(OPERATION_TYPE.WRITE+ " ALLOWED? "+operationAllowed); + GWT.log(OPERATION_TYPE.WRITE + " ALLOWED? " + operationAllowed); break; case UNKNOWN: operationAllowed = false; - GWT.log(OPERATION_TYPE.UNKNOWN+ " ALLOWED? "+operationAllowed); + GWT.log(OPERATION_TYPE.UNKNOWN + " ALLOWED? " + operationAllowed); break; default: break; } - + return operationAllowed; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 7b3b4fc..524d8d9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -125,6 +125,9 @@ public class GeonaMainTabPanel extends Composite { @UiField NavLink navEditMode; + @UiField + NavLink navCloneProject; + @UiField NavLink navDelete; @@ -133,7 +136,7 @@ public class GeonaMainTabPanel extends Composite { @UiField Button resetSearch; - + @UiField Label roleLabel; @@ -173,7 +176,7 @@ public class GeonaMainTabPanel extends Composite { alertSearchFor.setText(searchForFields.get(0).getDisplayName()); alertSortBy.setText(toLabelFilter((initialSortFilter.getOrderByFields().get(0)), initialSortFilter.getOrder())); - + bindEvents(); resetSearch.setIconSize(IconSize.TWO_TIMES); resetSearch.setType(ButtonType.LINK); @@ -310,6 +313,20 @@ public class GeonaMainTabPanel extends Composite { } }); + navCloneProject.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus + .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.CLONE_PROJECT)); + } + }); + navDelete.addClickHandler(new ClickHandler() { @Override @@ -347,7 +364,7 @@ public class GeonaMainTabPanel extends Composite { }); } - + public void setRoleLabel(String msg) { roleLabel.setText(msg); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 7f5e5ec..b7f75e8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -90,6 +90,8 @@ title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report Edit + Clone Project Delete Project From 2c2109836c1e088234e5923d225bd448609d9be2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 26 May 2022 17:43:48 +0200 Subject: [PATCH 2/7] created the CloneOperationPanel.. --- .settings/org.eclipse.wst.common.component | 35 ++-- pom.xml | 8 +- .../client/GeoPortalDataEntryApp.java | 176 +++++------------- .../client/GeoportalDataEntryService.java | 10 + .../GeoportalDataEntryServiceAsync.java | 2 + .../client/events/CloneProjectEvent.java | 54 ++++++ .../events/CloneProjectEventHandler.java | 20 ++ .../client/events/CreateNewProjectEvent.java | 21 ++- .../client/ui/CloneOperationPanel.java | 79 ++++++++ .../client/ui/CloneOperationPanel.ui.xml | 79 ++++++++ .../client/ui/GeonaMainTabPanel.ui.xml | 2 +- .../server/GeoportalDataEntryServiceImpl.java | 51 ++++- 12 files changed, 381 insertions(+), 156 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index c37aa99..2a1378f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -24,7 +26,9 @@ - + + + @@ -49,7 +53,9 @@ - + + + @@ -74,7 +80,9 @@ - + + + @@ -99,10 +107,9 @@ - - uses - - + + + @@ -127,7 +134,9 @@ - + + + @@ -152,7 +161,9 @@ - + + + @@ -177,7 +188,9 @@ - + + + diff --git a/pom.xml b/pom.xml index f4dd68c..34a86c1 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ - 2.8.2 + 2.9.0 ${project.build.directory}/${project.build.finalName} UTF-8 @@ -163,13 +163,17 @@ org.gcube.application geoportal-client - [1.0.0, 1.0.7-SNAPSHOT) + [1.0.0, 1.0.8-SNAPSHOT) compile javax.servlet servlet-api + + org.ow2.asm + asm + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 7db1a3f..4024dd0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -24,6 +24,8 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEven import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.ActionPerformedOnItemEventHandler; +import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; @@ -31,6 +33,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecords import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler; import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; +import org.gcube.portlets.user.geoportaldataentry.client.ui.CloneOperationPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView; import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow; @@ -120,40 +123,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { RootPanel.get(DIV_PORTLET_ID).add(loader); - /* - * GeoportalDataEntryServiceAsync.Util.getInstance().listDisplayFields(new - * AsyncCallback>() { - * - * @Override public void onFailure(Throwable caught) { - * Window.alert(caught.getMessage()); - * - * } - * - * @Override public void onSuccess(List result) { - * - * for (ItemField itemField : result) { if(itemField.isDisplayAsResult()) { - * displayFields.add(itemField); } - * - * if(itemField.isSearchable()) { searchByFields.add(itemField); } - * - * if(itemField.isSortable()) { sortByFields.add(itemField); } } - * - * - * GWT.log("List display fields: "+result); SearchingFilter initialSortFilter = - * new SearchingFilter(); initialSortFilter.setOrder(ORDER.ASC); - * initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", - * Arrays.asList("name"), true, true, true))); - * - * displayFields = result; mainTabPanel = new GeonaMainTabPanel(appManagerBus, - * displayFields, sortByFields, searchByFields, initialSortFilter); - * mainTabPanel.setLoaderVisible("Loading...", true); - * - * geoNaMainForm = new GeonaDataEntryMainForm(appManagerBus); - * mainTabPanel.addFormPanel(geoNaMainForm); - * - * } }); - */ - GeoportalDataEntryServiceAsync.Util.getInstance() .readDataViewerConfig(new AsyncCallback() { @@ -262,79 +231,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); - -// GeoportalDataEntryServiceAsync.Util.getInstance().getMyRightsInTheContext(new AsyncCallback() { -// -// @Override -// public void onFailure(Throwable caught) { -// String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support"; -// Alert alert = new Alert(errorMsg, AlertType.ERROR); -// alert.setClose(false); -// try { -// RootPanel.get(DIV_PORTLET_ID).remove(loader); -// } catch (Exception e) { -// -// } -// RootPanel.get(DIV_PORTLET_ID).add(alert); -// Window.alert(errorMsg); -// -// } -// -// @Override -// public void onSuccess(UserRights result) { -// try { -// RootPanel.get(DIV_PORTLET_ID).remove(loader); -// } catch (Exception e) { -// -// } -// -// myRights = result; -// initGUI(); -// GcubeUserRole userRole = myRights.getRoleRights().getUserRole(); -// String msg = "Logged in as "; -// if(userRole != null && userRole.getName()!=null) { -// msg+= userRole.getName().substring(userRole.getName().indexOf("-")+1, userRole.getName().length()); -// }else -// msg+="Member"; -// -// mainTabPanel.setRoleLabel(msg); -// -// -// RoleRights roleRights = myRights.getRoleRights(); -// boolean canCreateNewItem = roleRights.getListPermessions().keySet().contains(ACTION_ON_ITEM.CREATE_NEW_PROJECT); -// -// if (!canCreateNewItem) { -// // removing Tab "Create New Project" -// mainTabPanel.removeTab(0); -// // activating Tab "List of Project" -// mainTabPanel.setTabActive(0); -// mainTabPanel.instanceAndShowListOfConcessioni(); -// return; -// } -// -// GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback() { -// -// @Override -// public void onFailure(Throwable caught) { -// Window.alert( -// "Sorry, an error occurrend when loading configurations. Please, contact the support"); -// } -// -// @Override -// public void onSuccess(GeonaISConfig result) { -// -// if (result != null && result.getgRSecondaryType() != null -// && result.getScope() != null) { -// callGetMetadataProfiles(result.getScope(), result.getgRSecondaryType()); -// } else -// Window.alert( -// "Sorry, no configuration found in the context. Please, contact the support"); -// -// } -// }); -// -// } -// }); } private void initGUI() { @@ -654,6 +550,38 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); + appManagerBus.addHandler(CloneProjectEvent.TYPE, new CloneProjectEventHandler() { + + @Override + public void onCreateNewProject(CloneProjectEvent cloneProject) { + + if (cloneProject.getConcessione() != null) { + + GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord( + cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(), + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + Alert alert = new Alert(caught.getMessage()); + alert.setType(AlertType.ERROR); + alert.setClose(false); + Modal modal = new Modal(true); + modal.add(alert); + + } + + @Override + public void onSuccess(CommitReport result) { + // TODO Auto-generated method stub + + } + }); + } + + } + }); + appManagerBus.addHandler(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() { @Override @@ -844,32 +772,20 @@ public class GeoPortalDataEntryApp implements EntryPoint { case CLONE_PROJECT: { - String htmlMsg = "Going to create a copy of the project with:"; - htmlMsg += "
      "; - htmlMsg += "
    • id: " + concessione.getItemId() + "
    • "; - htmlMsg += "
    • name: " + concessione.getNome() + "
    • "; - htmlMsg += "
    "; - htmlMsg += "
    "; - htmlMsg += "Would you like to proceed?"; + final Modal modal3 = new Modal(true, true); + modal3.setTitle("Creating a copy of the project..."); + modal3.setWidth(950); + modal3.setHeight("700px"); + modal3.setCloseVisible(true); + ((Element) modal3.getElement().getChildNodes().getItem(1)) + .addClassName("modal-body-custom"); - final DialogConfirm dialog = new DialogConfirm(null, "Cloning Confirm?", htmlMsg); - dialog.center(); + CloneOperationPanel clonePanel = new CloneOperationPanel(appManagerBus, concessione); - 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("Creating a copy of the project..."); - hp.add(lc); - modal.add(hp); - - } - }); + modal3.add(clonePanel); + modal3.show(); break; + } case DELETE_PROJECT: { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index d2d8bb0..16154ae 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -139,4 +139,14 @@ public interface GeoportalDataEntryService extends RemoteService { */ GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception; + /** + * Clone the record. + * + * @param itemId the item id + * @param newProjectName the new project name + * @return the commit report + * @throws Exception the exception + */ + CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index c3593de..e16267e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -63,4 +63,6 @@ public interface GeoportalDataEntryServiceAsync { void readDataViewerConfig(AsyncCallback asyncCallback); + void cloneTheRecord(String itemId, String newProjectName, AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java new file mode 100644 index 0000000..5dd4955 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java @@ -0,0 +1,54 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class CloneProjectEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * May 26, 2022 + */ +public class CloneProjectEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + private ConcessioneDV concessione; + private String newProjectName; + + public CloneProjectEvent(ConcessioneDV concessione, String newProjectName) { + this.concessione = concessione; + this.newProjectName = newProjectName; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(CloneProjectEventHandler handler) { + handler.onCreateNewProject(this); + } + + public ConcessioneDV getConcessione() { + return concessione; + } + + public String getNewProjectName() { + return newProjectName; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java new file mode 100644 index 0000000..1bce0da --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface CreateNewProjectEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Oct 13, 2020 + */ +public interface CloneProjectEventHandler extends EventHandler { + + /** + * On create new project. + * + * @param cloneProject the clone project + */ + void onCreateNewProject(CloneProjectEvent cloneProject); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CreateNewProjectEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CreateNewProjectEvent.java index bbcce94..f809984 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CreateNewProjectEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CreateNewProjectEvent.java @@ -2,23 +2,18 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import com.google.gwt.event.shared.GwtEvent; - -// TODO: Auto-generated Javadoc /** * The Class CreateNewProjectEvent. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 13, 2020 + * Oct 13, 2020 */ public class CreateNewProjectEvent extends GwtEvent { - + /** The type. */ public static Type TYPE = new Type(); - /** - * Instantiates a new cancel upload event. - */ public CreateNewProjectEvent() { } @@ -27,7 +22,9 @@ public class CreateNewProjectEvent extends GwtEvent { + } + + private HandlerManager appManagerBus; + + public CloneOperationPanel(HandlerManager appManagerBus, ConcessioneDV concessione) { + initWidget(uiBinder.createAndBindUi(this)); + this.appManagerBus = appManagerBus; + } + + @UiField + TextBox projectNameTextBox; + + @UiField + AlertBlock infoBlock; + + @UiField + AlertBlock infoProjectName; + + @UiField + Button publishNewProjectButton; + + private ConcessioneDV selectedProject; + + public CloneOperationPanel(ConcessioneDV concessione) { + initWidget(uiBinder.createAndBindUi(this)); + + this.selectedProject = concessione; + infoProjectName.setText(selectedProject.getNome()); + projectNameTextBox.setText(selectedProject.getNome()); + projectNameTextBox.setEnabled(false); + + publishNewProjectButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + boolean isValid = checkIsValidForm(); + + if (isValid) { + appManagerBus.fireEvent(event); + } + } + }); + } + + protected boolean checkIsValidForm() { + String text = projectNameTextBox.getText(); + if (text == null || text.isEmpty()) { + infoBlock.setVisible(true); + infoBlock.setText("The Project's name cannot be empty!"); + infoBlock.setType(AlertType.ERROR); + return false; + } + + return true; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml new file mode 100644 index 0000000..44e30dc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml @@ -0,0 +1,79 @@ + + + + .form-main-style { + margin-left: 10px; + } + + .fieldset-border-style { + border: 1px groove #444; + -webkit-box-shadow: 0px 0px 0px 0px #000; + box-shadow: 0px 0px 0px 0px #000; + padding: 10px; + } + + .legend-style { + width: auto; + padding: 10px; + margin-bottom: 0px; + } + + @external .form-horizontal .input-large; + .form-horizontal .input-large { + width: 95%; + } + + .block-alert-style { + margin-top: 10px; + padding: 10px; + margin-bottom: 10px; + } + + .button-save-style { + margin-top: 10px; + float: right; + } + + + + + + + + Clone Project + + * + is required + + + + + + * + Name : + + + + + + + + + + + + + Publish as New Project + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index b7f75e8..71654ef 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -91,7 +91,7 @@ Edit Clone Project + icon="COPY">Clone Project Delete Project diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index d6187d5..53a8fec 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.gcube.application.geoportal.client.utils.ConcessioniUtils; import org.gcube.application.geoportal.common.model.legacy.AbstractRelazione; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths; @@ -66,6 +67,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE"; private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class); + // private String mongoId; /** * Gets the GNA data entry config profile. @@ -78,7 +80,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen GNADataEntryConfigProfile profile = SessionUtil.getGNADataEntryConfigProfile(getThreadLocalRequest()); if (profile == null) { LOG.info(GNADataEntryConfigProfile.class.getSimpleName() + " is null, loading configurations from IS"); - //to be sure + // to be sure SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gCommon = new GeoportalCommon(); profile = gCommon.readGNADataEntryConfig(); @@ -381,6 +383,45 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } + /** + * Clone the record. + * + * @param itemId the item id + * @param newProjectName the new project name + * @return the commit report + * @throws Exception the exception + */ + @Override + public CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception { + + try { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + // TO be sure + Concessione concessione = clientMongo.getById(itemId); + Concessione concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id()); + // Publishing cloned Concessione + concessioneNew = clientMongo.publish(concessioneNew.getMongo_id()); + // server report + ValidationReport report = concessioneNew.getReport(); + LOG.info("ValidationReport: " + report); + + // to client + CommitReport cRep = new CommitReport(); + // cRep.setRecordId(concessione.getId()); + cRep.setMongoId(concessioneNew.getMongo_id()); + ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); + cRep.setValidationReportDV(vr); + + return cRep; + + } catch (Exception e) { + LOG.warn("Error occurred during cloning the project with id: " + itemId, e); + throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again"); + } + } + /** * Gets the geona init config. * @@ -748,7 +789,13 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); } } - + + /** + * Read data viewer config. + * + * @return the GNA data entry ext config profile + * @throws Exception the exception + */ @Override public GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception { LOG.info("readDataViewerConfig called"); From 213b515c5d074b956b5308ad27a208e651826c3e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 27 May 2022 12:01:30 +0200 Subject: [PATCH 3/7] #23390 clone facility implemented --- .../client/GeoPortalDataEntryApp.java | 103 +++++++++++++++++- .../client/ui/CloneOperationPanel.java | 42 ++++--- .../server/GeoportalDataEntryServiceImpl.java | 2 +- 3 files changed, 122 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 4024dd0..57f8590 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -57,11 +57,13 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import com.github.gwtbootstrap.client.ui.Alert; +import com.github.gwtbootstrap.client.ui.AlertBlock; import com.github.gwtbootstrap.client.ui.Modal; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -557,26 +559,123 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (cloneProject.getConcessione() != null) { + final Modal modal = new Modal(true); + modal.setCloseVisible(false); + modal.setTitle("Cloning and Publishing the project..."); + modal.hide(false); + modal.setWidth(800); + modal.setMaxHeigth("650px"); + AlertBlock alertConcessioneSource = new AlertBlock(AlertType.INFO); + alertConcessioneSource.setClose(false); + alertConcessioneSource.setHTML(cloneProject.getConcessione().getNome()); + alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX); + final VerticalPanel modalContainerPanel = new VerticalPanel(); + final LoaderIcon loader = new LoaderIcon(); + loader.setText("Trying to clone and publishing as new project, please wait..."); + modalContainerPanel.add(alertConcessioneSource); + modalContainerPanel.add(loader); + modal.add(modalContainerPanel); + GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord( cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(), new AsyncCallback() { @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 modal = new Modal(true); modal.add(alert); } @Override public void onSuccess(CommitReport result) { - // TODO Auto-generated method stub + modalContainerPanel.clear(); + modal.setCloseVisible(true); + HTML recordPublished = new HTML(); + ValidationReportDV vr = result.getValidationReportDV(); + switch (vr.getStatus()) { + case PASSED: + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, + "SUCCESS"); + recordPublished.setHTML("Record Cloned and Published with " + success); + projectSavedWithSuccess = true; + String msg = "Record published with success"; + geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); + purgeFileUploaded(); + break; + case WARNING: + String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, + "WARNING"); + recordPublished.setHTML("Record Cloned and Published with " + warning); + geoNaMainForm.enableButtonSave(true); + break; + case ERROR: + String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + "ERROR"); + recordPublished.setHTML(error + " on cloning and publishing the Record"); + geoNaMainForm.enableButtonSave(true); + break; + default: + break; + } + + modalContainerPanel.add(recordPublished); + + if (result.getMongoId() != null) { + modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); + +// 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() { +// +// @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 = "
    Go to record: " + theURL + "
    "; +// HTML html = new HTML(htmlLink); +// hpGetLink.add(html); +// // modal.add(html); +// } +// }); + + //Reloading list of Concessioni + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + mainTabPanel.getCurrentSortFilter())); + } + + // geoNaMainForm.enableButtonSave(true); + // resetUI(); + + if (vr.getAsJSONString() != null) { + modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false)); + } } }); + + modal.show(); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java index 7ad6337..8a009dd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEvent; import com.github.gwtbootstrap.client.ui.AlertBlock; import com.github.gwtbootstrap.client.ui.Button; @@ -24,28 +25,10 @@ public class CloneOperationPanel extends Composite { private HandlerManager appManagerBus; - public CloneOperationPanel(HandlerManager appManagerBus, ConcessioneDV concessione) { + public CloneOperationPanel(HandlerManager eventBus, ConcessioneDV concessione) { initWidget(uiBinder.createAndBindUi(this)); - this.appManagerBus = appManagerBus; - } - - @UiField - TextBox projectNameTextBox; - - @UiField - AlertBlock infoBlock; - - @UiField - AlertBlock infoProjectName; - - @UiField - Button publishNewProjectButton; - - private ConcessioneDV selectedProject; - - public CloneOperationPanel(ConcessioneDV concessione) { - initWidget(uiBinder.createAndBindUi(this)); - + GWT.log("Cloning the: " + concessione); + this.appManagerBus = eventBus; this.selectedProject = concessione; infoProjectName.setText(selectedProject.getNome()); projectNameTextBox.setText(selectedProject.getNome()); @@ -58,12 +41,27 @@ public class CloneOperationPanel extends Composite { boolean isValid = checkIsValidForm(); if (isValid) { - appManagerBus.fireEvent(event); + appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText())); + publishNewProjectButton.setEnabled(false); } } }); } + @UiField + TextBox projectNameTextBox; + + @UiField + AlertBlock infoBlock; + + @UiField + AlertBlock infoProjectName; + + @UiField + Button publishNewProjectButton; + + private ConcessioneDV selectedProject; + protected boolean checkIsValidForm() { String text = projectNameTextBox.getText(); if (text == null || text.isEmpty()) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index 53a8fec..a08ca79 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -815,7 +815,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // DEV MODE if (!SessionUtil.isIntoPortal()) { LOG.warn("OUT OF PORTAL - DEV MODE detected"); - GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR; + GcubeUserRole myRole = GcubeUserRole.DATA_MANAGER; for (RoleRights roleRight : listUserRightsForRole) { if (roleRight.getUserRole().equals(myRole)) { From 59ab1e4285d466f448d02b68161fa727b2765679 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 27 May 2022 17:39:56 +0200 Subject: [PATCH 4/7] Updated geoportal-common range to [1.0.0,1.0.9-SNAPSHOT) --- .settings/org.eclipse.wst.common.component | 24 ++++++++++++++-------- pom.xml | 4 +--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 2a1378f..497fd59 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -26,7 +27,8 @@ - + + @@ -53,7 +55,8 @@ - + + @@ -80,7 +83,8 @@ - + + @@ -107,7 +111,8 @@ - + + @@ -134,7 +139,8 @@ - + + @@ -161,7 +167,8 @@ - + + @@ -188,7 +195,8 @@ - + + diff --git a/pom.xml b/pom.xml index 34a86c1..0d8fa3b 100644 --- a/pom.xml +++ b/pom.xml @@ -99,8 +99,6 @@ compile - - org.gcube.portlets.widgets metadata-profile-form-builder-widget @@ -145,7 +143,7 @@ org.gcube.application geoportal-common - [1.0.0,1.0.8-SNAPSHOT) + [1.0.0,1.0.9-SNAPSHOT) From d87e2499ae96585b8560e231fb9220bcca08d6b0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Jun 2022 12:24:48 +0200 Subject: [PATCH 5/7] "Clone (and publish) Project" facility improved and completed --- .settings/org.eclipse.wst.common.component | 24 ++++-- pom.xml | 11 +-- .../client/GeoPortalDataEntryApp.java | 84 ++++++++++++------- .../client/GeoportalDataEntryService.java | 4 +- .../GeoportalDataEntryServiceAsync.java | 3 +- .../client/events/CloneProjectEvent.java | 10 ++- .../client/ui/CloneOperationPanel.java | 47 +++++++---- .../client/ui/CloneOperationPanel.ui.xml | 37 +++++--- .../server/GeoportalDataEntryServiceImpl.java | 54 ++++++++---- .../shared/CommitReport.java | 14 +++- 10 files changed, 196 insertions(+), 92 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 497fd59..fbfd93b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -27,7 +28,8 @@ - + + @@ -55,7 +57,8 @@ - + + @@ -83,7 +86,8 @@ - + + @@ -111,7 +115,8 @@ - + + @@ -139,7 +144,8 @@ - + + @@ -167,7 +173,8 @@ - + + @@ -195,7 +202,8 @@ - + + diff --git a/pom.xml b/pom.xml index 0d8fa3b..e340b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -140,28 +140,23 @@ - - org.gcube.application - geoportal-common - [1.0.0,1.0.9-SNAPSHOT) - - org.gcube.common metadata-profile-discovery [1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT) - + org.gcube.application geoportal-data-common [1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT) compile + org.gcube.application geoportal-client - [1.0.0, 1.0.8-SNAPSHOT) + [1.0.0, 1.0.7] compile diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index 57f8590..f2f2c49 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -561,7 +561,16 @@ public class GeoPortalDataEntryApp implements EntryPoint { final Modal modal = new Modal(true); modal.setCloseVisible(false); - modal.setTitle("Cloning and Publishing the project..."); + String title = "Cloning"; + String msg = "Trying to clone"; + if (cloneProject.isPublishProject()) { + title += " and Publishing"; + msg += " and publish"; + } + title += " the project.."; + msg += " as new project, please wait..."; + + modal.setTitle(title); modal.hide(false); modal.setWidth(800); modal.setMaxHeigth("650px"); @@ -571,14 +580,14 @@ public class GeoPortalDataEntryApp implements EntryPoint { alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX); final VerticalPanel modalContainerPanel = new VerticalPanel(); final LoaderIcon loader = new LoaderIcon(); - loader.setText("Trying to clone and publishing as new project, please wait..."); + loader.setText(msg); modalContainerPanel.add(alertConcessioneSource); modalContainerPanel.add(loader); modal.add(modalContainerPanel); GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord( cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(), - new AsyncCallback() { + cloneProject.isPublishProject(), new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -599,35 +608,46 @@ public class GeoPortalDataEntryApp implements EntryPoint { public void onSuccess(CommitReport result) { modalContainerPanel.clear(); modal.setCloseVisible(true); - HTML recordPublished = new HTML(); ValidationReportDV vr = result.getValidationReportDV(); - switch (vr.getStatus()) { - case PASSED: - String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, - "SUCCESS"); - recordPublished.setHTML("Record Cloned and Published with " + success); - projectSavedWithSuccess = true; - String msg = "Record published with success"; - geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); - purgeFileUploaded(); - break; - case WARNING: - String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, - "WARNING"); - recordPublished.setHTML("Record Cloned and Published with " + warning); - geoNaMainForm.enableButtonSave(true); - break; - case ERROR: - String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", - "ERROR"); - recordPublished.setHTML(error + " on cloning and publishing the Record"); - geoNaMainForm.enableButtonSave(true); - break; - default: - break; - } - modalContainerPanel.add(recordPublished); + HTML messageHTML = new HTML(); + + // here the record has been cloned and published + if (vr != null) { + + switch (vr.getStatus()) { + case PASSED: + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, + "SUCCESS"); + messageHTML.setHTML("Record Cloned and Published with " + success); + projectSavedWithSuccess = true; + String msg = "Record published with success"; + geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); + purgeFileUploaded(); + break; + case WARNING: + String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, + "WARNING"); + messageHTML.setHTML("Record Cloned and Published with " + warning); + geoNaMainForm.enableButtonSave(true); + break; + case ERROR: + String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + "ERROR"); + messageHTML.setHTML(error + " on cloning and publishing the Record"); + geoNaMainForm.enableButtonSave(true); + break; + default: + break; + } + + modalContainerPanel.add(messageHTML); + + } else { + // here the record has been just cloned (not published) + messageHTML.setHTML(result.getMessageToDisplay()); + modalContainerPanel.add(messageHTML); + } if (result.getMongoId() != null) { modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); @@ -659,8 +679,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // // modal.add(html); // } // }); - - //Reloading list of Concessioni + + // Reloading list of Concessioni appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, mainTabPanel.getCurrentSortFilter())); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index 16154ae..8e1b46c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -139,14 +139,16 @@ public interface GeoportalDataEntryService extends RemoteService { */ GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception; + /** * Clone the record. * * @param itemId the item id * @param newProjectName the new project name + * @param publishTheProject the publish the project * @return the commit report * @throws Exception the exception */ - CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception; + CommitReport cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index e16267e..88ea500 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -63,6 +63,7 @@ public interface GeoportalDataEntryServiceAsync { void readDataViewerConfig(AsyncCallback asyncCallback); - void cloneTheRecord(String itemId, String newProjectName, AsyncCallback callback); + void cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject, + AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java index 5dd4955..97d1966 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java @@ -17,10 +17,12 @@ public class CloneProjectEvent extends GwtEvent { public static Type TYPE = new Type(); private ConcessioneDV concessione; private String newProjectName; + private boolean publishProject; - public CloneProjectEvent(ConcessioneDV concessione, String newProjectName) { + public CloneProjectEvent(ConcessioneDV concessione, String newProjectName, boolean publishProject) { this.concessione = concessione; this.newProjectName = newProjectName; + this.publishProject = publishProject; } /** @@ -46,9 +48,13 @@ public class CloneProjectEvent extends GwtEvent { public ConcessioneDV getConcessione() { return concessione; } - + public String getNewProjectName() { return newProjectName; } + public boolean isPublishProject() { + return publishProject; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java index 8a009dd..8ff1cd3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java @@ -5,6 +5,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEven import com.github.gwtbootstrap.client.ui.AlertBlock; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.google.gwt.core.client.GWT; @@ -18,6 +19,21 @@ import com.google.gwt.user.client.ui.Widget; public class CloneOperationPanel extends Composite { + @UiField + TextBox projectNameTextBox; + + @UiField + AlertBlock infoBlock; + + @UiField + AlertBlock infoProjectName; + + @UiField + Button submitButton; + + @UiField + CheckBox checkBoxPublish; + private static CloneOperationPanelUiBinder uiBinder = GWT.create(CloneOperationPanelUiBinder.class); interface CloneOperationPanelUiBinder extends UiBinder { @@ -34,32 +50,33 @@ public class CloneOperationPanel extends Composite { projectNameTextBox.setText(selectedProject.getNome()); projectNameTextBox.setEnabled(false); - publishNewProjectButton.addClickHandler(new ClickHandler() { + submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { boolean isValid = checkIsValidForm(); if (isValid) { - appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText())); - publishNewProjectButton.setEnabled(false); + appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText(), checkBoxPublish.getValue())); + submitButton.setEnabled(false); } } }); + + checkBoxPublish.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + if(checkBoxPublish.getValue()) { + submitButton.setText("Clone and Publish as New Project"); + }else + submitButton.setText("Clone as New Project"); + + } + }); } - @UiField - TextBox projectNameTextBox; - - @UiField - AlertBlock infoBlock; - - @UiField - AlertBlock infoProjectName; - - @UiField - Button publishNewProjectButton; - private ConcessioneDV selectedProject; protected boolean checkIsValidForm() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml index 44e30dc..f068cf4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml @@ -8,16 +8,17 @@ } .fieldset-border-style { - border: 1px groove #444; - -webkit-box-shadow: 0px 0px 0px 0px #000; - box-shadow: 0px 0px 0px 0px #000; - padding: 10px; + border: 1px groove #444 !important; + box-shadow: 0px 0px 0px 0px #000 !important; + padding: 10px !important; + margin: 5px !important; } .legend-style { - width: auto; - padding: 10px; - margin-bottom: 0px; + width: auto !important; + padding: 10px !important; + margin-bottom: 0 !important; + border-bottom: 0 !important; } @external .form-horizontal .input-large; @@ -63,6 +64,22 @@ + + + * + Publish : + + + the Project in GNA + + By selecting "Publish", the Project will be cloned and + published in GNA (the centroid of the layer/s will be + calculated and + selectable by GNA (Map) Viewer). No otherwise, the + Project will just be cloned and avaialbe for editing in the GNA + Data Entry. + + - Publish as New Project + Clone as New Project \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index a08ca79..f594ddf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -386,33 +386,59 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen /** * Clone the record. * - * @param itemId the item id - * @param newProjectName the new project name + * @param itemId the item id + * @param newProjectName the new project name + * @param publishTheProject the publish the project * @return the commit report * @throws Exception the exception */ @Override - public CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception { + public CommitReport cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject) + throws Exception { + LOG.info("cloneTheRecord called with itemId: " + itemId + ", newProjectName: " + newProjectName + + ", publishTheProject: " + publishTheProject); + + Concessione concessioneNew = null; + // to client + CommitReport cRep = null; try { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); // TO be sure Concessione concessione = clientMongo.getById(itemId); - Concessione concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id()); - // Publishing cloned Concessione - concessioneNew = clientMongo.publish(concessioneNew.getMongo_id()); - // server report - ValidationReport report = concessioneNew.getReport(); - LOG.info("ValidationReport: " + report); + concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id()); - // to client - CommitReport cRep = new CommitReport(); - // cRep.setRecordId(concessione.getId()); + } catch (Exception e) { + LOG.warn("Error occurred during cloning the project with id: " + itemId, e); + throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again"); + } + + try { + cRep = new CommitReport(); cRep.setMongoId(concessioneNew.getMongo_id()); - ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); - cRep.setValidationReportDV(vr); + + if (publishTheProject) { + + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + // Publishing cloned Concessione + concessioneNew = clientMongo.publish(concessioneNew.getMongo_id()); + cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been cloned and published"); + // server report + ValidationReport report = concessioneNew.getReport(); + LOG.info("ValidationReport: " + report); + // cRep.setRecordId(concessione.getId()); + cRep.setMongoId(concessioneNew.getMongo_id()); + ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); + + cRep.setValidationReportDV(vr); + + } else { + cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been cloned correctly"); + } return cRep; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 0750f2f..1c396cb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -20,6 +20,7 @@ public class CommitReport implements Serializable { public Long recordId; public String mongoId; + private String messageToDisplay; public ValidationReportDV validationReportDV; /** @@ -29,10 +30,11 @@ public class CommitReport implements Serializable { } - public CommitReport(Long recordId, String mongoId, ValidationReportDV validationReportDV) { + public CommitReport(Long recordId, String mongoId, String messageToDisplay, ValidationReportDV validationReportDV) { super(); this.recordId = recordId; this.mongoId = mongoId; + this.messageToDisplay = messageToDisplay; this.validationReportDV = validationReportDV; } @@ -60,6 +62,14 @@ public class CommitReport implements Serializable { this.validationReportDV = validationReportDV; } + public String getMessageToDisplay() { + return messageToDisplay; + } + + public void setMessageToDisplay(String messageToDisplay) { + this.messageToDisplay = messageToDisplay; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -67,6 +77,8 @@ public class CommitReport implements Serializable { builder.append(recordId); builder.append(", mongoId="); builder.append(mongoId); + builder.append(", messageToDisplay="); + builder.append(messageToDisplay); builder.append(", validationReportDV="); builder.append(validationReportDV); builder.append("]"); From 1d5d6f9cb6b7a54bd0752e10fd48531b66ab625a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Jun 2022 17:59:28 +0200 Subject: [PATCH 6/7] in progress on #23457 --- .settings/org.eclipse.wst.common.component | 3 + CHANGELOG.md | 1 + .../client/GeoPortalDataEntryApp.java | 185 ++++++++++++++---- .../client/GeoportalDataEntryService.java | 12 ++ .../GeoportalDataEntryServiceAsync.java | 4 + .../client/events/CloneProjectEvent.java | 2 +- .../events/CloneProjectEventHandler.java | 10 +- .../events/PublishUnPublishProjectEvent.java | 48 +++++ .../PublishUnPublishProjectEventHandler.java | 20 ++ .../client/ui/CloneOperationPanel.ui.xml | 20 +- .../client/ui/GeonaMainTabPanel.java | 17 ++ .../client/ui/GeonaMainTabPanel.ui.xml | 7 +- .../ui/PublishUnPublishOperationPanel.java | 105 ++++++++++ .../ui/PublishUnPublishOperationPanel.ui.xml | 112 +++++++++++ .../server/GeoportalDataEntryServiceImpl.java | 61 +++++- .../PUBLISHING_UNPUBLISHING_OPERATION.java | 17 ++ 16 files changed, 570 insertions(+), 54 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.ui.xml create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/PUBLISHING_UNPUBLISHING_OPERATION.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index fbfd93b..238ad1a 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -115,6 +115,9 @@ + + uses + diff --git a/CHANGELOG.md b/CHANGELOG.md index 77bb3e4..acff848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements - [#23390] Implemented facility: "Clone Project" +- [#23457] Implemented the "Publish/UnPublish Project" facility ## [v2.1.0] - 2021-11-24 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java index f2f2c49..e841a16 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoPortalDataEntryApp.java @@ -30,6 +30,8 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProject import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler; +import org.gcube.portlets.user.geoportaldataentry.client.events.PublishUnPublishProjectEvent; +import org.gcube.portlets.user.geoportaldataentry.client.events.PublishUnPublishProjectEventHandler; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler; import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; @@ -37,6 +39,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.CloneOperationPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView; import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow; +import org.gcube.portlets.user.geoportaldataentry.client.ui.PublishUnPublishOperationPanel; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord; import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm; @@ -552,10 +555,125 @@ public class GeoPortalDataEntryApp implements EntryPoint { } }); + appManagerBus.addHandler(PublishUnPublishProjectEvent.TYPE, new PublishUnPublishProjectEventHandler() { + + @Override + public void onPublishingUnPublishingOperation(PublishUnPublishProjectEvent publishUnPublishEvent) { + + if (publishUnPublishEvent.getConcessione() != null) { + + final Modal modal = new Modal(true); + modal.setCloseVisible(false); + String title = publishUnPublishEvent.getOperation().getTitle() + " the project.."; + String msg = "Trying to " + publishUnPublishEvent.getOperation().getTitle() + + " the project, please wait..."; + modal.setTitle(title); + modal.hide(false); + modal.setWidth(800); + modal.setMaxHeigth("650px"); + AlertBlock alertConcessioneSource = new AlertBlock(AlertType.INFO); + alertConcessioneSource.setClose(false); + alertConcessioneSource.setHTML(publishUnPublishEvent.getConcessione().getNome()); + alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX); + final VerticalPanel modalContainerPanel = new VerticalPanel(); + final LoaderIcon loader = new LoaderIcon(); + loader.setText(msg); + modalContainerPanel.add(alertConcessioneSource); + modalContainerPanel.add(loader); + modal.add(modalContainerPanel); + + GeoportalDataEntryServiceAsync.Util.getInstance().publishUpublishRecord( + publishUnPublishEvent.getConcessione().getItemId(), publishUnPublishEvent.getOperation(), + new AsyncCallback() { + + @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); + + } + + @Override + public void onSuccess(CommitReport result) { + modalContainerPanel.clear(); + modal.setCloseVisible(true); + ValidationReportDV vr = result.getValidationReportDV(); + + HTML messageHTML = new HTML(); + + // here the record has been published + if (vr != null) { + + switch (vr.getStatus()) { + case PASSED: + String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null, + "SUCCESS"); + messageHTML.setHTML("Record Published with " + success); + projectSavedWithSuccess = true; + String msg = "Record published with success"; + geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true); + purgeFileUploaded(); + break; + case WARNING: + String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null, + "WARNING"); + messageHTML.setHTML("Record Published with " + warning); + geoNaMainForm.enableButtonSave(true); + break; + case ERROR: + String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold", + "ERROR"); + messageHTML.setHTML(error + " on publishing the Record"); + geoNaMainForm.enableButtonSave(true); + break; + default: + break; + } + + modalContainerPanel.add(messageHTML); + + } else { + // here the record has been unpublished + messageHTML.setHTML(result.getMessageToDisplay()); + modalContainerPanel.add(messageHTML); + } + + if (result.getMongoId() != null) { + modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); + + // Reloading list of Concessioni + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + mainTabPanel.getCurrentSortFilter())); + } + + // geoNaMainForm.enableButtonSave(true); + // resetUI(); + + if (vr.getAsJSONString() != null) { + modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false)); + } + + } + }); + + modal.show(); + } + + } + }); + appManagerBus.addHandler(CloneProjectEvent.TYPE, new CloneProjectEventHandler() { @Override - public void onCreateNewProject(CloneProjectEvent cloneProject) { + public void onCloningProject(CloneProjectEvent cloneProject) { if (cloneProject.getConcessione() != null) { @@ -569,7 +687,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { } title += " the project.."; msg += " as new project, please wait..."; - + modal.setTitle(title); modal.hide(false); modal.setWidth(800); @@ -652,34 +770,6 @@ public class GeoPortalDataEntryApp implements EntryPoint { if (result.getMongoId() != null) { modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId()))); -// 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() { -// -// @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 = "
    Go to record: " + theURL + "
    "; -// HTML html = new HTML(htmlLink); -// hpGetLink.add(html); -// // modal.add(html); -// } -// }); - // Reloading list of Concessioni appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, mainTabPanel.getCurrentSortFilter())); @@ -891,18 +981,35 @@ public class GeoPortalDataEntryApp implements EntryPoint { case CLONE_PROJECT: { - final Modal modal3 = new Modal(true, true); - modal3.setTitle("Creating a copy of the project..."); - modal3.setWidth(950); - modal3.setHeight("700px"); - modal3.setCloseVisible(true); - ((Element) modal3.getElement().getChildNodes().getItem(1)) - .addClassName("modal-body-custom"); + final Modal modal = new Modal(true, true); + modal.setTitle("Creating a copy of the project..."); + modal.setWidth(950); + // modal.setHeight("600px"); + modal.setCloseVisible(true); + ((Element) modal.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); CloneOperationPanel clonePanel = new CloneOperationPanel(appManagerBus, concessione); - modal3.add(clonePanel); - modal3.show(); + modal.add(clonePanel); + modal.show(); + break; + + } + + case PUBLISH_UNPUBLISH_PROJECT: { + + final Modal modal = new Modal(true, true); + modal.setTitle("Publishing or UnPublishing the project..."); + modal.setWidth(950); + // modal.setHeight("600px"); + modal.setCloseVisible(true); + ((Element) modal.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom"); + + PublishUnPublishOperationPanel pubUnpubPanel = new PublishUnPublishOperationPanel( + appManagerBus, concessione); + + modal.add(pubUnpubPanel); + modal.show(); break; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java index 8e1b46c..e0373b4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java @@ -13,6 +13,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; +import org.gcube.portlets.user.geoportaldataentry.shared.PUBLISHING_UNPUBLISHING_OPERATION; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.user.client.rpc.RemoteService; @@ -151,4 +152,15 @@ public interface GeoportalDataEntryService extends RemoteService { */ CommitReport cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject) throws Exception; + /** + * Publish upublish project. + * + * @param itemId the item id + * @param newProjectName the new project name + * @param publishTheProject the publish the project + * @return the commit report + * @throws Exception the exception + */ + CommitReport publishUpublishRecord(String itemId, PUBLISHING_UNPUBLISHING_OPERATION operation) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java index 88ea500..c225fee 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryServiceAsync.java @@ -13,6 +13,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; +import org.gcube.portlets.user.geoportaldataentry.shared.PUBLISHING_UNPUBLISHING_OPERATION; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.core.client.GWT; @@ -66,4 +67,7 @@ public interface GeoportalDataEntryServiceAsync { void cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject, AsyncCallback callback); + void publishUpublishRecord(String itemId, PUBLISHING_UNPUBLISHING_OPERATION operation, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java index 97d1966..91b7fde 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java @@ -42,7 +42,7 @@ public class CloneProjectEvent extends GwtEvent { @Override protected void dispatch(CloneProjectEventHandler handler) { - handler.onCreateNewProject(this); + handler.onCloningProject(this); } public ConcessioneDV getConcessione() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java index 1bce0da..ff6621d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java @@ -3,18 +3,18 @@ package org.gcube.portlets.user.geoportaldataentry.client.events; import com.google.gwt.event.shared.EventHandler; /** - * The Interface CreateNewProjectEventHandler. + * The Interface CloneProjectEventHandler. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Oct 13, 2020 + * Jun 1, 2022 */ public interface CloneProjectEventHandler extends EventHandler { /** - * On create new project. + * On cloning project. * * @param cloneProject the clone project */ - void onCreateNewProject(CloneProjectEvent cloneProject); + void onCloningProject(CloneProjectEvent cloneProject); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEvent.java new file mode 100644 index 0000000..1f176d0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEvent.java @@ -0,0 +1,48 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.shared.PUBLISHING_UNPUBLISHING_OPERATION; + +import com.google.gwt.event.shared.GwtEvent; + +public class PublishUnPublishProjectEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + private ConcessioneDV concessione; + private PUBLISHING_UNPUBLISHING_OPERATION operation; + + public PublishUnPublishProjectEvent(ConcessioneDV concessione, PUBLISHING_UNPUBLISHING_OPERATION operation) { + this.concessione = concessione; + this.operation = operation; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(PublishUnPublishProjectEventHandler handler) { + handler.onPublishingUnPublishingOperation(this); + } + + public ConcessioneDV getConcessione() { + return concessione; + } + + public PUBLISHING_UNPUBLISHING_OPERATION getOperation() { + return operation; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEventHandler.java new file mode 100644 index 0000000..6f8a199 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/PublishUnPublishProjectEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataentry.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface PublishUnPublishProjectEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 1, 2022 + */ +public interface PublishUnPublishProjectEventHandler extends EventHandler { + + /** + * On publishing un publishing operation. + * + * @param publishUnPublishProjectEvent the publish un publish project event + */ + void onPublishingUnPublishingOperation(PublishUnPublishProjectEvent publishUnPublishProjectEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml index f068cf4..bef512b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml @@ -36,6 +36,10 @@ margin-top: 10px; float: right; } + + .margin-top-20 { + margin-top: 20px; + } the Project in GNA - By selecting "Publish", the Project will be cloned and - published in GNA (the centroid of the layer/s will be - calculated and - selectable by GNA (Map) Viewer). No otherwise, the - Project will just be cloned and avaialbe for editing in the GNA - Data Entry. + + By selecting "Publish", the Project will be cloned and + published in GNA (the centroid of the layer/s will be + calculated + and + selectable by GNA (Map) Viewer). No otherwise, the + Project will + just be cloned and avaialbe for editing in the GNA + Data Entry. + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java index 524d8d9..c4aee8a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.java @@ -128,6 +128,9 @@ public class GeonaMainTabPanel extends Composite { @UiField NavLink navCloneProject; + @UiField + NavLink navPublishUnPublishProject; + @UiField NavLink navDelete; @@ -327,6 +330,20 @@ public class GeonaMainTabPanel extends Composite { } }); + navPublishUnPublishProject.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + + List listConcessioni = null; + if (grpw != null && grpw.getSelectItems() != null) { + listConcessioni = grpw.getSelectItems(); + } + appManagerBus.fireEvent(new ActionOnItemEvent(listConcessioni, + ACTION_ON_ITEM.PUBLISH_UNPUBLISH_PROJECT)); + } + }); + navDelete.addClickHandler(new ClickHandler() { @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml index 71654ef..a1b21f1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/GeonaMainTabPanel.ui.xml @@ -90,8 +90,11 @@ title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report Edit - Clone Project + Clone Project + Publish/UnPublish + Project Delete Project diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.java new file mode 100644 index 0000000..60b6980 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.java @@ -0,0 +1,105 @@ +package org.gcube.portlets.user.geoportaldataentry.client.ui; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataentry.client.events.PublishUnPublishProjectEvent; +import org.gcube.portlets.user.geoportaldataentry.shared.PUBLISHING_UNPUBLISHING_OPERATION; + +import com.github.gwtbootstrap.client.ui.AlertBlock; +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Widget; + +/** + * The Class PublishUnPublishOperationPanel. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 1, 2022 + */ +public class PublishUnPublishOperationPanel extends Composite { + + @UiField + TextBox projectNameTextBox; + + @UiField + AlertBlock infoBlock; + + @UiField + AlertBlock infoProjectName; + + @UiField + Button submitButton; + + @UiField + ListBox listBoxPublisUnPublish; + + private HandlerManager appManagerBus; + + private ConcessioneDV selectedProject; + + private static PublishUnPublishOperationPanelUiBinder uiBinder = GWT + .create(PublishUnPublishOperationPanelUiBinder.class); + + /** + * The Interface PublishUnPublishOperationPanelUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 1, 2022 + */ + interface PublishUnPublishOperationPanelUiBinder extends UiBinder { + } + + /** + * Instantiates a new publish un publish operation panel. + * + * @param eventBus the event bus + * @param concessione the concessione + */ + public PublishUnPublishOperationPanel(HandlerManager eventBus, ConcessioneDV concessione) { + initWidget(uiBinder.createAndBindUi(this)); + this.appManagerBus = eventBus; + this.selectedProject = concessione; + infoProjectName.setText(selectedProject.getNome()); + projectNameTextBox.setText(selectedProject.getNome()); + projectNameTextBox.setEnabled(false); + + listBoxPublisUnPublish.addItem(PUBLISHING_UNPUBLISHING_OPERATION.PUBLISH.name(), + PUBLISHING_UNPUBLISHING_OPERATION.PUBLISH.getTitle()); + listBoxPublisUnPublish.addItem(PUBLISHING_UNPUBLISHING_OPERATION.UNPUBLISH.name(), + PUBLISHING_UNPUBLISHING_OPERATION.UNPUBLISH.getTitle()); + + submitButton.setText("Confirm " + listBoxPublisUnPublish.getSelectedValue()); + + listBoxPublisUnPublish.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + submitButton.setText("Confirm " + listBoxPublisUnPublish.getSelectedValue()); + + } + }); + + submitButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + appManagerBus.fireEvent(new PublishUnPublishProjectEvent(selectedProject, + PUBLISHING_UNPUBLISHING_OPERATION.valueOf(listBoxPublisUnPublish.getSelectedValue().toUpperCase()))); + submitButton.setEnabled(false); + + } + }); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.ui.xml new file mode 100644 index 0000000..9266555 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/PublishUnPublishOperationPanel.ui.xml @@ -0,0 +1,112 @@ + + + + .form-main-style { + margin-left: 10px; + } + + .fieldset-border-style { + border: 1px groove #444 !important; + box-shadow: 0px 0px 0px 0px #000 !important; + padding: 10px !important; + margin: 5px !important; + } + + .legend-style { + width: auto !important; + padding: 10px !important; + margin-bottom: 0 !important; + border-bottom: 0 !important; + } + + @external .form-horizontal .input-large; + .form-horizontal .input-large { + width: 95%; + } + + .block-alert-style { + margin-top: 10px; + padding: 10px; + margin-bottom: 10px; + } + + .button-save-style { + margin-top: 10px; + float: right; + } + + .margin-top-20 { + margin-top: 20px; + } + + + + + + + + Publish/UnPublish Project + + * + is required + + + + + + * + Name : + + + + + + + + + * + Operation : + + + + + + By selecting "Publish", the Project will + be published in + GNA + (the centroid of the layer/s will be + calculated + and + selectable by + GNA + (Map) Viewer) + By selecting "UnPublish" + the Project will be + unpublished + from + GNA and the centroid of the layer/s will be + removed and not + selectable by GNA + (Map) Viewer + + + + + + + + + + Confirm + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java index f594ddf..5c244f1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/GeoportalDataEntryServiceImpl.java @@ -41,6 +41,7 @@ import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig; +import org.gcube.portlets.user.geoportaldataentry.shared.PUBLISHING_UNPUBLISHING_OPERATION; import org.gcube.portlets.user.geoportaldataentry.shared.UserRights; import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; @@ -409,6 +410,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // TO be sure Concessione concessione = clientMongo.getById(itemId); concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id()); + LOG.info("Project with id: " + concessioneNew.getMongo_id() + " cloned"); } catch (Exception e) { LOG.warn("Error occurred during cloning the project with id: " + itemId, e); @@ -426,6 +428,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); // Publishing cloned Concessione concessioneNew = clientMongo.publish(concessioneNew.getMongo_id()); + LOG.info("Project with id: " + concessioneNew.getMongo_id() + " published"); cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been cloned and published"); // server report ValidationReport report = concessioneNew.getReport(); @@ -433,7 +436,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen // cRep.setRecordId(concessione.getId()); cRep.setMongoId(concessioneNew.getMongo_id()); ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); - cRep.setValidationReportDV(vr); } else { @@ -442,6 +444,63 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen return cRep; + } catch (Exception e) { + LOG.warn("Error occurred during publishing the project with id: " + itemId, e); + throw new Exception("Sorry an error occurred during publishing the Project. Refresh and try again"); + } + } + + /** + * Publish upublish record. + * + * @param itemId the item id + * @param operation the operation + * @return the commit report + * @throws Exception the exception + */ + @Override + public CommitReport publishUpublishRecord(String itemId, PUBLISHING_UNPUBLISHING_OPERATION operation) + throws Exception { + LOG.info("publishUpublishRecord called with itemId: " + itemId + ", operation: " + operation); + + // to client + CommitReport cRep = new CommitReport(); + + try { + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + MongoServiceUtil serviceUtil = new MongoServiceUtil(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + // TO be sure + Concessione concessione = clientMongo.getById(itemId); + + switch (operation) { + + case PUBLISH: { + Concessione concessioneNew = clientMongo.publish(concessione.getMongo_id()); + cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been Published correctly"); + ValidationReport report = concessioneNew.getReport(); + LOG.info("ValidationReport: " + report); + // cRep.setRecordId(concessione.getId()); + cRep.setMongoId(concessioneNew.getMongo_id()); + ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report); + cRep.setValidationReportDV(vr); + LOG.info(operation + "of the project with id: " + concessione.getMongo_id() + ", done!"); + break; + } + + case UNPUBLISH: { + clientMongo.unPublish(concessione.getMongo_id()); + cRep.setMessageToDisplay("The project " + concessione.getNome() + " has been UnPublished correctly"); + LOG.info(operation + "of the project with id: " + concessione.getMongo_id() + ", done!"); + break; + } + + default: + break; + } + + return cRep; + } catch (Exception e) { LOG.warn("Error occurred during cloning the project with id: " + itemId, e); throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again"); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/PUBLISHING_UNPUBLISHING_OPERATION.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/PUBLISHING_UNPUBLISHING_OPERATION.java new file mode 100644 index 0000000..70048a1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/PUBLISHING_UNPUBLISHING_OPERATION.java @@ -0,0 +1,17 @@ +package org.gcube.portlets.user.geoportaldataentry.shared; + +public enum PUBLISHING_UNPUBLISHING_OPERATION { + + PUBLISH("Publish"), UNPUBLISH("UnPublish"); + + String title; + + PUBLISHING_UNPUBLISHING_OPERATION(String title) { + this.title = title; + } + + public String getTitle() { + return title; + } + +} From 561ce44ba84f79828556b708ea0869f4d29cc3ab Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 8 Jun 2022 11:32:26 +0200 Subject: [PATCH 7/7] fixed description --- .../geoportaldataentry/client/ui/CloneOperationPanel.ui.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml index bef512b..f68611d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml @@ -83,7 +83,7 @@ and selectable by GNA (Map) Viewer). No otherwise, the Project will - just be cloned and avaialbe for editing in the GNA + just be cloned and available for editing in the GNA Data Entry.