"Clone (and publish) Project" facility improved and completed
This commit is contained in:
parent
59ab1e4285
commit
d87e2499ae
|
@ -18,6 +18,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -47,6 +48,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -75,6 +77,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -103,6 +106,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -131,6 +135,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -159,6 +164,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -187,6 +193,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -214,6 +221,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -140,12 +140,6 @@
|
|||
|
||||
|
||||
<!-- FORCING THESE DEPENDENCIES IN ORDER TO USE THE "OLD" CONCESSIONI CLIENT/MODEL -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
<version>[1.0.0,1.0.9-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>metadata-profile-discovery</artifactId>
|
||||
|
@ -158,10 +152,11 @@
|
|||
<version>[1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-client</artifactId>
|
||||
<version>[1.0.0, 1.0.8-SNAPSHOT)</version>
|
||||
<version>[1.0.0, 1.0.7]</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -561,7 +561,16 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
final Modal modal = new Modal(true);
|
||||
modal.setCloseVisible(false);
|
||||
modal.setTitle("Cloning and Publishing the project...");
|
||||
String title = "Cloning";
|
||||
String msg = "Trying to clone";
|
||||
if (cloneProject.isPublishProject()) {
|
||||
title += " and Publishing";
|
||||
msg += " and publish";
|
||||
}
|
||||
title += " the project..";
|
||||
msg += " as new project, please wait...";
|
||||
|
||||
modal.setTitle(title);
|
||||
modal.hide(false);
|
||||
modal.setWidth(800);
|
||||
modal.setMaxHeigth("650px");
|
||||
|
@ -571,14 +580,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX);
|
||||
final VerticalPanel modalContainerPanel = new VerticalPanel();
|
||||
final LoaderIcon loader = new LoaderIcon();
|
||||
loader.setText("Trying to clone and publishing as new project, please wait...");
|
||||
loader.setText(msg);
|
||||
modalContainerPanel.add(alertConcessioneSource);
|
||||
modalContainerPanel.add(loader);
|
||||
modal.add(modalContainerPanel);
|
||||
|
||||
GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord(
|
||||
cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(),
|
||||
new AsyncCallback<CommitReport>() {
|
||||
cloneProject.isPublishProject(), new AsyncCallback<CommitReport>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -599,35 +608,46 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
public void onSuccess(CommitReport result) {
|
||||
modalContainerPanel.clear();
|
||||
modal.setCloseVisible(true);
|
||||
HTML recordPublished = new HTML();
|
||||
ValidationReportDV vr = result.getValidationReportDV();
|
||||
switch (vr.getStatus()) {
|
||||
case PASSED:
|
||||
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
||||
"SUCCESS");
|
||||
recordPublished.setHTML("Record Cloned and Published with " + success);
|
||||
projectSavedWithSuccess = true;
|
||||
String msg = "Record published with success";
|
||||
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
||||
purgeFileUploaded();
|
||||
break;
|
||||
case WARNING:
|
||||
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
|
||||
"WARNING");
|
||||
recordPublished.setHTML("Record Cloned and Published with " + warning);
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
case ERROR:
|
||||
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
|
||||
"ERROR");
|
||||
recordPublished.setHTML(error + " on cloning and publishing the Record");
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
modalContainerPanel.add(recordPublished);
|
||||
HTML messageHTML = new HTML();
|
||||
|
||||
// here the record has been cloned and published
|
||||
if (vr != null) {
|
||||
|
||||
switch (vr.getStatus()) {
|
||||
case PASSED:
|
||||
String success = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "32CD32", null,
|
||||
"SUCCESS");
|
||||
messageHTML.setHTML("Record Cloned and Published with " + success);
|
||||
projectSavedWithSuccess = true;
|
||||
String msg = "Record published with success";
|
||||
geoNaMainForm.showAlertOnSaveAction(msg, AlertType.SUCCESS, true);
|
||||
purgeFileUploaded();
|
||||
break;
|
||||
case WARNING:
|
||||
String warning = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF8000", null,
|
||||
"WARNING");
|
||||
messageHTML.setHTML("Record Cloned and Published with " + warning);
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
case ERROR:
|
||||
String error = HTMLUtil.getHTMLElement(HTML_TAG.span, 14, "FF0000", "bold",
|
||||
"ERROR");
|
||||
messageHTML.setHTML(error + " on cloning and publishing the Record");
|
||||
geoNaMainForm.enableButtonSave(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
modalContainerPanel.add(messageHTML);
|
||||
|
||||
} else {
|
||||
// here the record has been just cloned (not published)
|
||||
messageHTML.setHTML(result.getMessageToDisplay());
|
||||
modalContainerPanel.add(messageHTML);
|
||||
}
|
||||
|
||||
if (result.getMongoId() != null) {
|
||||
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
||||
|
@ -660,7 +680,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
// }
|
||||
// });
|
||||
|
||||
//Reloading list of Concessioni
|
||||
// Reloading list of Concessioni
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
mainTabPanel.getCurrentSortFilter()));
|
||||
}
|
||||
|
|
|
@ -139,14 +139,16 @@ public interface GeoportalDataEntryService extends RemoteService {
|
|||
*/
|
||||
GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Clone the record.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param newProjectName the new project name
|
||||
* @param publishTheProject the publish the project
|
||||
* @return the commit report
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception;
|
||||
CommitReport cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public interface GeoportalDataEntryServiceAsync {
|
|||
|
||||
void readDataViewerConfig(AsyncCallback<GNADataEntryExtConfigProfile> asyncCallback);
|
||||
|
||||
void cloneTheRecord(String itemId, String newProjectName, AsyncCallback<CommitReport> callback);
|
||||
void cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject,
|
||||
AsyncCallback<CommitReport> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ public class CloneProjectEvent extends GwtEvent<CloneProjectEventHandler> {
|
|||
public static Type<CloneProjectEventHandler> TYPE = new Type<CloneProjectEventHandler>();
|
||||
private ConcessioneDV concessione;
|
||||
private String newProjectName;
|
||||
private boolean publishProject;
|
||||
|
||||
public CloneProjectEvent(ConcessioneDV concessione, String newProjectName) {
|
||||
public CloneProjectEvent(ConcessioneDV concessione, String newProjectName, boolean publishProject) {
|
||||
this.concessione = concessione;
|
||||
this.newProjectName = newProjectName;
|
||||
this.publishProject = publishProject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,4 +53,8 @@ public class CloneProjectEvent extends GwtEvent<CloneProjectEventHandler> {
|
|||
return newProjectName;
|
||||
}
|
||||
|
||||
public boolean isPublishProject() {
|
||||
return publishProject;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.events.CloneProjectEven
|
|||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -18,6 +19,21 @@ import com.google.gwt.user.client.ui.Widget;
|
|||
|
||||
public class CloneOperationPanel extends Composite {
|
||||
|
||||
@UiField
|
||||
TextBox projectNameTextBox;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoBlock;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoProjectName;
|
||||
|
||||
@UiField
|
||||
Button submitButton;
|
||||
|
||||
@UiField
|
||||
CheckBox checkBoxPublish;
|
||||
|
||||
private static CloneOperationPanelUiBinder uiBinder = GWT.create(CloneOperationPanelUiBinder.class);
|
||||
|
||||
interface CloneOperationPanelUiBinder extends UiBinder<Widget, CloneOperationPanel> {
|
||||
|
@ -34,32 +50,33 @@ public class CloneOperationPanel extends Composite {
|
|||
projectNameTextBox.setText(selectedProject.getNome());
|
||||
projectNameTextBox.setEnabled(false);
|
||||
|
||||
publishNewProjectButton.addClickHandler(new ClickHandler() {
|
||||
submitButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
boolean isValid = checkIsValidForm();
|
||||
|
||||
if (isValid) {
|
||||
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText()));
|
||||
publishNewProjectButton.setEnabled(false);
|
||||
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText(), checkBoxPublish.getValue()));
|
||||
submitButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
checkBoxPublish.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
if(checkBoxPublish.getValue()) {
|
||||
submitButton.setText("Clone and Publish as New Project");
|
||||
}else
|
||||
submitButton.setText("Clone as New Project");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@UiField
|
||||
TextBox projectNameTextBox;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoBlock;
|
||||
|
||||
@UiField
|
||||
AlertBlock infoProjectName;
|
||||
|
||||
@UiField
|
||||
Button publishNewProjectButton;
|
||||
|
||||
private ConcessioneDV selectedProject;
|
||||
|
||||
protected boolean checkIsValidForm() {
|
||||
|
|
|
@ -8,16 +8,17 @@
|
|||
}
|
||||
|
||||
.fieldset-border-style {
|
||||
border: 1px groove #444;
|
||||
-webkit-box-shadow: 0px 0px 0px 0px #000;
|
||||
box-shadow: 0px 0px 0px 0px #000;
|
||||
padding: 10px;
|
||||
border: 1px groove #444 !important;
|
||||
box-shadow: 0px 0px 0px 0px #000 !important;
|
||||
padding: 10px !important;
|
||||
margin: 5px !important;
|
||||
}
|
||||
|
||||
.legend-style {
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
margin-bottom: 0px;
|
||||
width: auto !important;
|
||||
padding: 10px !important;
|
||||
margin-bottom: 0 !important;
|
||||
border-bottom: 0 !important;
|
||||
}
|
||||
|
||||
@external .form-horizontal .input-large;
|
||||
|
@ -63,6 +64,22 @@
|
|||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:ControlGroup>
|
||||
<b:ControlLabel for="publish" title="Publish">
|
||||
<font color="red">*</font>
|
||||
Publish :
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:CheckBox ui:field="checkBoxPublish">the Project in GNA</b:CheckBox>
|
||||
</b:Controls>
|
||||
<g:HTML>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.</g:HTML>
|
||||
</b:ControlGroup>
|
||||
|
||||
<!-- Alert blocks for info/errors -->
|
||||
<b:AlertBlock type="INFO" animation="true"
|
||||
visible="false" close="false" ui:field="infoBlock"
|
||||
|
@ -71,9 +88,9 @@
|
|||
</b:Form>
|
||||
|
||||
<g:FlowPanel>
|
||||
<b:Button title="Publish as New Project"
|
||||
ui:field="publishNewProjectButton" visible="true" type="PRIMARY"
|
||||
addStyleNames="{style.button-save-style}">Publish as New Project</b:Button>
|
||||
<b:Button title="Submit" ui:field="submitButton"
|
||||
visible="true" type="PRIMARY"
|
||||
addStyleNames="{style.button-save-style}">Clone as New Project</b:Button>
|
||||
</g:FlowPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -386,33 +386,59 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
/**
|
||||
* Clone the record.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param newProjectName the new project name
|
||||
* @param itemId the item id
|
||||
* @param newProjectName the new project name
|
||||
* @param publishTheProject the publish the project
|
||||
* @return the commit report
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public CommitReport cloneTheRecord(String itemId, String newProjectName) throws Exception {
|
||||
public CommitReport cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject)
|
||||
throws Exception {
|
||||
|
||||
LOG.info("cloneTheRecord called with itemId: " + itemId + ", newProjectName: " + newProjectName
|
||||
+ ", publishTheProject: " + publishTheProject);
|
||||
|
||||
Concessione concessioneNew = null;
|
||||
// to client
|
||||
CommitReport cRep = null;
|
||||
try {
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
MongoServiceUtil serviceUtil = new MongoServiceUtil();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
// TO be sure
|
||||
Concessione concessione = clientMongo.getById(itemId);
|
||||
Concessione concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id());
|
||||
// Publishing cloned Concessione
|
||||
concessioneNew = clientMongo.publish(concessioneNew.getMongo_id());
|
||||
// server report
|
||||
ValidationReport report = concessioneNew.getReport();
|
||||
LOG.info("ValidationReport: " + report);
|
||||
concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id());
|
||||
|
||||
// to client
|
||||
CommitReport cRep = new CommitReport();
|
||||
// cRep.setRecordId(concessione.getId());
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error occurred during cloning the project with id: " + itemId, e);
|
||||
throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again");
|
||||
}
|
||||
|
||||
try {
|
||||
cRep = new CommitReport();
|
||||
cRep.setMongoId(concessioneNew.getMongo_id());
|
||||
ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report);
|
||||
cRep.setValidationReportDV(vr);
|
||||
|
||||
if (publishTheProject) {
|
||||
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
MongoServiceUtil serviceUtil = new MongoServiceUtil();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
// Publishing cloned Concessione
|
||||
concessioneNew = clientMongo.publish(concessioneNew.getMongo_id());
|
||||
cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been cloned and published");
|
||||
// server report
|
||||
ValidationReport report = concessioneNew.getReport();
|
||||
LOG.info("ValidationReport: " + report);
|
||||
// cRep.setRecordId(concessione.getId());
|
||||
cRep.setMongoId(concessioneNew.getMongo_id());
|
||||
ValidationReportDV vr = ConvertToDataViewModel.toValidationReport(report);
|
||||
|
||||
cRep.setValidationReportDV(vr);
|
||||
|
||||
} else {
|
||||
cRep.setMessageToDisplay("The project " + concessioneNew.getNome() + " has been cloned correctly");
|
||||
}
|
||||
|
||||
return cRep;
|
||||
|
||||
|
|
|
@ -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("]");
|
||||
|
|
Loading…
Reference in New Issue