Merge pull request 'task_24166' (!2) from task_24166 into master

Reviewed-on: #2
This commit is contained in:
Francesco Mangiacrapa 2023-09-14 15:17:43 +02:00
commit 78c3c06d89
23 changed files with 786 additions and 529 deletions

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/home/francesco-mangiacrapa/git/metadata-profile-form-builder-widget/target/metadata-profile-form-builder-widget-0.1.0-SNAPSHOT jarsExcludedFromWebInfLib=
warSrcDir=src/main/webapp lastWarOutDir=/home/francesco-mangiacrapa/git/metadata-profile-form-builder-widget/target/metadata-profile-form-builder-widget-2.0.0
warSrcDir=
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -1,11 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 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.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,29 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="2.0.0">
<wb-module deploy-name="metadata-profile-form-builder-widget-0.1.0-SNAPSHOT">
<wb-module deploy-name="metadata-profile-form-builder-widget-2.0.0">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -33,7 +21,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
@ -41,6 +31,7 @@
<property name="context-root" value="metadata-profile-form-builder-widget"/> <property name="context-root" value="metadata-profile-form-builder-widget"/>
@ -48,6 +39,7 @@
<property name="java-output-path" value="/metadata-profile-form-builder-widget/target/classes"/> <property name="java-output-path" value="/metadata-profile-form-builder-widget/target/classes"/>
@ -55,6 +47,7 @@
</wb-module> </wb-module>
@ -62,4 +55,5 @@
</project-modules> </project-modules>

View File

@ -2,7 +2,6 @@
<faceted-project> <faceted-project>
<fixed facet="wst.jsdt.web"/> <fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/> <installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/> <installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
<installed facet="wst.jsdt.web" version="1.0"/> <installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.jaxrs" version="2.0"/> <installed facet="jst.jaxrs" version="2.0"/>

View File

