From 20295446493a6816fe3896d0822846c164a67c6c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 9 Nov 2022 15:12:42 +0100 Subject: [PATCH] Removed old model "Concessioni" --- .settings/org.eclipse.wst.common.component | 39 +- .../client/GeoportalDataEntryService.java | 27 - .../GeoportalDataEntryServiceAsync.java | 10 - .../client/ui/edit/UpdateFileset.java | 1086 ++++++++--------- .../client/ui/edit/UpdateFileset.ui.xml | 8 +- .../server/GeoportalDataEntryServiceImpl.java | 171 +-- .../server/MongoServiceUtil.java | 114 +- 7 files changed, 629 insertions(+), 826 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 65accbf..9dff6c2 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,7 @@ - + + + @@ -56,7 +58,9 @@ - + + + @@ -113,7 +117,9 @@ - + + + @@ -170,7 +176,9 @@ - + + + @@ -227,7 +235,9 @@ - + + + @@ -236,10 +246,9 @@ - - uses - - + + + @@ -296,7 +305,9 @@ - + + + @@ -353,7 +364,9 @@ - + + + @@ -410,7 +423,9 @@ - + + + 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 5d17c0f..d56cf1c 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 @@ -11,15 +11,11 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleI import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; -import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -89,29 +85,6 @@ public interface GeoportalDataEntryService extends RemoteService { */ ProjectDV updateRecord(String profileID, String projectID, String jsonUpdate) throws Exception; - /** - * Read file set paths. - * - * @return the file set paths DV - * @throws Exception the exception - */ - FileSetPathsDV readFileSetPaths() throws Exception; - - /** - * Update record. - * - * @param itemId the item id - * @param recordType the record type - * @param section the section - * @param pathIndex the path index - * @param keepCurrentContent the keep current content - * @param gDBean the g D bean - * @return the updated JSON string representing the itemId - * @throws Exception the exception - */ - ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, - List keepCurrentContent, GenericDatasetBean gDBean) throws Exception; - /** * Read data viewer config. * 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 c766468..4015843 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 @@ -11,15 +11,11 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleI import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport; import org.gcube.portlets.user.geoportaldataentry.shared.GNADataEntryExtendedConfigProfile; import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject; import org.gcube.portlets.user.geoportaldataentry.shared.GeoportalISConfig; import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node; -import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -67,12 +63,6 @@ public interface GeoportalDataEntryServiceAsync { void updateRecord(String profileID, String projectID, String jsonUpdate, AsyncCallback callback); - void readFileSetPaths(AsyncCallback callback); - - void updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, - List keepCurrentContent, GenericDatasetBean gDBean, - AsyncCallback callback); - void readDataViewerConfig(AsyncCallback asyncCallback); void getListUseCaseDescriptors(List handlersIds, AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java index 6629ed1..9b6173d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.java @@ -1,550 +1,550 @@ -package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ModalConfirm; -import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.StringUtil; -import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; -import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION; -import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; -import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload; -import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; -import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; -import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper; -import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; - -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.ControlGroup; -import com.github.gwtbootstrap.client.ui.Controls; -import com.github.gwtbootstrap.client.ui.Label; -import com.github.gwtbootstrap.client.ui.ListBox; -import com.github.gwtbootstrap.client.ui.constants.IconType; -import com.github.gwtbootstrap.client.ui.constants.LabelType; -import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Style.Unit; -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.dom.client.DomEvent; -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.Window; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.HTMLPanel; -import com.google.gwt.user.client.ui.Widget; - -/** - * The Class UpdateFileset. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 27, 2021 - */ -public class UpdateFileset extends Composite { - - private static final String SECTION_PIANTE = "piante"; - - private static final String SECTION_POSIZIONAMENTO_SCAVO = "posizionamentoScavo"; - - private static final String SECTION_RELAZIONE = "relazione"; - - private static final String SECTION_IMMAGINI = "immagini"; - - private static final String SECTION_ABSTRACT_RELAZIONE = "abstract_relazione"; - - private static final String _FORM_WIDTH_FIELDS_SIZE = "730px"; - - private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); - - /** - * The Interface UpdateFilesetUiBinder. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 27, 2021 - */ - interface UpdateFilesetUiBinder extends UiBinder { - } - - @UiField - ListBox listBoxPaths; - - @UiField - ControlGroup cgSelectFile; - - @UiField - Controls controlsContent; - - @UiField - HTMLPanel uploadFileContainer; - - @UiField - Button buttonUpdate; - - private List listFileSetPaths; - - private boolean placeholderListBoxPaths = true; - - private BaseConcessioneDV selectedConcessione; - - private ConcessioneDV fullConcessione; - - private boolean placeholderListBoxIndex = true; - - private HandlerManager uiBus = new HandlerManager(null); - - private MetaDataField fieldUploadWidget; - - private Integer pathIndex = null; - - private Map mapForCCUploading = null; - - private Map> mapWSContentListBox = null; - - private HandlerManager editorManagerBus; - - private String profileID; - - - /** - * Instantiates a new update fileset. - * - * @param editorManagerBus the editor manager bus - * @param selectedConcessione the selected concessione - * @param recordType the record type - * @param listFileSetPaths the list file set paths - */ - public UpdateFileset(HandlerManager editorManagerBus, BaseConcessioneDV selectedConcessione, String profileID, List listFileSetPaths) { - initWidget(uiBinder.createAndBindUi(this)); - this.editorManagerBus = editorManagerBus; - this.selectedConcessione = selectedConcessione; - this.profileID = profileID; - this.listFileSetPaths = listFileSetPaths; - listBoxPaths.addItem("Select a section..."); - for (String path : listFileSetPaths) { - listBoxPaths.addItem(path); - } - listBoxPaths.setWidth(_FORM_WIDTH_FIELDS_SIZE); - - // add handler on select - listBoxPaths.addChangeHandler(new ChangeHandler() { - - @Override - public void onChange(ChangeEvent event) { - GWT.log("Profile type selection changed..."); - cgSelectFile.setVisible(false); - - if (placeholderListBoxPaths) { - listBoxPaths.removeItem(0); // this is the placeholder, removing it once - placeholderListBoxPaths = false; - } - showUploadFileGUI(); - } - - }); - - - Window.alert("This part must be revisited"); - -// GeoPortalDataEntryApp.geoportalDataEntryService.getRecord(selectedConcessione.getItemId(), recordType, -// new AsyncCallback() { +//package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; // -// @Override -// public void onSuccess(ConcessioneDV theRecord) { -// fullConcessione = theRecord; +//import java.util.ArrayList; +//import java.util.Collection; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +//import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +//import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; +//import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform; +//import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.ModalConfirm; +//import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.StringUtil; +//import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; +//import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION; +//import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton; +//import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload; +//import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean; +//import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; +//import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper; +//import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; +// +//import com.github.gwtbootstrap.client.ui.Button; +//import com.github.gwtbootstrap.client.ui.ControlGroup; +//import com.github.gwtbootstrap.client.ui.Controls; +//import com.github.gwtbootstrap.client.ui.Label; +//import com.github.gwtbootstrap.client.ui.ListBox; +//import com.github.gwtbootstrap.client.ui.constants.IconType; +//import com.github.gwtbootstrap.client.ui.constants.LabelType; +//import com.google.gwt.core.client.GWT; +//import com.google.gwt.dom.client.Document; +//import com.google.gwt.dom.client.Style.Unit; +//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.dom.client.DomEvent; +//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.Window; +//import com.google.gwt.user.client.rpc.AsyncCallback; +//import com.google.gwt.user.client.ui.Composite; +//import com.google.gwt.user.client.ui.FlexTable; +//import com.google.gwt.user.client.ui.HTML; +//import com.google.gwt.user.client.ui.HTMLPanel; +//import com.google.gwt.user.client.ui.Widget; +// +///** +// * The Class UpdateFileset. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it +// * +// * Sep 27, 2021 +// */ +//public class UpdateFileset extends Composite { +// +// private static final String SECTION_PIANTE = "piante"; +// +// private static final String SECTION_POSIZIONAMENTO_SCAVO = "posizionamentoScavo"; +// +// private static final String SECTION_RELAZIONE = "relazione"; +// +// private static final String SECTION_IMMAGINI = "immagini"; +// +// private static final String SECTION_ABSTRACT_RELAZIONE = "abstract_relazione"; +// +// private static final String _FORM_WIDTH_FIELDS_SIZE = "730px"; +// +// private static UpdateFilesetUiBinder uiBinder = GWT.create(UpdateFilesetUiBinder.class); +// +// /** +// * The Interface UpdateFilesetUiBinder. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it +// * +// * Sep 27, 2021 +// */ +// interface UpdateFilesetUiBinder extends UiBinder { +// } +// +// @UiField +// ListBox listBoxPaths; +// +// @UiField +// ControlGroup cgSelectFile; +// +// @UiField +// Controls controlsContent; +// +// @UiField +// HTMLPanel uploadFileContainer; +// +// @UiField +// Button buttonUpdate; +// +// private List listFileSetPaths; +// +// private boolean placeholderListBoxPaths = true; +// +// private BaseConcessioneDV selectedConcessione; +// +// private ConcessioneDV fullConcessione; +// +// private boolean placeholderListBoxIndex = true; +// +// private HandlerManager uiBus = new HandlerManager(null); +// +// private MetaDataField fieldUploadWidget; +// +// private Integer pathIndex = null; +// +// private Map mapForCCUploading = null; +// +// private Map> mapWSContentListBox = null; +// +// private HandlerManager editorManagerBus; +// +// private String profileID; +// +// +// /** +// * Instantiates a new update fileset. +// * +// * @param editorManagerBus the editor manager bus +// * @param selectedConcessione the selected concessione +// * @param recordType the record type +// * @param listFileSetPaths the list file set paths +// */ +// public UpdateFileset(HandlerManager editorManagerBus, BaseConcessioneDV selectedConcessione, String profileID, List listFileSetPaths) { +// initWidget(uiBinder.createAndBindUi(this)); +// this.editorManagerBus = editorManagerBus; +// this.selectedConcessione = selectedConcessione; +// this.profileID = profileID; +// this.listFileSetPaths = listFileSetPaths; +// listBoxPaths.addItem("Select a section..."); +// for (String path : listFileSetPaths) { +// listBoxPaths.addItem(path); +// } +// listBoxPaths.setWidth(_FORM_WIDTH_FIELDS_SIZE); +// +// // add handler on select +// listBoxPaths.addChangeHandler(new ChangeHandler() { +// +// @Override +// public void onChange(ChangeEvent event) { +// GWT.log("Profile type selection changed..."); +// cgSelectFile.setVisible(false); +// +// if (placeholderListBoxPaths) { +// listBoxPaths.removeItem(0); // this is the placeholder, removing it once +// placeholderListBoxPaths = false; +// } +// showUploadFileGUI(); +// } +// +// }); +// +// +// Window.alert("This part must be revisited"); +// +//// GeoPortalDataEntryApp.geoportalDataEntryService.getRecord(selectedConcessione.getItemId(), recordType, +//// new AsyncCallback() { +//// +//// @Override +//// public void onSuccess(ConcessioneDV theRecord) { +//// fullConcessione = theRecord; +//// } +//// +//// @Override +//// public void onFailure(Throwable caught) { +//// Window.alert(caught.getMessage()); +//// } +//// }); +// +// buttonUpdate.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// +// String errorMsg = checkValidUpload(); +// if (errorMsg == null) { +// List listFilesUploaded = new ArrayList(); +// List listMetaDataFieldSkeleton = fieldUploadWidget.getListOfMetadataFields(); +// for (MetaDataFieldSkeleton field : listMetaDataFieldSkeleton) { +// DialogUpload dUpload = (DialogUpload) field.getHolder(); +// // adding it only if exists +// if (dUpload.getFileUploadingState() != null) +// listFilesUploaded.add(dUpload.getFileUploadingState().getFile()); // } // +// GenericDatasetBean gdb = new GenericDatasetBean(); +// gdb.setFilesUploaded(listFilesUploaded); +// // adding it only if exists +// +// GWT.log("Section selected: " + listBoxPaths.getSelectedItemText()); +// GWT.log("Content index selected: " + pathIndex); +// GWT.log("FileUploaded selected: " + gdb.getFilesUploaded()); +// +// List listCurrentContent = new ArrayList(); +// if (mapForCCUploading != null) { +// Collection currentContent = mapForCCUploading.values(); +// if (currentContent != null) +// listCurrentContent.addAll(currentContent); +// } +// +// String htmlMsg = "Going to update the section " + listBoxPaths.getSelectedItemText() + ":"; +// htmlMsg += "
    "; +// htmlMsg += "
  • keeping " + listCurrentContent.size() + " current file/s
  • "; +// htmlMsg += "
  • uploading " + listFilesUploaded.size() + " new file/s
  • "; +// htmlMsg += "
"; +// htmlMsg += "
"; +// htmlMsg += "This operation cannot be undone. Would you like to proceed?"; +// +// GWT.log(htmlMsg); +// +// final ModalConfirm dialogConfirm = new ModalConfirm(null, "Update Confirm?", htmlMsg); +// dialogConfirm.getElement().getStyle().setZIndex(100000); +// dialogConfirm.getYesButton().addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// dialogConfirm.hide(); +// buttonUpdate.setEnabled(false); +// +// final DialogInform dialogInf = new DialogInform(null, "Updating Project...", ""); +// dialogInf.setZIndex(100000); +// dialogInf.showLoader("Updating file/s for project: "+fullConcessione.getNome()); +// //dialogInf.setWidth("400px"); +// +// GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord( +// fullConcessione.getItemId(), fullConcessione.getRecordType(), +// listBoxPaths.getSelectedItemText(), pathIndex, listCurrentContent, gdb, +// new AsyncCallback() { +// +// @Override +// public void onFailure(Throwable caught) { +// dialogInf.hideLoader(); +// dialogInf.setMsg( +// "Sorry error occurred during project update. Error reported: " +// + caught.getMessage()); +// buttonUpdate.setEnabled(true); +// showUploadFileGUI(); +// +// } +// +// @Override +// public void onSuccess(ConcessioneDV result) { +// dialogInf.hideLoader(); +// dialogInf.setText("Project updated!"); +// dialogInf.setMsg(result.getNome() + " updated correclty"); +// dialogInf.center(); +// fullConcessione = result; +// GWT.log("new concessione: "+fullConcessione); +// buttonUpdate.setEnabled(true); +// showUploadFileGUI(); +// +// Window.alert("updateSectionForRecord must be revisited"); +// +// /* +// editorManagerBus.fireEvent( +// new OperationPerformedOnItemEvent(Arrays.asList(fullConcessione), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT)); +// +// */ +// +// } +// }); +// dialogInf.center(); +// } +// }); +// dialogConfirm.show(); +// +// } else { +// Window.alert(errorMsg); +// } +// +// } +// }); +// +// } +// +// /** +// * Show upload file GUI. +// */ +// private void showUploadFileGUI() { +// uploadFileContainer.setVisible(true); +// buttonUpdate.setVisible(false); +// uploadFileContainer.clear(); +// controlsContent.clear(); +// placeholderListBoxIndex = true; +// fieldUploadWidget = null; +// pathIndex = null; +// mapForCCUploading = null; +// mapWSContentListBox = null; +// +//// listBoxIndex.clear(); +// cgSelectFile.setVisible(true); +// +// ListBox listBoxContentIndex = new ListBox(); +// listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE); +// listBoxContentIndex.addItem("Select a content..."); +// String section = null; +// Integer posizIndex = 0; +// if (listBoxPaths.getSelectedItemText().contains(SECTION_ABSTRACT_RELAZIONE)) { +// section = SECTION_ABSTRACT_RELAZIONE; +// AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); +// +// if (ar == null) { +// showMessage(SECTION_ABSTRACT_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); +//// pathIndex = 0; +//// showNewFileUpload(); +// return; +// } +// +// fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, ar.getTitolo(), +// ar.getListWsContent()); +// +// } else if (listBoxPaths.getSelectedItemText().contains(SECTION_IMMAGINI)) { +// section = SECTION_IMMAGINI; +// List listImmagini = fullConcessione.getImmaginiRappresentative(); +// if (listImmagini == null || listImmagini.isEmpty()) { +// showMessage(SECTION_IMMAGINI + " NOT AVAILABLE", LabelType.WARNING); +//// pathIndex = 0; +//// showNewFileUpload(); +// return; +// } +// +// for (UploadedImageDV uploadedImageDV : listImmagini) { +// fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, StringUtil.ellipsize(uploadedImageDV.getDidascalia(),30), +// uploadedImageDV.getListWsContent()); +// posizIndex++; +// } +// +// } else if (listBoxPaths.getSelectedItemText().contains(SECTION_RELAZIONE)) { +// section = SECTION_RELAZIONE; +// RelazioneScavoDV relazioneScavo = fullConcessione.getRelazioneScavo(); +// if (relazioneScavo == null) { +// showMessage(SECTION_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); +//// pathIndex = 0; +//// showNewFileUpload(); +// return; +// } +// +// fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, relazioneScavo.getTitolo(), +// relazioneScavo.getListWsContent()); +// +// } else if (listBoxPaths.getSelectedItemText().contains(SECTION_POSIZIONAMENTO_SCAVO)) { +// section = SECTION_POSIZIONAMENTO_SCAVO; +// LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo(); +// if (posiz == null) { +// showMessage(SECTION_POSIZIONAMENTO_SCAVO + " NOT AVAILABLE", LabelType.WARNING); +//// pathIndex = 0; +//// showNewFileUpload(); +// return; +// } +// +// fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, posiz.getTitolo(), +// posiz.getListWsContent()); +// +// } else if (listBoxPaths.getSelectedItemText().contains(SECTION_PIANTE)) { +// section = SECTION_PIANTE; +// List piante = fullConcessione.getPianteFineScavo(); +// if (piante == null || piante.isEmpty()) { +// showMessage(SECTION_PIANTE + " NOT AVAILABLE", LabelType.WARNING); +//// pathIndex = 0; +//// showNewFileUpload(); +// return; +// } +// +// for (LayerConcessioneDV lcDV : piante) { +// fillListBoxToBeReplaced(listBoxContentIndex, SECTION_PIANTE, posizIndex, lcDV.getTitolo(), +// lcDV.getListWsContent()); +// posizIndex++; +// } +// +// } +// +// controlsContent.add(listBoxContentIndex); +// +// if (listBoxContentIndex.getItemCount() == 2) { +// // listBoxContentIndex.setSelectedIndex(1); +// listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(1)); +// +// DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxContentIndex); +// } +// +// } +// +// private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title, +// List listWSC) { +// GWT.log("fillListBoxToBeReplaced called, posizIndex: "+posizIndex+", listWSC: "+listWSC); +// +// if(mapWSContentListBox==null) { +// mapWSContentListBox = new HashMap>(); +// } +// +// listBoxContentIndex.addItem(title, posizIndex + ""); +// mapWSContentListBox.put(posizIndex, listWSC); +// +// // adding handler once +// if (posizIndex == 0) { +// +// listBoxContentIndex.addChangeHandler(new ChangeHandler() { +// +// @Override +// public void onChange(ChangeEvent event) { +// GWT.log("listBoxContentIndex changed, value: "+listBoxContentIndex.getSelectedValue()); +// +// if (placeholderListBoxIndex) { +// listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once +// placeholderListBoxIndex = false; +// } +// int selectedIndex = listBoxContentIndex.getSelectedIndex(); +// GWT.log("selected index: "+selectedIndex); +// List theListWC = mapWSContentListBox.get(selectedIndex); +// +// if (theListWC == null || theListWC.isEmpty()) { +// uploadFileContainer.clear(); +// showMessage(section + " does not contain file!", LabelType.WARNING); +// pathIndex = posizIndex; +// showNewFileUpload(); +// return; +// } +// +// showFileBrowseInteraction(selectedIndex, mapWSContentListBox.get(selectedIndex)); +// } +// }); +// } +//// +// +// } +// +// private void showFileBrowseInteraction(int pathContentIndex, List listWSC) { +// uploadFileContainer.clear(); +// pathIndex = pathContentIndex; +// GWT.log("showing pathContentIndex: "+pathContentIndex); +// GWT.log("showing ws content: "+listWSC); +// +// // map for current content uploading +// mapForCCUploading = new HashMap(listWSC.size()); +// int index = 0; +// for (WorkspaceContentDV workspaceContentDV : listWSC) { +// workspaceContentDV.setCliendId(index); +// mapForCCUploading.put(index, workspaceContentDV); +// index++; +// } +// +// if (listWSC.size() > 0) { +// FlexTable table = new FlexTable(); +// table.addStyleName("table-current-content"); +// table.setHTML(0, 0, "Current content:"); +// table.setHTML(1, 0, "Filename"); +// table.setHTML(1, 1, "MimeType"); +// table.setHTML(1, 2, "Link"); +// +// int i = 2; +// for (final WorkspaceContentDV wsContent : listWSC) { +// table.setHTML(i, 0, wsContent.getName()); +// table.setHTML(i, 1, wsContent.getMimetype()); +// String link = "View"; +// table.setHTML(i, 2, link); +// +// final int rowIndexToRem = i; +// Button buttonRemoveFile = new Button(); +// buttonRemoveFile.setIcon(IconType.TRASH); +// buttonRemoveFile.setTitle("Remove this file"); +// buttonRemoveFile.addClickHandler(new ClickHandler() { +// // @Override -// public void onFailure(Throwable caught) { -// Window.alert(caught.getMessage()); +// public void onClick(ClickEvent event) { +// mapForCCUploading.remove(wsContent.getCliendId()); +// table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden"); // } // }); - - buttonUpdate.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - String errorMsg = checkValidUpload(); - if (errorMsg == null) { - List listFilesUploaded = new ArrayList(); - List listMetaDataFieldSkeleton = fieldUploadWidget.getListOfMetadataFields(); - for (MetaDataFieldSkeleton field : listMetaDataFieldSkeleton) { - DialogUpload dUpload = (DialogUpload) field.getHolder(); - // adding it only if exists - if (dUpload.getFileUploadingState() != null) - listFilesUploaded.add(dUpload.getFileUploadingState().getFile()); - } - - GenericDatasetBean gdb = new GenericDatasetBean(); - gdb.setFilesUploaded(listFilesUploaded); - // adding it only if exists - - GWT.log("Section selected: " + listBoxPaths.getSelectedItemText()); - GWT.log("Content index selected: " + pathIndex); - GWT.log("FileUploaded selected: " + gdb.getFilesUploaded()); - - List listCurrentContent = new ArrayList(); - if (mapForCCUploading != null) { - Collection currentContent = mapForCCUploading.values(); - if (currentContent != null) - listCurrentContent.addAll(currentContent); - } - - String htmlMsg = "Going to update the section " + listBoxPaths.getSelectedItemText() + ":"; - htmlMsg += "
    "; - htmlMsg += "
  • keeping " + listCurrentContent.size() + " current file/s
  • "; - htmlMsg += "
  • uploading " + listFilesUploaded.size() + " new file/s
  • "; - htmlMsg += "
