From 731cac1e959733d3d349fe80d06b8de91c8f67a1 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 2 Mar 2022 13:24:58 +0100 Subject: [PATCH 01/15] Moved to 1.1.0-SNAPSHOT. Added getProfilesInTheScopeForName --- .classpath | 6 -- CHANGELOG.md | 12 +++- pom.xml | 2 +- .../MetadataProfileFormBuilderService.java | 12 +++- ...etadataProfileFormBuilderServiceAsync.java | 3 + .../server/MetadataDiscovery.java | 57 +++++++++++++++++++ ...MetadataProfileFormBuilderServiceImpl.java | 36 +++++++++++- 7 files changed, 116 insertions(+), 12 deletions(-) diff --git a/.classpath b/.classpath index bf026c8..9450698 100644 --- a/.classpath +++ b/.classpath @@ -28,11 +28,5 @@ - - - - - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 757f8bd..5ba2ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,17 +4,23 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.1.0-SNAPSHOT] - 2022-03-01 + +#### Enhancement + +- [#22890] Overloaded the method getProfilesInTheScope + ## [v1.0.1-SNAPSHOT] - 2020-10-08 #### Bug fixes -[#20446] Catalogue Publishing Widget: field value unexpectedly added in case of optional field +- [#20446] Catalogue Publishing Widget: field value unexpectedly added in case of optional field ## [v1.0.0] - 2020-10-08 #### First release -[#19884] Create widget to build a data-entry form by using metadata-profile-discovery +- [#19884] Create widget to build a data-entry form by using metadata-profile-discovery -[#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile" \ No newline at end of file +- [#19878] Create a data entry facility to get (meta)data object defined by "gCube Metada Profile" \ No newline at end of file diff --git a/pom.xml b/pom.xml index d1f3e49..0c01f11 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.widgets metadata-profile-form-builder-widget jar - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT Metadata Profile Form Builder The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s" diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderService.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderService.java index ff0e871..57eb5bd 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderService.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderService.java @@ -8,7 +8,6 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; -// TODO: Auto-generated Javadoc /** * The client side stub for the RPC service. * @@ -54,4 +53,15 @@ public interface MetadataProfileFormBuilderService extends RemoteService { * @throws Exception the exception */ Integer purgeFilesUploaded() throws Exception; + + /** + * Gets the profiles in the scope. + * + * @param scope the scope + * @param genericResourceSecondaryType the generic resource secondary type + * @param resourceName the resource name + * @return the profiles in the scope + * @throws Exception the exception + */ + List getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderServiceAsync.java index fc98a96..56c7e93 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderServiceAsync.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/MetadataProfileFormBuilderServiceAsync.java @@ -42,4 +42,7 @@ public interface MetadataProfileFormBuilderServiceAsync { void getUploadStatus(String clientUploadKey, AsyncCallback asyncCallback); void purgeFilesUploaded(AsyncCallback callback); + + void getProfilesInTheScopeForName(String scope, String genericResourceSecondaryType, String resourceName, + AsyncCallback> callback); } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java index 53968d3..c12b761 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java @@ -75,6 +75,63 @@ public class MetadataDiscovery { } + /** + * Gets the metadata profiles list. + * + * @param scope the scope + * @param gRSecondaryType the g R secondary type + * @param resourceName the resource name + * @return the metadata profiles list + * @throws Exception the exception + */ + public static List getMetadataProfilesList(String scope, String gRSecondaryType, String resourceName) + throws Exception { + + List beans = new ArrayList(); + + LOG.debug("Discovering into scope " + scope); + + String currentContext = ScopeProvider.instance.get(); + try { + + ScopeProvider.instance.set(scope); + + // TODO two reset methods could be added to force the reader to read again these + // information (after a while) + MetadataProfileReader reader = new MetadataProfileReader(gRSecondaryType, resourceName); + + List profiles = reader.getListOfMetadataProfiles(); + prettyPrintProfiles(profiles); + LOG.info("Profiles are " + profiles.size()); + + List categories = reader.getListOfNamespaceCategories(); + if (categories == null) + categories = new ArrayList(); + + LOG.debug("All Categories are " + categories); + + for (MetadataProfile profile : profiles) { + LOG.debug("Wrapping profile with name " + profile.getName() + " and type " + profile.getMetadataType()); + MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile); + MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName()); + beans.add(bean); + } + + prettyPrintList(beans); + LOG.info("Returning " + beans.size() + " profile/s"); + + } catch (Exception e) { + LOG.error("Error while retrieving metadata beans ", e); + throw new Exception("Failed to parse Types: " + e.getMessage()); + } finally { + ScopeProvider.instance.set(currentContext); + } + + return beans; + } + + + /** * Gets the metadata profiles list. * diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderServiceImpl.java index 45ff593..c44a657 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderServiceImpl.java @@ -66,6 +66,40 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet return toReturn; } + + /** + * Gets the profiles in the scope. + * + * @param scope the scope + * @param genericResourceSecondaryType the generic resource secondary type + * @param resourceName the resource name + * @return the profiles in the scope + * @throws Exception the exception + */ + @Override + public List getProfilesInTheScopeForName(String scope,String genericResourceSecondaryType, String resourceName) throws Exception { + LOG.info("Called getProfilesInTheScope with parameter scope: " +scope+ ", genericResourceSecondaryType: "+genericResourceSecondaryType, "resourceName: "+resourceName); + + if(genericResourceSecondaryType==null || genericResourceSecondaryType.isEmpty()) + throw new Exception("The input parameter 'genericResourceSecondaryType' is not valid"); + + if(resourceName==null || resourceName.isEmpty()) + throw new Exception("The input parameter 'resourceName' is not valid"); + + List toReturn = new ArrayList(); + try { + + String evaluatedScope = scope == null || scope.isEmpty()?ScopeProvider.instance.get():scope; + LOG.debug("Evaluated scope is " + scope); + toReturn = MetadataDiscovery.getMetadataProfilesList(evaluatedScope, genericResourceSecondaryType, resourceName); + } catch (Exception e) { + LOG.error("Failed to retrieve profiles for scope " +scope, e); + throw e; + } + + return toReturn; + } + /** * Gets the profile for metadata. * @@ -132,7 +166,7 @@ public class MetadataProfileFormBuilderServiceImpl extends RemoteServiceServlet /** - * Purge files uploaded in the current session + * Purge files uploaded in the current session. * * @return number of files deleted. Null otherwise. * @throws Exception the exception From f83312dbf336cd478cd68e294b4feb296b24cb7a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 3 Mar 2022 18:42:59 +0100 Subject: [PATCH 02/15] in progress on update --- ....eclipse.wst.common.project.facet.core.xml | 1 + CHANGELOG.md | 5 +- pom.xml | 2 +- .../client/form/MetaDataField.java | 10 +- .../form/generic/CreateMetadataForm.java | 18 +- .../ui/metadata/MetaDataFieldSkeleton.java | 158 ++++++++++++++---- .../server/MetadataDiscovery.java | 30 ++++ .../shared/metadata/MetaDataProfileBean.java | 65 ++++++- .../shared/metadata/MetadataFieldWrapper.java | 84 ++++++---- .../shared/metadata/UpdatableField.java | 8 + 10 files changed, 299 insertions(+), 82 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/UpdatableField.java diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 2ad8c36..5f50479 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -5,4 +5,5 @@ + diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ba2ea3..d020b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v1.1.0-SNAPSHOT] - 2022-03-01 +## [v2.0.0-SNAPSHOT] - 2022-03-01 #### Enhancement -- [#22890] Overloaded the method getProfilesInTheScope +- [#22890] Overloaded the method getProfilesInTheScope(forName) +- [#22890] Including the set/get currentValue for Update facility ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/pom.xml b/pom.xml index 0c01f11..74b1066 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.widgets metadata-profile-form-builder-widget jar - 1.1.0-SNAPSHOT + 2.0.0-SNAPSHOT Metadata Profile Form Builder The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s" diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/MetaDataField.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/MetaDataField.java index 5076a76..1d0b7f5 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/MetaDataField.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/MetaDataField.java @@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.mpformbuilder.client.form; import java.util.ArrayList; import java.util.List; +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.shared.metadata.MetadataFieldWrapper; @@ -34,8 +35,6 @@ public class MetaDataField extends Composite { @UiField VerticalPanel panelMetaDataFieldsSkeleton; @UiField Label repeatabilityLabel; - - //@UiField ControlGroup cgMetaDataFieldSkeletonFields; @UiField Button addFieldButton; @@ -47,6 +46,8 @@ public class MetaDataField extends Composite { private HandlerManager eventBus; + private OPERATION operation; + /** * The Interface MetaDataFieldUiBinder. * @@ -65,10 +66,11 @@ public class MetaDataField extends Composite { * @param eventBus the event bus * @throws Exception the exception */ - public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception { + public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation) throws Exception { initWidget(uiBinder.createAndBindUi(this)); this.fieldWrapper = field; this.eventBus = eventBus; + this.operation = operation; addNewOccurrenceOfField(); checkAllowedAddField(); checkAllowedRemoveField(); @@ -143,7 +145,7 @@ public class MetaDataField extends Composite { */ private void addNewOccurrenceOfField() { try { - MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus); + MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus, operation); listOfMetadataFields.add(fieldWidget); panelMetaDataFieldsSkeleton.add(fieldWidget); } catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java index bd2c262..c628922 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java @@ -61,7 +61,7 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; -// TODO: Auto-generated Javadoc + /** * Create metadata form for ckan product. * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) @@ -238,6 +238,10 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe /** The form data bean. */ private GenericDatasetBean formDataBean; + private OPERATION operationPerfom; + + public enum OPERATION {NEW, UPDATE} + /** * Invoked in the most general case. * @@ -271,8 +275,9 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe * * @param profiles the profiles */ - public CreateMetadataForm(List profiles, HandlerManager eventBus) { + public CreateMetadataForm(List profiles, HandlerManager eventBus, OPERATION operation) { this(eventBus); + this.operationPerfom = operation; showLoadingProfiles(true); createDatasetFormBody(profiles); showLoadingProfiles(false); @@ -302,7 +307,8 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe showChooseProfileForm(false); showCustomFieldsEntries(false); } - + + /** * Show loading profiles. * @@ -464,7 +470,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe MetaDataField fieldWidget; try { - fieldWidget = new MetaDataField(field, uiBus); + fieldWidget = new MetaDataField(field, uiBus, operationPerfom); metadataFieldsPanel.add(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch (Exception e) { @@ -493,7 +499,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe MetaDataField fieldWidget; try { - fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus); + fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus,operationPerfom); cp.addField(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch (Exception e) { @@ -519,7 +525,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe MetaDataField fieldWidget; try { - fieldWidget = new MetaDataField(field, uiBus); + fieldWidget = new MetaDataField(field, uiBus, operationPerfom); extrasCategory.addField(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 8bd7a59..4a512df 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -5,6 +5,7 @@ import java.util.List; import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormEvent; import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormEventHandler; +import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION; import org.gcube.portlets.widgets.mpformbuilder.client.openlayerwidget.GeoJsonAreaSelectionDialog; import org.gcube.portlets.widgets.mpformbuilder.client.ui.timeandranges.DataTimeBox; import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload; @@ -118,10 +119,11 @@ public class MetaDataFieldSkeleton extends Composite { // time range separator public static final String RANGE_SEPARATOR = ","; private static final String TOOLTIP_MULTISELECTION = "Hold down the Control (CTRL) or Command (CMD) button to select multiple options"; - + private static final String UPLOAD_MISSING_FILE = "You must upload a file"; - public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception { + public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation) + throws Exception { initWidget(uiBinder.createAndBindUi(this)); // prepare information @@ -133,6 +135,9 @@ public class MetaDataFieldSkeleton extends Composite { // bind bind(); + if (operation == null) + operation = OPERATION.NEW; + switch (field.getType()) { case Boolean: @@ -141,6 +146,16 @@ public class MetaDataFieldSkeleton extends Composite { holder = new CheckBox(); if (field.getDefaultValue() != null) ((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue())); + + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + ((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue())); + } catch (Exception e) { + // TODO: handle exception + } + } + break; case GeoJSON: @@ -154,6 +169,15 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) textArea.setText(field.getDefaultValue()); + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + textArea.setText((String) field.getCurrentValue()); + } catch (Exception e) { + // TODO: handle exception + } + } + containerGeoJSON.add(textArea); HorizontalPanel hp = new HorizontalPanel(); @@ -216,6 +240,16 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) ((TextArea) holder).setText(field.getDefaultValue()); + + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + ((TextArea) holder).setText((String) field.getCurrentValue()); + } catch (Exception e) { + // TODO: handle exception + } + } + break; case Time: @@ -230,6 +264,22 @@ public class MetaDataFieldSkeleton extends Composite { ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null); } } + + if (operation.equals(OPERATION.UPDATE)) { + // set time, if present + try { + if (field.getCurrentValue() != null) { + String currentValue = (String) field.getCurrentValue(); + String[] dateAndTime = currentValue.split(" "); + if (dateAndTime.length > 0) { + ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null); + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + break; case Time_Interval: @@ -237,6 +287,15 @@ public class MetaDataFieldSkeleton extends Composite { DataTimeBox rangeBox; holder = rangeBox = new DataTimeBox(true); setRangeTimeInTimeBox(field.getDefaultValue(), rangeBox); + if (operation.equals(OPERATION.UPDATE)) { + // set time, if present + try { + setRangeTimeInTimeBox((String) field.getCurrentValue(), rangeBox); + } catch (Exception e) { + // TODO: handle exception + } + } + rangesList.add(rangeBox); break; @@ -251,6 +310,15 @@ public class MetaDataFieldSkeleton extends Composite { SimplePanel panelFirstRange = new SimplePanel(); DataTimeBox rangeBoxFirst = new DataTimeBox(true); setRangeTimeInTimeBox(field.getDefaultValue(), rangeBoxFirst); + + if (operation.equals(OPERATION.UPDATE)) { + try { + setRangeTimeInTimeBox((String) field.getCurrentValue(), rangeBoxFirst); + } catch (Exception e) { + // TODO: handle exception + } + } + panelFirstRange.add(rangeBoxFirst); rangesList.add(rangeBoxFirst); @@ -303,8 +371,17 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) ((TextBox) holder).setText(field.getDefaultValue()); + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + ((TextBox) holder).setText((String) field.getCurrentValue()); + } catch (Exception e) { + // TODO: handle exception + } + } + break; - + case File: holder = new MultipleDilaogUpload(); @@ -322,6 +399,15 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) ((TextBox) holder).setText(field.getDefaultValue()); + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + ((TextBox) holder).setText((String) field.getCurrentValue()); + } catch (Exception e) { + // TODO: handle exception + } + } + } else { // listbox @@ -331,11 +417,13 @@ public class MetaDataFieldSkeleton extends Composite { if (field.isMultiSelection()) tempListBox.setTitle(TOOLTIP_MULTISELECTION); - // if it is not mandatory and not multi-selection, add a disabled option (placeholder) - if(!field.getMandatory() && !field.isMultiSelection()){ + // if it is not mandatory and not multi-selection, add a disabled option + // (placeholder) + if (!field.getMandatory() && !field.isMultiSelection()) { tempListBox.addItem("Select " + field.getFieldName()); tempListBox.setValue(0, ""); - tempListBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled"); + tempListBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", + "disabled"); tempListBox.setSelectedValue("Select " + field.getFieldName()); } @@ -350,6 +438,15 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) tempListBox.setSelectedValue(field.getDefaultValue()); + if (operation.equals(OPERATION.UPDATE)) { + try { + if (field.getCurrentValue() != null) + tempListBox.setSelectedValue((String) field.getCurrentValue()); + } catch (Exception e) { + // TODO: handle exception + } + } + } break; @@ -358,24 +455,22 @@ public class MetaDataFieldSkeleton extends Composite { return; } - + try { ChangeHandler handler = new ChangeHandler() { - + @Override public void onChange(ChangeEvent event) { GWT.log("Fired is field value"); removeError(); isFieldValueValid(); - + } }; holder.addDomHandler(handler, ChangeEvent.getType()); - }catch (Exception e) { + } catch (Exception e) { // TODO: handle exception } - - // add custom css properties controls.addStyleName("form-controls-custom"); @@ -421,8 +516,7 @@ public class MetaDataFieldSkeleton extends Composite { }); } - - + /** * Gets the holder. * @@ -631,22 +725,24 @@ public class MetaDataFieldSkeleton extends Composite { } return null; - + case File: - + GWT.log("Checking is valid File"); if (field.getMandatory()) { - if (holder.getClass().equals(DialogUpload.class) || holder.getClass().equals(MultipleDilaogUpload.class)) { + if (holder.getClass().equals(DialogUpload.class) + || holder.getClass().equals(MultipleDilaogUpload.class)) { DialogUpload dUpload = (DialogUpload) holder; - if(dUpload.getFileUploadingState()!=null && dUpload.getFileUploadingState().getFile()!=null) { - return dUpload.getFileUploadingState().getFile().getTempSystemPath()!=null?null:UPLOAD_MISSING_FILE; + if (dUpload.getFileUploadingState() != null && dUpload.getFileUploadingState().getFile() != null) { + return dUpload.getFileUploadingState().getFile().getTempSystemPath() != null ? null + : UPLOAD_MISSING_FILE; } } return UPLOAD_MISSING_FILE; - + } return null; - + default: return null; @@ -772,14 +868,14 @@ public class MetaDataFieldSkeleton extends Composite { } // if it was not mandatory but there was no choice, returning empty string - if(!field.getMandatory()) { - //Task #20446 - bug fix. Ignoring the placeholder - if(toReturn.size()==1) { + if (!field.getMandatory()) { + // Task #20446 - bug fix. Ignoring the placeholder + if (toReturn.size() == 1) { String placeholder = "Select " + field.getFieldName(); - if(toReturn.get(0).equals(placeholder)){ - GWT.log("Skipping placeholder: "+placeholder); + if (toReturn.get(0).equals(placeholder)) { + GWT.log("Skipping placeholder: " + placeholder); toReturn.clear(); - //toReturn.add(""); + // toReturn.add(""); } } } @@ -787,16 +883,16 @@ public class MetaDataFieldSkeleton extends Composite { break; case File: - + if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) { DialogUpload dUpload = (DialogUpload) holder; - if(dUpload.getFileUploadingState()!=null) { + if (dUpload.getFileUploadingState() != null) { String filePath = dUpload.getFileUploadingState().getFile().getTempSystemPath(); toReturn.add(filePath); - }else + } else toReturn.add(null); } - + break; default: diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java index c12b761..47484a7 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Random; +import java.util.UUID; import javax.xml.bind.JAXBException; @@ -19,6 +21,7 @@ import org.gcube.common.metadataprofilediscovery.jaxb.MetadataValidator; import org.gcube.common.metadataprofilediscovery.jaxb.MetadataVocabulary; import org.gcube.common.metadataprofilediscovery.jaxb.NamespaceCategory; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.widgets.mpformbuilder.server.util.WsUtil; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsGroup; @@ -115,6 +118,11 @@ public class MetadataDiscovery { MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile); MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName()); beans.add(bean); + + if(!WsUtil.isWithinPortal()) { + LOG.info("DEV MODE ENABLED - Out of portal!"); + randomizeCurrentValues(bean.getMetadataFields()); + } } prettyPrintList(beans); @@ -130,6 +138,28 @@ public class MetadataDiscovery { return beans; } + private static void randomizeCurrentValues(List listFields) { + LOG.info("DEV MODE ENABLED - Generationg random current value"); + for (MetadataFieldWrapper metadataFieldWrapper : listFields) { + DataTypeWrapper dtw = metadataFieldWrapper.getType(); + + switch (dtw) { + case Boolean: + metadataFieldWrapper.setCurrentValue(Boolean.FALSE.toString()); + break; + case Number: + metadataFieldWrapper.setCurrentValue(new Random().nextInt()+""); + break; + case String: + case Text: + metadataFieldWrapper.setCurrentValue("Text "+UUID.randomUUID()); + break; + default: + break; + } + } + } + /** diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetaDataProfileBean.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetaDataProfileBean.java index bec1e35..1d3e2e0 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetaDataProfileBean.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetaDataProfileBean.java @@ -3,22 +3,40 @@ package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; import java.io.Serializable; import java.util.List; + /** - * A MetaDataProfileBean with its children (MetaDataType, MetaDataFields, Categories) - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + * The Class MetaDataProfileBean. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 3, 2022 */ public class MetaDataProfileBean implements Serializable{ - private static final long serialVersionUID = -7377022025375553568L; - + /** + * + */ + private static final long serialVersionUID = -8307518917648131477L; private String type; private String title; private List categories; private List metadataFields; + /** + * Instantiates a new meta data profile bean. + */ public MetaDataProfileBean(){ super(); } + + /** + * Instantiates a new meta data profile bean. + * + * @param type the type + * @param title the title + * @param metadataFields the metadata fields + * @param categories the categories + */ public MetaDataProfileBean(String type, String title, List metadataFields, @@ -31,43 +49,82 @@ public class MetaDataProfileBean implements Serializable{ } /** + * Gets the type. + * * @return the type */ public String getType() { return type; } + /** + * Sets the type. + * * @param type the type to set */ public void setType(String type) { this.type = type; } + /** + * Gets the metadata fields. + * * @return the metadataFields */ public List getMetadataFields() { return metadataFields; } + /** + * Sets the metadata fields. + * * @param metadataFields the metadataFields to set */ public void setMetadataFields(List metadataFields) { this.metadataFields = metadataFields; } + /** + * Gets the categories. + * + * @return the categories + */ public List getCategories() { return categories; } + /** + * Sets the categories. + * + * @param categories the new categories + */ public void setCategories(List categories) { this.categories = categories; } + + /** + * Gets the title. + * + * @return the title + */ public String getTitle() { return title; } + + /** + * Sets the title. + * + * @param title the new title + */ public void setTitle(String title) { this.title = title; } + + /** + * To string. + * + * @return the string + */ @Override public String toString() { final int maxLen = 10; diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java index dd2291f..1094a4b 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java @@ -1,16 +1,16 @@ package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; - import java.io.Serializable; import java.util.List; /** * The Class MetadataFieldWrapper. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * @author francesco-mangiacrapa at ISTI-CNR (costantino.perciante@isti.cnr.it) + * Mar 3, 2022 */ -public class MetadataFieldWrapper implements Serializable{ +public class MetadataFieldWrapper implements UpdatableField, Serializable { private static final long serialVersionUID = -8476731365884466698L; private String fieldName; @@ -25,9 +25,11 @@ public class MetadataFieldWrapper implements Serializable{ private CategoryWrapper ownerCategory; private FieldAsGroup asGroup; private FieldAsTag asTag; - + private Integer maxOccurs = 1; + private String currentValue; + /** * Instantiates a new metadata field. */ @@ -38,19 +40,17 @@ public class MetadataFieldWrapper implements Serializable{ /** * Instantiates a new metadata field. * - * @param fieldName the field name - * @param mandatory the mandatory - * @param type the type + * @param fieldName the field name + * @param mandatory the mandatory + * @param type the type * @param defaultValue the default value - * @param note the note - * @param vocabulary the vocabulary - * @param validator the validator - * @param category the category + * @param note the note + * @param vocabulary the vocabulary + * @param validator the validator + * @param category the category */ - public MetadataFieldWrapper( - String fieldName, Boolean mandatory, DataTypeWrapper type, - String defaultValue, String note, List vocabulary, - String validator, CategoryWrapper category) { + public MetadataFieldWrapper(String fieldName, Boolean mandatory, DataTypeWrapper type, String defaultValue, + String note, List vocabulary, String validator, CategoryWrapper category) { super(); this.fieldName = fieldName; this.mandatory = mandatory; @@ -61,8 +61,6 @@ public class MetadataFieldWrapper implements Serializable{ this.validator = validator; this.ownerCategory = category; } - - /** * Gets the max occurs. @@ -310,30 +308,48 @@ public class MetadataFieldWrapper implements Serializable{ this.asTag = asTag; } - /* (non-Javadoc) + /** + * Sets the current value. + * + * @param value the new current value + */ + public void setCurrentValue(String value) { + this.currentValue = value; + + } + + /** + * Gets the current value. + * + * @return the current value + */ + public String getCurrentValue() { + return currentValue; + } + + /** + * To string. + * + * @return the string + */ + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "MetadataFieldWrapper [" - + (fieldName != null ? "fieldName=" + fieldName + ", " : "") - + (fieldNameFromCategory != null ? "fieldNameFromCategory=" - + fieldNameFromCategory + ", " : "") + return "MetadataFieldWrapper [" + (fieldName != null ? "fieldName=" + fieldName + ", " : "") + + (fieldNameFromCategory != null ? "fieldNameFromCategory=" + fieldNameFromCategory + ", " : "") + (mandatory != null ? "mandatory=" + mandatory + ", " : "") + (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "") + (type != null ? "type=" + type + ", " : "") - + (defaultValue != null ? "defaultValue=" + defaultValue + ", " - : "") + + (defaultValue != null ? "defaultValue=" + defaultValue + ", " : "") + (note != null ? "note=" + note + ", " : "") - + (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "") - + "multiSelection=" - + multiSelection - + ", " - + (validator != null ? "validator=" + validator + ", " : "") - + (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId() - + ", " : "") - + (asGroup != null ? "asGroup=" + asGroup + ", " : "") - + (asTag != null ? "asTag=" + asTag : "") + "]"; + + (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "") + "multiSelection=" + multiSelection + + ", " + (validator != null ? "validator=" + validator + ", " : "") + + (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId() + ", " : "") + + (asGroup != null ? "asGroup=" + asGroup + ", " : "") + (asTag != null ? "asTag=" + asTag : "") + "]"; } } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/UpdatableField.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/UpdatableField.java new file mode 100644 index 0000000..e8c67c7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/UpdatableField.java @@ -0,0 +1,8 @@ +package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; + +public interface UpdatableField { + + void setCurrentValue(String value); + + String getCurrentValue(); +} From 70b4d02a5d267e648b203a7b0f985ce3d45a0a79 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 7 Mar 2022 16:42:24 +0100 Subject: [PATCH 03/15] Moved to LinkedHashMap --- .../client/form/generic/CreateMetadataForm.java | 3 ++- .../widgets/mpformbuilder/shared/GenericDatasetBean.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java index c628922..c0c045d 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/generic/CreateMetadataForm.java @@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.mpformbuilder.client.form.generic; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -573,7 +574,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe //Set tags = new HashSet(tagsPanel.getTags()); List groups = new ArrayList(); List groupsToForceCreation = new ArrayList(); - Map> customFieldsMap = new HashMap>(); + LinkedHashMap> customFieldsMap = new LinkedHashMap>(); List listFilesUploaded = new ArrayList(); // prepare custom fields diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java index 7783e47..a2c316f 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java @@ -1,6 +1,7 @@ package org.gcube.portlets.widgets.mpformbuilder.shared; import java.io.Serializable; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -25,7 +26,7 @@ public class GenericDatasetBean implements Serializable { private List metadataProfileList; /** The form data entry fields. */ - private Map> formDataEntryFields; + private LinkedHashMap> formDataEntryFields; /** The files uploaded. */ private List filesUploaded; @@ -44,7 +45,7 @@ public class GenericDatasetBean implements Serializable { * @param formDataEntryFields the form data entry fields * @param filesUploaded the files uploaded */ - public GenericDatasetBean(List metadataProfileList, Map> formDataEntryFields, + public GenericDatasetBean(List metadataProfileList, LinkedHashMap> formDataEntryFields, List filesUploaded) { super(); this.metadataProfileList = metadataProfileList; @@ -88,7 +89,7 @@ public class GenericDatasetBean implements Serializable { * * @param formDataEntryFields the form data entry fields */ - public void setFormDataEntryFields(Map> formDataEntryFields) { + public void setFormDataEntryFields(LinkedHashMap> formDataEntryFields) { this.formDataEntryFields = formDataEntryFields; } From 0887144f9cc47defa46b5652e6851335a1dff0d7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 7 Mar 2022 16:46:41 +0100 Subject: [PATCH 04/15] passed to LinkedHashMap --- .../widgets/mpformbuilder/shared/GenericDatasetBean.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java index a2c316f..b3ed0c6 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java @@ -79,7 +79,7 @@ public class GenericDatasetBean implements Serializable { * * @return the form data entry fields */ - public Map> getFormDataEntryFields() { + public LinkedHashMap> getFormDataEntryFields() { return formDataEntryFields; } From 1b79e7bf74e19a03d6db2dd6cf5229426847c92c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 21 Mar 2022 16:31:43 +0100 Subject: [PATCH 05/15] Added the parameter "FIELD_NAME" (as hidden parameter) in the form uploader --- ...se.wst.common.project.facet.core.prefs.xml | 7 + .../client/ConstantsMPFormBuilder.java | 1 + .../ui/metadata/MetaDataFieldSkeleton.java | 2 +- .../client/ui/upload/DialogUpload.java | 201 ++++---- .../client/ui/upload/FileUpload.java | 4 +- .../ui/upload/MultipleDilaogUpload.java | 9 +- ...tadataProfileFormBuilderUploadServlet.java | 481 ++++++++++-------- .../shared/GenericDatasetBean.java | 1 - .../shared/metadata/MetadataFieldWrapper.java | 8 +- .../mpformbuilder/shared/upload/FilePath.java | 67 +++ .../shared/upload/FileUploaded.java | 63 ++- 11 files changed, 497 insertions(+), 347 deletions(-) create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.prefs.xml create mode 100644 src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FilePath.java diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..cc81385 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java index ee6685b..c51f849 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java @@ -10,6 +10,7 @@ public class ConstantsMPFormBuilder { //public static final String CURR_USER_ID = "currUserId"; public static final String IS_OVERWRITE = "isOverwrite"; public static final String UPLOAD_TYPE = "uploadType"; + public static final String FIELD_NAME = "fieldName"; public static enum THE_UPLOAD_TYPE {File, Archive}; public static final String ID_FOLDER = "idFolder"; public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement"; diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 4a512df..1a8a42f 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -384,7 +384,7 @@ public class MetaDataFieldSkeleton extends Composite { case File: - holder = new MultipleDilaogUpload(); + holder = new MultipleDilaogUpload(field.getFieldName()); break; diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java index 39ba43b..8bd7c97 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java @@ -1,6 +1,5 @@ package org.gcube.portlets.widgets.mpformbuilder.client.ui.upload; - import java.util.ArrayList; import java.util.List; @@ -25,58 +24,56 @@ import com.google.gwt.user.client.ui.Hidden; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.VerticalPanel; - // TODO: Auto-generated Javadoc /** * The Class DialogUploadStream. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Sep 24, 2015 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 24, 2015 */ -public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotificationListener{ +public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotificationListener { /** The file upload. */ - //protected final FormPanel formPanel = new FormPanel(); + // protected final FormPanel formPanel = new FormPanel(); protected FileUpload fileUpload; - + /** The json client keys. */ protected Hidden jsonClientKeys; - + /** The fake uploaders. */ protected List fakeUploaders = new ArrayList(); - + /** The controller. */ protected WorkspaceUploaderListenerController controller = new WorkspaceUploaderListenerController(); - + /** The timer. */ protected TimerUpload timer; + private String fieldName; + /** * The Enum UPLOAD_TYPE. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Sep 11, 2015 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 11, 2015 */ private HTML UPLOADING = new HTML("Uploading..."); - + /** The vertical main panel. */ protected VerticalPanel verticalMainPanel; // private MonitorPanel monitorPanel; - //protected String clientUploadKey; - + // protected String clientUploadKey; + /** The purged uploading file name. */ private String purgedUploadingFileName; - + /** The upv. */ private UploaderProgressView upv; /** * Instantiates a new dialog upload stream. */ - public DialogUpload(){ - //setWidth("400px"); + public DialogUpload() { fileUpload = new FileUpload(); - //fileUpload.getElement().setAttribute("multiple", "multiple"); + // fileUpload.getElement().setAttribute("multiple", "multiple"); setAction(ConstantsMPFormBuilder.METADATA_FORM_BUILDER_UPLOADING_SERVLET); setEncoding(FormPanel.ENCODING_MULTIPART); setMethod(FormPanel.METHOD_POST); @@ -89,8 +86,12 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific fileUpload.setName(ConstantsMPFormBuilder.UPLOAD_FORM_ELEMENT); // Add hidden parameters - verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId())); - verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.UPLOAD_TYPE, ConstantsMPFormBuilder.THE_UPLOAD_TYPE.File.name())); + verticalMainPanel + .add(new Hidden(ConstantsMPFormBuilder.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId())); + verticalMainPanel.add( + new Hidden(ConstantsMPFormBuilder.UPLOAD_TYPE, ConstantsMPFormBuilder.THE_UPLOAD_TYPE.File.name())); + + verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.FIELD_NAME, fieldName)); initJsonClientKeys(); verticalMainPanel.add(jsonClientKeys); @@ -105,6 +106,24 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific verticalMainPanel.add(hp); } + /** + * Sets the field name. + * + * @param fieldName the new field name + */ + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + /** + * Gets the field name. + * + * @return the field name + */ + public String getFieldName() { + return fieldName; + } + /** * Gets the panel. * @@ -117,14 +136,14 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific /** * Inits the json client keys. */ - protected void initJsonClientKeys(){ - jsonClientKeys = new Hidden(ConstantsMPFormBuilder.CLIENT_UPLOAD_KEYS,""); + protected void initJsonClientKeys() { + jsonClientKeys = new Hidden(ConstantsMPFormBuilder.CLIENT_UPLOAD_KEYS, ""); } /** * Bind events. */ - public void bindEvents(){ + public void bindEvents() { this.addHandlers(); // this.addListeners(); } @@ -143,10 +162,11 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific // isStatusCompleted = true; String result = event.getResults(); - if (result == null) { + if (result == null) { removeLoading(); Window.alert("An error occurred during file upload"); - //new DialogResult(null, "Error during upload", "An error occurred during file upload.").center(); + // new DialogResult(null, "Error during upload", "An error occurred during file + // upload.").center(); return; } String strippedResult = new HTML(result).getText(); @@ -155,25 +175,25 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific switch (resultMessage.getStatus()) { case ERROR: removeLoading(); - //timer.cancel(); - GWT.log("Error during upload "+resultMessage.getMessage()); + // timer.cancel(); + GWT.log("Error during upload " + resultMessage.getMessage()); break; case UNKNOWN: removeLoading(); - //timer.cancel(); - GWT.log("Error during upload "+resultMessage.getMessage()); + // timer.cancel(); + GWT.log("Error during upload " + resultMessage.getMessage()); break; case WARN: { - GWT.log("Upload completed with warnings "+resultMessage.getMessage()); + GWT.log("Upload completed with warnings " + resultMessage.getMessage()); removeLoading(); - //timer.cancel(); + // timer.cancel(); break; } - case SESSION_EXPIRED:{ - GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage()); + case SESSION_EXPIRED: { + GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage()); Window.alert("Session expired, please reload the page"); removeLoading(); - //timer.cancel(); + // timer.cancel(); break; } case OK: { @@ -193,7 +213,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific } }); - //TODO NEVER USED, WE ARE USING MULTIPLE DIALOG UPLOAD + // TODO NEVER USED, WE ARE USING MULTIPLE DIALOG UPLOAD addSubmitHandler(new SubmitHandler() { @Override @@ -209,41 +229,45 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific public void onChange(ChangeEvent event) { GWT.log("btnSubmit click"); - if (fileUpload.getFilename()==null || !(fileUpload.getFilename().length()>2)) { + if (fileUpload.getFilename() == null || !(fileUpload.getFilename().length() > 2)) { GWT.log("No file specified "); return; } - GWT.log("fileUpload.getFilename() "+fileUpload.getFilename()); + GWT.log("fileUpload.getFilename() " + fileUpload.getFilename()); /* - * TODO: recall: Some browser would write in fileUploadField.getValue() C:\fakepath\$fileName + * TODO: recall: Some browser would write in fileUploadField.getValue() + * C:\fakepath\$fileName */ String normalizedFileName = fileUpload.getFilename(); if (normalizedFileName.contains("\\")) { - normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\")+1); //remove C:\fakepath\ if exists + normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove + // C:\fakepath\ + // if + // exists } - + purgedUploadingFileName = normalizedFileName; submitForm(); } }); } - + /** * On submit action. */ protected void onSubmitAction() { GWT.log("SubmitEvent"); try { - if(upv!=null) + if (upv != null) verticalMainPanel.remove(upv.getPanel()); - }catch (Exception e) { + } catch (Exception e) { // TODO: handle exception } addLoading(); enableButtons(false); - //Only the first, just to manage single uploading - FileUploadingState workspaceUploaderItem = fakeUploaders.get(0); + // Only the first, just to manage single uploading + FileUploadingState workspaceUploaderItem = fakeUploaders.get(0); upv = new UploaderProgressView(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName(), null); verticalMainPanel.add(upv.getPanel()); removeLoading(); @@ -252,33 +276,32 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific fakeUploaders.clear(); } - /** * Gets the file uploading state. * * @return the file uploading state */ public FileUploadingState getFileUploadingState() { - if(timer!=null) + if (timer != null) return timer.getLastWorkspaceUploader(); - + return null; } /** * Adds the loading. */ - protected void addLoading(){ + protected void addLoading() { verticalMainPanel.add(UPLOADING); } /** * Removes the loading. */ - protected void removeLoading(){ - try{ + protected void removeLoading() { + try { verticalMainPanel.remove(UPLOADING); - }catch(Exception e){ + } catch (Exception e) { } } @@ -288,7 +311,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific * * @param bool the bool */ - protected void enableButtons(boolean bool){ + protected void enableButtons(boolean bool) { // btnUpload.setEnabled(bool); // btnCancel.setEnabled(bool); // upload.setEnabled(bool); @@ -297,37 +320,33 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific /** * Submit form. */ - public void submitForm(){ + public void submitForm() { submit(); } - /** * Removes the item and submit form. * * @param itemId the item id */ - protected void removeItemAndSubmitForm(String itemId){ + protected void removeItemAndSubmitForm(String itemId) { /* - AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - Info.display("Error", caught.getMessage()); - - - } - - @Override - public void onSuccess(Boolean result) { - if(result){ - hiddenOverwrite.setValue("true"); - submitForm(); - } - - } - - });*/ + * AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new + * AsyncCallback() { + * + * @Override public void onFailure(Throwable caught) { Info.display("Error", + * caught.getMessage()); + * + * + * } + * + * @Override public void onSuccess(Boolean result) { if(result){ + * hiddenOverwrite.setValue("true"); submitForm(); } + * + * } + * + * }); + */ } /** @@ -335,8 +354,8 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific * * @param itemId the item id */ - protected void updateItemSubmitForm(String itemId){ - //hiddenOverwrite.setValue("true"); + protected void updateItemSubmitForm(String itemId) { + // hiddenOverwrite.setValue("true"); submitForm(); } @@ -345,8 +364,14 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific * * @param handler the handler */ - /* (non-Javadoc) - * @see org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#addWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.widgets.workspaceuploader.client. + * WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener# + * addWorkspaceUploadNotificationListener(org.gcube.portlets.widgets. + * workspaceuploader.client.WorkspaceUploadNotification. + * WorskpaceUploadNotificationListener) */ @Override public void addWorkspaceUploadNotificationListener(WorskpaceUploadNotificationListener handler) { @@ -358,22 +383,26 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific * * @param handler the handler */ - /* (non-Javadoc) - * @see org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener#removeWorkspaceUploadNotificationListener(org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.widgets.workspaceuploader.client. + * WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener# + * removeWorkspaceUploadNotificationListener(org.gcube.portlets.widgets. + * workspaceuploader.client.WorkspaceUploadNotification. + * WorskpaceUploadNotificationListener) */ @Override public void removeWorkspaceUploadNotificationListener(WorskpaceUploadNotificationListener handler) { controller.removeWorkspaceUploadListener(handler); } - - + /** * Enable upload. * * @param bool the bool */ - public void enableUpload(boolean bool){ + public void enableUpload(boolean bool) { fileUpload.setEnabled(bool); } } - diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/FileUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/FileUpload.java index a4ef1f0..b823537 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/FileUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/FileUpload.java @@ -16,9 +16,9 @@ public class FileUpload extends Composite { @UiField HTMLPanel fileUploadPanel; - public FileUpload() { + public FileUpload(String fielName) { initWidget(uiBinder.createAndBindUi(this)); - fileUploadPanel.add(new MultipleDilaogUpload()); + fileUploadPanel.add(new MultipleDilaogUpload(fielName)); } } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java index 642b9eb..4a6bc95 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java @@ -49,9 +49,10 @@ public class MultipleDilaogUpload extends DialogUpload { /** * Instantiates a new multiple dilaog upload. */ - public MultipleDilaogUpload() { - fileUploadID = GenerateUUID.get(10, 16); // is tagID - fileUpload.getElement().setId(fileUploadID); + public MultipleDilaogUpload(String fieldName) { + this.fileUploadID = GenerateUUID.get(10, 16); // is tagID + this.fileUpload.getElement().setId(fileUploadID); + super.setFieldName(fieldName); this.addHandlers(); } @@ -165,7 +166,7 @@ public class MultipleDilaogUpload extends DialogUpload { @Override public void onChange(ChangeEvent event) { - GWT.log("file upload change handler, browse return..."); + GWT.log("file upload change handler, browse returns..."); if (fileUpload.getFilename() == null || fileUpload.getFilename().isEmpty()) { GWT.log("No file specified "); //MultipleDilaogUpload.this.hide(); diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java index ddcb5a3..be41981 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java @@ -33,6 +33,7 @@ import org.gcube.common.portal.PortalContext; import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; import org.gcube.portlets.widgets.mpformbuilder.server.util.WsUtil; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.AbstractUploadProgressListener; +import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FilePath; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState.UPLOAD_STATUS; @@ -54,9 +55,9 @@ import org.slf4j.LoggerFactory; * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it at ISTI-CNR * - * Oct 5, 2020 + * Oct 5, 2020 */ -public class MetadataProfileFormBuilderUploadServlet extends HttpServlet implements Servlet{ +public class MetadataProfileFormBuilderUploadServlet extends HttpServlet implements Servlet { /** The Constant UNKNOWN_UNKNOWN. */ public static final String UNKNOWN_UNKNOWN = "unknown/unknown"; @@ -69,11 +70,12 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** The Constant VRE_ID_ATTR_NAME. */ public static final String VRE_ID_ATTR_NAME = "gcube-vreid"; - + /** The Constant CURR_GROUP_ID. */ public static final String CURR_GROUP_ID = ConstantsMPFormBuilder.CURR_GROUP_ID; - //public static final String CURR_USER_ID = ConstantsWorkspaceUploader.CURR_USER_ID; + // public static final String CURR_USER_ID = + // ConstantsWorkspaceUploader.CURR_USER_ID; /** The Constant UPLOAD_FORM_ELEMENT. */ public static final String UPLOAD_FORM_ELEMENT = ConstantsMPFormBuilder.UPLOAD_FORM_ELEMENT; @@ -90,12 +92,14 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** The Constant UPLOAD_TYPE. */ public static final String UPLOAD_TYPE = ConstantsMPFormBuilder.UPLOAD_TYPE; + public static final String FIELD_NAME = ConstantsMPFormBuilder.FIELD_NAME; + /** The logger. */ public static Logger logger = LoggerFactory.getLogger(MetadataProfileFormBuilderUploadServlet.class); /** The app engine. */ private static boolean appEngine = false; - + public static final String JAVA_IO_TMPDIR = System.getProperty("java.io.tmpdir"); /** @@ -119,7 +123,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme appEngine = isAppEngine(); } - logger.debug("init: appEngine is "+appEngine); + logger.debug("init: appEngine is " + appEngine); } /** @@ -127,32 +131,32 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - logger.debug("GET method in "+MetadataProfileFormBuilderUploadServlet.class.getName()+" is running"); + logger.debug("GET method in " + MetadataProfileFormBuilderUploadServlet.class.getName() + " is running"); String clientUploadKey = request.getParameter(CLIENT_UPLOAD_KEYS); - if (clientUploadKey == null){ - sendError(response, "Internal error: UPLOAD KEY NOT FOUND"); - return; - } - logger.debug("GET method CLIENT_UPLOAD_KEY "+clientUploadKey); + if (clientUploadKey == null) { + sendError(response, "Internal error: UPLOAD KEY NOT FOUND"); + return; + } + logger.debug("GET method CLIENT_UPLOAD_KEY " + clientUploadKey); - boolean cancelUpload = Boolean.parseBoolean(request.getParameter(CANCEL_UPLOAD)); - logger.debug("GET method CANCEL_UPLOAD "+cancelUpload); - if (cancelUpload) { - boolean cancelled = cancelUpload(request.getSession(), clientUploadKey); - if(cancelled){ - sendMessage(response, "Upload aborted "+clientUploadKey); + boolean cancelUpload = Boolean.parseBoolean(request.getParameter(CANCEL_UPLOAD)); + logger.debug("GET method CANCEL_UPLOAD " + cancelUpload); + if (cancelUpload) { + boolean cancelled = cancelUpload(request.getSession(), clientUploadKey); + if (cancelled) { + sendMessage(response, "Upload aborted " + clientUploadKey); // try { //// removeCurrentListener(request.getSession(), clientUploadKey); // WsUtil.eraseWorkspaceUploaderInSession(request.getSession(), clientUploadKey); // }catch (Exception e) { // logger.warn("An error occurred during removing cancelled upload from session "); // } - } - else - sendWarnMessage(response, "Upload aborted for id: "+clientUploadKey +" has skipped, already aborted or completed?"); - }else - logger.debug(CANCEL_UPLOAD + " param not found"); - return; + } else + sendWarnMessage(response, + "Upload aborted for id: " + clientUploadKey + " has skipped, already aborted or completed?"); + } else + logger.debug(CANCEL_UPLOAD + " param not found"); + return; } /** @@ -160,8 +164,9 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("POST on UploadServlet"); - boolean requestIsNull = request==null; - logger.trace("[1] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName()); + boolean requestIsNull = request == null; + logger.trace("[1] HttpServletRequest is: null? " + requestIsNull + ", URI: " + request.getRequestURI() + + ", ServerName: " + request.getServerName()); if (!ServletFileUpload.isMultipartContent(request)) { logger.error("ERROR: multipart request not found"); @@ -172,41 +177,46 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme try { logger.info("UPLOAD-SERVLET starting"); - HttpSession session = request.getSession(); - logger.info("UPLOAD-SERVLET session: "+session); - logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received."); + HttpSession session = request.getSession(); + logger.info("UPLOAD-SERVLET session: " + session); + logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received."); - if(WsUtil.isSessionExpired(request)){ - logger.error("SESSION_EXPIRED: session is expired"); - sendSessionExpired(response, "SESSION_EXPIRED: session is expired"); - return; - } + if (WsUtil.isSessionExpired(request)) { + logger.error("SESSION_EXPIRED: session is expired"); + sendSessionExpired(response, "SESSION_EXPIRED: session is expired"); + return; + } String uploadType = null; - // String clientUploadKey = null; + String fieldName = null; + // String clientUploadKey = null; FileItemStream uploadItem = null; ArrayList listClientUploadKeys = null; - + GCubeUser user = PortalContext.getConfiguration().getCurrentUser(request); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload servletFileUpload = new ServletFileUpload(factory); /** - * An iterator to instances of FileItemStream - * parsed from the request, in the order that they were - *transmitted. + * An iterator to instances of FileItemStream parsed from the + * request, in the order that they were transmitted. */ FileItemIterator fileItemIterator = servletFileUpload.getItemIterator(request); int uploadItemsCnt = 0; String scopeGroupId = ""; - //GET FILE STREAM + // GET FILE STREAM while (fileItemIterator.hasNext()) { FileItemStream item = fileItemIterator.next(); - if (item.isFormField() && UPLOAD_TYPE.equals(item.getFieldName())){ + if (item.isFormField() && UPLOAD_TYPE.equals(item.getFieldName())) { uploadType = Streams.asString(item.openStream()); - logger.debug("UPLOAD_TYPE OK " +uploadType); + logger.debug(UPLOAD_TYPE + " OK " + uploadType); + } + + if (item.isFormField() && FIELD_NAME.equals(item.getFieldName())) { + fieldName = Streams.asString(item.openStream()); + logger.debug(FIELD_NAME + " OK " + fieldName); } // if (item.isFormField() && IS_OVERWRITE.equals(item.getFieldName())){ @@ -218,24 +228,27 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme // } // } - if(item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())){ + if (item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())) { String jsonClientUploadKey = Streams.asString(item.openStream()); - logger.debug("CLIENT_UPLOAD_KEY OK "+jsonClientUploadKey); + logger.debug(CLIENT_UPLOAD_KEYS + " OK " + jsonClientUploadKey); LinkedHashMap mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey); listClientUploadKeys = new ArrayList(mapKeys.keySet()); removeListenersIfDone(session, listClientUploadKeys); for (String clientUploadKey : listClientUploadKeys) { String fileName = mapKeys.get(clientUploadKey); - FileUploadingState workspaceUploader = createNewWorkspaceUploader(clientUploadKey,fileName, user.getUsername()); - logger.debug("created "+workspaceUploader); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession()); + FileUploadingState workspaceUploader = createNewWorkspaceUploader(clientUploadKey, fileName, + user.getUsername(), fieldName); + logger.debug("created " + workspaceUploader); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, + "Uploading " + fileName + " at 0%", request.getSession()); } } - if (item.isFormField() && CURR_GROUP_ID.equals(item.getFieldName())){ + if (item.isFormField() && CURR_GROUP_ID.equals(item.getFieldName())) { scopeGroupId = Streams.asString(item.openStream()); logger.debug("currentGroupId passed as parameter = " + scopeGroupId); - logger.debug("currentGroupId into PortalContext scope= " + PortalContext.getConfiguration().getCurrentScope(scopeGroupId)); + logger.debug("currentGroupId into PortalContext scope= " + + PortalContext.getConfiguration().getCurrentScope(scopeGroupId)); } // if (item.isFormField() && CURR_USER_ID.equals(item.getFieldName())){ @@ -244,12 +257,13 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme // logger.debug("currUserinto PortalContext = " + PortalContext.getConfiguration().getCurrentUser(request)); // } - //MUST BE THE LAST PARAMETER TRASMITTED - if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){ + // MUST BE THE LAST PARAMETER TRASMITTED + if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())) { uploadItem = item; - logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName() + " scopeGroupId="+scopeGroupId); + logger.debug("UPLOAD_FORM_ELEMENT OK " + uploadItem.getName() + " scopeGroupId=" + scopeGroupId); // break; - uploadData(user, scopeGroupId, request, response, uploadItem, uploadType, listClientUploadKeys.get(uploadItemsCnt)); + uploadData(user, scopeGroupId, request, response, uploadItem, uploadType, + listClientUploadKeys.get(uploadItemsCnt), fieldName); uploadItemsCnt++; } } @@ -265,26 +279,25 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme } } - /** * Removes the listener if done. * * @param session the session - * @param keys the keys + * @param keys the keys */ - private void removeListenersIfDone(HttpSession session, List keys){ + private void removeListenersIfDone(HttpSession session, List keys) { for (String key : keys) { - AbstractUploadProgressListener listener = getCurrentListener(session, key); - if (listener != null) { - logger.debug("Listener found"); - if (listener.isCanceled() || listener.getPercentage() >= 100){ - logger.debug("Listener isCanceled or 100%, removing"); - removeCurrentListener(session, key); - } - }else - logger.debug("Session id: "+session.getId() +" - "+key+" - Listener not found"); + AbstractUploadProgressListener listener = getCurrentListener(session, key); + if (listener != null) { + logger.debug("Listener found"); + if (listener.isCanceled() || listener.getPercentage() >= 100) { + logger.debug("Listener isCanceled or 100%, removing"); + removeCurrentListener(session, key); + } + } else + logger.debug("Session id: " + session.getId() + " - " + key + " - Listener not found"); } } @@ -297,7 +310,8 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * @throws FileUploadException the file upload exception */ @SuppressWarnings("rawtypes") - private static LinkedHashMap parseJSONClientUploadKeys(final String jsonClientUploadKeys) throws FileUploadException{ + private static LinkedHashMap parseJSONClientUploadKeys(final String jsonClientUploadKeys) + throws FileUploadException { JSONTokener tokener = new JSONTokener(jsonClientUploadKeys); JSONObject root; LinkedHashMap keyFiles = null; @@ -306,147 +320,157 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme root = new JSONObject(tokener); JSONArray jsonArray = root.getJSONArray(JSON_CLIENT_KEYS); keyFiles = new LinkedHashMap(jsonArray.length()); - logger.debug("jsonArray :"+jsonArray.toString()); - for (int i=0; i listFiles = (List) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR); - - if(listFiles==null) + if (fileUploaded != null) { + List listFiles = (List) httpSession + .getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR); + + if (listFiles == null) listFiles = new ArrayList(); - + listFiles.add(fileUploaded); httpSession.setAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR, listFiles); - logger.info("Added: "+fileUploaded +" in session"); + logger.info("Added: " + fileUploaded + " in session"); } } - //TEST TIME + // TEST TIME /** * Prints the start time. * * @return the long */ - public static Long printStartTime(){ - Long startTime = System.currentTimeMillis(); - logger.debug("Start time: "+startTime); + public static Long printStartTime() { + Long startTime = System.currentTimeMillis(); + logger.debug("Start time: " + startTime); return startTime; } - //TEST TIME + + // TEST TIME /** * Prints the elapsed time. * * @param startTime the start time */ - public static void printElapsedTime(long startTime){ + public static void printElapsedTime(long startTime) { Long endTime = System.currentTimeMillis() - startTime; String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); - logger.debug("Elapsed Time: "+time); + logger.debug("Elapsed Time: " + time); } /** * Send error. * * @param response the response - * @param message the message + * @param message the message * @throws IOException Signals that an I/O exception has occurred. */ - protected void sendError(HttpServletResponse response, String message) throws IOException{ + protected void sendError(HttpServletResponse response, String message) throws IOException { try { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message); response.getWriter().write(resultMessage.toString()); - //5.6 Closure of Response Object: - //When a response is closed, the container must immediately flush all remaining content in the response buffer to the client + // 5.6 Closure of Response Object: + // When a response is closed, the container must immediately flush all remaining + // content in the response buffer to the client // response.flushBuffer(); - } catch (IOException e){ - logger.warn("IOException class name: "+e.getClass().getSimpleName()); + } catch (IOException e) { + logger.warn("IOException class name: " + e.getClass().getSimpleName()); if (e.getClass().getSimpleName().equals("ClientAbortException")) - logger.warn("Skipping ClientAbortException: "+e.getMessage()); + logger.warn("Skipping ClientAbortException: " + e.getMessage()); else - throw e; //Sending Exceptions + throw e; // Sending Exceptions } } - /** * Send session expired. * * @param response the response - * @param message the message + * @param message the message * @throws IOException Signals that an I/O exception has occurred. */ - protected void sendSessionExpired(HttpServletResponse response, String message) throws IOException{ + protected void sendSessionExpired(HttpServletResponse response, String message) throws IOException { try { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); HandlerResultMessage resultMessage = HandlerResultMessage.sessionExpiredResult(message); response.getWriter().write(resultMessage.toString()); - //5.6 Closure of Response Object: - //When a response is closed, the container must immediately flush all remaining content in the response buffer to the client + // 5.6 Closure of Response Object: + // When a response is closed, the container must immediately flush all remaining + // content in the response buffer to the client // response.flushBuffer(); - } catch (IOException e){ - logger.warn("IOException class name: "+e.getClass().getSimpleName()); + } catch (IOException e) { + logger.warn("IOException class name: " + e.getClass().getSimpleName()); if (e.getClass().getSimpleName().equals("ClientAbortException")) - logger.warn("Skipping ClientAbortException: "+e.getMessage()); + logger.warn("Skipping ClientAbortException: " + e.getMessage()); else - throw e; //Sending Exceptions + throw e; // Sending Exceptions } } @@ -643,24 +674,25 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * Send message. * * @param response the response - * @param message the message + * @param message the message * @throws IOException Signals that an I/O exception has occurred. */ - protected void sendMessage(HttpServletResponse response, String message) throws IOException{ + protected void sendMessage(HttpServletResponse response, String message) throws IOException { try { response.setStatus(HttpServletResponse.SC_ACCEPTED); message = message.replaceAll(":", ""); HandlerResultMessage resultMessage = HandlerResultMessage.okResult(message); response.getWriter().write(resultMessage.toString()); - //5.6 Closure of Response Object: - //When a response is closed, the container must immediately flush all remaining content in the response buffer to the client + // 5.6 Closure of Response Object: + // When a response is closed, the container must immediately flush all remaining + // content in the response buffer to the client // response.flushBuffer(); - } catch (IOException e){ - logger.warn("IOException class name: "+e.getClass().getSimpleName()); + } catch (IOException e) { + logger.warn("IOException class name: " + e.getClass().getSimpleName()); if (e.getClass().getSimpleName().equals("ClientAbortException")) - logger.warn("Skipping ClientAbortException: "+e.getMessage()); + logger.warn("Skipping ClientAbortException: " + e.getMessage()); else - throw e; //Sending Exceptions + throw e; // Sending Exceptions } } @@ -668,41 +700,42 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * Send warn message. * * @param response the response - * @param message the message + * @param message the message * @throws IOException Signals that an I/O exception has occurred. */ - protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException{ + protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException { try { response.setStatus(HttpServletResponse.SC_ACCEPTED); HandlerResultMessage resultMessage = HandlerResultMessage.warnResult(message); response.getWriter().write(resultMessage.toString()); - //5.6 Closure of Response Object: - //When a response is closed, the container must immediately flush all remaining content in the response buffer to the client + // 5.6 Closure of Response Object: + // When a response is closed, the container must immediately flush all remaining + // content in the response buffer to the client // response.flushBuffer(); - } catch (IOException e){ - logger.warn("IOException class name: "+e.getClass().getSimpleName()); + } catch (IOException e) { + logger.warn("IOException class name: " + e.getClass().getSimpleName()); if (e.getClass().getSimpleName().equals("ClientAbortException")) - logger.warn("Skipping ClientAbortException: "+e.getMessage()); + logger.warn("Skipping ClientAbortException: " + e.getMessage()); else - throw e; //Sending Exceptions + throw e; // Sending Exceptions } } /** * Mark the current upload process to be canceled. * - * @param session the session + * @param session the session * @param clientUploadKey the client upload key * @return true, if successful */ public boolean cancelUpload(HttpSession session, String clientUploadKey) { - logger.debug("UPLOAD-SERVLET (" + session.getId()+ ") cancelling Upload: "+clientUploadKey); + logger.debug("UPLOAD-SERVLET (" + session.getId() + ") cancelling Upload: " + clientUploadKey); AbstractUploadProgressListener listener = getCurrentListener(session, clientUploadKey); if (listener != null && !listener.isCanceled()) { - logger.info("CancelUpload listener is "+listener.toString()); + logger.info("CancelUpload listener is " + listener.toString()); listener.setException(new UploadCanceledException()); return true; - }else{ + } else { logger.info("Skipping cancel upload: listener is null or is cancel"); return false; } @@ -711,7 +744,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** * Get the listener active in this session. * - * @param session the session + * @param session the session * @param clientUploadKey the client upload key * @return the listener active */ @@ -724,8 +757,8 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme } /** - * Just a method to detect whether the web container is running with - * appengine restrictions. + * Just a method to detect whether the web container is running with appengine + * restrictions. * * @return true if the case of the application is running in appengine */ @@ -736,7 +769,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** * Create a new listener for this session. * - * @param session the session + * @param session the session * @param clientUploadKey the client upload key * @return the appropriate listener */ @@ -748,7 +781,6 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme } } - /** * Gets the content length. * @@ -758,8 +790,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme private long getContentLength(HttpServletRequest request) { long size = -1; try { - size = Long.parseLong(request - .getHeader(FileUploadBase.CONTENT_LENGTH)); + size = Long.parseLong(request.getHeader(FileUploadBase.CONTENT_LENGTH)); } catch (NumberFormatException e) { } return size; @@ -768,17 +799,17 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** * Remove the listener active in this session. * - * @param session the session + * @param session the session * @param clientUploadKey the client upload key */ protected void removeCurrentListener(HttpSession session, String clientUploadKey) { - logger.debug("RemoveCurrentListener: "+clientUploadKey); + logger.debug("RemoveCurrentListener: " + clientUploadKey); AbstractUploadProgressListener listener = getCurrentListener(session, clientUploadKey); if (listener != null) { - logger.debug("Removing listener: "+listener.getClientUploadKey()); + logger.debug("Removing listener: " + listener.getClientUploadKey()); listener.remove(); - }else - logger.warn("Listener "+clientUploadKey+ "is null"); + } else + logger.warn("Listener " + clientUploadKey + "is null"); } } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java index b3ed0c6..fa4a3e6 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/GenericDatasetBean.java @@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.mpformbuilder.shared; import java.io.Serializable; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java index 1094a4b..a406b78 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java @@ -38,7 +38,7 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { } /** - * Instantiates a new metadata field. + * Instantiates a new metadata field wrapper. * * @param fieldName the field name * @param mandatory the mandatory @@ -83,7 +83,7 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { /** * Gets the field name. * - * @return the fieldName + * @return the serviceFieldName */ public String getFieldName() { @@ -143,7 +143,7 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { /** * Sets the field name. * - * @param fieldName the fieldName to set + * @param fieldName the new field name */ public void setFieldName(String fieldName) { @@ -339,7 +339,7 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { */ @Override public String toString() { - return "MetadataFieldWrapper [" + (fieldName != null ? "fieldName=" + fieldName + ", " : "") + return "MetadataFieldWrapper [" + (fieldName != null ? "serviceFieldName=" + fieldName + ", " : "") + (fieldNameFromCategory != null ? "fieldNameFromCategory=" + fieldNameFromCategory + ", " : "") + (mandatory != null ? "mandatory=" + mandatory + ", " : "") + (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "") diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FilePath.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FilePath.java new file mode 100644 index 0000000..22d0d2a --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FilePath.java @@ -0,0 +1,67 @@ +package org.gcube.portlets.widgets.mpformbuilder.shared.upload; + +import java.io.Serializable; + +/** + * The Class FilePath. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 21, 2022 + */ +public class FilePath implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5321133561716734223L; + String formFieldLabel; // is the gcubeProfileFieldName in the UCD of Geoportal + + /** + * Instantiates a new file paths. + */ + public FilePath() { + } + + /** + * Instantiates a new file path. + * + * @param formFieldLabel the form field label + */ + public FilePath(String formFieldLabel) { + this.formFieldLabel = formFieldLabel; + } + + /** + * Gets the form field label. + * + * @return the form field label + */ + public String getFormFieldLabel() { + return formFieldLabel; + } + + /** + * Sets the form field label. + * + * @param formFieldLabel the new form field label + */ + public void setFormFieldLabel(String formFieldLabel) { + this.formFieldLabel = formFieldLabel; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("FilePath [formFieldLabel="); + builder.append(formFieldLabel); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FileUploaded.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FileUploaded.java index 65cf9e4..38ce12d 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FileUploaded.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/upload/FileUploaded.java @@ -7,49 +7,50 @@ import java.io.Serializable; import com.google.gwt.user.client.rpc.IsSerializable; - /** * The Class FileUploaded. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 8, 2020 + * Oct 8, 2020 */ -public class FileUploaded implements Serializable, IsSerializable{ - +public class FileUploaded implements Serializable, IsSerializable { /** * */ - private static final long serialVersionUID = -7869956386977214114L; + private static final long serialVersionUID = -6666006742990360875L; /** The file name. */ private String fileName; - + /** The item id. */ private String tempSystemPath; - + private String createdByUser; + private FilePath filePath; + /** * Instantiates a new workspace upload file. */ public FileUploaded() { } - - + /** - * Instantiates a new workspace upload file. + * Instantiates a new file uploaded. * - * @param fileName the file name + * @param fileName the file name * @param tempSystemPath the temp system path - * @param createdByUser the created by user + * @param createdByUser the created by user + * @param filePath the file path */ - public FileUploaded(String fileName, String tempSystemPath, String createdByUser) { + public FileUploaded(String fileName, String tempSystemPath, String createdByUser, FilePath filePath) { super(); this.fileName = fileName; this.tempSystemPath = tempSystemPath; this.createdByUser = createdByUser; + this.filePath = filePath; } /** @@ -61,8 +62,6 @@ public class FileUploaded implements Serializable, IsSerializable{ return fileName; } - - /** * Sets the file name. * @@ -72,8 +71,6 @@ public class FileUploaded implements Serializable, IsSerializable{ this.fileName = fileName; } - - /** * Gets the temp system path. * @@ -83,8 +80,6 @@ public class FileUploaded implements Serializable, IsSerializable{ return tempSystemPath; } - - /** * Sets the temp system path. * @@ -94,8 +89,6 @@ public class FileUploaded implements Serializable, IsSerializable{ this.tempSystemPath = tempSystemPath; } - - /** * Gets the created by user. * @@ -105,8 +98,6 @@ public class FileUploaded implements Serializable, IsSerializable{ return createdByUser; } - - /** * Sets the created by user. * @@ -116,7 +107,29 @@ public class FileUploaded implements Serializable, IsSerializable{ this.createdByUser = createdByUser; } + /** + * Gets the file paths. + * + * @return the file paths + */ + public FilePath getFilePath() { + return filePath; + } + /** + * Sets the file paths. + * + * @param filePaths the new file paths + */ + public void setFilePaths(FilePath filePaths) { + this.filePath = filePaths; + } + + /** + * To string. + * + * @return the string + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -126,8 +139,10 @@ public class FileUploaded implements Serializable, IsSerializable{ builder.append(tempSystemPath); builder.append(", createdByUser="); builder.append(createdByUser); + builder.append(", filePath="); + builder.append(filePath); builder.append("]"); return builder.toString(); } - + } From 0710f4426945399573a251355cf50431e2999404 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 20 Apr 2022 15:42:03 +0200 Subject: [PATCH 06/15] #23188 enhancement implemented --- CHANGELOG.md | 3 +- .../client/ConstantsMPFormBuilder.java | 5 +- .../client/ui/upload/DialogUpload.java | 4 +- .../ui/upload/MultipleDilaogUpload.java | 98 +++++++++---------- .../server/JSONFileUploaded.java | 48 +++++++++ ...tadataProfileFormBuilderUploadServlet.java | 56 +++++++---- 6 files changed, 141 insertions(+), 73 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/JSONFileUploaded.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d020b74..2fab079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancement -- [#22890] Overloaded the method getProfilesInTheScope(forName) +- [#23188] Overloaded the method getProfilesInTheScope(forName) - [#22890] Including the set/get currentValue for Update facility +- [#23188] Advanced the MultipleDilaogUpload with a more complex object ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java index c51f849..c3cd469 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ConstantsMPFormBuilder.java @@ -10,7 +10,7 @@ public class ConstantsMPFormBuilder { //public static final String CURR_USER_ID = "currUserId"; public static final String IS_OVERWRITE = "isOverwrite"; public static final String UPLOAD_TYPE = "uploadType"; - public static final String FIELD_NAME = "fieldName"; + public static enum THE_UPLOAD_TYPE {File, Archive}; public static final String ID_FOLDER = "idFolder"; public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement"; @@ -18,6 +18,9 @@ public class ConstantsMPFormBuilder { public static final String CLIENT_UPLOAD_KEYS = "client_upload_keys"; public static final String CANCEL_UPLOAD = "cancel_upload"; public static final String JSON_CLIENT_KEYS = "ClientKeys"; + public static final String UPL_FILENAME = "filename"; + public static final String UPL_CLIENT_KEY = "client_key"; + public static final String UPL_FIELD_NAME_FILEPATH = "fieldname_filepath"; public static final int LIMIT_UPLOADS = 50; diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java index 8bd7c97..3202b76 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java @@ -48,7 +48,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific /** The timer. */ protected TimerUpload timer; - private String fieldName; + protected String fieldName; /** * The Enum UPLOAD_TYPE. @@ -91,7 +91,7 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific verticalMainPanel.add( new Hidden(ConstantsMPFormBuilder.UPLOAD_TYPE, ConstantsMPFormBuilder.THE_UPLOAD_TYPE.File.name())); - verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.FIELD_NAME, fieldName)); + verticalMainPanel.add(new Hidden(ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH, fieldName)); initJsonClientKeys(); verticalMainPanel.add(jsonClientKeys); diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java index 4a6bc95..44d30ff 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/MultipleDilaogUpload.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Arrays; import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; +import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FilePath; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadingState.UPLOAD_STATUS; @@ -31,21 +32,20 @@ public class MultipleDilaogUpload extends DialogUpload { /** The Constant FILE_DELEMITER. */ public static final String FILE_DELEMITER = ";"; - + /** The file upload ID. */ private String fileUploadID; - + /** The instance. */ - //private MultipleDNDUpload dnd; + // private MultipleDNDUpload dnd; public MultipleDilaogUpload instance = this; - + /** The json keys. */ private String jsonKeys; /** The id folder. */ private String idFolder; - /** * Instantiates a new multiple dilaog upload. */ @@ -64,7 +64,7 @@ public class MultipleDilaogUpload extends DialogUpload { */ public void generateFakeUploaders(String filesSelected) { - if(filesSelected==null || filesSelected.isEmpty()) + if (filesSelected == null || filesSelected.isEmpty()) return; String[] files = filesSelected.split(FILE_DELEMITER); @@ -73,11 +73,12 @@ public class MultipleDilaogUpload extends DialogUpload { for (int i = 0; i < files.length; i++) { String normalizedFileName = files[i]; if (normalizedFileName.contains("\\")) { - files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath if exists + files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath + // if exists } } - GWT.log("generating fake uploaders on: "+Arrays.asList(files.toString())); + GWT.log("generating fake uploaders on: " + Arrays.asList(files.toString())); fakeUploaders = new ArrayList(files.length); for (int i = 0; i < files.length; i++) { FileUploadingState fakeItem = new FileUploadingState(); @@ -86,10 +87,12 @@ public class MultipleDilaogUpload extends DialogUpload { FileUploaded fakeFile = new FileUploaded(); fakeFile.setFileName(files[i]); fakeItem.setFile(fakeFile); + fakeFile.setFilePaths(new FilePath(getFieldName())); // The Form Field Label is unique for single-multiple + // upload fakeUploaders.add(fakeItem); } - GWT.log("fakeUploaders generated: "+fakeUploaders.toString()); + GWT.log("fakeUploaders generated: " + fakeUploaders.toString()); } /** @@ -104,7 +107,7 @@ public class MultipleDilaogUpload extends DialogUpload { @Override public void onSubmitComplete(SubmitCompleteEvent event) { GWT.log("onSubmitComplete in multipleupload"); - + // isStatusCompleted = true; String result = event.getResults(); @@ -116,31 +119,30 @@ public class MultipleDilaogUpload extends DialogUpload { return; } String strippedResult = new HTML(result).getText(); - final HandlerResultMessage resultMessage = HandlerResultMessage - .parseResult(strippedResult); + final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult); switch (resultMessage.getStatus()) { case ERROR: removeLoading(); - //timer.cancel(); + // timer.cancel(); GWT.log("Error during upload " + resultMessage.getMessage()); break; case UNKNOWN: removeLoading(); - //timer.cancel(); + // timer.cancel(); GWT.log("Error during upload " + resultMessage.getMessage()); break; case WARN: { - GWT.log("Upload completed with warnings "+ resultMessage.getMessage()); + GWT.log("Upload completed with warnings " + resultMessage.getMessage()); removeLoading(); - //timer.cancel(); + // timer.cancel(); break; } - case SESSION_EXPIRED:{ - GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage()); + case SESSION_EXPIRED: { + GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage()); Window.alert("Session expired, please reload the page"); removeLoading(); - //timer.cancel(); + // timer.cancel(); break; } case OK: { @@ -169,17 +171,17 @@ public class MultipleDilaogUpload extends DialogUpload { GWT.log("file upload change handler, browse returns..."); if (fileUpload.getFilename() == null || fileUpload.getFilename().isEmpty()) { GWT.log("No file specified "); - //MultipleDilaogUpload.this.hide(); + // MultipleDilaogUpload.this.hide(); return; } String[] files = null; - GWT.log("Current Uploader has id: "+fileUploadID); + GWT.log("Current Uploader has id: " + fileUploadID); String filesSelected = getFilesSelected(fileUploadID, FILE_DELEMITER); GWT.log("getFilesSelected: " + filesSelected); files = filesSelected.split(FILE_DELEMITER); - if(isLimitExceeded(files.length)) + if (isLimitExceeded(files.length)) return; // GENERATE NEW UPLOADERS @@ -200,24 +202,19 @@ public class MultipleDilaogUpload extends DialogUpload { } }); - } - - /** * Checks if is limit exceeded. * * @param numbOfFiles the numb of files * @return true, if is limit exceeded */ - public boolean isLimitExceeded(int numbOfFiles){ + public boolean isLimitExceeded(int numbOfFiles) { if (numbOfFiles > ConstantsMPFormBuilder.LIMIT_UPLOADS) { - Window.alert("Multiple upload limit is " - + ConstantsMPFormBuilder.LIMIT_UPLOADS - + " files"); - //MultipleDilaogUpload.this.hide(); + Window.alert("Multiple upload limit is " + ConstantsMPFormBuilder.LIMIT_UPLOADS + " files"); + // MultipleDilaogUpload.this.hide(); return true; } @@ -227,21 +224,22 @@ public class MultipleDilaogUpload extends DialogUpload { /** * Adds the new submit to monitor. */ - public void addNewSubmitToMonitor(){ + public void addNewSubmitToMonitor() { GWT.log("addNewSubmitToMonitor..."); - /*int queueIndex = UploaderMonitor.getInstance().newQueue(); - for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) { - UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName()); - setVisible(false); - removeLoading(); - UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem); -// UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem); - } - - UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);*/ + /* + * int queueIndex = UploaderMonitor.getInstance().newQueue(); for (final + * WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) { + * UploaderMonitor.getInstance().addNewUploaderToMonitorPanel( + * workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName()); + * setVisible(false); removeLoading(); + * UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, + * workspaceUploaderItem); // + * UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem); } + * + * UploaderMonitor.getInstance().doStartPollingQueue(queueIndex); + */ } - /** * Creates the json key for files. * @@ -258,12 +256,17 @@ public class MultipleDilaogUpload extends DialogUpload { for (int i = 0; i < fakeUploaders.size(); i++) { FileUploadingState file = fakeUploaders.get(i); JSONObject obj = new JSONObject(); - obj.put(file.getClientUploadKey(), new JSONString(file.getFile().getFileName())); + // JSONObject innerObj = new JSONObject(); + obj.put(ConstantsMPFormBuilder.UPL_CLIENT_KEY, new JSONString(file.getClientUploadKey())); + obj.put(ConstantsMPFormBuilder.UPL_FILENAME, new JSONString(file.getFile().getFileName())); + obj.put(ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH, new JSONString(file.getFile().getFilePath().getFormFieldLabel())); + // obj.put(file.getClientUploadKey(), new + // JSONString(file.getFile().getFileName())); jsonArray.set(i, obj); } jsonKeys = productObj.toString(); - GWT.log("updated jsonKeys: "+jsonKeys); + GWT.log("updated jsonKeys: " + jsonKeys); } catch (Exception e) { GWT.log("error " + e.getMessage()); jsonKeys = null; @@ -306,14 +309,11 @@ public class MultipleDilaogUpload extends DialogUpload { }-*/; - /** * Gets the files selected. * - * @param tagId - * the tag id - * @param fileDelimiter - * the file delimiter + * @param tagId the tag id + * @param fileDelimiter the file delimiter * @return the files selected */ public static native String getFilesSelected(final String tagId, final String fileDelimiter) /*-{ diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/JSONFileUploaded.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/JSONFileUploaded.java new file mode 100644 index 0000000..1449b03 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/JSONFileUploaded.java @@ -0,0 +1,48 @@ +package org.gcube.portlets.widgets.mpformbuilder.server; + +import org.gcube.portlets.widgets.mpformbuilder.client.ConstantsMPFormBuilder; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class JSONFileUploaded { + + @JsonProperty(value = ConstantsMPFormBuilder.UPL_CLIENT_KEY) + protected String clienKey; + @JsonProperty(value = ConstantsMPFormBuilder.UPL_FILENAME) + protected String fileName; + + // THIS IS THE FIELD LABEL USED IN THE WEB-FORM + // AND DECLARED IN THE FIELDNAME OF THE GCUBE METADATA PROFILE + @JsonProperty(value = ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH) + protected String fieldNameFilePath; + + public JSONFileUploaded() { + super(); + } + + public String getClienKey() { + return clienKey; + } + + public String getFileName() { + return fileName; + } + + public String getFieldNameFilePath() { + return fieldNameFilePath; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("JSONFileUploaded [clienKey="); + builder.append(clienKey); + builder.append(", fileName="); + builder.append(fileName); + builder.append(", fieldNameFilePath="); + builder.append(fieldNameFilePath); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java index be41981..9fffbad 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataProfileFormBuilderUploadServlet.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Random; import java.util.concurrent.TimeUnit; import javax.servlet.Servlet; @@ -50,6 +51,8 @@ import org.json.JSONTokener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * The Class MetadataProfileBuilderUploadServlet. * @@ -92,7 +95,11 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme /** The Constant UPLOAD_TYPE. */ public static final String UPLOAD_TYPE = ConstantsMPFormBuilder.UPLOAD_TYPE; - public static final String FIELD_NAME = ConstantsMPFormBuilder.FIELD_NAME; + public static final String FIELD_NAME_FILEPATH = ConstantsMPFormBuilder.UPL_FIELD_NAME_FILEPATH; + + public static final String FILENAME = ConstantsMPFormBuilder.UPL_FILENAME; + + public static final String JSON_CLIENT_KEY = ConstantsMPFormBuilder.UPL_CLIENT_KEY; /** The logger. */ public static Logger logger = LoggerFactory.getLogger(MetadataProfileFormBuilderUploadServlet.class); @@ -214,9 +221,9 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme logger.debug(UPLOAD_TYPE + " OK " + uploadType); } - if (item.isFormField() && FIELD_NAME.equals(item.getFieldName())) { + if (item.isFormField() && FIELD_NAME_FILEPATH.equals(item.getFieldName())) { fieldName = Streams.asString(item.openStream()); - logger.debug(FIELD_NAME + " OK " + fieldName); + logger.debug(FIELD_NAME_FILEPATH + " OK " + fieldName); } // if (item.isFormField() && IS_OVERWRITE.equals(item.getFieldName())){ @@ -231,11 +238,16 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme if (item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())) { String jsonClientUploadKey = Streams.asString(item.openStream()); logger.debug(CLIENT_UPLOAD_KEYS + " OK " + jsonClientUploadKey); - LinkedHashMap mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey); + LinkedHashMap mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey); listClientUploadKeys = new ArrayList(mapKeys.keySet()); removeListenersIfDone(session, listClientUploadKeys); for (String clientUploadKey : listClientUploadKeys) { - String fileName = mapKeys.get(clientUploadKey); + JSONFileUploaded fileUploaded = mapKeys.get(clientUploadKey); + logger.debug("Read file: " + fileUploaded); + String fileName = fileUploaded.getFileName() != null ? fileUploaded.getFileName() + : "No filename " + new Random().nextInt(); + fieldName = fileUploaded.getFieldNameFilePath() != null ? fileUploaded.getFieldNameFilePath() + : fieldName; FileUploadingState workspaceUploader = createNewWorkspaceUploader(clientUploadKey, fileName, user.getUsername(), fieldName); logger.debug("created " + workspaceUploader); @@ -263,7 +275,7 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme logger.debug("UPLOAD_FORM_ELEMENT OK " + uploadItem.getName() + " scopeGroupId=" + scopeGroupId); // break; uploadData(user, scopeGroupId, request, response, uploadItem, uploadType, - listClientUploadKeys.get(uploadItemsCnt), fieldName); + listClientUploadKeys.get(uploadItemsCnt)); uploadItemsCnt++; } } @@ -310,27 +322,31 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * @throws FileUploadException the file upload exception */ @SuppressWarnings("rawtypes") - private static LinkedHashMap parseJSONClientUploadKeys(final String jsonClientUploadKeys) + private static LinkedHashMap parseJSONClientUploadKeys(final String jsonClientUploadKeys) throws FileUploadException { JSONTokener tokener = new JSONTokener(jsonClientUploadKeys); JSONObject root; - LinkedHashMap keyFiles = null; + LinkedHashMap keyFiles = null; try { root = new JSONObject(tokener); JSONArray jsonArray = root.getJSONArray(JSON_CLIENT_KEYS); - keyFiles = new LinkedHashMap(jsonArray.length()); + keyFiles = new LinkedHashMap(jsonArray.length()); logger.debug("jsonArray :" + jsonArray.toString()); for (int i = 0; i < jsonArray.length(); i++) { - JSONObject object = jsonArray.getJSONObject(i); - logger.debug("object :" + object); - String key = (String) object.keys().next(); - String value = object.getString(key); - logger.debug("key :" + key + ", value: " + value); - keyFiles.put(key, value); + String objectString = jsonArray.getString(i); + ObjectMapper om = new ObjectMapper(); + JSONFileUploaded jfu = om.readValue(objectString, JSONFileUploaded.class); + keyFiles.put(jfu.clienKey, jfu); + /* + * JSONObject object = jsonArray.getJSONObject(i); logger.debug("object :" + + * object); String key = (String) object.keys().next(); String value = + * object.getString(key); logger.debug("key :" + key + ", value: " + value); + * keyFiles.put(key, value); + */ } - } catch (JSONException e) { + } catch (JSONException | IOException e) { logger.error("An error occurred during parsing file names: " + keyFiles, e); throw new FileUploadException("An error occurred during parsing file names"); } @@ -349,13 +365,12 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * @param uploadItem the upload item * @param uploadType the upload type * @param clientUploadKey the client upload key - * @param fieldName the field name * @throws ServletException the servlet exception * @throws IOException Signals that an I/O exception has occurred. */ private void uploadData(GCubeUser user, String scopeGroupId, HttpServletRequest request, final HttpServletResponse response, final FileItemStream uploadItem, String uploadType, - String clientUploadKey, String fieldName) throws ServletException, IOException { + String clientUploadKey) throws ServletException, IOException { String fileName = uploadItem.getName(); logger.info("Upload servlet parameters: [fileName: " + fileName + ", uploadType: " + uploadType @@ -487,10 +502,11 @@ public class MetadataProfileFormBuilderUploadServlet extends HttpServlet impleme * @param clientUploadKey the client upload key * @param fileName the file name * @param user the user - * @param formFieldName the form field name + * @param formFieldName the form field name * @return the workspace uploader item */ - private FileUploadingState createNewWorkspaceUploader(String clientUploadKey, String fileName, String user, String formFieldName) { + private FileUploadingState createNewWorkspaceUploader(String clientUploadKey, String fileName, String user, + String formFieldName) { // CLIENT UPLOAD IS THE KEY FileUploadingState workspaceUploader = new FileUploadingState(clientUploadKey); workspaceUploader.setClientUploadKey(clientUploadKey); From fc23e553f7c9255dbf7f086b38073998a6304d33 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 7 Jul 2022 17:49:22 +0200 Subject: [PATCH 07/15] #23544 Integrated with the fieldId --- CHANGELOG.md | 1 + .../ui/metadata/MetaDataFieldSkeleton.java | 10 ++- .../server/MetadataDiscovery.java | 1 + .../shared/metadata/MetadataFieldWrapper.java | 82 +++++++++++++------ 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fab079..9058566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23188] Overloaded the method getProfilesInTheScope(forName) - [#22890] Including the set/get currentValue for Update facility - [#23188] Advanced the MultipleDilaogUpload with a more complex object +- [#23544] Integrated with the fieldId added to gCube Metadata Profile ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 1a8a42f..f705f1e 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -921,8 +921,16 @@ public class MetaDataFieldSkeleton extends Composite { */ public String getFieldNameQualified() { - if (field.getFieldNameFromCategory() != null) + //see https://support.d4science.org/issues/23544 + if (field.getFieldId() != null) { + return field.getFieldId(); + } + + //Using the getFieldNameFromCategory if the category is present in the model as cateogory:fieldName + if (field.getFieldNameFromCategory() != null && field.getFieldNameFromCategory().compareTo(field.getFieldName())!=0) { return field.getFieldNameFromCategory(); + } + return field.getFieldName(); } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java index 47484a7..e468022 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/MetadataDiscovery.java @@ -298,6 +298,7 @@ public class MetadataDiscovery { wrapperObj.setType(DataTypeWrapper.String); } wrapperObj.setDefaultValue(metadataField.getDefaultValue()); + wrapperObj.setFieldId(metadataField.getFieldId()); wrapperObj.setFieldName(metadataField.getFieldName()); wrapperObj.setMandatory(metadataField.getMandatory()); wrapperObj.setNote(metadataField.getNote()); diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java index a406b78..5392dd8 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java @@ -13,6 +13,7 @@ import java.util.List; public class MetadataFieldWrapper implements UpdatableField, Serializable { private static final long serialVersionUID = -8476731365884466698L; + private String fieldId; private String fieldName; private String fieldNameFromCategory; private Boolean mandatory = false; @@ -40,6 +41,8 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { /** * Instantiates a new metadata field wrapper. * + * @param fieldId the field id (optional) if present is used instead of + * fieldName as result * @param fieldName the field name * @param mandatory the mandatory * @param type the type @@ -49,9 +52,10 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { * @param validator the validator * @param category the category */ - public MetadataFieldWrapper(String fieldName, Boolean mandatory, DataTypeWrapper type, String defaultValue, - String note, List vocabulary, String validator, CategoryWrapper category) { + public MetadataFieldWrapper(String fieldId, String fieldName, Boolean mandatory, DataTypeWrapper type, + String defaultValue, String note, List vocabulary, String validator, CategoryWrapper category) { super(); + this.fieldId = fieldId; this.fieldName = fieldName; this.mandatory = mandatory; this.type = type; @@ -80,6 +84,24 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { this.maxOccurs = maxOccurs; } + /** + * Gets the field id. + * + * @return the field id + */ + public String getFieldId() { + return fieldId; + } + + /** + * Sets the field id. + * + * @param fieldId the new field id + */ + public void setFieldId(String fieldId) { + this.fieldId = fieldId; + } + /** * Gets the field name. * @@ -327,29 +349,43 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { return currentValue; } - /** - * To string. - * - * @return the string - */ - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ @Override public String toString() { - return "MetadataFieldWrapper [" + (fieldName != null ? "serviceFieldName=" + fieldName + ", " : "") - + (fieldNameFromCategory != null ? "fieldNameFromCategory=" + fieldNameFromCategory + ", " : "") - + (mandatory != null ? "mandatory=" + mandatory + ", " : "") - + (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "") - + (type != null ? "type=" + type + ", " : "") - + (defaultValue != null ? "defaultValue=" + defaultValue + ", " : "") - + (note != null ? "note=" + note + ", " : "") - + (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "") + "multiSelection=" + multiSelection - + ", " + (validator != null ? "validator=" + validator + ", " : "") - + (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId() + ", " : "") - + (asGroup != null ? "asGroup=" + asGroup + ", " : "") + (asTag != null ? "asTag=" + asTag : "") + "]"; + StringBuilder builder = new StringBuilder(); + builder.append("MetadataFieldWrapper [fieldId="); + builder.append(fieldId); + builder.append(", fieldName="); + builder.append(fieldName); + builder.append(", fieldNameFromCategory="); + builder.append(fieldNameFromCategory); + builder.append(", mandatory="); + builder.append(mandatory); + builder.append(", type="); + builder.append(type); + builder.append(", defaultValue="); + builder.append(defaultValue); + builder.append(", note="); + builder.append(note); + builder.append(", vocabulary="); + builder.append(vocabulary); + builder.append(", multiSelection="); + builder.append(multiSelection); + builder.append(", validator="); + builder.append(validator); + builder.append(", ownerCategory="); + builder.append(ownerCategory); + builder.append(", asGroup="); + builder.append(asGroup); + builder.append(", asTag="); + builder.append(asTag); + builder.append(", maxOccurs="); + builder.append(maxOccurs); + builder.append(", currentValue="); + builder.append(currentValue); + builder.append("]"); + return builder.toString(); } + + } From f8367e7c2ef264e51718328556a63098cfb49746 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 8 Sep 2022 12:06:47 +0200 Subject: [PATCH 08/15] Updated CSS --- .../client/form/catalogue/CreateDatasetForm.ui.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/catalogue/CreateDatasetForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/catalogue/CreateDatasetForm.ui.xml index cf4440a..ef4aca5 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/catalogue/CreateDatasetForm.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/form/catalogue/CreateDatasetForm.ui.xml @@ -4,20 +4,20 @@ xmlns:m="urn:import:org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.tags"> .form-main-style { - margin-left: 10px; + margin-left: 10px !important; } .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; - padding: 10px; + box-shadow: 0px 0px 0px 0px #000 !important; + padding: 10px !important; } .legend-style { - width: auto; - padding: 10px; - margin-bottom: 0px; + width: auto !important; + padding: 10px !important; + margin-bottom: 0px !important; } @external .form-horizontal .input-large; From c8f39f7163be7105a034831b06127cadf4436804 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 9 Nov 2022 15:51:53 +0100 Subject: [PATCH 09/15] - Moved to GWT 2.9 - Moed to maven-portal-bom 3.6.4 --- .settings/org.eclipse.jdt.core.prefs | 4 ++-- CHANGELOG.md | 5 ++++- pom.xml | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 43c8195..cac0df4 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9058566..2fed1f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v2.0.0-SNAPSHOT] - 2022-03-01 +## [v2.0.0-SNAPSHOT] - 2022-11-09 #### Enhancement @@ -12,6 +12,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#22890] Including the set/get currentValue for Update facility - [#23188] Advanced the MultipleDilaogUpload with a more complex object - [#23544] Integrated with the fieldId added to gCube Metadata Profile +- Moved to GWT 2.9 +- Moed to maven-portal-bom 3.6.4 + ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/pom.xml b/pom.xml index 74b1066..e03e322 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,10 @@ - 2.7.0 + 2.9.0 UTF-8 UTF-8 - 1.7 + 1.8 1.8 @@ -53,7 +53,7 @@ org.gcube.distribution maven-portal-bom - 3.6.0 + 3.7.0-SNAPSHOT pom import From a2b23ce59fd70fc18a9f2471817db58b8e1f397c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 10 Nov 2022 09:32:35 +0100 Subject: [PATCH 10/15] reverted to gwt 2.7.0 and java source 1.7 --- .settings/org.eclipse.jdt.core.prefs | 4 ++-- pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index cac0df4..43c8195 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/pom.xml b/pom.xml index e03e322..c819744 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,10 @@ - 2.9.0 + 2.7.0 UTF-8 UTF-8 - 1.8 + 1.7 1.8 From c89ca1ede668f2a08b53411a13fd5268ea5e0c13 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 10 Nov 2022 09:42:32 +0100 Subject: [PATCH 11/15] moved to source java 1.8 e gwt 2.8.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c819744..7275ca7 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,10 @@ - 2.7.0 + 2.8.2 UTF-8 UTF-8 - 1.7 + 1.8 1.8 From bc8852dd61571a51d117acec682c67e66fab3681 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 10 Nov 2022 10:00:29 +0100 Subject: [PATCH 12/15] moved to gwt 2.9.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7275ca7..e03e322 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ - 2.8.2 + 2.9.0 UTF-8 UTF-8 1.8 From d88bb99829c0ec392b5a0fb55c4098f4198cb4e7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 10 Nov 2022 10:03:17 +0100 Subject: [PATCH 13/15] #24111 Added dependencies required for building with JDK_11 --- CHANGELOG.md | 1 + pom.xml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fed1f5..1c681e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23544] Integrated with the fieldId added to gCube Metadata Profile - Moved to GWT 2.9 - Moed to maven-portal-bom 3.6.4 +- [#24111] Added dependencies required for building with JDK_11 ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/pom.xml b/pom.xml index e03e322..3e378dc 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,23 @@ + + + + org.projectlombok + lombok + 1.18.4 + provided + + + + javax.xml.bind + jaxb-api + 2.3.0 + provided + + + org.json From bf1959af7b2daa9fa6da22ee869af78a70bfb8a6 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 11 Nov 2022 10:10:54 +0100 Subject: [PATCH 14/15] Updated dependency as reported at #24111#note-1 --- CHANGELOG.md | 2 +- pom.xml | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c681e2..1b73b61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23544] Integrated with the fieldId added to gCube Metadata Profile - Moved to GWT 2.9 - Moed to maven-portal-bom 3.6.4 -- [#24111] Added dependencies required for building with JDK_11 +- [#24111] Added dependency required for building with JDK_11 ## [v1.0.1-SNAPSHOT] - 2020-10-08 diff --git a/pom.xml b/pom.xml index 3e378dc..1c31d47 100644 --- a/pom.xml +++ b/pom.xml @@ -99,13 +99,6 @@ - - - org.projectlombok - lombok - 1.18.4 - provided - javax.xml.bind @@ -114,6 +107,8 @@ provided + + From 55a63b3d3f01523dd3db950b01547f21cce6db6b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 14 Nov 2022 15:49:12 +0100 Subject: [PATCH 15/15] Only updated some description --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b73b61..8d76ffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,17 +4,17 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v2.0.0-SNAPSHOT] - 2022-11-09 +## [v2.0.0-SNAPSHOT] - 2022-11-14 -#### Enhancement +#### Enhancements - [#23188] Overloaded the method getProfilesInTheScope(forName) -- [#22890] Including the set/get currentValue for Update facility +- [#22890] Including the set/get currentValue for the "Update" facility - [#23188] Advanced the MultipleDilaogUpload with a more complex object - [#23544] Integrated with the fieldId added to gCube Metadata Profile -- Moved to GWT 2.9 -- Moed to maven-portal-bom 3.6.4 - [#24111] Added dependency required for building with JDK_11 +- Moved to GWT 2.9 +- Moved to maven-portal-bom 3.6.4 ## [v1.0.1-SNAPSHOT] - 2020-10-08