@ -4,6 +4,13 @@
All notable changes to this project will be documented in this file. 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). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.1.0-SNAPSHOT] - 2023-02-01
#### Enhancements
- [#23188] Improved Legend "is required field"
- [#24515] Managed the files already uploaded
## [v2.0.0] - 2022-11-14 ## [v2.0.0] - 2022-11-14
#### Enhancements #### Enhancements

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId> <artifactId>metadata-profile-form-builder-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>2.0.0</version> <version>2.1.0-SNAPSHOT</version>
<name>Metadata Profile Form Builder</name> <name>Metadata Profile Form Builder</name>
<description> <description>
The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s" The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s"
@ -53,7 +53,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.4</version> <version>3.7.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -10,17 +10,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MetadataProfileFormBuilderServiceAsync { public interface MetadataProfileFormBuilderServiceAsync {
/**
* GWT-RPC service asynchronous (client-side) interface
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderService
*/
void getProfilesInTheScope(String scope, String genericResourceSecondaryType, AsyncCallback<List<MetaDataProfileBean>> callback);
void getProfileForMetadata(String metadata,
AsyncCallback<MetaDataProfileBean> callback);
/** /**
* Utility class to get the RPC Async interface from client-side code * Utility class to get the RPC Async interface from client-side code
*/ */
@ -39,6 +28,17 @@ public interface MetadataProfileFormBuilderServiceAsync {
} }
} }
/**
* GWT-RPC service asynchronous (client-side) interface
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.MetadataProfileFormBuilderService
*/
void getProfilesInTheScope(String scope, String genericResourceSecondaryType,
AsyncCallback<List<MetaDataProfileBean>> callback);
void getProfileForMetadata(String metadata, AsyncCallback<MetaDataProfileBean> callback);
void getUploadStatus(String clientUploadKey, AsyncCallback<FileUploadingState> asyncCallback); void getUploadStatus(String clientUploadKey, AsyncCallback<FileUploadingState> asyncCallback);
void purgeFilesUploaded(AsyncCallback<Integer> callback); void purgeFilesUploaded(AsyncCallback<Integer> callback);

View File

@ -62,19 +62,19 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
* Create metadata form for ckan product. * Create metadata form for ckan product.
*
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class CreateMetadataForm extends Composite implements HasGenericFormListenerRegistration{ public class CreateMetadataForm extends Composite implements HasGenericFormListenerRegistration {
/** The ui binder. */ /** The ui binder. */
private static EditMetadataFormUiBinder uiBinder = GWT private static EditMetadataFormUiBinder uiBinder = GWT.create(EditMetadataFormUiBinder.class);
.create(EditMetadataFormUiBinder.class);
/** The listeners generic form events. */ /** The listeners generic form events. */
private List<GenericFormEventsListener> listenersGenericFormEvents = new ArrayList<GenericFormEventsListener>(); private List<GenericFormEventsListener> listenersGenericFormEvents = new ArrayList<GenericFormEventsListener>();
/** /**
* The Interface EditMetadataFormUiBinder. * The Interface EditMetadataFormUiBinder.
* *
@ -82,88 +82,115 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* *
* Oct 1, 2020 * Oct 1, 2020
*/ */
interface EditMetadataFormUiBinder extends interface EditMetadataFormUiBinder extends UiBinder<Widget, CreateMetadataForm> {
UiBinder<Widget, CreateMetadataForm> {
} }
/** The create dataset main panel. */ /** The create dataset main panel. */
@UiField HTMLPanel createDatasetMainPanel; @UiField
HTMLPanel createDatasetMainPanel;
/** The custom fields. */ /** The custom fields. */
@UiField ControlGroup customFields; @UiField
ControlGroup customFields;
/** The custom fields group. */ /** The custom fields group. */
@UiField ControlGroup customFieldsGroup; @UiField
ControlGroup customFieldsGroup;
/** The add custom field button. */ /** The add custom field button. */
@UiField Button addCustomFieldButton; @UiField
Button addCustomFieldButton;
/** The create button. */ /** The create button. */
@UiField Button createButton; @UiField
Button createButton;
/** The create button. */ /** The create button. */
@UiField Button editButton; @UiField
Button editButton;
/** The info block. */ /** The info block. */
// @UiField Button resetButton; // @UiField Button resetButton;
@UiField AlertBlock infoBlock; @UiField
AlertBlock infoBlock;
/** The on continue alert block. */ /** The on continue alert block. */
@UiField AlertBlock onContinueAlertBlock; @UiField
AlertBlock onContinueAlertBlock;
/** The on create alert block. */ /** The on create alert block. */
@UiField AlertBlock onCreateAlertBlock; @UiField
AlertBlock onCreateAlertBlock;
/** The metadata fields panel. */ /** The metadata fields panel. */
@UiField VerticalPanel metadataFieldsPanel; @UiField
VerticalPanel metadataFieldsPanel;
@UiField
VerticalPanel filesUploadedPanel;
/** The metadata type listbox. */ /** The metadata type listbox. */
@UiField ListBox metadataTypeListbox; @UiField
ListBox metadataTypeListbox;
/** The form first step. */ /** The form first step. */
@UiField Form formFirstStep; @UiField
Form formFirstStep;
/** The form third step. */ /** The form third step. */
@UiField Form formThirdStep; @UiField
Form formThirdStep;
/** The selected profile. */ /** The selected profile. */
// @UiField Button continueButton; // @UiField Button continueButton;
@UiField Paragraph selectedProfile; @UiField
Paragraph selectedProfile;
/** The loader profiles. */ /** The loader profiles. */
@UiField LoaderIcon loaderProfiles; @UiField
LoaderIcon loaderProfiles;
/** The loader profile information. */ /** The loader profile information. */
@UiField LoaderIcon loaderProfileInformation; @UiField
//@UiField TagsPanel tagsPanel; LoaderIcon loaderProfileInformation;
// @UiField TagsPanel tagsPanel;
/** The info icon types. */ /** The info icon types. */
// info panels // info panels
@UiField Icon infoIconTypes; @UiField
Icon infoIconTypes;
/** The focus panel types. */ /** The focus panel types. */
@UiField FocusPanel focusPanelTypes; @UiField
FocusPanel focusPanelTypes;
/** The popover types. */ /** The popover types. */
@UiField Popover popoverTypes; @UiField
Popover popoverTypes;
/** The info icon custom fields. */ /** The info icon custom fields. */
@UiField Icon infoIconCustomFields; @UiField
Icon infoIconCustomFields;
/** The focus panel custom fields. */ /** The focus panel custom fields. */
@UiField FocusPanel focusPanelCustomFields; @UiField
FocusPanel focusPanelCustomFields;
/** The popover custom fields. */ /** The popover custom fields. */
@UiField Popover popoverCustomFields; @UiField
Popover popoverCustomFields;
/** The metadata types control group. */ /** The metadata types control group. */
@UiField ControlGroup metadataTypesControlGroup; @UiField
ControlGroup metadataTypesControlGroup;
/** The custom legend. */ /** The custom legend. */
@UiField CustomLegend customLegend; @UiField
CustomLegend customLegend;
/** The form builder service. */ /** The form builder service. */
private final MetadataProfileFormBuilderServiceAsync formBuilderService = GWT.create(MetadataProfileFormBuilderService.class); private final MetadataProfileFormBuilderServiceAsync formBuilderService = GWT
.create(MetadataProfileFormBuilderService.class);
/** The Constant NONE_PROFILE. */ /** The Constant NONE_PROFILE. */
private static final String NONE_PROFILE = "none"; private static final String NONE_PROFILE = "none";
@ -208,7 +235,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
private List<MetaDataField> listOfMetadataFields = new ArrayList<MetaDataField>(); private List<MetaDataField> listOfMetadataFields = new ArrayList<MetaDataField>();
// dataset metadata bean // dataset metadata bean
//private DatasetBean receivedBean; // private DatasetBean receivedBean;
/** The owner. */ /** The owner. */
// the owner // the owner
@ -232,7 +259,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
/** The generic resource secondary type. */ /** The generic resource secondary type. */
private String genericResourceSecondaryType; private String genericResourceSecondaryType;
/** The metadata profiles. */ /** The metadata profiles. */
private List<MetaDataProfileBean> metadataProfiles; private List<MetaDataProfileBean> metadataProfiles;
@ -241,20 +267,33 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
private OPERATION operationPerfom; private OPERATION operationPerfom;
public enum OPERATION {NEW, UPDATE} /**
* The Enum OPERATION.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 15, 2023
*/
public enum OPERATION {
NEW, UPDATE
}
private UploadedFilesBrowse uploadedFileBrowse;
/** /**
* Invoked in the most general case. * Invoked in the most general case.
* *
* @param scope the scope * @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type * @param genericResourceSecondaryType the generic resource secondary type
* @param eventBus the event bus
*/ */
public CreateMetadataForm(String scope, String genericResourceSecondaryType, HandlerManager eventBus) { public CreateMetadataForm(String scope, String genericResourceSecondaryType, HandlerManager eventBus) {
this(eventBus); this(eventBus);
this.scope = scope; this.scope = scope;
this.genericResourceSecondaryType = genericResourceSecondaryType; this.genericResourceSecondaryType = genericResourceSecondaryType;
showLoadingProfiles(true); showLoadingProfiles(true);
MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope, genericResourceSecondaryType, new AsyncCallback<List<MetaDataProfileBean>>() { MetadataProfileFormBuilderServiceAsync.Util.getInstance().getProfilesInTheScope(scope,
genericResourceSecondaryType, new AsyncCallback<List<MetaDataProfileBean>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -262,7 +301,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
@Override @Override
public void onSuccess(List<MetaDataProfileBean> profiles) { public void onSuccess(List<MetaDataProfileBean> profiles) {
createDatasetFormBody(profiles); createDatasetFormBody(profiles, null);
showLoadingProfiles(false); showLoadingProfiles(false);
} }
@ -270,20 +309,37 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
} }
/** /**
* Instantiates a new creates the dataset form. * Instantiates a new creates the dataset form.
* *
* @param profiles the profiles * @param profiles the profiles
* @param eventBus the event bus
* @param operation the operation
*/ */
public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus, OPERATION operation) { public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus, OPERATION operation) {
this(eventBus); this(eventBus);
this.operationPerfom = operation; this.operationPerfom = operation;
showLoadingProfiles(true); showLoadingProfiles(true);
createDatasetFormBody(profiles); createDatasetFormBody(profiles, null);
showLoadingProfiles(false); showLoadingProfiles(false);
} }
/**
* Instantiates a new creates the metadata form.
*
* @param profiles the profiles
* @param eventBus the event bus
* @param operation the operation
* @param listFileUploaded the list file uploaded
*/
public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus, OPERATION operation,
List<? extends FileUploaded> listFileUploaded) {
this(eventBus);
this.operationPerfom = operation;
showLoadingProfiles(true);
createDatasetFormBody(profiles, listFileUploaded);
showLoadingProfiles(false);
}
/** /**
* Show choose profile form. * Show choose profile form.
@ -294,10 +350,10 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
formFirstStep.setVisible(bool); formFirstStep.setVisible(bool);
} }
/** /**
* Instantiates a new creates the dataset form. * Instantiates a new creates the dataset form.
* @param eventBus2 *
* @param eventBus the event bus
*/ */
private CreateMetadataForm(HandlerManager eventBus) { private CreateMetadataForm(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
@ -309,7 +365,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
showCustomFieldsEntries(false); showCustomFieldsEntries(false);
} }
/** /**
* Show loading profiles. * Show loading profiles.
* *
@ -330,7 +385,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
loaderProfileInformation.setVisible(bool); loaderProfileInformation.setVisible(bool);
} }
/** /**
* Bind on events. * Bind on events.
*/ */
@ -358,34 +412,36 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* Creates the dataset form body. * Creates the dataset form body.
* *
* @param profiles the profiles * @param profiles the profiles
* @param listFileUploaded the list file uploaded
*/ */
private void createDatasetFormBody(final List<MetaDataProfileBean> profiles){ private void createDatasetFormBody(final List<MetaDataProfileBean> profiles,
List<? extends FileUploaded> listFileUploaded) {
if(profiles == null){ if (profiles == null) {
setAlertBlock("An unknow error occurred while retrieving types, sorry", AlertType.ERROR, true); setAlertBlock("An unknow error occurred while retrieving types, sorry", AlertType.ERROR, true);
} } else {
else{
this.metadataProfiles = profiles; this.metadataProfiles = profiles;
prepareMetadataList(profiles); prepareMetadataList(profiles, listFileUploaded);
metadataTypeListbox.setEnabled(true); metadataTypeListbox.setEnabled(true);
} }
} }
/** /**
* Add the items to the listbox and put data into the metadataPanel. * Add the items to the listbox and put data into the metadataPanel.
* *
* @param profiles the profiles * @param profiles the profiles
* @param listFileUploaded the file uploaded
*/ */
private void prepareMetadataList(final List<MetaDataProfileBean> profiles) { private void prepareMetadataList(final List<MetaDataProfileBean> profiles,
List<? extends FileUploaded> listFileUploaded) {
if(profiles != null && !profiles.isEmpty()){ if (profiles != null && !profiles.isEmpty()) {
GWT.log("Building form/s for profile/s: "+profiles); GWT.log("Building form/s for profile/s: " + profiles);
if(profiles.size()>1) if (profiles.size() > 1)
showChooseProfileForm(true); showChooseProfileForm(true);
for(MetaDataProfileBean metadataBean: profiles){ for (MetaDataProfileBean metadataBean : profiles) {
metadataTypeListbox.addItem(metadataBean.getType()); metadataTypeListbox.addItem(metadataBean.getType());
} }
@ -398,29 +454,30 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
String selectedItemText = metadataTypeListbox.getSelectedItemText(); String selectedItemText = metadataTypeListbox.getSelectedItemText();
metadataFieldsPanel.clear(); metadataFieldsPanel.clear();
if(selectedItemText.equals(NONE_PROFILE)){ if (selectedItemText.equals(NONE_PROFILE)) {
metadataFieldsPanel.setVisible(false); metadataFieldsPanel.setVisible(false);
formThirdStep.setVisible(false); formThirdStep.setVisible(false);
selectedProfile.setText("Selected Profile is " + NONE_PROFILE); selectedProfile.setText("Selected Profile is " + NONE_PROFILE);
//receivedBean.setChosenType(null); // receivedBean.setChosenType(null);
}else{ } else {
//receivedBean.setChosenType(selectedItemText); // receivedBean.setChosenType(selectedItemText);
showLoadingProfileInformation(true); showLoadingProfileInformation(true);
formThirdStep.setVisible(true); formThirdStep.setVisible(true);
customLegend.setText("Insert Information for: "+metadataTypeListbox.getSelectedItemText(), true); customLegend.setText("Insert Information for: " + metadataTypeListbox.getSelectedItemText(),
true);
selectedProfile.setText("Selected Profile is " + metadataTypeListbox.getSelectedItemText()); selectedProfile.setText("Selected Profile is " + metadataTypeListbox.getSelectedItemText());
addFields(selectedItemText, profiles); addFields(selectedItemText, profiles, listFileUploaded);
showLoadingProfileInformation(false); showLoadingProfileInformation(false);
} }
} }
}); });
}else{ } else {
// just hide this listbox // just hide this listbox
metadataTypesControlGroup.setVisible(false); metadataTypesControlGroup.setVisible(false);
metadataFieldsPanel.clear(); metadataFieldsPanel.clear();
listOfMetadataFields.clear(); listOfMetadataFields.clear();
//receivedBean.setChosenType(null); // receivedBean.setChosenType(null);
} }
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -443,11 +500,13 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* *
* @param selectedItem the selected item * @param selectedItem the selected item
* @param listProfiles the list profiles * @param listProfiles the list profiles
* @param listFileUploaded the list file uploaded
*/ */
protected void addFields(String selectedItem, List<MetaDataProfileBean> listProfiles) { protected void addFields(String selectedItem, List<MetaDataProfileBean> listProfiles,
List<? extends FileUploaded> listFileUploaded) {
for(MetaDataProfileBean bean: listProfiles){ for (MetaDataProfileBean bean : listProfiles) {
if(bean.getType().equals(selectedItem)){ if (bean.getType().equals(selectedItem)) {
// clear old data // clear old data
listOfMetadataFields.clear(); listOfMetadataFields.clear();
@ -458,16 +517,14 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
GWT.log("There are " + categories.size() + " categories for profile " + bean.getTitle()); GWT.log("There are " + categories.size() + " categories for profile " + bean.getTitle());
if(categories == null || categories.isEmpty()){ if (categories == null || categories.isEmpty()) {
for (MetadataFieldWrapper field : fields) { for (MetadataFieldWrapper field : fields) {
/*MetaDataFieldSkeleton fieldWidget; /*
try { * MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
fieldWidget = new MetaDataFieldSkeleton(field, eventBus); * MetaDataFieldSkeleton(field, eventBus); metadataFieldsPanel.add(fieldWidget);
metadataFieldsPanel.add(fieldWidget); * listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
listOfMetadataFields.add(fieldWidget); * GWT.log("Unable to build such widget", e); }
} catch (Exception e) { */
GWT.log("Unable to build such widget", e);
}*/
MetaDataField fieldWidget; MetaDataField fieldWidget;
try { try {
@ -478,29 +535,31 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
GWT.log("Unable to build such widget", e); GWT.log("Unable to build such widget", e);
} }
} }
}else{ } else {
// create the categories, then parse the fields. Fields do not belonging to a category are put at the end // create the categories, then parse the fields. Fields do not belonging to a
// category are put at the end
for (CategoryWrapper categoryWrapper : categories) { for (CategoryWrapper categoryWrapper : categories) {
if(categoryWrapper.getFieldsForThisCategory() != null && categoryWrapper.getFieldsForThisCategory().size() > 0){ if (categoryWrapper.getFieldsForThisCategory() != null
CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(), categoryWrapper.getDescription()); && categoryWrapper.getFieldsForThisCategory().size() > 0) {
List<MetadataFieldWrapper> fieldsForThisCategory = categoryWrapper.getFieldsForThisCategory(); CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(),
categoryWrapper.getDescription());
List<MetadataFieldWrapper> fieldsForThisCategory = categoryWrapper
.getFieldsForThisCategory();
fields.removeAll(fieldsForThisCategory); fields.removeAll(fieldsForThisCategory);
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) { for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
/*MetaDataFieldSkeleton fieldWidget; /*
try { * MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
fieldWidget = new MetaDataFieldSkeleton(metadataFieldWrapper, eventBus); * MetaDataFieldSkeleton(metadataFieldWrapper, eventBus);
cp.addField(fieldWidget); * cp.addField(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch
listOfMetadataFields.add(fieldWidget); * (Exception e) { GWT.log("Unable to build such widget", e); }
} catch (Exception e) { */
GWT.log("Unable to build such widget", e);
}*/
MetaDataField fieldWidget; MetaDataField fieldWidget;
try { try {
fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus,operationPerfom); fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus, operationPerfom);
cp.addField(fieldWidget); cp.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget); listOfMetadataFields.add(fieldWidget);
} catch (Exception e) { } catch (Exception e) {
@ -515,14 +574,12 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
CategoryPanel extrasCategory = new CategoryPanel("Other", null); CategoryPanel extrasCategory = new CategoryPanel("Other", null);
for (MetadataFieldWrapper field : fields) { for (MetadataFieldWrapper field : fields) {
/*MetaDataFieldSkeleton fieldWidget; /*
try { * MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
fieldWidget = new MetaDataFieldSkeleton(field, eventBus); * MetaDataFieldSkeleton(field, eventBus); extrasCategory.addField(fieldWidget);
extrasCategory.addField(fieldWidget); * listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
listOfMetadataFields.add(fieldWidget); * GWT.log("Unable to build such widget", e); }
} catch (Exception e) { */
GWT.log("Unable to build such widget", e);
}*/
MetaDataField fieldWidget; MetaDataField fieldWidget;
try { try {
@ -538,8 +595,13 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
metadataFieldsPanel.setVisible(true); metadataFieldsPanel.setVisible(true);
} }
} }
}
if (listFileUploaded != null && listFileUploaded.size() > 0) {
filesUploadedPanel.setVisible(true);
uploadedFileBrowse = new UploadedFilesBrowse(listFileUploaded);
filesUploadedPanel.add(uploadedFileBrowse);
}
}
/** /**
* Adds the custom field event. * Adds the custom field event.
@ -547,7 +609,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @param e the e * @param e the e
*/ */
@UiHandler("addCustomFieldButton") @UiHandler("addCustomFieldButton")
void addCustomFieldEvent(ClickEvent e){ void addCustomFieldEvent(ClickEvent e) {
CustomFieldEntry toAdd = new CustomFieldEntry(uiBus, "", "", true); CustomFieldEntry toAdd = new CustomFieldEntry(uiBus, "", "", true);
customFieldEntriesList.add(toAdd); customFieldEntriesList.add(toAdd);
@ -555,23 +617,22 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
} }
/** /**
* Creates the dataset event. * Creates the dataset event.
* *
* @param e the e * @param e the e
*/ */
@UiHandler("createButton") @UiHandler("createButton")
void createDatasetEvent(ClickEvent e){ void createDatasetEvent(ClickEvent e) {
String errorMessage = areProfileDataValid(); String errorMessage = areProfileDataValid();
if(errorMessage != null){ if (errorMessage != null) {
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage +"]", AlertType.ERROR, true); alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage + "]",
} AlertType.ERROR, true);
else{ } else {
//Set<String> tags = new HashSet<String>(tagsPanel.getTags()); // Set<String> tags = new HashSet<String>(tagsPanel.getTags());
List<OrganizationBean> groups = new ArrayList<OrganizationBean>(); List<OrganizationBean> groups = new ArrayList<OrganizationBean>();
List<OrganizationBean> groupsToForceCreation = new ArrayList<OrganizationBean>(); List<OrganizationBean> groupsToForceCreation = new ArrayList<OrganizationBean>();
LinkedHashMap<String, List<String>> customFieldsMap = new LinkedHashMap<String, List<String>>(); LinkedHashMap<String, List<String>> customFieldsMap = new LinkedHashMap<String, List<String>>();
@ -585,17 +646,17 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
switch (field.getField().getType()) { switch (field.getField().getType()) {
case File: case File:
DialogUpload dUpload = (DialogUpload) field.getHolder(); DialogUpload dUpload = (DialogUpload) field.getHolder();
//adding it only if exists // adding it only if exists
if(dUpload.getFileUploadingState()!=null) if (dUpload.getFileUploadingState() != null)
listFilesUploaded.add(dUpload.getFileUploadingState().getFile()); listFilesUploaded.add(dUpload.getFileUploadingState().getFile());
break; break;
default: default:
List<String> valuesForField = field.getFieldCurrentValue(); List<String> valuesForField = field.getFieldCurrentValue();
if(!valuesForField.isEmpty()){ if (!valuesForField.isEmpty()) {
String key = field.getFieldNameQualified(); String key = field.getFieldNameQualified();
List<String> valuesForThisField = null; List<String> valuesForThisField = null;
if(customFieldsMap.containsKey(key)) if (customFieldsMap.containsKey(key))
valuesForThisField = customFieldsMap.get(key); valuesForThisField = customFieldsMap.get(key);
else else
valuesForThisField = new ArrayList<String>(); valuesForThisField = new ArrayList<String>();
@ -609,12 +670,14 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
// tags.addAll(tagsField); // tags.addAll(tagsField);
List<String> groupsTitle = field.getGroupTitleFromThisGroup(); List<String> groupsTitle = field.getGroupTitleFromThisGroup();
if(groupsTitle != null){ if (groupsTitle != null) {
for (String groupTitle : groupsTitle) { for (String groupTitle : groupsTitle) {
if(field.isGroupToForce()) if (field.isGroupToForce())
groupsToForceCreation.add(new OrganizationBean(groupTitle, groupTitle, false, field.isPropagateUp())); groupsToForceCreation.add(new OrganizationBean(groupTitle, groupTitle, false,
field.isPropagateUp()));
else else
groups.add(new OrganizationBean(groupTitle, groupTitle, false, field.isPropagateUp())); groups.add(new OrganizationBean(groupTitle, groupTitle, false,
field.isPropagateUp()));
} }
} }
} }
@ -623,12 +686,12 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
} }
} }
for(CustomFieldEntry customEntry : customFieldEntriesList){ for (CustomFieldEntry customEntry : customFieldEntriesList) {
String key = customEntry.getKey(); String key = customEntry.getKey();
String value = customEntry.getValue(); String value = customEntry.getValue();
if(value != null && !value.isEmpty()){ if (value != null && !value.isEmpty()) {
List<String> valuesForThisField = null; List<String> valuesForThisField = null;
if(customFieldsMap.containsKey(key)) if (customFieldsMap.containsKey(key))
valuesForThisField = customFieldsMap.get(key); valuesForThisField = customFieldsMap.get(key);
else else
valuesForThisField = new ArrayList<String>(); valuesForThisField = new ArrayList<String>();
@ -641,6 +704,16 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
GenericDatasetBean gdb = new GenericDatasetBean(); GenericDatasetBean gdb = new GenericDatasetBean();
gdb.setMetadataProfileList(metadataProfiles); gdb.setMetadataProfileList(metadataProfiles);
gdb.setFormDataEntryFields(customFieldsMap); gdb.setFormDataEntryFields(customFieldsMap);
// THIS IS TRUE IN UPDATE MODE
if (uploadedFileBrowse != null) {
List<FileUploaded> rFilesUploaded = uploadedFileBrowse.getListRemainingFileUploaded();
if (rFilesUploaded != null) {
GWT.log("Added to FilesUploaded the remaining (current content) files: " + rFilesUploaded);
listFilesUploaded.addAll(rFilesUploaded);
}
}
gdb.setFilesUploaded(listFilesUploaded); gdb.setFilesUploaded(listFilesUploaded);
formDataBean = gdb; formDataBean = gdb;
@ -661,7 +734,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @param e the e * @param e the e
*/ */
@UiHandler("editButton") @UiHandler("editButton")
void editButtonClickHandler(ClickEvent e){ void editButtonClickHandler(ClickEvent e) {
formDataBean = null; formDataBean = null;
createButton.setEnabled(true); createButton.setEnabled(true);
createButton.setVisible(true); createButton.setVisible(true);
@ -671,7 +744,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
notifyOnEditForm(); notifyOnEditForm();
} }
/** /**
* Checks if is form data valid. * Checks if is form data valid.
* *
@ -679,19 +751,18 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
*/ */
public boolean isFormDataValid() { public boolean isFormDataValid() {
//means no error // means no error
if(areProfileDataValid() == null) { if (areProfileDataValid() == null) {
//means created button already fired // means created button already fired
if(formDataBean != null) { if (formDataBean != null) {
return true; return true;
}else { } else {
alertOnCreate("Please press the button 'Create' to confirm your data entries", AlertType.ERROR, true); alertOnCreate("Please press the button 'Create' to confirm your data entries", AlertType.ERROR, true);
} }
} }
return false; return false;
} }
/** /**
* Gets the form data bean. * Gets the form data bean.
* *
@ -707,30 +778,17 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
private void prepareInfoIcons() { private void prepareInfoIcons() {
// tags // tags
//tagsPanel.prepareIcon(popupOpenedIds); // tagsPanel.prepareIcon(popupOpenedIds);
// profiles (or types) // profiles (or types)
InfoIconsLabels.preparePopupPanelAndPopover( InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.PROFILES_INFO_ID_POPUP,
InfoIconsLabels.PROFILES_INFO_ID_POPUP, InfoIconsLabels.PROFILES_INFO_TEXT, InfoIconsLabels.PROFILES_INFO_CAPTION, infoIconTypes, popoverTypes,
InfoIconsLabels.PROFILES_INFO_TEXT, focusPanelTypes, popupOpenedIds);
InfoIconsLabels.PROFILES_INFO_CAPTION,
infoIconTypes,
popoverTypes,
focusPanelTypes,
popupOpenedIds
);
// custom fields // custom fields
InfoIconsLabels.preparePopupPanelAndPopover( InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP,
InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP, InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT, InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT, infoIconCustomFields, popoverCustomFields, focusPanelCustomFields, popupOpenedIds);
InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
infoIconCustomFields,
popoverCustomFields,
focusPanelCustomFields,
popupOpenedIds
);
} }
/** /**
@ -747,7 +805,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
field.removeError(); field.removeError();
String error = field.isFieldValueValid(); String error = field.isFieldValueValid();
if(error != null){ if (error != null) {
field.showError(); field.showError();
String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error; String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
notifyValidationError(null, errorMsg); notifyValidationError(null, errorMsg);
@ -766,16 +824,16 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @param type the type * @param type the type
* @param hideAfterAWhile the hide after A while * @param hideAfterAWhile the hide after A while
*/ */
private void alertOnCreate(String text, AlertType type, boolean hideAfterAWhile){ private void alertOnCreate(String text, AlertType type, boolean hideAfterAWhile) {
//Window.alert("Called alertOnCreate"); // Window.alert("Called alertOnCreate");
onCreateAlertBlock.setText(text); onCreateAlertBlock.setText(text);
onCreateAlertBlock.setType(type); onCreateAlertBlock.setType(type);
onCreateAlertBlock.setVisible(true); onCreateAlertBlock.setVisible(true);
createButton.setEnabled(true); createButton.setEnabled(true);
//goBackButtonSecondStep.setEnabled(true); // goBackButtonSecondStep.setEnabled(true);
if(hideAfterAWhile){ if (hideAfterAWhile) {
// hide after some seconds // hide after some seconds
Timer t = new Timer() { Timer t = new Timer() {
@ -795,26 +853,25 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* *
* @param bool the bool * @param bool the bool
*/ */
/*@UiHandler("resetButton") /*
void resetFormEvent(ClickEvent e){ * @UiHandler("resetButton") void resetFormEvent(ClickEvent e){
*
// delete custom fields * // delete custom fields for (CustomFieldEntry customField :
for (CustomFieldEntry customField : customFieldEntriesList) { * customFieldEntriesList) { customField.removeFromParent(); }
customField.removeFromParent(); * customFieldEntriesList.clear(); }
} */
customFieldEntriesList.clear();
}*/
/** /**
* Disable dataset editable fields once the dataset has been successfully created. * Disable dataset editable fields once the dataset has been successfully
* created.
*/ */
protected void disableDatasetFields(boolean bool) { protected void disableDatasetFields(boolean bool) {
//tagsPanel.freeze(); // tagsPanel.freeze();
addCustomFieldButton.setEnabled(!bool); addCustomFieldButton.setEnabled(!bool);
metadataTypeListbox.setEnabled(!bool); metadataTypeListbox.setEnabled(!bool);
for(CustomFieldEntry ce: customFieldEntriesList) for (CustomFieldEntry ce : customFieldEntriesList)
ce.freeze(!bool); ce.freeze(!bool);
// disable profile fields // disable profile fields
@ -826,8 +883,16 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
} }
// freeze table of resources // freeze table of resources
if(resourcesTwinPanel != null) if (resourcesTwinPanel != null)
resourcesTwinPanel.freeze(bool); resourcesTwinPanel.freeze(bool);
// TRUE in UPDATE MODE - freeze manage of current content (means file already
// uploaded)
if (uploadedFileBrowse != null) {
uploadedFileBrowse.enableManageOfContent(!bool);
}
} }
/** /**
@ -837,7 +902,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @param type the type * @param type the type
* @param visible the visible * @param visible the visible
*/ */
private void setAlertBlock(String textToShow, AlertType type, boolean visible){ private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
infoBlock.setText(textToShow); infoBlock.setText(textToShow);
infoBlock.setType(type); infoBlock.setType(type);
@ -864,14 +929,18 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
this.selectedProfile.setVisible(show); this.selectedProfile.setVisible(show);
} }
/** /**
* Adds the listener. * Adds the listener.
* *
* @param listener the listener * @param listener the listener
*/ */
/* (non-Javadoc) /*
* @see org.gcube.portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.HasGenericFormListenerRegistration#addListener(org.gcube.portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.GenericFormEventsListener) * (non-Javadoc)
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.form.generic.
* GenericFormEvents.HasGenericFormListenerRegistration#addListener(org.gcube.
* portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.
* GenericFormEventsListener)
*/ */
@Override @Override
public void addListener(GenericFormEventsListener listener) { public void addListener(GenericFormEventsListener listener) {
@ -883,14 +952,18 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
} }
} }
/** /**
* Removes the listener. * Removes the listener.
* *
* @param listener the listener * @param listener the listener
*/ */
/* (non-Javadoc) /*
* @see org.gcube.portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.HasGenericFormListenerRegistration#removeListener(org.gcube.portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.GenericFormEventsListener) * (non-Javadoc)
*
* @see org.gcube.portlets.widgets.mpformbuilder.client.form.generic.
* GenericFormEvents.HasGenericFormListenerRegistration#removeListener(org.gcube
* .portlets.widgets.mpformbuilder.client.form.generic.GenericFormEvents.
* GenericFormEventsListener)
*/ */
@Override @Override
public void removeListener(GenericFormEventsListener listener) { public void removeListener(GenericFormEventsListener listener) {
@ -899,13 +972,12 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
listenersGenericFormEvents.remove(listener); listenersGenericFormEvents.remove(listener);
} }
/** /**
* Notify valid form. * Notify valid form.
* *
* @param genericDatasetBean the generic dataset bean * @param genericDatasetBean the generic dataset bean
*/ */
private void notifyValidForm(GenericDatasetBean genericDatasetBean){ private void notifyValidForm(GenericDatasetBean genericDatasetBean) {
for (GenericFormEventsListener listener : listenersGenericFormEvents) { for (GenericFormEventsListener listener : listenersGenericFormEvents) {
listener.onFormDataValid(genericDatasetBean); listener.onFormDataValid(genericDatasetBean);
} }
@ -913,23 +985,20 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
/** /**
* Notify valid form. * Notify valid form.
*
* @param genericDatasetBean the generic dataset bean
*/ */
private void notifyOnEditForm(){ private void notifyOnEditForm() {
for (GenericFormEventsListener listener : listenersGenericFormEvents) { for (GenericFormEventsListener listener : listenersGenericFormEvents) {
listener.onFormDataEdit(); listener.onFormDataEdit();
} }
} }
/** /**
* Notify validation error. * Notify validation error.
* *
* @param throwable the throwable * @param throwable the throwable
* @param errorMsg the error msg * @param errorMsg the error msg
*/ */
private void notifyValidationError(Throwable throwable, String errorMsg){ private void notifyValidationError(Throwable throwable, String errorMsg) {
// listenersSize(); // listenersSize();
for (GenericFormEventsListener listener : listenersGenericFormEvents) { for (GenericFormEventsListener listener : listenersGenericFormEvents) {
listener.onValidationError(throwable, errorMsg); listener.onValidationError(throwable, errorMsg);
@ -945,7 +1014,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
// return createButton; // return createButton;
// } // }
/** /**
* Gets the metadata profiles. * Gets the metadata profiles.
* *

View File

@ -59,10 +59,6 @@
<b:Fieldset styleName="{style.fieldset-border-style}"> <b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}"> <b:Legend styleName="{style.legend-style}">
Choose a Profile Choose a Profile
<!-- <small> -->
<!-- <span style="color:red;">*</span> -->
<!-- is required -->
<!-- </small> -->
</b:Legend> </b:Legend>
<!-- Alert blocks for info/errors --> <!-- Alert blocks for info/errors -->
@ -91,18 +87,11 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<!-- TAGS Panel -->
<!-- <m:TagsPanel ui:field="tagsPanel"></m:TagsPanel> -->
<!-- Alert block on continue --> <!-- Alert block on continue -->
<b:AlertBlock type="INFO" close="false" <b:AlertBlock type="INFO" close="false"
animation="true" visible="false" ui:field="onContinueAlertBlock"> animation="true" visible="false" ui:field="onContinueAlertBlock">
</b:AlertBlock> </b:AlertBlock>
<!-- <b:Button title="Continue" ui:field="continueButton" type="PRIMARY" -->
<!-- block="true">Continue</b:Button> -->
<!-- <b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button> -->
</b:Fieldset> </b:Fieldset>
</b:Form> </b:Form>
@ -112,14 +101,6 @@
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}" <b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formThirdStep" visible="false"> ui:field="formThirdStep" visible="false">
<b:Fieldset styleName="{style.fieldset-border-style}"> <b:Fieldset styleName="{style.fieldset-border-style}">
<!-- <b:Legend styleName="{style.legend-style}" -->
<!-- ui:field="legendInsertInformation"> -->
<!-- Insert Information -->
<!-- <small> -->
<!-- <span style="color:red;">*</span> -->
<!-- is required -->
<!-- </small> -->
<!-- </b:Legend> -->
<u:CustomLegend ui:field="customLegend"> <u:CustomLegend ui:field="customLegend">
Insert Information Insert Information
@ -136,6 +117,9 @@
<g:VerticalPanel ui:field="metadataFieldsPanel" <g:VerticalPanel ui:field="metadataFieldsPanel"
visible="false" width="100%"></g:VerticalPanel> visible="false" width="100%"></g:VerticalPanel>
<g:VerticalPanel ui:field="filesUploadedPanel"
visible="false" width="100%"></g:VerticalPanel>
<!-- Custom fields can be dinamically added --> <!-- Custom fields can be dinamically added -->
<b:ControlGroup ui:field="customFields" <b:ControlGroup ui:field="customFields"
visible="false"> visible="false">
@ -165,27 +149,12 @@
styleName="{style.block-alert-style}"> styleName="{style.block-alert-style}">
</b:AlertBlock> </b:AlertBlock>
<!-- <g:HorizontalPanel ui:field="goToDatasetButtonPanel" visible="false"> -->
<!-- <g:Label>Go to the Item</g:Label> -->
<!-- <b:Button title="Go to the Item" ui:field="goToDatasetButton" -->
<!-- type="LINK" visible="false" styleName="{style.the-margin-left}"></b:Button> -->
<!-- </g:HorizontalPanel> -->
<!-- <b:Button title="Add resources to the just created item" -->
<!-- block="true" type="PRIMARY" visible="false" ui:field="addResourcesButton">Add
Resources</b:Button> -->
<b:Button title="Create Item" ui:field="createButton" <b:Button title="Create Item" ui:field="createButton"
type="PRIMARY" block="true">Create</b:Button> type="PRIMARY" block="true">Create</b:Button>
<b:Button title="Edit Item" ui:field="editButton" <b:Button title="Edit Item" ui:field="editButton"
type="PRIMARY" block="true" visible="false">Edit</b:Button> type="PRIMARY" block="true" visible="false">Edit</b:Button>
<!-- <b:Button title="Go Back" ui:field="goBackButtonSecondStep" -->
<!-- block="true">Go -->
<!-- Back</b:Button> -->
</b:Fieldset> </b:Fieldset>
</b:Form> </b:Form>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -0,0 +1,130 @@
package org.gcube.portlets.widgets.mpformbuilder.client.form.generic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploadedRemote;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class UploadedFilesBrowse<T extends FileUploaded> extends Composite {
private static UploadedFilesBrowseUiBinder uiBinder = GWT.create(UploadedFilesBrowseUiBinder.class);
interface UploadedFilesBrowseUiBinder extends UiBinder<Widget, UploadedFilesBrowse> {
}
private List<T> listFileUploaded;
@UiField
HTMLPanel uploadFileContainer;
private FlexTable table = new FlexTable();
private List<Button> listButtonRemove = new ArrayList<Button>();
private HashMap<Integer, T> mapPositionalFU = new HashMap<Integer, T>();
public UploadedFilesBrowse(List<T> fileUploaded) {
initWidget(uiBinder.createAndBindUi(this));
this.listFileUploaded = fileUploaded;
// Filling map of files uploaded
int i = 0;
for (T file : listFileUploaded) {
mapPositionalFU.put(i, file);
i++;
}
showFileBrowseInteraction();
}
private void showFileBrowseInteraction() {
uploadFileContainer.clear();
// pathIndex = pathContentIndex;
// GWT.log("showing pathContentIndex: "+pathContentIndex);
GWT.log("showing files: " + listFileUploaded);
table.clear();
if (listFileUploaded.size() > 0) {
table.addStyleName("table-current-content");
table.setHTML(0, 0, "<span style='color:rgb(155, 80, 78); font-weight:bold;'>Current content:</span>");
table.setHTML(1, 0, "<span style='color:rgb(155, 80, 78);'>Filename</span>");
table.setHTML(1, 1, "<span style='color:rgb(155, 80, 78);'>MimeType<span>");
table.setHTML(1, 2, "<span style='color:rgb(155, 80, 78);'>Field Label</span>");
table.setHTML(1, 3, "<span style='color:rgb(155, 80, 78);'>Link</span>");
int i = 2;
int index = 0;
for (final FileUploaded file : listFileUploaded) {
final int filePointer = index;
int columnIndex = 0;
table.setHTML(i, columnIndex, file.getFileName());
if (file instanceof FileUploadedRemote) {
FileUploadedRemote fur = (FileUploadedRemote) file;
table.setHTML(i, ++columnIndex, fur.getMimeType());
String fieldLabel = file.getFilePath().getFormFieldLabel();
table.setHTML(i, ++columnIndex, fieldLabel);
String link = "<a target=\"_blank\" href=" + fur.getUrl() + ">View</a>";
table.setHTML(i, ++columnIndex, link);
}
final int rowIndexToRem = i;
Button buttonRemoveFile = new Button();
buttonRemoveFile.setIcon(IconType.TRASH);
buttonRemoveFile.setTitle("Remove this file");
buttonRemoveFile.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
mapPositionalFU.remove(filePointer);
table.getRowFormatter().getElement(rowIndexToRem).setAttribute("hidden", "hidden");
}
});
listButtonRemove.add(buttonRemoveFile);
table.setWidget(i, ++columnIndex, buttonRemoveFile);
i++;
index++;
}
uploadFileContainer.add(table);
}
}
public void enableManageOfContent(boolean bool) {
for (Button button : listButtonRemove) {
button.setEnabled(bool);
}
double opacity = bool ? 1 : 0.8;
uploadFileContainer.getElement().getStyle().setOpacity(opacity);
}
public List<T> getListRemainingFileUploaded() {
Collection<T> collFileUplaoded = mapPositionalFU.values();
if (collFileUplaoded != null)
return new ArrayList<T>(collFileUplaoded);
return null;
}
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.padding-panel {
padding-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="uploadFileContainer"
addStyleNames="{style.padding-panel}"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -149,7 +149,7 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentSingleValue() != null)
((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue())); ((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue()));
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
@ -171,8 +171,8 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentSingleValue() != null)
textArea.setText((String) field.getCurrentValue()); textArea.setText((String) field.getCurrentSingleValue());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -243,8 +243,8 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentSingleValue() != null)
((TextArea) holder).setText((String) field.getCurrentValue()); ((TextArea) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -268,8 +268,8 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
// set time, if present // set time, if present
try { try {
if (field.getCurrentValue() != null) { if (field.getCurrentSingleValue() != null) {
String currentValue = (String) field.getCurrentValue(); String currentValue = (String) field.getCurrentSingleValue();
String[] dateAndTime = currentValue.split(" "); String[] dateAndTime = currentValue.split(" ");
if (dateAndTime.length > 0) { if (dateAndTime.length > 0) {
ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null); ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null);
@ -290,7 +290,7 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
// set time, if present // set time, if present
try { try {
setRangeTimeInTimeBox((String) field.getCurrentValue(), rangeBox); setRangeTimeInTimeBox((String) field.getCurrentSingleValue(), rangeBox);
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -313,7 +313,7 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
setRangeTimeInTimeBox((String) field.getCurrentValue(), rangeBoxFirst); setRangeTimeInTimeBox((String) field.getCurrentSingleValue(), rangeBoxFirst);
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -373,8 +373,8 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentSingleValue() != null)
((TextBox) holder).setText((String) field.getCurrentValue()); ((TextBox) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -401,8 +401,8 @@ public class MetaDataFieldSkeleton extends Composite {
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentSingleValue() != null)
((TextBox) holder).setText((String) field.getCurrentValue()); ((TextBox) holder).setText((String) field.getCurrentSingleValue());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -431,17 +431,31 @@ public class MetaDataFieldSkeleton extends Composite {
List<String> vocabulary = field.getVocabulary(); List<String> vocabulary = field.getVocabulary();
for (String term : vocabulary) { for (String term : vocabulary) {
tempListBox.addItem(term); tempListBox.addItem(term, term);
} }
// set default value // set default value
if (field.getDefaultValue() != null) if (field.getDefaultValue() != null)
tempListBox.setSelectedValue(field.getDefaultValue()); tempListBox.setSelectedValue(field.getDefaultValue());
//to be sure
tempListBox.setMultipleSelect(field.isMultiSelection());
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValue() != null) if (field.getCurrentValues() != null) {
tempListBox.setSelectedValue((String) field.getCurrentValue()); if (field.isMultiSelection()) {
//Buggy in Bootstrap
for (String value : field.getCurrentValues()) {
GWT.log("Multiple Selecting: "+value);
tempListBox.setSelectedValue((String) value);
}
}else {
GWT.log("Selecting: "+field.getCurrentSingleValue());
tempListBox.setSelectedValue((String) field.getCurrentSingleValue());
}
}
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -984,7 +998,7 @@ public class MetaDataFieldSkeleton extends Composite {
break; break;
case File: case File:
GWT.log("here");
if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) { if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder; DialogUpload dUpload = (DialogUpload) holder;
dUpload.enableUpload(!bool); dUpload.enableUpload(!bool);

View File

@ -22,7 +22,6 @@ import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
// TODO: Auto-generated Javadoc
/** /**
* The Class MultipleDilaogUploadStream. * The Class MultipleDilaogUploadStream.
* *
@ -46,8 +45,11 @@ public class MultipleDilaogUpload extends DialogUpload {
/** The id folder. */ /** The id folder. */
private String idFolder; private String idFolder;
/** /**
* Instantiates a new multiple dilaog upload. * Instantiates a new multiple dilaog upload.
*
* @param fieldName the field name used in the web form
*/ */
public MultipleDilaogUpload(String fieldName) { public MultipleDilaogUpload(String fieldName) {
this.fileUploadID = GenerateUUID.get(10, 16); // is tagID this.fileUploadID = GenerateUUID.get(10, 16); // is tagID
@ -87,7 +89,7 @@ public class MultipleDilaogUpload extends DialogUpload {
FileUploaded fakeFile = new FileUploaded(); FileUploaded fakeFile = new FileUploaded();
fakeFile.setFileName(files[i]); fakeFile.setFileName(files[i]);
fakeItem.setFile(fakeFile); fakeItem.setFile(fakeFile);
fakeFile.setFilePaths(new FilePath(getFieldName())); // The Form Field Label is unique for single-multiple fakeFile.setFilePath(new FilePath(getFieldName())); // The Form Field Label is unique for single-multiple
// upload // upload
fakeUploaders.add(fakeItem); fakeUploaders.add(fakeItem);
} }

View File

@ -46,7 +46,7 @@ public class CustomLegend extends Legend {
String htmlToAdd = text; String htmlToAdd = text;
if (addIsRequiredTxt) if (addIsRequiredTxt)
htmlToAdd += "<small><span style='color:red;'>&nbsp*</span> is required</small>"; htmlToAdd += "<small><span style='color:red;'>&nbsp*</span> is required field</small>";
HTML toHMTL = new HTML(htmlToAdd); HTML toHMTL = new HTML(htmlToAdd);

View File

@ -3,6 +3,13 @@
.legend-style { .legend-style {
width: auto; width: auto;
padding: 10px; padding-left: 10px;
margin-bottom: 0px; margin-bottom: 0px;
border-bottom: 0px;
padding-right: 10px;
}
.legend-style small {
display: block;
font-size: 12px !important;
} }

View File

@ -21,7 +21,6 @@ import org.gcube.common.metadataprofilediscovery.jaxb.MetadataValidator;
import org.gcube.common.metadataprofilediscovery.jaxb.MetadataVocabulary; import org.gcube.common.metadataprofilediscovery.jaxb.MetadataVocabulary;
import org.gcube.common.metadataprofilediscovery.jaxb.NamespaceCategory; import org.gcube.common.metadataprofilediscovery.jaxb.NamespaceCategory;
import org.gcube.common.scope.api.ScopeProvider; 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.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsGroup; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsGroup;
@ -119,10 +118,10 @@ public class MetadataDiscovery {
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName()); MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
beans.add(bean); beans.add(bean);
if(!WsUtil.isWithinPortal()) { // if(!WsUtil.isWithinPortal()) {
LOG.info("DEV MODE ENABLED - Out of portal!"); // LOG.info("DEV MODE ENABLED - Out of portal!");
randomizeCurrentValues(bean.getMetadataFields()); // randomizeCurrentValues(bean.getMetadataFields());
} // }
} }
prettyPrintList(beans); prettyPrintList(beans);
@ -145,14 +144,14 @@ public class MetadataDiscovery {
switch (dtw) { switch (dtw) {
case Boolean: case Boolean:
metadataFieldWrapper.setCurrentValue(Boolean.FALSE.toString()); metadataFieldWrapper.setCurrentValues(Boolean.FALSE.toString());
break; break;
case Number: case Number:
metadataFieldWrapper.setCurrentValue(new Random().nextInt()+""); metadataFieldWrapper.setCurrentValues(new Random().nextInt()+"");
break; break;
case String: case String:
case Text: case Text:
metadataFieldWrapper.setCurrentValue("Text "+UUID.randomUUID()); metadataFieldWrapper.setCurrentValues("Text "+UUID.randomUUID());
break; break;
default: default:
break; break;

View File

@ -7,7 +7,6 @@ import java.util.List;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean; import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded; import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
/** /**
* The Class GenericDatasetBean. * The Class GenericDatasetBean.
* *
@ -15,28 +14,26 @@ import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
* *
* Oct 19, 2020 * Oct 19, 2020
*/ */
public class GenericDatasetBean implements Serializable { public class GenericDatasetBean<T extends MetaDataProfileBean, F extends FileUploaded> implements Serializable {
/** The Constant serialVersionUID. */ /** The Constant serialVersionUID. */
private static final long serialVersionUID = -5215392381589702647L; private static final long serialVersionUID = -5215392381589702647L;
/** The metadata profile list. */ /** The metadata profile list. */
private List<MetaDataProfileBean> metadataProfileList; private List<T> metadataProfileList;
/** The form data entry fields. */ /** The form data entry fields. */
private LinkedHashMap<String, List<String>> formDataEntryFields; private LinkedHashMap<String, List<String>> formDataEntryFields;
/** The files uploaded. */ /** The files uploaded. */
private List<FileUploaded> filesUploaded; private List<F> filesUploaded;
/** /**
* Instantiates a new generic dataset bean. * Instantiates a new generic dataset bean.
*/ */
public GenericDatasetBean(){ public GenericDatasetBean() {
} }
/** /**
* Instantiates a new generic dataset bean. * Instantiates a new generic dataset bean.
* *
@ -44,35 +41,32 @@ public class GenericDatasetBean implements Serializable {
* @param formDataEntryFields the form data entry fields * @param formDataEntryFields the form data entry fields
* @param filesUploaded the files uploaded * @param filesUploaded the files uploaded
*/ */
public GenericDatasetBean(List<MetaDataProfileBean> metadataProfileList, LinkedHashMap<String, List<String>> formDataEntryFields, public GenericDatasetBean(List<T> metadataProfileList, LinkedHashMap<String, List<String>> formDataEntryFields,
List<FileUploaded> filesUploaded) { List<F> filesUploaded) {
super(); super();
this.metadataProfileList = metadataProfileList; this.metadataProfileList = metadataProfileList;
this.formDataEntryFields = formDataEntryFields; this.formDataEntryFields = formDataEntryFields;
this.filesUploaded = filesUploaded; this.filesUploaded = filesUploaded;
} }
/** /**
* Gets the metadata profile list. * Gets the metadata profile list.
* *
* @return the metadata profile list * @return the metadata profile list
*/ */
public List<MetaDataProfileBean> getMetadataProfileList() { public List<T> getMetadataProfileList() {
return metadataProfileList; return metadataProfileList;
} }
/** /**
* Sets the metadata profile list. * Sets the metadata profile list.
* *
* @param metadataProfileList the new metadata profile list * @param metadataProfileList the new metadata profile list
*/ */
public void setMetadataProfileList(List<MetaDataProfileBean> metadataProfileList) { public void setMetadataProfileList(List<T> metadataProfileList) {
this.metadataProfileList = metadataProfileList; this.metadataProfileList = metadataProfileList;
} }
/** /**
* Gets the form data entry fields. * Gets the form data entry fields.
* *
@ -82,7 +76,6 @@ public class GenericDatasetBean implements Serializable {
return formDataEntryFields; return formDataEntryFields;
} }
/** /**
* Sets the form data entry fields. * Sets the form data entry fields.
* *
@ -92,27 +85,24 @@ public class GenericDatasetBean implements Serializable {
this.formDataEntryFields = formDataEntryFields; this.formDataEntryFields = formDataEntryFields;
} }
/** /**
* Gets the files uploaded. * Gets the files uploaded.
* *
* @return the files uploaded * @return the files uploaded
*/ */
public List<FileUploaded> getFilesUploaded() { public List<F> getFilesUploaded() {
return filesUploaded; return filesUploaded;
} }
/** /**
* Sets the files uploaded. * Sets the files uploaded.
* *
* @param filesUploaded the new files uploaded * @param filesUploaded the new files uploaded
*/ */
public void setFilesUploaded(List<FileUploaded> filesUploaded) { public void setFilesUploaded(List<F> filesUploaded) {
this.filesUploaded = filesUploaded; this.filesUploaded = filesUploaded;
} }
/** /**
* To string. * To string.
* *
@ -124,6 +114,4 @@ public class GenericDatasetBean implements Serializable {
+ formDataEntryFields + ", filesUploaded=" + filesUploaded + "]"; + formDataEntryFields + ", filesUploaded=" + filesUploaded + "]";
} }
} }

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* The Class MetaDataProfileBean. * The Class MetaDataProfileBean.
* *
@ -11,7 +10,7 @@ import java.util.List;
* *
* Mar 3, 2022 * Mar 3, 2022
*/ */
public class MetaDataProfileBean implements Serializable{ public class MetaDataProfileBean implements Serializable {
/** /**
* *
@ -25,7 +24,7 @@ public class MetaDataProfileBean implements Serializable{
/** /**
* Instantiates a new meta data profile bean. * Instantiates a new meta data profile bean.
*/ */
public MetaDataProfileBean(){ public MetaDataProfileBean() {
super(); super();
} }
@ -37,9 +36,7 @@ public class MetaDataProfileBean implements Serializable{
* @param metadataFields the metadata fields * @param metadataFields the metadata fields
* @param categories the categories * @param categories the categories
*/ */
public MetaDataProfileBean(String type, public MetaDataProfileBean(String type, String title, List<MetadataFieldWrapper> metadataFields,
String title,
List<MetadataFieldWrapper> metadataFields,
List<CategoryWrapper> categories) { List<CategoryWrapper> categories) {
super(); super();
this.type = type; this.type = type;
@ -48,96 +45,51 @@ public class MetaDataProfileBean implements Serializable{
this.metadataFields = metadataFields; this.metadataFields = metadataFields;
} }
/**
* Gets the type.
*
* @return the type
*/
public String getType() { public String getType() {
return type; 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<MetadataFieldWrapper> getMetadataFields() {
return metadataFields;
}
/**
* Sets the metadata fields.
*
* @param metadataFields the metadataFields to set
*/
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
this.metadataFields = metadataFields;
}
/**
* Gets the categories.
*
* @return the categories
*/
public List<CategoryWrapper> getCategories() {
return categories;
}
/**
* Sets the categories.
*
* @param categories the new categories
*/
public void setCategories(List<CategoryWrapper> categories) {
this.categories = categories;
}
/**
* Gets the title.
*
* @return the title
*/
public String getTitle() { public String getTitle() {
return title; return title;
} }
/** public List<CategoryWrapper> getCategories() {
* Sets the title. return categories;
* }
* @param title the new title
*/ public List<MetadataFieldWrapper> getMetadataFields() {
return metadataFields;
}
public void setType(String type) {
this.type = type;
}
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
/** public void setCategories(List<CategoryWrapper> categories) {
* To string. this.categories = categories;
* }
* @return the string
*/ public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
this.metadataFields = metadataFields;
}
@Override @Override
public String toString() { public String toString() {
final int maxLen = 10; StringBuilder builder = new StringBuilder();
return "MetaDataProfileBean [type=" builder.append("MetaDataProfileBean [type=");
+ type builder.append(type);
+ ", title=" builder.append(", title=");
+ title builder.append(title);
+ ", categories=" builder.append(", categories=");
+ (categories != null ? categories.subList(0, builder.append(categories);
Math.min(categories.size(), maxLen)) : null) builder.append(", metadataFields=");
+ ", metadataFields=" builder.append(metadataFields);
+ (metadataFields != null ? metadataFields.subList(0, builder.append("]");
Math.min(metadataFields.size(), maxLen)) : null) + "]"; return builder.toString();
} }
} }

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -29,7 +30,7 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable {
private Integer maxOccurs = 1; private Integer maxOccurs = 1;
private String currentValue; private String[] currentValues;
/** /**
* Instantiates a new metadata field. * Instantiates a new metadata field.
@ -331,24 +332,42 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable {
} }
/** /**
* Sets the current value. * Gets the current values.
* *
* @param value the new current value * @return the current values
*/ */
public void setCurrentValue(String value) { public List<String> getCurrentValues() {
this.currentValue = value; if (currentValues == null)
return null;
return Arrays.asList(currentValues);
} }
/** /**
* Gets the current value. * Sets the current values.
* *
* @return the current value * @param currentValues the new current values
*/ */
public String getCurrentValue() { public void setCurrentValues(String... currentValues) {
return currentValue; this.currentValues = currentValues;
} }
/**
* Gets the current single value.
*
* @return the current single value
*/
public String getCurrentSingleValue() {
if (this.currentValues != null && this.currentValues.length > 0)
return this.currentValues[0];
return null;
}
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -380,12 +399,10 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable {
builder.append(asTag); builder.append(asTag);
builder.append(", maxOccurs="); builder.append(", maxOccurs=");
builder.append(maxOccurs); builder.append(maxOccurs);
builder.append(", currentValue="); builder.append(", currentValues=");
builder.append(currentValue); builder.append(currentValues);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -1,8 +1,10 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
import java.util.List;
public interface UpdatableField { public interface UpdatableField {
void setCurrentValue(String value); void setCurrentValues(String... values);
String getCurrentValue(); List<String> getCurrentValues();
} }

View File

@ -7,15 +7,16 @@ import java.io.Serializable;
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Mar 21, 2022 * Apr 13, 2023
*/ */
public class FilePath implements Serializable { public class FilePath implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = 5321133561716734223L; private static final long serialVersionUID = -1544808784879956412L;
String formFieldLabel; // is the gcubeProfileFieldName in the UCD of Geoportal private String formFieldLabel; // It is the gcubeProfileFieldName registered in the UCD of Geoportal
private String fieldName; // It is the fieldName registered in the UCD of Geoportal
/** /**
* Instantiates a new file paths. * Instantiates a new file paths.
@ -32,6 +33,17 @@ public class FilePath implements Serializable {
this.formFieldLabel = formFieldLabel; this.formFieldLabel = formFieldLabel;
} }
/**
* Instantiates a new file path.
*
* @param formFieldLabel the form field label
* @param fieldName the field name
*/
public FilePath(String formFieldLabel, String fieldName) {
this.formFieldLabel = formFieldLabel;
this.fieldName = fieldName;
}
/** /**
* Gets the form field label. * Gets the form field label.
* *
@ -50,6 +62,24 @@ public class FilePath implements Serializable {
this.formFieldLabel = formFieldLabel; this.formFieldLabel = formFieldLabel;
} }
/**
* Gets the field name.
*
* @return the field name
*/
public String getFieldName() {
return fieldName;
}
/**
* Sets the field name.
*
* @param fieldName the new field name
*/
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
/** /**
* To string. * To string.
* *
@ -60,6 +90,8 @@ public class FilePath implements Serializable {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("FilePath [formFieldLabel="); builder.append("FilePath [formFieldLabel=");
builder.append(formFieldLabel); builder.append(formFieldLabel);
builder.append(", fieldName=");
builder.append(fieldName);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -117,32 +117,14 @@ public class FileUploaded implements Serializable, IsSerializable {
} }
/** /**
* Sets the file paths. * Sets the file path.
* *
* @param filePaths the new file paths * @param filePath the new file path
*/ */
public void setFilePaths(FilePath filePaths) { public void setFilePath(FilePath filePath) {
this.filePath = filePaths; this.filePath = filePath;
} }
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FileUploaded [fileName=");
builder.append(fileName);
builder.append(", tempSystemPath=");
builder.append(tempSystemPath);
builder.append(", createdByUser=");
builder.append(createdByUser);
builder.append(", filePath=");
builder.append(filePath);
builder.append("]");
return builder.toString();
}
} }

View File

@ -0,0 +1,74 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.upload;
/**
* The Class FileUploadedRemote.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 1, 2023
*/
public class FileUploadedRemote extends FileUploaded {
/**
*
*/
private static final long serialVersionUID = 2991541932545131966L;
private String url;
private String mimeType;
/**
* Instantiates a new file uploaded remote.
*/
public FileUploadedRemote() {
}
/**
* Gets the url.
*
* @return the url
*/
public String getUrl() {
return url;
}
/**
* Sets the url.
*
* @param url the new url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Gets the mime type.
*
* @return the mime type
*/
public String getMimeType() {
return mimeType;
}
/**
* Sets the mime type.
*
* @param mimeType the new mime type
*/
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FileUploadedRemote [url=");
builder.append(url);
builder.append(", mimeType=");
builder.append(mimeType);
builder.append("]");
return builder.toString();
}
}