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..238ad1a 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,5 +1,5 @@
-
+
@@ -22,8 +22,18 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -47,7 +57,12 @@
-
+
+
+
+
+
+
@@ -71,7 +86,12 @@
-
+
+
+
+
+
+
@@ -95,10 +115,15 @@
-
+
uses
-
+
+
+
+
+
+
@@ -122,7 +147,12 @@
-
+
+
+
+
+
+
@@ -146,7 +176,12 @@
-
+
+
+
+
+
+
@@ -170,7 +205,12 @@
-
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a69f535..acff848 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,13 @@
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"
+- [#23457] Implemented the "Publish/UnPublish Project" facility
+
## [v2.1.0] - 2021-11-24
#### Enhancements
diff --git a/pom.xml b/pom.xml
index d855017..e340b3b 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
@@ -98,6 +98,7 @@
gwt-bootstrap
compile
+
org.gcube.portlets.widgets
metadata-profile-form-builder-widget
@@ -136,24 +137,40 @@
[1.0.0, 2.0.0-SNAPSHOT)
compile
+
+
+
+
+ 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]
compile
javax.servlet
servlet-api
+
+ org.ow2.asm
+ asm
+
+
+
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..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
@@ -24,16 +24,22 @@ 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;
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;
+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;
@@ -54,11 +60,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;
@@ -108,7 +116,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,225 +128,114 @@ 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() {
-
- @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() {
-//
-// @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() {
@@ -657,7 +554,243 @@ public class GeoPortalDataEntryApp implements EntryPoint {
mainTabPanel.showListOfConcessioniView(grpw);
}
});
-
+
+ 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 onCloningProject(CloneProjectEvent cloneProject) {
+
+ if (cloneProject.getConcessione() != null) {
+
+ final Modal modal = new Modal(true);
+ modal.setCloseVisible(false);
+ 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");
+ 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(msg);
+ modalContainerPanel.add(alertConcessioneSource);
+ modalContainerPanel.add(loader);
+ modal.add(modalContainerPanel);
+
+ GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord(
+ cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(),
+ cloneProject.isPublishProject(), 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 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())));
+
+ // 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(ActionPerformedOnItemEvent.TYPE, new ActionPerformedOnItemEventHandler() {
@Override
@@ -731,40 +864,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 +935,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 +955,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 +972,48 @@ 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: {
+
+ 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);
+
+ 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;
+
+ }
+ case DELETE_PROJECT: {
String htmlMsg = "Going to delete the project with:";
htmlMsg += "";
@@ -895,6 +1070,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal.show();
}
});
+ }
default:
break;
@@ -907,8 +1083,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 +1101,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/GeoportalDataEntryService.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/GeoportalDataEntryService.java
index d2d8bb0..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;
@@ -139,4 +140,27 @@ 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, 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 c3593de..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;
@@ -63,4 +64,10 @@ public interface GeoportalDataEntryServiceAsync {
void readDataViewerConfig(AsyncCallback asyncCallback);
+ 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
new file mode 100644
index 0000000..91b7fde
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEvent.java
@@ -0,0 +1,60 @@
+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;
+ private boolean publishProject;
+
+ public CloneProjectEvent(ConcessioneDV concessione, String newProjectName, boolean publishProject) {
+ this.concessione = concessione;
+ this.newProjectName = newProjectName;
+ this.publishProject = publishProject;
+ }
+
+ /**
+ * 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.onCloningProject(this);
+ }
+
+ 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/events/CloneProjectEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/events/CloneProjectEventHandler.java
new file mode 100644
index 0000000..ff6621d
--- /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 CloneProjectEventHandler.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Jun 1, 2022
+ */
+public interface CloneProjectEventHandler extends EventHandler {
+
+ /**
+ * On cloning project.
+ *
+ * @param cloneProject the clone project
+ */
+ void onCloningProject(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 {
+
+ /** 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.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java
new file mode 100644
index 0000000..8ff1cd3
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java
@@ -0,0 +1,94 @@
+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;
+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;
+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;
+
+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 {
+ }
+
+ private HandlerManager appManagerBus;
+
+ public CloneOperationPanel(HandlerManager eventBus, 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());
+ projectNameTextBox.setEnabled(false);
+
+ submitButton.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ boolean isValid = checkIsValidForm();
+
+ if (isValid) {
+ 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");
+
+ }
+ });
+ }
+
+ private ConcessioneDV selectedProject;
+
+ 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..f68611d
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.ui.xml
@@ -0,0 +1,104 @@
+
+
+
+ .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;
+ }
+
+
+
+
+
+
+
+ Clone Project
+
+ *
+ is required
+
+
+
+
+
+ *
+ Name :
+
+
+
+
+
+
+
+
+ *
+ 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 available for editing in the GNA
+ Data Entry.
+
+
+
+
+
+
+
+
+
+ Clone as New Project
+
+
+
\ No newline at end of file
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..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
@@ -125,6 +125,12 @@ public class GeonaMainTabPanel extends Composite {
@UiField
NavLink navEditMode;
+ @UiField
+ NavLink navCloneProject;
+
+ @UiField
+ NavLink navPublishUnPublishProject;
+
@UiField
NavLink navDelete;
@@ -133,7 +139,7 @@ public class GeonaMainTabPanel extends Composite {
@UiField
Button resetSearch;
-
+
@UiField
Label roleLabel;
@@ -173,7 +179,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 +316,34 @@ 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));
+ }
+ });
+
+ 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
@@ -347,7 +381,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..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,6 +90,11 @@
title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report
Edit
+ 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 d6187d5..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
@@ -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;
@@ -40,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;
@@ -66,6 +68,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 +81,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 +384,129 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
}
+ /**
+ * 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
+ */
+ @Override
+ 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);
+ 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);
+ throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again");
+ }
+
+ try {
+ cRep = new CommitReport();
+ cRep.setMongoId(concessioneNew.getMongo_id());
+
+ if (publishTheProject) {
+
+ SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
+ MongoServiceUtil serviceUtil = new MongoServiceUtil();
+ 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();
+ 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;
+
+ } 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");
+ }
+ }
+
/**
* Gets the geona init config.
*
@@ -748,7 +874,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");
@@ -768,7 +900,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)) {
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("]");
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;
+ }
+
+}