in progress on update
This commit is contained in:
parent
731cac1e95
commit
f83312dbf3
|
@ -5,4 +5,5 @@
|
||||||
<installed facet="jst.web" version="2.3"/>
|
<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"/>
|
||||||
</faceted-project>
|
</faceted-project>
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
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).
|
||||||
|
|
||||||
## [v1.1.0-SNAPSHOT] - 2022-03-01
|
## [v2.0.0-SNAPSHOT] - 2022-03-01
|
||||||
|
|
||||||
#### Enhancement
|
#### 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
|
## [v1.0.1-SNAPSHOT] - 2020-10-08
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -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>1.1.0-SNAPSHOT</version>
|
<version>2.0.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"
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.mpformbuilder.client.form;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
||||||
|
|
||||||
|
@ -34,8 +35,6 @@ public class MetaDataField extends Composite {
|
||||||
@UiField VerticalPanel panelMetaDataFieldsSkeleton;
|
@UiField VerticalPanel panelMetaDataFieldsSkeleton;
|
||||||
|
|
||||||
@UiField Label repeatabilityLabel;
|
@UiField Label repeatabilityLabel;
|
||||||
|
|
||||||
//@UiField ControlGroup cgMetaDataFieldSkeletonFields;
|
|
||||||
|
|
||||||
@UiField Button addFieldButton;
|
@UiField Button addFieldButton;
|
||||||
|
|
||||||
|
@ -47,6 +46,8 @@ public class MetaDataField extends Composite {
|
||||||
|
|
||||||
private HandlerManager eventBus;
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
private OPERATION operation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface MetaDataFieldUiBinder.
|
* The Interface MetaDataFieldUiBinder.
|
||||||
*
|
*
|
||||||
|
@ -65,10 +66,11 @@ public class MetaDataField extends Composite {
|
||||||
* @param eventBus the event bus
|
* @param eventBus the event bus
|
||||||
* @throws Exception the exception
|
* @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));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
this.fieldWrapper = field;
|
this.fieldWrapper = field;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
this.operation = operation;
|
||||||
addNewOccurrenceOfField();
|
addNewOccurrenceOfField();
|
||||||
checkAllowedAddField();
|
checkAllowedAddField();
|
||||||
checkAllowedRemoveField();
|
checkAllowedRemoveField();
|
||||||
|
@ -143,7 +145,7 @@ public class MetaDataField extends Composite {
|
||||||
*/
|
*/
|
||||||
private void addNewOccurrenceOfField() {
|
private void addNewOccurrenceOfField() {
|
||||||
try {
|
try {
|
||||||
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus);
|
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus, operation);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
panelMetaDataFieldsSkeleton.add(fieldWidget);
|
panelMetaDataFieldsSkeleton.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -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.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
|
@ -238,6 +238,10 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
/** The form data bean. */
|
/** The form data bean. */
|
||||||
private GenericDatasetBean formDataBean;
|
private GenericDatasetBean formDataBean;
|
||||||
|
|
||||||
|
private OPERATION operationPerfom;
|
||||||
|
|
||||||
|
public enum OPERATION {NEW, UPDATE}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked in the most general case.
|
* Invoked in the most general case.
|
||||||
*
|
*
|
||||||
|
@ -271,8 +275,9 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
*
|
*
|
||||||
* @param profiles the profiles
|
* @param profiles the profiles
|
||||||
*/
|
*/
|
||||||
public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus) {
|
public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus, OPERATION operation) {
|
||||||
this(eventBus);
|
this(eventBus);
|
||||||
|
this.operationPerfom = operation;
|
||||||
showLoadingProfiles(true);
|
showLoadingProfiles(true);
|
||||||
createDatasetFormBody(profiles);
|
createDatasetFormBody(profiles);
|
||||||
showLoadingProfiles(false);
|
showLoadingProfiles(false);
|
||||||
|
@ -302,7 +307,8 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
showChooseProfileForm(false);
|
showChooseProfileForm(false);
|
||||||
showCustomFieldsEntries(false);
|
showCustomFieldsEntries(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show loading profiles.
|
* Show loading profiles.
|
||||||
*
|
*
|
||||||
|
@ -464,7 +470,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(field, uiBus);
|
fieldWidget = new MetaDataField(field, uiBus, operationPerfom);
|
||||||
metadataFieldsPanel.add(fieldWidget);
|
metadataFieldsPanel.add(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -493,7 +499,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus);
|
fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus,operationPerfom);
|
||||||
cp.addField(fieldWidget);
|
cp.addField(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -519,7 +525,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(field, uiBus);
|
fieldWidget = new MetaDataField(field, uiBus, operationPerfom);
|
||||||
extrasCategory.addField(fieldWidget);
|
extrasCategory.addField(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -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.CloseCreationFormEvent;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.events.CloseCreationFormEventHandler;
|
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.openlayerwidget.GeoJsonAreaSelectionDialog;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.timeandranges.DataTimeBox;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.timeandranges.DataTimeBox;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.DialogUpload;
|
||||||
|
@ -118,10 +119,11 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
// time range separator
|
// time range separator
|
||||||
public static final String 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 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";
|
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));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
// prepare information
|
// prepare information
|
||||||
|
@ -133,6 +135,9 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
// bind
|
// bind
|
||||||
bind();
|
bind();
|
||||||
|
|
||||||
|
if (operation == null)
|
||||||
|
operation = OPERATION.NEW;
|
||||||
|
|
||||||
switch (field.getType()) {
|
switch (field.getType()) {
|
||||||
|
|
||||||
case Boolean:
|
case Boolean:
|
||||||
|
@ -141,6 +146,16 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
holder = new CheckBox();
|
holder = new CheckBox();
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
((CheckBox) holder).setValue(Boolean.valueOf(field.getDefaultValue()));
|
((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;
|
break;
|
||||||
|
|
||||||
case GeoJSON:
|
case GeoJSON:
|
||||||
|
@ -154,6 +169,15 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
textArea.setText(field.getDefaultValue());
|
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);
|
containerGeoJSON.add(textArea);
|
||||||
|
|
||||||
HorizontalPanel hp = new HorizontalPanel();
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
@ -216,6 +240,16 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
|
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
((TextArea) holder).setText(field.getDefaultValue());
|
((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;
|
break;
|
||||||
|
|
||||||
case Time:
|
case Time:
|
||||||
|
@ -230,6 +264,22 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
ref.setStartDate(dateAndTime[0], dateAndTime.length > 1 ? dateAndTime[1] : null);
|
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;
|
break;
|
||||||
|
|
||||||
case Time_Interval:
|
case Time_Interval:
|
||||||
|
@ -237,6 +287,15 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
DataTimeBox rangeBox;
|
DataTimeBox rangeBox;
|
||||||
holder = rangeBox = new DataTimeBox(true);
|
holder = rangeBox = new DataTimeBox(true);
|
||||||
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBox);
|
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);
|
rangesList.add(rangeBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -251,6 +310,15 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
SimplePanel panelFirstRange = new SimplePanel();
|
SimplePanel panelFirstRange = new SimplePanel();
|
||||||
DataTimeBox rangeBoxFirst = new DataTimeBox(true);
|
DataTimeBox rangeBoxFirst = new DataTimeBox(true);
|
||||||
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBoxFirst);
|
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBoxFirst);
|
||||||
|
|
||||||
|
if (operation.equals(OPERATION.UPDATE)) {
|
||||||
|
try {
|
||||||
|
setRangeTimeInTimeBox((String) field.getCurrentValue(), rangeBoxFirst);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
panelFirstRange.add(rangeBoxFirst);
|
panelFirstRange.add(rangeBoxFirst);
|
||||||
rangesList.add(rangeBoxFirst);
|
rangesList.add(rangeBoxFirst);
|
||||||
|
|
||||||
|
@ -303,8 +371,17 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
((TextBox) holder).setText(field.getDefaultValue());
|
((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;
|
break;
|
||||||
|
|
||||||
case File:
|
case File:
|
||||||
|
|
||||||
holder = new MultipleDilaogUpload();
|
holder = new MultipleDilaogUpload();
|
||||||
|
@ -322,6 +399,15 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
((TextBox) holder).setText(field.getDefaultValue());
|
((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 {
|
} else {
|
||||||
|
|
||||||
// listbox
|
// listbox
|
||||||
|
@ -331,11 +417,13 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
if (field.isMultiSelection())
|
if (field.isMultiSelection())
|
||||||
tempListBox.setTitle(TOOLTIP_MULTISELECTION);
|
tempListBox.setTitle(TOOLTIP_MULTISELECTION);
|
||||||
|
|
||||||
// if it is not mandatory and not multi-selection, add a disabled option (placeholder)
|
// if it is not mandatory and not multi-selection, add a disabled option
|
||||||
if(!field.getMandatory() && !field.isMultiSelection()){
|
// (placeholder)
|
||||||
|
if (!field.getMandatory() && !field.isMultiSelection()) {
|
||||||
tempListBox.addItem("Select " + field.getFieldName());
|
tempListBox.addItem("Select " + field.getFieldName());
|
||||||
tempListBox.setValue(0, "");
|
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());
|
tempListBox.setSelectedValue("Select " + field.getFieldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +438,15 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
if (field.getDefaultValue() != null)
|
if (field.getDefaultValue() != null)
|
||||||
tempListBox.setSelectedValue(field.getDefaultValue());
|
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;
|
break;
|
||||||
|
@ -358,24 +455,22 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ChangeHandler handler = new ChangeHandler() {
|
ChangeHandler handler = new ChangeHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(ChangeEvent event) {
|
public void onChange(ChangeEvent event) {
|
||||||
GWT.log("Fired is field value");
|
GWT.log("Fired is field value");
|
||||||
removeError();
|
removeError();
|
||||||
isFieldValueValid();
|
isFieldValueValid();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
holder.addDomHandler(handler, ChangeEvent.getType());
|
holder.addDomHandler(handler, ChangeEvent.getType());
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add custom css properties
|
// add custom css properties
|
||||||
controls.addStyleName("form-controls-custom");
|
controls.addStyleName("form-controls-custom");
|
||||||
|
@ -421,8 +516,7 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the holder.
|
* Gets the holder.
|
||||||
*
|
*
|
||||||
|
@ -631,22 +725,24 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case File:
|
case File:
|
||||||
|
|
||||||
GWT.log("Checking is valid File");
|
GWT.log("Checking is valid File");
|
||||||
if (field.getMandatory()) {
|
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;
|
DialogUpload dUpload = (DialogUpload) holder;
|
||||||
if(dUpload.getFileUploadingState()!=null && dUpload.getFileUploadingState().getFile()!=null) {
|
if (dUpload.getFileUploadingState() != null && dUpload.getFileUploadingState().getFile() != null) {
|
||||||
return dUpload.getFileUploadingState().getFile().getTempSystemPath()!=null?null:UPLOAD_MISSING_FILE;
|
return dUpload.getFileUploadingState().getFile().getTempSystemPath() != null ? null
|
||||||
|
: UPLOAD_MISSING_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UPLOAD_MISSING_FILE;
|
return UPLOAD_MISSING_FILE;
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
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 it was not mandatory but there was no choice, returning empty string
|
||||||
if(!field.getMandatory()) {
|
if (!field.getMandatory()) {
|
||||||
//Task #20446 - bug fix. Ignoring the placeholder
|
// Task #20446 - bug fix. Ignoring the placeholder
|
||||||
if(toReturn.size()==1) {
|
if (toReturn.size() == 1) {
|
||||||
String placeholder = "Select " + field.getFieldName();
|
String placeholder = "Select " + field.getFieldName();
|
||||||
if(toReturn.get(0).equals(placeholder)){
|
if (toReturn.get(0).equals(placeholder)) {
|
||||||
GWT.log("Skipping placeholder: "+placeholder);
|
GWT.log("Skipping placeholder: " + placeholder);
|
||||||
toReturn.clear();
|
toReturn.clear();
|
||||||
//toReturn.add("");
|
// toReturn.add("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,16 +883,16 @@ public class MetaDataFieldSkeleton extends Composite {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case File:
|
case File:
|
||||||
|
|
||||||
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;
|
||||||
if(dUpload.getFileUploadingState()!=null) {
|
if (dUpload.getFileUploadingState() != null) {
|
||||||
String filePath = dUpload.getFileUploadingState().getFile().getTempSystemPath();
|
String filePath = dUpload.getFileUploadingState().getFile().getTempSystemPath();
|
||||||
toReturn.add(filePath);
|
toReturn.add(filePath);
|
||||||
}else
|
} else
|
||||||
toReturn.add(null);
|
toReturn.add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
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.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;
|
||||||
|
@ -115,6 +118,11 @@ public class MetadataDiscovery {
|
||||||
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
|
MetadataFormat metadata = reader.getMetadataFormatForMetadataProfile(profile);
|
||||||
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
|
MetaDataProfileBean bean = toMetaDataProfileBean(metadata, categories, profile.getName());
|
||||||
beans.add(bean);
|
beans.add(bean);
|
||||||
|
|
||||||
|
if(!WsUtil.isWithinPortal()) {
|
||||||
|
LOG.info("DEV MODE ENABLED - Out of portal!");
|
||||||
|
randomizeCurrentValues(bean.getMetadataFields());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prettyPrintList(beans);
|
prettyPrintList(beans);
|
||||||
|
@ -130,6 +138,28 @@ public class MetadataDiscovery {
|
||||||
return beans;
|
return beans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void randomizeCurrentValues(List<MetadataFieldWrapper> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,22 +3,40 @@ package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A MetaDataProfileBean with its children (MetaDataType, MetaDataFields, Categories)
|
* The Class MetaDataProfileBean.
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Mar 3, 2022
|
||||||
*/
|
*/
|
||||||
public class MetaDataProfileBean implements Serializable{
|
public class MetaDataProfileBean implements Serializable{
|
||||||
|
|
||||||
private static final long serialVersionUID = -7377022025375553568L;
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -8307518917648131477L;
|
||||||
private String type;
|
private String type;
|
||||||
private String title;
|
private String title;
|
||||||
private List<CategoryWrapper> categories;
|
private List<CategoryWrapper> categories;
|
||||||
private List<MetadataFieldWrapper> metadataFields;
|
private List<MetadataFieldWrapper> metadataFields;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new meta data profile bean.
|
||||||
|
*/
|
||||||
public MetaDataProfileBean(){
|
public MetaDataProfileBean(){
|
||||||
super();
|
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,
|
public MetaDataProfileBean(String type,
|
||||||
String title,
|
String title,
|
||||||
List<MetadataFieldWrapper> metadataFields,
|
List<MetadataFieldWrapper> metadataFields,
|
||||||
|
@ -31,43 +49,82 @@ public class MetaDataProfileBean implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the type.
|
||||||
|
*
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the type.
|
||||||
|
*
|
||||||
* @param type the type to set
|
* @param type the type to set
|
||||||
*/
|
*/
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the metadata fields.
|
||||||
|
*
|
||||||
* @return the metadataFields
|
* @return the metadataFields
|
||||||
*/
|
*/
|
||||||
public List<MetadataFieldWrapper> getMetadataFields() {
|
public List<MetadataFieldWrapper> getMetadataFields() {
|
||||||
return metadataFields;
|
return metadataFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the metadata fields.
|
||||||
|
*
|
||||||
* @param metadataFields the metadataFields to set
|
* @param metadataFields the metadataFields to set
|
||||||
*/
|
*/
|
||||||
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
|
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
|
||||||
this.metadataFields = metadataFields;
|
this.metadataFields = metadataFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the categories.
|
||||||
|
*
|
||||||
|
* @return the categories
|
||||||
|
*/
|
||||||
public List<CategoryWrapper> getCategories() {
|
public List<CategoryWrapper> getCategories() {
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the categories.
|
||||||
|
*
|
||||||
|
* @param categories the new categories
|
||||||
|
*/
|
||||||
public void setCategories(List<CategoryWrapper> categories) {
|
public void setCategories(List<CategoryWrapper> categories) {
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the title.
|
||||||
|
*
|
||||||
|
* @return the title
|
||||||
|
*/
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the title.
|
||||||
|
*
|
||||||
|
* @param title the new title
|
||||||
|
*/
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final int maxLen = 10;
|
final int maxLen = 10;
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
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.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class MetadataFieldWrapper.
|
* 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 static final long serialVersionUID = -8476731365884466698L;
|
||||||
private String fieldName;
|
private String fieldName;
|
||||||
|
@ -25,9 +25,11 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
private CategoryWrapper ownerCategory;
|
private CategoryWrapper ownerCategory;
|
||||||
private FieldAsGroup asGroup;
|
private FieldAsGroup asGroup;
|
||||||
private FieldAsTag asTag;
|
private FieldAsTag asTag;
|
||||||
|
|
||||||
private Integer maxOccurs = 1;
|
private Integer maxOccurs = 1;
|
||||||
|
|
||||||
|
private String currentValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new metadata field.
|
* Instantiates a new metadata field.
|
||||||
*/
|
*/
|
||||||
|
@ -38,19 +40,17 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
/**
|
/**
|
||||||
* Instantiates a new metadata field.
|
* Instantiates a new metadata field.
|
||||||
*
|
*
|
||||||
* @param fieldName the field name
|
* @param fieldName the field name
|
||||||
* @param mandatory the mandatory
|
* @param mandatory the mandatory
|
||||||
* @param type the type
|
* @param type the type
|
||||||
* @param defaultValue the default value
|
* @param defaultValue the default value
|
||||||
* @param note the note
|
* @param note the note
|
||||||
* @param vocabulary the vocabulary
|
* @param vocabulary the vocabulary
|
||||||
* @param validator the validator
|
* @param validator the validator
|
||||||
* @param category the category
|
* @param category the category
|
||||||
*/
|
*/
|
||||||
public MetadataFieldWrapper(
|
public MetadataFieldWrapper(String fieldName, Boolean mandatory, DataTypeWrapper type, String defaultValue,
|
||||||
String fieldName, Boolean mandatory, DataTypeWrapper type,
|
String note, List<String> vocabulary, String validator, CategoryWrapper category) {
|
||||||
String defaultValue, String note, List<String> vocabulary,
|
|
||||||
String validator, CategoryWrapper category) {
|
|
||||||
super();
|
super();
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
this.mandatory = mandatory;
|
this.mandatory = mandatory;
|
||||||
|
@ -61,8 +61,6 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
this.ownerCategory = category;
|
this.ownerCategory = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the max occurs.
|
* Gets the max occurs.
|
||||||
|
@ -310,30 +308,48 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
this.asTag = asTag;
|
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()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MetadataFieldWrapper ["
|
return "MetadataFieldWrapper [" + (fieldName != null ? "fieldName=" + fieldName + ", " : "")
|
||||||
+ (fieldName != null ? "fieldName=" + fieldName + ", " : "")
|
+ (fieldNameFromCategory != null ? "fieldNameFromCategory=" + fieldNameFromCategory + ", " : "")
|
||||||
+ (fieldNameFromCategory != null ? "fieldNameFromCategory="
|
|
||||||
+ fieldNameFromCategory + ", " : "")
|
|
||||||
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
|
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
|
||||||
+ (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
|
+ (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
|
||||||
+ (type != null ? "type=" + type + ", " : "")
|
+ (type != null ? "type=" + type + ", " : "")
|
||||||
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", "
|
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", " : "")
|
||||||
: "")
|
|
||||||
+ (note != null ? "note=" + note + ", " : "")
|
+ (note != null ? "note=" + note + ", " : "")
|
||||||
+ (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "")
|
+ (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "") + "multiSelection=" + multiSelection
|
||||||
+ "multiSelection="
|
+ ", " + (validator != null ? "validator=" + validator + ", " : "")
|
||||||
+ multiSelection
|
+ (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId() + ", " : "")
|
||||||
+ ", "
|
+ (asGroup != null ? "asGroup=" + asGroup + ", " : "") + (asTag != null ? "asTag=" + asTag : "") + "]";
|
||||||
+ (validator != null ? "validator=" + validator + ", " : "")
|
|
||||||
+ (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId()
|
|
||||||
+ ", " : "")
|
|
||||||
+ (asGroup != null ? "asGroup=" + asGroup + ", " : "")
|
|
||||||
+ (asTag != null ? "asTag=" + asTag : "") + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
|
||||||
|
|
||||||
|
public interface UpdatableField {
|
||||||
|
|
||||||
|
void setCurrentValue(String value);
|
||||||
|
|
||||||
|
String getCurrentValue();
|
||||||
|
}
|
Loading…
Reference in New Issue