From fbbc84e6e4e709d564037615ff390dc858980df4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 21 Apr 2023 16:34:11 +0200 Subject: [PATCH] Improved GUI. Fixed some issues on Update facility --- .../client/GeoPortalDataEntryApp.java | 8 ++--- .../client/ui/action/ActionListPanel.java | 2 +- .../client/ui/edit/UpdateRecord.java | 6 ++-- .../server/FormDataObjectToJSON.java | 4 ++- .../server/GeoportalDataEntryServiceImpl.java | 36 ++++++++++--------- 5 files changed, 32 insertions(+), 24 deletions(-) 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 e54cf58..cf8cd40 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 @@ -203,7 +203,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurrend when loading configurations. Please, contact the support"; + String errorMsg = "Sorry, an error occurred when loading configurations. Please, contact the support"; Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { @@ -234,7 +234,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurrend on istancing the application. Please, contact the support"; + String errorMsg = "Sorry, an error occurred on istancing the application. Please, contact the support"; Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { @@ -315,7 +315,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { @Override public void onFailure(Throwable caught) { - String errorMsg = "Sorry, an error occurrend on loading configurations. Please, contact the support"; + String errorMsg = "Sorry, an error occurred on loading configurations. Please, contact the support"; Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); try { @@ -1569,7 +1569,7 @@ public class GeoPortalDataEntryApp implements EntryPoint { // } UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(), - resultDocumentDV.getId(), height); + resultDocumentDV.getId(), width, height); if (isNotInDRAFT) { ur.noUpdateMode(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java index 39ef992..ef62c3b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/action/ActionListPanel.java @@ -79,7 +79,7 @@ public class ActionListPanel extends Composite { Button butt = new Button(); butt.setText(actionDefinitionDV.getTitle()); butt.setTitle(actionDefinitionDV.getDescription()); - butt.setType(ButtonType.LINK); + butt.setType(ButtonType.INFO); butt.addClickHandler(new ClickHandler() { @Override diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java index b9e2e49..dcc68dd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/edit/UpdateRecord.java @@ -89,7 +89,7 @@ public class UpdateRecord extends Composite { private HandlerManager appManagerBus; - public UpdateRecord(HandlerManager appManagerBus, String profileID, String projectID, int modalHeight) { + public UpdateRecord(HandlerManager appManagerBus, String profileID, String projectID, int modalWidth, int modalHeight) { initWidget(uiBinder.createAndBindUi(this)); this.appManagerBus = appManagerBus; this.profileID = profileID; @@ -101,6 +101,8 @@ public class UpdateRecord extends Composite { alertHTMLPanel.add(loaderProjectSections); scrollSectionContent.setHeight((modalHeight-300)+"px"); + + listBoxSections.setWidth((modalWidth-50)+"px"); GeoportalDataEntryServiceAsync.Util.getInstance().getProjectEdit(profileID, projectID, new AsyncCallback() { @@ -259,7 +261,7 @@ public class UpdateRecord extends Composite { modal.setCloseVisible(true); modal.setTitle("Error :-("); panelContainer.clear(); - String errorMsg = "Sorry, an error occurrend when updating the project with id: "+projectID+". Please, try again. If the problem persists, please contact the support"; + String errorMsg = "Sorry, an error occurred when updating the project with id: "+projectID+". Please, try again. If the problem persists, please contact the support"; Alert alert = new Alert(errorMsg, AlertType.ERROR); alert.setClose(false); modal.add(alert); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/FormDataObjectToJSON.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/FormDataObjectToJSON.java index d38362e..dd76577 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/FormDataObjectToJSON.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/server/FormDataObjectToJSON.java @@ -180,7 +180,9 @@ public class FormDataObjectToJSON { // value is a list JSONArray array = new JSONArray(); for (String value : listValues) { - array.put(value); + if(value!=null && !value.isEmpty()) { + array.put(value); + } } sectJSONObject.put(key, array); 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 e525587..abafecb 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 @@ -293,32 +293,36 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Document updatedDocument = Serialization.read(newDocJson.toString(), Document.class); LOG.info("New document is: {}", updatedDocument.toJson()); - //Project project = client.updateProject(profileID, projectID, updatedDocument); - Project project = client.getProjectByID(profileID, projectID); + Project project = client.updateProject(profileID, projectID, updatedDocument); + // Project project = client.getProjectByID(profileID, projectID); LOG.debug("Medatata Updated with document: {}", project.getTheDocument()); SessionUtil.getCurrentContext(getThreadLocalRequest(), true); - if(listFilePaths!=null) { - - //Cleaning all the fileset path of the section (defined in the UCD) - for (FilePathDV filePath: listFilePaths) { - + if (listFilePaths != null) { + + // Cleaning all the fileset path of the section (defined in the UCD) + for (FilePathDV filePath : listFilePaths) { + String filesetFieldName = filePath.getFieldName(); - String filesetPath = sectionPath+"."+filesetFieldName; - //Replacing $.abc with $..abc + String filesetPath = sectionPath + "." + filesetFieldName; + // Replacing $.abc with $..abc filesetPath = filesetPath.replaceFirst("\\.", ".."); LOG.info("Going to delete fileset path: {}", filesetPath); - //client.deleteFileset(profileID, projectID, filesetPath, true); + try { + client.deleteFileset(profileID, projectID, filesetPath, true); + } catch (Exception e) { + LOG.warn("Error on into project id {} the fileset path {} ", projectID, filesetPath); + } } - - //Registering new files + + // Registering new files List filesUploaded = sectionBean.getFilesUploaded(); - if(filesUploaded!=null && !filesUploaded.isEmpty()) { + if (filesUploaded != null && !filesUploaded.isEmpty()) { replaceFiles(project, sectionPath, section.getGcubeProfileDV(), filesUploaded); } } - + LOG.info("Project with id " + project.getId() + " updated correclty"); ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true); ProjectDV toProjectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); @@ -568,8 +572,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen Access access = ConvertToDataServiceModel.getAccessFromDocumentSection(theJSONDocument, sectionJSONPath); LOG.info("Going to registrer files: " + Arrays.asList(fileset).toString()); -// mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath, -// filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); + mongoService.registerFileSet(theProject.getProfileID(), theProject, sectionJSONPath, + filePath.getFieldName(), filePath.getFieldDefinition(), access, fileset); } }