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; + } + +}