diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 497fd59..fbfd93b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -27,7 +28,8 @@ - + + @@ -55,7 +57,8 @@ - + + @@ -83,7 +86,8 @@ - + + @@ -111,7 +115,8 @@ - + + @@ -139,7 +144,8 @@ - + + @@ -167,7 +173,8 @@ - + + @@ -195,7 +202,8 @@ - + + diff --git a/pom.xml b/pom.xml index 0d8fa3b..e340b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -140,28 +140,23 @@ - - org.gcube.application - geoportal-common - [1.0.0,1.0.9-SNAPSHOT) - - org.gcube.common metadata-profile-discovery [1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT) - + org.gcube.application geoportal-data-common [1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT) compile + org.gcube.application geoportal-client - [1.0.0, 1.0.8-SNAPSHOT) + [1.0.0, 1.0.7] compile 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 57f8590..f2f2c49 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 @@ -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() { + cloneProject.isPublishProject(), new AsyncCallback() { @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()))); @@ -659,8 +679,8 @@ public class GeoPortalDataEntryApp implements EntryPoint { // // modal.add(html); // } // }); - - //Reloading list of Concessioni + + // Reloading list of Concessioni appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, mainTabPanel.getCurrentSortFilter())); } 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 16154ae..8e1b46c 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 @@ -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; } 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 e16267e..88ea500 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 @@ -63,6 +63,7 @@ public interface GeoportalDataEntryServiceAsync { void readDataViewerConfig(AsyncCallback asyncCallback); - void cloneTheRecord(String itemId, String newProjectName, AsyncCallback callback); + void cloneTheRecord(String itemId, String newProjectName, boolean publishTheProject, + 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 5dd4955..97d1966 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 @@ -17,10 +17,12 @@ public class CloneProjectEvent extends GwtEvent { public static Type TYPE = new Type(); 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; } /** @@ -46,9 +48,13 @@ public class CloneProjectEvent extends GwtEvent { public ConcessioneDV getConcessione() { return concessione; } - + public String getNewProjectName() { return newProjectName; } + public boolean isPublishProject() { + return publishProject; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java index 8a009dd..8ff1cd3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/CloneOperationPanel.java @@ -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 { @@ -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() { 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 44e30dc..f068cf4 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 @@ -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 @@ + + + * + Publish : + + + 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. + + - Publish as New Project + Clone as New Project \ 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 a08ca79..f594ddf 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 @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java index 0750f2f..1c396cb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/shared/CommitReport.java @@ -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("]");