"; - htmlMsg += "
"; - htmlMsg += "This operation cannot be undone. Would you like to proceed?"; - - GWT.log(htmlMsg); - - final ModalConfirm dialogConfirm = new ModalConfirm(null, "Update Confirm?", htmlMsg); - dialogConfirm.getElement().getStyle().setZIndex(100000); - dialogConfirm.getYesButton().addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - dialogConfirm.hide(); - buttonUpdate.setEnabled(false); - - final DialogInform dialogInf = new DialogInform(null, "Updating Project...", ""); - dialogInf.setZIndex(100000); - dialogInf.showLoader("Updating file/s for project: "+fullConcessione.getNome()); - //dialogInf.setWidth("400px"); - - GeoportalDataEntryServiceAsync.Util.getInstance().updateSectionForRecord( - fullConcessione.getItemId(), fullConcessione.getRecordType(), - listBoxPaths.getSelectedItemText(), pathIndex, listCurrentContent, gdb, - new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - dialogInf.hideLoader(); - dialogInf.setMsg( - "Sorry error occurred during project update. Error reported: " - + caught.getMessage()); - buttonUpdate.setEnabled(true); - showUploadFileGUI(); - - } - - @Override - public void onSuccess(ConcessioneDV result) { - dialogInf.hideLoader(); - dialogInf.setText("Project updated!"); - dialogInf.setMsg(result.getNome() + " updated correclty"); - dialogInf.center(); - fullConcessione = result; - GWT.log("new concessione: "+fullConcessione); - buttonUpdate.setEnabled(true); - showUploadFileGUI(); - - Window.alert("updateSectionForRecord must be revisited"); - - /* - editorManagerBus.fireEvent( - new OperationPerformedOnItemEvent(Arrays.asList(fullConcessione), ACTION_PERFORMED_ON_ITEM.UPDATED_PROJECT)); - - */ - - } - }); - dialogInf.center(); - } - }); - dialogConfirm.show(); - - } else { - Window.alert(errorMsg); - } - - } - }); - - } - - /** - * Show upload file GUI. - */ - private void showUploadFileGUI() { - uploadFileContainer.setVisible(true); - buttonUpdate.setVisible(false); - uploadFileContainer.clear(); - controlsContent.clear(); - placeholderListBoxIndex = true; - fieldUploadWidget = null; - pathIndex = null; - mapForCCUploading = null; - mapWSContentListBox = null; - -// listBoxIndex.clear(); - cgSelectFile.setVisible(true); - - ListBox listBoxContentIndex = new ListBox(); - listBoxContentIndex.setWidth(_FORM_WIDTH_FIELDS_SIZE); - listBoxContentIndex.addItem("Select a content..."); - String section = null; - Integer posizIndex = 0; - if (listBoxPaths.getSelectedItemText().contains(SECTION_ABSTRACT_RELAZIONE)) { - section = SECTION_ABSTRACT_RELAZIONE; - AbstractRelazioneScavoDV ar = fullConcessione.getAbstractRelazioneScavo(); - - if (ar == null) { - showMessage(SECTION_ABSTRACT_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); -// pathIndex = 0; -// showNewFileUpload(); - return; - } - - fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, ar.getTitolo(), - ar.getListWsContent()); - - } else if (listBoxPaths.getSelectedItemText().contains(SECTION_IMMAGINI)) { - section = SECTION_IMMAGINI; - List listImmagini = fullConcessione.getImmaginiRappresentative(); - if (listImmagini == null || listImmagini.isEmpty()) { - showMessage(SECTION_IMMAGINI + " NOT AVAILABLE", LabelType.WARNING); -// pathIndex = 0; -// showNewFileUpload(); - return; - } - - for (UploadedImageDV uploadedImageDV : listImmagini) { - fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, StringUtil.ellipsize(uploadedImageDV.getDidascalia(),30), - uploadedImageDV.getListWsContent()); - posizIndex++; - } - - } else if (listBoxPaths.getSelectedItemText().contains(SECTION_RELAZIONE)) { - section = SECTION_RELAZIONE; - RelazioneScavoDV relazioneScavo = fullConcessione.getRelazioneScavo(); - if (relazioneScavo == null) { - showMessage(SECTION_RELAZIONE + " NOT AVAILABLE", LabelType.WARNING); -// pathIndex = 0; -// showNewFileUpload(); - return; - } - - fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, relazioneScavo.getTitolo(), - relazioneScavo.getListWsContent()); - - } else if (listBoxPaths.getSelectedItemText().contains(SECTION_POSIZIONAMENTO_SCAVO)) { - section = SECTION_POSIZIONAMENTO_SCAVO; - LayerConcessioneDV posiz = fullConcessione.getPosizionamentoScavo(); - if (posiz == null) { - showMessage(SECTION_POSIZIONAMENTO_SCAVO + " NOT AVAILABLE", LabelType.WARNING); -// pathIndex = 0; -// showNewFileUpload(); - return; - } - - fillListBoxToBeReplaced(listBoxContentIndex, section, posizIndex, posiz.getTitolo(), - posiz.getListWsContent()); - - } else if (listBoxPaths.getSelectedItemText().contains(SECTION_PIANTE)) { - section = SECTION_PIANTE; - List piante = fullConcessione.getPianteFineScavo(); - if (piante == null || piante.isEmpty()) { - showMessage(SECTION_PIANTE + " NOT AVAILABLE", LabelType.WARNING); -// pathIndex = 0; -// showNewFileUpload(); - return; - } - - for (LayerConcessioneDV lcDV : piante) { - fillListBoxToBeReplaced(listBoxContentIndex, SECTION_PIANTE, posizIndex, lcDV.getTitolo(), - lcDV.getListWsContent()); - posizIndex++; - } - - } - - controlsContent.add(listBoxContentIndex); - - if (listBoxContentIndex.getItemCount() == 2) { - // listBoxContentIndex.setSelectedIndex(1); - listBoxContentIndex.setSelectedValue(listBoxContentIndex.getItemText(1)); - - DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxContentIndex); - } - - } - - private void fillListBoxToBeReplaced(ListBox listBoxContentIndex, String section, int posizIndex, String title, - List listWSC) { - GWT.log("fillListBoxToBeReplaced called, posizIndex: "+posizIndex+", listWSC: "+listWSC); - - if(mapWSContentListBox==null) { - mapWSContentListBox = new HashMap>(); - } - - listBoxContentIndex.addItem(title, posizIndex + ""); - mapWSContentListBox.put(posizIndex, listWSC); - - // adding handler once - if (posizIndex == 0) { - - listBoxContentIndex.addChangeHandler(new ChangeHandler() { - - @Override - public void onChange(ChangeEvent event) { - GWT.log("listBoxContentIndex changed, value: "+listBoxContentIndex.getSelectedValue()); - - if (placeholderListBoxIndex) { - listBoxContentIndex.removeItem(0); // this is the placeholder, removing it once - placeholderListBoxIndex = false; - } - int selectedIndex = listBoxContentIndex.getSelectedIndex(); - GWT.log("selected index: "+selectedIndex); - List theListWC = mapWSContentListBox.get(selectedIndex); - - if (theListWC == null || theListWC.isEmpty()) { - uploadFileContainer.clear(); - showMessage(section + " does not contain file!", LabelType.WARNING); - pathIndex = posizIndex; - showNewFileUpload(); - return; - } - - showFileBrowseInteraction(selectedIndex, mapWSContentListBox.get(selectedIndex)); - } - }); - } +// table.setWidget(i, 3, buttonRemoveFile); +// i++; +// } +// +// uploadFileContainer.add(table); +// } +// +// showNewFileUpload(); +// } +// +// +// private void showNewFileUpload() { // - - } - - private void showFileBrowseInteraction(int pathContentIndex, List listWSC) { - uploadFileContainer.clear(); - pathIndex = pathContentIndex; - GWT.log("showing pathContentIndex: "+pathContentIndex); - GWT.log("showing ws content: "+listWSC); - - // map for current content uploading - mapForCCUploading = new HashMap(listWSC.size()); - int index = 0; - for (WorkspaceContentDV workspaceContentDV : listWSC) { - workspaceContentDV.setCliendId(index); - mapForCCUploading.put(index, workspaceContentDV); - index++; - } - - if (listWSC.size() > 0) { - FlexTable table = new FlexTable(); - table.addStyleName("table-current-content"); - table.setHTML(0, 0, "Current content:"); - table.setHTML(1, 0, "Filename"); - table.setHTML(1, 1, "MimeType"); - table.setHTML(1, 2, "Link"); - - int i = 2; - for (final WorkspaceContentDV wsContent : listWSC) { - table.setHTML(i, 0, wsContent.getName()); - table.setHTML(i, 1, wsContent.getMimetype()); - String link = "View"; - table.setHTML(i, 2, link); - - final int rowIndexToRem = i; - Button buttonRemoveFile = new Button(); - buttonRemoveFile.setIcon(IconType.TRASH); - buttonRemoveFile.setTitle("Remove this file"); - buttonRemoveFile.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - mapForCCUploading.remove(wsContent.getCliendId()); - table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden"); - } - }); - table.setWidget(i, 3, buttonRemoveFile); - i++; - } - - uploadFileContainer.add(table); - } - - showNewFileUpload(); - } - - - private void showNewFileUpload() { - - HTML label = new HTML(); - label.getElement().getStyle().setMarginTop(10, Unit.PX); - label.getElement().getStyle().setMarginBottom(10, Unit.PX); - label.setHTML("Add new file/s:"); - uploadFileContainer.add(label); - // mDU = new MultipleDilaogUpload(); - - MetadataFieldWrapper uploadField = new MetadataFieldWrapper(); - uploadField.setFieldName("File"); - uploadField.setMandatory(false); - uploadField.setType(DataTypeWrapper.File); - uploadField.setMaxOccurs(1000); - - try { - fieldUploadWidget = new MetaDataField(uploadField, uiBus, OPERATION.NEW); - uploadFileContainer.add(fieldUploadWidget); - - buttonUpdate.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - /** - * Test if profile data are valid. - * - * @return the string - */ - private String checkValidUpload() { - - if (fieldUploadWidget == null) - return "No file uploaded"; - - for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) { - - field.removeError(); - - String error = field.isFieldValueValid(); - if (error != null) { - field.showError(); - String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error; - return errorMsg; - } - } - - return null; - } - - private void showMessage(String txt, LabelType type) { - Label l = new Label(); - l.setType(type); - l.setText(txt); - uploadFileContainer.add(l); - } - -} +// HTML label = new HTML(); +// label.getElement().getStyle().setMarginTop(10, Unit.PX); +// label.getElement().getStyle().setMarginBottom(10, Unit.PX); +// label.setHTML("Add new file/s:"); +// uploadFileContainer.add(label); +// // mDU = new MultipleDilaogUpload(); +// +// MetadataFieldWrapper uploadField = new MetadataFieldWrapper(); +// uploadField.setFieldName("File"); +// uploadField.setMandatory(false); +// uploadField.setType(DataTypeWrapper.File); +// uploadField.setMaxOccurs(1000); +// +// try { +// fieldUploadWidget = new MetaDataField(uploadField, uiBus, OPERATION.NEW); +// uploadFileContainer.add(fieldUploadWidget); +// +// buttonUpdate.setVisible(true); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// +// /** +// * Test if profile data are valid. +// * +// * @return the string +// */ +// private String checkValidUpload() { +// +// if (fieldUploadWidget == null) +// return "No file uploaded"; +// +// for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) { +// +// field.removeError(); +// +// String error = field.isFieldValueValid(); +// if (error != null) { +// field.showError(); +// String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error; +// return errorMsg; +// } +// } +// +// return null; +// } +// +// private void showMessage(String txt, LabelType type) { +// Label l = new Label(); +// l.setType(type); +// l.setText(txt); +// uploadFileContainer.add(l); +// } +// +//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml index b2715e4..a5df4fd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateFileset.ui.xml @@ -1,4 +1,4 @@ - + - + @@ -47,4 +47,4 @@ addStyleNames="{style.button-save-style}" ui:field="buttonUpdate" visible="false">UPDATE - \ No newline at end of file + --> \ 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 720bc0a..39c3c44 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 @@ -23,7 +23,6 @@ import org.gcube.application.geoportal.common.model.useCaseDescriptor.Relationsh import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; -import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.ProjectDVBuilder; import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller; @@ -49,9 +48,6 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.common.portal.PortalContext; import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService; @@ -89,8 +85,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen public static final String GEONA_GENERIC_RESOURCE_SECONDARY_TYPE = "GEONA_GENERIC_RESOURCE_SECONDARY_TYPE"; private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataEntryServiceImpl.class); - // private String tmpDirsLocation = System.getProperty("java.io.tmpdir"); - /** * Gets the GNA data entry config profile. * @@ -195,7 +189,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen throw new Exception("Error occurred on loading LifecycleInformation for the project: " + theProject.getId() + ". Error: " + e.getMessage()); } finally { - + LOG.debug("List listTempDirs is: " + listTempDirs); if (listTempDirs != null && listTempDirs.size() > 0) { for (File file : listTempDirs) { @@ -555,34 +549,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } - /** - * Pretty print client data entry map. - * - * @param toMap the to map - */ - private void prettyPrintClientDataEntryMap(HashMap> toMap) { - - for (ProjectFormCard theType : toMap.keySet()) { - LOG.debug("\n\n"); - LOG.debug(theType.toString()); - List list = toMap.get(theType); - for (GeoNaFormDataObject geoNaFormDataObject : list) { - LOG.debug("\t has " + geoNaFormDataObject.getListGDB().size() + " data bean/s"); - int i = 0; - for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) { - LOG.debug("\t " + ++i + ") " + GenericDatasetBean.class.getSimpleName() + " entries:"); - Map> map = gbd.getFormDataEntryFields(); - for (String keyEntry : map.keySet()) { - LOG.debug("\t " + keyEntry + ": " + map.get(keyEntry)); - } - for (FileUploaded fup : gbd.getFilesUploaded()) { - LOG.debug("\t " + fup); - } - } - } - } - } - /** * Delete project. * @@ -680,113 +646,6 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } } - /** - * Read file set paths. - * - * @return the list - * @throws Exception the exception - */ - @Override - public FileSetPathsDV readFileSetPaths() throws Exception { - LOG.info("readFileSetPaths called"); - return ConvertToDataViewModel.getFileSetPaths(); - - } - - /** - * Update record. - * - * @param itemId the item id - * @param recordType the record type - * @param section the section - * @param pathIndex the path index - * @param keepCurrentContent the keep current content - * @param gDBean the g D bean - * @return the updated JSON string representing the itemId - * @throws Exception the exception - */ - @Override - public ConcessioneDV updateSectionForRecord(String itemId, String recordType, String section, int pathIndex, - List keepCurrentContent, GenericDatasetBean gDBean) throws Exception { - LOG.info("updateSectionForRecord called with itemId: " + itemId + ", section: " + section + ", pathIndex: " - + pathIndex + ", gDBean: " + gDBean, ""); - try { - - throw new Exception("updateSectionForRecord not implemented!"); - /* - * if (itemId == null) throw new Exception("Item id is null"); - * - * if (recordType.equalsIgnoreCase(RECORD_TYPE.CONCESSIONE.name())) { - * SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - * MongoServiceUtil serviceUtil = new MongoServiceUtil(); MongoConcessioni - * clientMongo = serviceUtil.getInstanceMongoConcessioni(); - * - * String toEditPath = null; AddSectionToConcessioneRequest request = null; - * List files = new ArrayList(); - * - * // Managing files already present as current content and kept by user - * List keepFiles = serviceUtil.toTemFilesFromWSC(keepCurrentContent); - * if (keepFiles != null) { files.addAll(keepFiles); LOG.debug(keepFiles.size() - * + " current corrent file/s has/have been added to list of files"); } - * - * // Managing new files uploaded by user List newFiles = - * serviceUtil.toTemFiles(gDBean.getFilesUploaded()); if (newFiles != null) { - * files.addAll(newFiles); LOG.debug(newFiles.size() + - * " new file/s has/have been added to list of files"); } - * - * // TODO MUST BE REVISITED - * - * - * if (section.contains("abstract_relazione")) { - * - * toEditPath = Paths.ABSTRACT_RELAZIONE; request = new - * AddSectionToConcessioneRequest(toEditPath, files); - * - * } else if (section.contains("immagini")) { toEditPath = - * Paths.imgByIndex(pathIndex); request = new - * AddSectionToConcessioneRequest(toEditPath, files); - * - * } else if (section.contains("relazione")) { toEditPath = Paths.RELAZIONE; - * request = new AddSectionToConcessioneRequest(toEditPath, files); - * - * } else if (section.contains("posizionamentoScavo")) { toEditPath = - * Paths.POSIZIONAMENTO; request = new - * AddSectionToConcessioneRequest(toEditPath, files); - * - * } else if (section.contains("piante")) { toEditPath = - * Paths.piantaByIndex(pathIndex); request = new - * AddSectionToConcessioneRequest(toEditPath, files); } - * - * - * // Unpublish LOG.info("Unpublishing " + itemId); - * clientMongo.unPublish(itemId); - * - * // update Fileset LOG.info("Removing old fileset.. "); Concessione - * concessione = clientMongo.cleanFileSet(itemId, toEditPath); - * - * LOG.debug("Sending new Fileset .."); if (files.size() > 0) { // StorageUtils - * storage=new StorageUtils(); // Building TempFile - * SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - * LOG.info("Registering FileSet into recordId " + itemId + - * " with request path: " + toEditPath + " and: " + files.size() + " file/s"); - * concessione = clientMongo.registerFileSet(itemId, request); } else { - * LOG.info("Fileset is empty, skipping registerFileSet"); } - * - * LOG.info("Publishing itemId: " + itemId); concessione = - * clientMongo.publish(itemId); - * - * LOG.debug("returning concessione: " + concessione); return - * ConvertToDataViewModel.toConcessione(concessione); } - * - */ - - } catch (Exception e) { - LOG.error("Error on updating the project with item id: " + itemId, e); - throw new Exception( - "Error occurred on updating the project with id: " + itemId + ". Error: " + e.getMessage()); - } - } - /** * Read data viewer config. * @@ -1154,4 +1013,32 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen } + /** + * Pretty print client data entry map. + * + * @param toMap the to map + */ + private void prettyPrintClientDataEntryMap(HashMap> toMap) { + + for (ProjectFormCard theType : toMap.keySet()) { + LOG.debug("\n\n"); + LOG.debug(theType.toString()); + List list = toMap.get(theType); + for (GeoNaFormDataObject geoNaFormDataObject : list) { + LOG.debug("\t has " + geoNaFormDataObject.getListGDB().size() + " data bean/s"); + int i = 0; + for (GenericDatasetBean gbd : geoNaFormDataObject.getListGDB()) { + LOG.debug("\t " + ++i + ") " + GenericDatasetBean.class.getSimpleName() + " entries:"); + Map> map = gbd.getFormDataEntryFields(); + for (String keyEntry : map.keySet()) { + LOG.debug("\t " + keyEntry + ": " + map.get(keyEntry)); + } + for (FileUploaded fup : gbd.getFilesUploaded()) { + LOG.debug("\t " + fup); + } + } + } + } + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java index 721692a..066f1ec 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/MongoServiceUtil.java @@ -6,19 +6,15 @@ import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPl import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.rmi.RemoteException; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import org.bson.Document; import org.gcube.application.geoportal.client.utils.Serialization; import org.gcube.application.geoportal.common.faults.InvalidRequestException; import org.gcube.application.geoportal.common.model.document.Project; -import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest; import org.gcube.application.geoportal.common.model.rest.TempFile; import org.gcube.application.geoportal.common.rest.MongoConcessioni; @@ -26,8 +22,6 @@ import org.gcube.application.geoportal.common.rest.Projects; import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI; import org.gcube.application.geoportal.common.utils.FileSets; import org.gcube.application.geoportal.common.utils.StorageUtils; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.slf4j.Logger; @@ -141,32 +135,32 @@ public class MongoServiceUtil { return files; } - /** - * To tem files from WSC. - * - * @param listFiles the list files - * @return the list - */ - public List toTemFilesFromWSC(List listFiles) { - LOG.debug("toTemFilesFromWSC called"); - if (listFiles == null || listFiles.isEmpty()) - return null; - - // Building TempFile - List files = new ArrayList(listFiles.size()); - for (WorkspaceContentDV fileUploaded : listFiles) { - InputStream is; - try { - is = new URL(fileUploaded.getLink()).openStream(); - // Creating TempFile - TempFile storageTempFile = createTempFileOnStorage(is, fileUploaded.getName()); - files.add(storageTempFile); - } catch (IOException e) { - LOG.error("Error on creating temp file from URL: " + fileUploaded.getLink(), e); - } - } - return files; - } +// /** +// * To tem files from WSC. +// * +// * @param listFiles the list files +// * @return the list +// */ +// public List toTemFilesFromWSC(List listFiles) { +// LOG.debug("toTemFilesFromWSC called"); +// if (listFiles == null || listFiles.isEmpty()) +// return null; +// +// // Building TempFile +// List files = new ArrayList(listFiles.size()); +// for (WorkspaceContentDV fileUploaded : listFiles) { +// InputStream is; +// try { +// is = new URL(fileUploaded.getLink()).openStream(); +// // Creating TempFile +// TempFile storageTempFile = createTempFileOnStorage(is, fileUploaded.getName()); +// files.add(storageTempFile); +// } catch (IOException e) { +// LOG.error("Error on creating temp file from URL: " + fileUploaded.getLink(), e); +// } +// } +// return files; +// } /** * To JSON. @@ -189,60 +183,4 @@ public class MongoServiceUtil { } } - /** - * The Class ConcessioneValidationReportStatusComparator. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 14, 2021 - */ - public static class ConcessioneValidationReportStatusComparator implements Comparator { - - /** - * Compare. - * - * @param o1 the o 1 - * @param o2 the o 2 - * @return the int - */ - @Override - public int compare(Concessione o1, Concessione o2) { - if (o1 == null || o1.getReport() == null || o1.getReport().getStatus() == null) - return 1; - if (o2 == null || o2.getReport() == null || o2.getReport().getStatus() == null) - return -1; - - return o1.getReport().getStatus().name().compareTo(o2.getReport().getStatus().name()); - } - - } - - /** - * The Class ConcessioneDVValidationReportStatusComparator. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 16, 2021 - */ - public static class ConcessioneDVValidationReportStatusComparator implements Comparator { - - /** - * Compare. - * - * @param o1 the o 1 - * @param o2 the o 2 - * @return the int - */ - @Override - public int compare(ConcessioneDV o1, ConcessioneDV o2) { - if (o1.getValidationStatus() == null) - return 1; - if (o2.getValidationStatus() == null) - return -1; - - return o1.getValidationStatus().name().compareTo(o2.getValidationStatus().name()); - } - - } - }