in progress on #23457
This commit is contained in:
parent
d87e2499ae
commit
1d5d6f9cb6
|
@ -115,6 +115,9 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<dependent-module archiveName="geoportal-data-common-1.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<CommitReport>() {
|
||||
|
||||
@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) {
|
||||
|
||||
|
@ -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<GeoNaItemRef>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// hpGetLink.clear();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(GeoNaItemRef result) {
|
||||
// hpGetLink.clear();
|
||||
// String theURL = result.getRestrictedLink().getShortURL() != null
|
||||
// ? result.getRestrictedLink().getShortURL()
|
||||
// : result.getRestrictedLink().getCompleteURL();
|
||||
// String htmlLink = "<div>Go to record: <a href=" + theURL
|
||||
// + " target=\"_blank\">" + theURL + "</a></div>";
|
||||
// HTML html = new HTML(htmlLink);
|
||||
// hpGetLink.add(html);
|
||||
// // modal.add(html);
|
||||
// }
|
||||
// });
|
||||
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<CommitReport> callback);
|
||||
|
||||
void publishUpublishRecord(String itemId, PUBLISHING_UNPUBLISHING_OPERATION operation,
|
||||
AsyncCallback<CommitReport> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CloneProjectEvent extends GwtEvent<CloneProjectEventHandler> {
|
|||
|
||||
@Override
|
||||
protected void dispatch(CloneProjectEventHandler handler) {
|
||||
handler.onCreateNewProject(this);
|
||||
handler.onCloningProject(this);
|
||||
}
|
||||
|
||||
public ConcessioneDV getConcessione() {
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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<PublishUnPublishProjectEventHandler> {
|
||||
|
||||
/** The type. */
|
||||
public static Type<PublishUnPublishProjectEventHandler> TYPE = new Type<PublishUnPublishProjectEventHandler>();
|
||||
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<PublishUnPublishProjectEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(PublishUnPublishProjectEventHandler handler) {
|
||||
handler.onPublishingUnPublishingOperation(this);
|
||||
}
|
||||
|
||||
public ConcessioneDV getConcessione() {
|
||||
return concessione;
|
||||
}
|
||||
|
||||
public PUBLISHING_UNPUBLISHING_OPERATION getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -36,6 +36,10 @@
|
|||
margin-top: 10px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.margin-top-20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
||||
|
@ -72,12 +76,16 @@
|
|||
<b:Controls>
|
||||
<b:CheckBox ui:field="checkBoxPublish">the Project in GNA</b:CheckBox>
|
||||
</b:Controls>
|
||||
<g:HTMLPanel styleName="{style.margin-top-20}">
|
||||
<g:HTML>By selecting "Publish", the Project will be cloned and
|
||||
published in GNA (the centroid of the layer/s will be
|
||||
calculated and
|
||||
calculated
|
||||
and
|
||||
selectable by GNA (Map) Viewer). No otherwise, the
|
||||
Project will just be cloned and avaialbe for editing in the GNA
|
||||
Project will
|
||||
just be cloned and avaialbe for editing in the GNA
|
||||
Data Entry.</g:HTML>
|
||||
</g:HTMLPanel>
|
||||
</b:ControlGroup>
|
||||
|
||||
<!-- Alert blocks for info/errors -->
|
||||
|
|
|
@ -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<ConcessioneDV> listConcessioni = null;
|
||||
if (grpw != null && grpw.getSelectItems() != null) {
|
||||
listConcessioni = grpw.getSelectItems();
|
||||
}
|
||||
appManagerBus.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni,
|
||||
ACTION_ON_ITEM.PUBLISH_UNPUBLISH_PROJECT));
|
||||
}
|
||||
});
|
||||
|
||||
navDelete.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,8 +90,11 @@
|
|||
title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report</b:NavLink>
|
||||
<b:NavLink ui:field="navEditMode" title="Edit"
|
||||
icon="PENCIL">Edit</b:NavLink>
|
||||
<b:NavLink ui:field="navCloneProject" title="Clone Project"
|
||||
icon="COPY">Clone Project</b:NavLink>
|
||||
<b:NavLink ui:field="navCloneProject"
|
||||
title="Clone Project" icon="COPY">Clone Project</b:NavLink>
|
||||
<b:NavLink ui:field="navPublishUnPublishProject"
|
||||
title="Publish or UnPublish Project" icon="STACKEXCHANGE">Publish/UnPublish
|
||||
Project</b:NavLink>
|
||||
<b:NavLink ui:field="navDelete" title="Delete Project"
|
||||
icon="TRASH">Delete Project</b:NavLink>
|
||||
</b:NavPills>
|
||||
|
|
|
@ -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<Widget, PublishUnPublishOperationPanel> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||
<ui:style>
|
||||
.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;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
||||
ui:field="form">
|
||||
<b:AlertBlock type="INFO" animation="true" close="false"
|
||||
ui:field="infoProjectName" styleName="{style.block-alert-style}"></b:AlertBlock>
|
||||
<b:Fieldset styleName="{style.fieldset-border-style}">
|
||||
|
||||
<b:Legend styleName="{style.legend-style}">
|
||||
Publish/UnPublish Project
|
||||
<small>
|
||||
<span style="color:red;">*</span>
|
||||
is required
|
||||
</small>
|
||||
</b:Legend>
|
||||
|
||||
<b:ControlGroup>
|
||||
<b:ControlLabel for="name" title="Item Name">
|
||||
<font color="red">*</font>
|
||||
Name :
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:TextBox alternateSize="LARGE" b:id="name"
|
||||
title="Project's name" ui:field="projectNameTextBox" />
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:ControlGroup>
|
||||
<b:ControlLabel for="publish" title="Publish">
|
||||
<font color="red">*</font>
|
||||
Operation :
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:ListBox ui:field="listBoxPublisUnPublish"></b:ListBox>
|
||||
</b:Controls>
|
||||
<g:HTMLPanel styleName="{style.margin-top-20}">
|
||||
<g:HTML>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)</g:HTML>
|
||||
<g:HTML>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</g:HTML>
|
||||
</g:HTMLPanel>
|
||||
</b:ControlGroup>
|
||||
|
||||
<!-- Alert blocks for info/errors -->
|
||||
<b:AlertBlock type="INFO" animation="true"
|
||||
visible="false" close="false" ui:field="infoBlock"
|
||||
styleName="{style.block-alert-style}"></b:AlertBlock>
|
||||
</b:Fieldset>
|
||||
</b:Form>
|
||||
|
||||
<g:FlowPanel>
|
||||
<b:Button title="Submit" ui:field="submitButton"
|
||||
visible="true" type="PRIMARY"
|
||||
addStyleNames="{style.button-save-style}">Confirm</b:Button>
|
||||
</g:FlowPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue