#23390 clone facility implemented
This commit is contained in:
parent
2c2109836c
commit
213b515c5d
|
@ -57,11 +57,13 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada
|
|||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Modal;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
|
@ -557,26 +559,123 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
if (cloneProject.getConcessione() != null) {
|
||||
|
||||
final Modal modal = new Modal(true);
|
||||
modal.setCloseVisible(false);
|
||||
modal.setTitle("Cloning and Publishing the project...");
|
||||
modal.hide(false);
|
||||
modal.setWidth(800);
|
||||
modal.setMaxHeigth("650px");
|
||||
AlertBlock alertConcessioneSource = new AlertBlock(AlertType.INFO);
|
||||
alertConcessioneSource.setClose(false);
|
||||
alertConcessioneSource.setHTML(cloneProject.getConcessione().getNome());
|
||||
alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX);
|
||||
final VerticalPanel modalContainerPanel = new VerticalPanel();
|
||||
final LoaderIcon loader = new LoaderIcon();
|
||||
loader.setText("Trying to clone and publishing as new project, please wait...");
|
||||
modalContainerPanel.add(alertConcessioneSource);
|
||||
modalContainerPanel.add(loader);
|
||||
modal.add(modalContainerPanel);
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord(
|
||||
cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(),
|
||||
new AsyncCallback<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 modal = new Modal(true);
|
||||
modal.add(alert);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(CommitReport result) {
|
||||
// TODO Auto-generated method stub
|
||||
modalContainerPanel.clear();
|
||||
modal.setCloseVisible(true);
|
||||
HTML recordPublished = new HTML();
|
||||
ValidationReportDV vr = result.getValidationReportDV();
|
||||
switch (vr.getStatus()) {
|
||||
case PASSED:
|
||||
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
||||
"SUCCESS");
|
||||
recordPublished.setHTML("Record Cloned and Published with " + success);
|
||||
projectSavedWithSuccess = true;
|
||||
String msg = "Record published with success";
|
||||
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
||||
purgeFileUploaded();
|
||||
break;
|
||||
case WARNING:
|
||||
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
|
||||
"WARNING");
|
||||
recordPublished.setHTML("Record Cloned and Published with " + warning);
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
case ERROR:
|
||||
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
|
||||
"ERROR");
|
||||
recordPublished.setHTML(error + " on cloning and publishing the Record");
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
modalContainerPanel.add(recordPublished);
|
||||
|
||||
if (result.getMongoId() != null) {
|
||||
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
||||
|
||||
// final HorizontalPanel hpGetLink = new HorizontalPanel();
|
||||
// final LoaderIcon lc = new LoaderIcon("Get link...");
|
||||
// hpGetLink.add(lc);
|
||||
// modalContainerPanel.add(hpGetLink);
|
||||
// GeoportalDataEntryServiceAsync.Util.getInstance().getLinksFor(
|
||||
// result.getMongoId(), RECORD_TYPE.CONCESSIONE,
|
||||
// new AsyncCallback<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()));
|
||||
}
|
||||
|
||||
// geoNaMainForm.enableButtonSave(true);
|
||||
// resetUI();
|
||||
|
||||
if (vr.getAsJSONString() != null) {
|
||||
modalContainerPanel.add(new ReportTemplateToHTML(vr.getAsJSONString(), false));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
modal.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEvent;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
|
@ -24,28 +25,10 @@ public class CloneOperationPanel extends Composite {
|
|||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
public CloneOperationPanel(HandlerManager appManagerBus, ConcessioneDV concessione) {
|
||||
public CloneOperationPanel(HandlerManager eventBus, ConcessioneDV concessione) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.appManagerBus = appManagerBus;
|
||||
}
|
||||
|
||||
@UiField
|
||||
TextBox projectNameTextBox;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoBlock;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoProjectName;
|
||||
|
||||
@UiField
|
||||
Button publishNewProjectButton;
|
||||
|
||||
private ConcessioneDV selectedProject;
|
||||
|
||||
public CloneOperationPanel(ConcessioneDV concessione) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
GWT.log("Cloning the: " + concessione);
|
||||
this.appManagerBus = eventBus;
|
||||
this.selectedProject = concessione;
|
||||
infoProjectName.setText(selectedProject.getNome());
|
||||
projectNameTextBox.setText(selectedProject.getNome());
|
||||
|
@ -58,12 +41,27 @@ public class CloneOperationPanel extends Composite {
|
|||
boolean isValid = checkIsValidForm();
|
||||
|
||||
if (isValid) {
|
||||
appManagerBus.fireEvent(event);
|
||||
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText()));
|
||||
publishNewProjectButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@UiField
|
||||
TextBox projectNameTextBox;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoBlock;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoProjectName;
|
||||
|
||||
@UiField
|
||||
Button publishNewProjectButton;
|
||||
|
||||
private ConcessioneDV selectedProject;
|
||||
|
||||
protected boolean checkIsValidForm() {
|
||||
String text = projectNameTextBox.getText();
|
||||
if (text == null || text.isEmpty()) {
|
||||
|
|
|
@ -815,7 +815,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
// DEV MODE
|
||||
if (!SessionUtil.isIntoPortal()) {
|
||||
LOG.warn("OUT OF PORTAL - DEV MODE detected");
|
||||
GcubeUserRole myRole = GcubeUserRole.DATA_EDITOR;
|
||||
GcubeUserRole myRole = GcubeUserRole.DATA_MANAGER;
|
||||
|
||||
for (RoleRights roleRight : listUserRightsForRole) {
|
||||
if (roleRight.getUserRole().equals(myRole)) {
|
||||
|
|
Loading…
Reference in New Issue