"Clone (and publish) Project" facility improved and completed
This commit is contained in:
parent
59ab1e4285
commit
d87e2499ae
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +28,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="geoportal-data-entry-app-2.2.0-SNAPSHOT">
|
<wb-module deploy-name="geoportal-data-entry-app-2.2.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +57,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +86,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +115,8 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +144,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="geoportal-data-entry-app"/>
|
<property name="context-root" value="geoportal-data-entry-app"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +173,8 @@
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +202,8 @@
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
11
pom.xml
11
pom.xml
|
@ -140,28 +140,23 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- FORCING THESE DEPENDENCIES IN ORDER TO USE THE "OLD" CONCESSIONI CLIENT/MODEL -->
|
<!-- 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>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>metadata-profile-discovery</artifactId>
|
<artifactId>metadata-profile-discovery</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.application</groupId>
|
<groupId>org.gcube.application</groupId>
|
||||||
<artifactId>geoportal-data-common</artifactId>
|
<artifactId>geoportal-data-common</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT)</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.application</groupId>
|
<groupId>org.gcube.application</groupId>
|
||||||
<artifactId>geoportal-client</artifactId>
|
<artifactId>geoportal-client</artifactId>
|
||||||
<version>[1.0.0, 1.0.8-SNAPSHOT)</version>
|
<version>[1.0.0, 1.0.7]</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
|
|
@ -561,7 +561,16 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
|
|
||||||
final Modal modal = new Modal(true);
|
final Modal modal = new Modal(true);
|
||||||
modal.setCloseVisible(false);
|
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.hide(false);
|
||||||
modal.setWidth(800);
|
modal.setWidth(800);
|
||||||
modal.setMaxHeigth("650px");
|
modal.setMaxHeigth("650px");
|
||||||
|
@ -571,14 +580,14 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX);
|
alertConcessioneSource.getElement().getStyle().setMarginBottom(20, Unit.PX);
|
||||||
final VerticalPanel modalContainerPanel = new VerticalPanel();
|
final VerticalPanel modalContainerPanel = new VerticalPanel();
|
||||||
final LoaderIcon loader = new LoaderIcon();
|
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(alertConcessioneSource);
|
||||||
modalContainerPanel.add(loader);
|
modalContainerPanel.add(loader);
|
||||||
modal.add(modalContainerPanel);
|
modal.add(modalContainerPanel);
|
||||||
|
|
||||||
GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord(
|
GeoportalDataEntryServiceAsync.Util.getInstance().cloneTheRecord(
|
||||||
cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(),
|
cloneProject.getConcessione().getItemId(), cloneProject.getNewProjectName(),
|
||||||
new AsyncCallback<CommitReport>() {
|
cloneProject.isPublishProject(), new AsyncCallback<CommitReport>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -599,35 +608,46 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
public void onSuccess(CommitReport result) {
|
public void onSuccess(CommitReport result) {
|
||||||
modalContainerPanel.clear();
|
modalContainerPanel.clear();
|
||||||
modal.setCloseVisible(true);
|
modal.setCloseVisible(true);
|
||||||
HTML recordPublished = new HTML();
|
|
||||||
ValidationReportDV vr = result.getValidationReportDV();
|
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) {
|
if (result.getMongoId() != null) {
|
||||||
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
modalContainerPanel.add(new HTML("Record id: " + (result.getMongoId())));
|
||||||
|
@ -659,8 +679,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
// // modal.add(html);
|
// // modal.add(html);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
//Reloading list of Concessioni
|
// Reloading list of Concessioni
|
||||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||||
mainTabPanel.getCurrentSortFilter()));
|
mainTabPanel.getCurrentSortFilter()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,14 +139,16 @@ public interface GeoportalDataEntryService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception;
|
GNADataEntryExtConfigProfile readDataViewerConfig() throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone the record.
|
* Clone the record.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param newProjectName the new project name
|
* @param newProjectName the new project name
|
||||||
|
* @param publishTheProject the publish the project
|
||||||
* @return the commit report
|
* @return the commit report
|
||||||
* @throws Exception the exception
|
* @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 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>();
|
public static Type<CloneProjectEventHandler> TYPE = new Type<CloneProjectEventHandler>();
|
||||||
private ConcessioneDV concessione;
|
private ConcessioneDV concessione;
|
||||||
private String newProjectName;
|
private String newProjectName;
|
||||||
|
private boolean publishProject;
|
||||||
|
|
||||||
public CloneProjectEvent(ConcessioneDV concessione, String newProjectName) {
|
public CloneProjectEvent(ConcessioneDV concessione, String newProjectName, boolean publishProject) {
|
||||||
this.concessione = concessione;
|
this.concessione = concessione;
|
||||||
this.newProjectName = newProjectName;
|
this.newProjectName = newProjectName;
|
||||||
|
this.publishProject = publishProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,9 +48,13 @@ public class CloneProjectEvent extends GwtEvent<CloneProjectEventHandler> {
|
||||||
public ConcessioneDV getConcessione() {
|
public ConcessioneDV getConcessione() {
|
||||||
return concessione;
|
return concessione;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNewProjectName() {
|
public String getNewProjectName() {
|
||||||
return newProjectName;
|
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.AlertBlock;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
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.TextBox;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -18,6 +19,21 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
public class CloneOperationPanel extends Composite {
|
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);
|
private static CloneOperationPanelUiBinder uiBinder = GWT.create(CloneOperationPanelUiBinder.class);
|
||||||
|
|
||||||
interface CloneOperationPanelUiBinder extends UiBinder<Widget, CloneOperationPanel> {
|
interface CloneOperationPanelUiBinder extends UiBinder<Widget, CloneOperationPanel> {
|
||||||
|
@ -34,32 +50,33 @@ public class CloneOperationPanel extends Composite {
|
||||||
projectNameTextBox.setText(selectedProject.getNome());
|
projectNameTextBox.setText(selectedProject.getNome());
|
||||||
projectNameTextBox.setEnabled(false);
|
projectNameTextBox.setEnabled(false);
|
||||||
|
|
||||||
publishNewProjectButton.addClickHandler(new ClickHandler() {
|
submitButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
boolean isValid = checkIsValidForm();
|
boolean isValid = checkIsValidForm();
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText()));
|
appManagerBus.fireEvent(new CloneProjectEvent(selectedProject, projectNameTextBox.getText(), checkBoxPublish.getValue()));
|
||||||
publishNewProjectButton.setEnabled(false);
|
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;
|
private ConcessioneDV selectedProject;
|
||||||
|
|
||||||
protected boolean checkIsValidForm() {
|
protected boolean checkIsValidForm() {
|
||||||
|
|
|
@ -8,16 +8,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.fieldset-border-style {
|
.fieldset-border-style {
|
||||||
border: 1px groove #444;
|
border: 1px groove #444 !important;
|
||||||
-webkit-box-shadow: 0px 0px 0px 0px #000;
|
box-shadow: 0px 0px 0px 0px #000 !important;
|
||||||
box-shadow: 0px 0px 0px 0px #000;
|
padding: 10px !important;
|
||||||
padding: 10px;
|
margin: 5px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.legend-style {
|
.legend-style {
|
||||||
width: auto;
|
width: auto !important;
|
||||||
padding: 10px;
|
padding: 10px !important;
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0 !important;
|
||||||
|
border-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@external .form-horizontal .input-large;
|
@external .form-horizontal .input-large;
|
||||||
|
@ -63,6 +64,22 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</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 -->
|
<!-- Alert blocks for info/errors -->
|
||||||
<b:AlertBlock type="INFO" animation="true"
|
<b:AlertBlock type="INFO" animation="true"
|
||||||
visible="false" close="false" ui:field="infoBlock"
|
visible="false" close="false" ui:field="infoBlock"
|
||||||
|
@ -71,9 +88,9 @@
|
||||||
</b:Form>
|
</b:Form>
|
||||||
|
|
||||||
<g:FlowPanel>
|
<g:FlowPanel>
|
||||||
<b:Button title="Publish as New Project"
|
<b:Button title="Submit" ui:field="submitButton"
|
||||||
ui:field="publishNewProjectButton" visible="true" type="PRIMARY"
|
visible="true" type="PRIMARY"
|
||||||
addStyleNames="{style.button-save-style}">Publish as New Project</b:Button>
|
addStyleNames="{style.button-save-style}">Clone as New Project</b:Button>
|
||||||
</g:FlowPanel>
|
</g:FlowPanel>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -386,33 +386,59 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
/**
|
/**
|
||||||
* Clone the record.
|
* Clone the record.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param newProjectName the new project name
|
* @param newProjectName the new project name
|
||||||
|
* @param publishTheProject the publish the project
|
||||||
* @return the commit report
|
* @return the commit report
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@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 {
|
try {
|
||||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
MongoServiceUtil serviceUtil = new MongoServiceUtil();
|
MongoServiceUtil serviceUtil = new MongoServiceUtil();
|
||||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||||
// TO be sure
|
// TO be sure
|
||||||
Concessione concessione = clientMongo.getById(itemId);
|
Concessione concessione = clientMongo.getById(itemId);
|
||||||
Concessione concessioneNew = ConcessioniUtils.clone(clientMongo, concessione.getMongo_id());
|
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);
|
|
||||||
|
|
||||||
// to client
|
} catch (Exception e) {
|
||||||
CommitReport cRep = new CommitReport();
|
LOG.warn("Error occurred during cloning the project with id: " + itemId, e);
|
||||||
// cRep.setRecordId(concessione.getId());
|
throw new Exception("Sorry an error occurred during cloning the Project. Refresh and try again");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
cRep = new CommitReport();
|
||||||
cRep.setMongoId(concessioneNew.getMongo_id());
|
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;
|
return cRep;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class CommitReport implements Serializable {
|
||||||
|
|
||||||
public Long recordId;
|
public Long recordId;
|
||||||
public String mongoId;
|
public String mongoId;
|
||||||
|
private String messageToDisplay;
|
||||||
public ValidationReportDV validationReportDV;
|
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();
|
super();
|
||||||
this.recordId = recordId;
|
this.recordId = recordId;
|
||||||
this.mongoId = mongoId;
|
this.mongoId = mongoId;
|
||||||
|
this.messageToDisplay = messageToDisplay;
|
||||||
this.validationReportDV = validationReportDV;
|
this.validationReportDV = validationReportDV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +62,14 @@ public class CommitReport implements Serializable {
|
||||||
this.validationReportDV = validationReportDV;
|
this.validationReportDV = validationReportDV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessageToDisplay() {
|
||||||
|
return messageToDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageToDisplay(String messageToDisplay) {
|
||||||
|
this.messageToDisplay = messageToDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -67,6 +77,8 @@ public class CommitReport implements Serializable {
|
||||||
builder.append(recordId);
|
builder.append(recordId);
|
||||||
builder.append(", mongoId=");
|
builder.append(", mongoId=");
|
||||||
builder.append(mongoId);
|
builder.append(mongoId);
|
||||||
|
builder.append(", messageToDisplay=");
|
||||||
|
builder.append(messageToDisplay);
|
||||||
builder.append(", validationReportDV=");
|
builder.append(", validationReportDV=");
|
||||||
builder.append(validationReportDV);
|
builder.append(validationReportDV);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|
Loading…
Reference in New Issue