Working on Feature #11331 Field repeatability
Updated pom version at 1.6.0 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@179748 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
849fe5e104
commit
16beccba5d
|
@ -1,18 +1,27 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset
|
||||||
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-6-0"
|
||||||
|
date="${buildDate}">
|
||||||
|
<Change>[Feature #11331] Field repeatability: support for catalogue widget
|
||||||
|
</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-5-0"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-5-0"
|
||||||
date="${buildDate}">
|
date="${buildDate}">
|
||||||
<Change>[Feature #13074] Integrated with 'openlayer-basic-widgets'</Change>
|
<Change>[Feature #13074] Integrated with 'openlayer-basic-widgets'
|
||||||
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-1"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-1"
|
||||||
date="2018-11-20">
|
date="2018-11-20">
|
||||||
<Change>[Bug #12914] The form to add/choice the resources to publishing remains frozen</Change>
|
<Change>[Bug #12914] The form to add/choice the resources to
|
||||||
|
publishing remains frozen</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-0"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-4-0"
|
||||||
date="2018-09-28">
|
date="2018-09-28">
|
||||||
<Change>[Incident #12563] Error when trying to publish the content of a workspace folder into the catalogue</Change>
|
<Change>[Incident #12563] Error when trying to publish the content of
|
||||||
|
a workspace folder into the catalogue</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset
|
<Changeset
|
||||||
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3"
|
component="org.gcube.portlets-widgets.ckan-metadata-publisher-widget.1-3-3"
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>ckan-metadata-publisher-widget</artifactId>
|
<artifactId>ckan-metadata-publisher-widget</artifactId>
|
||||||
<version>1.5.0-SNAPSHOT</version>
|
<version>1.6.0-SNAPSHOT</version>
|
||||||
<name>gCube Ckan metadata publisher widget</name>
|
<name>gCube Ckan metadata publisher widget</name>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -62,7 +62,6 @@ import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.FocusPanel;
|
import com.google.gwt.user.client.ui.FocusPanel;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
@ -193,8 +192,8 @@ public class CreateDatasetForm extends Composite{
|
||||||
// added custom field entries (by the user)
|
// added custom field entries (by the user)
|
||||||
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
|
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
|
||||||
|
|
||||||
// the list of MetaDataFieldSkeleton added
|
// the list of MetaDataField added
|
||||||
private List<MetaDataFieldSkeleton> listOfMetadataFields = new ArrayList<MetaDataFieldSkeleton>();
|
private List<MetaDataField> listOfMetadataFields = new ArrayList<MetaDataField>();
|
||||||
|
|
||||||
// dataset metadata bean
|
// dataset metadata bean
|
||||||
private DatasetBean receivedBean;
|
private DatasetBean receivedBean;
|
||||||
|
@ -713,13 +712,22 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
if(categories == null || categories.isEmpty()){
|
if(categories == null || categories.isEmpty()){
|
||||||
for (MetadataFieldWrapper field : fields) {
|
for (MetadataFieldWrapper field : fields) {
|
||||||
MetaDataFieldSkeleton fieldWidget;
|
/*MetaDataFieldSkeleton fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataFieldSkeleton(field, eventBus);
|
fieldWidget = new MetaDataFieldSkeleton(field, eventBus);
|
||||||
metadataFieldsPanel.add(fieldWidget);
|
metadataFieldsPanel.add(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("Unable to build such widget", e);
|
GWT.log("Unable to build such widget", e);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
MetaDataField fieldWidget;
|
||||||
|
try {
|
||||||
|
fieldWidget = new MetaDataField(field, eventBus);
|
||||||
|
metadataFieldsPanel.add(fieldWidget);
|
||||||
|
listOfMetadataFields.add(fieldWidget);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Unable to build such widget", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -732,13 +740,23 @@ public class CreateDatasetForm extends Composite{
|
||||||
fields.removeAll(fieldsForThisCategory);
|
fields.removeAll(fieldsForThisCategory);
|
||||||
|
|
||||||
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
||||||
MetaDataFieldSkeleton fieldWidget;
|
|
||||||
|
/*MetaDataFieldSkeleton fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataFieldSkeleton(metadataFieldWrapper, eventBus);
|
fieldWidget = new MetaDataFieldSkeleton(metadataFieldWrapper, eventBus);
|
||||||
cp.addField(fieldWidget);
|
cp.addField(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("Unable to build such widget", e);
|
GWT.log("Unable to build such widget", e);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
MetaDataField fieldWidget;
|
||||||
|
try {
|
||||||
|
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus);
|
||||||
|
cp.addField(fieldWidget);
|
||||||
|
listOfMetadataFields.add(fieldWidget);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Unable to build such widget", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metadataFieldsPanel.add(cp);
|
metadataFieldsPanel.add(cp);
|
||||||
|
@ -748,13 +766,23 @@ public class CreateDatasetForm extends Composite{
|
||||||
// add the remaining one at the end of the categories
|
// add the remaining one at the end of the categories
|
||||||
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
||||||
for (MetadataFieldWrapper field : fields) {
|
for (MetadataFieldWrapper field : fields) {
|
||||||
MetaDataFieldSkeleton fieldWidget;
|
|
||||||
|
/*MetaDataFieldSkeleton fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataFieldSkeleton(field, eventBus);
|
fieldWidget = new MetaDataFieldSkeleton(field, eventBus);
|
||||||
extrasCategory.addField(fieldWidget);
|
extrasCategory.addField(fieldWidget);
|
||||||
listOfMetadataFields.add(fieldWidget);
|
listOfMetadataFields.add(fieldWidget);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("Unable to build such widget", e);
|
GWT.log("Unable to build such widget", e);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
MetaDataField fieldWidget;
|
||||||
|
try {
|
||||||
|
fieldWidget = new MetaDataField(field, eventBus);
|
||||||
|
extrasCategory.addField(fieldWidget);
|
||||||
|
listOfMetadataFields.add(fieldWidget);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Unable to build such widget", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metadataFieldsPanel.add(extrasCategory);
|
metadataFieldsPanel.add(extrasCategory);
|
||||||
|
@ -931,7 +959,10 @@ public class CreateDatasetForm extends Composite{
|
||||||
Map<String, List<String>> customFieldsMap = new HashMap<String, List<String>>();
|
Map<String, List<String>> customFieldsMap = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
// prepare custom fields
|
// prepare custom fields
|
||||||
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
for (MetaDataField metaField : listOfMetadataFields) {
|
||||||
|
|
||||||
|
for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
|
||||||
|
|
||||||
List<String> valuesForField = field.getFieldCurrentValue();
|
List<String> valuesForField = field.getFieldCurrentValue();
|
||||||
if(!valuesForField.isEmpty()){
|
if(!valuesForField.isEmpty()){
|
||||||
String key = field.getFieldNameQualified();
|
String key = field.getFieldNameQualified();
|
||||||
|
@ -960,6 +991,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(CustomFieldEntry customEntry : customFieldEntriesList){
|
for(CustomFieldEntry customEntry : customFieldEntriesList){
|
||||||
String key = customEntry.getKey();
|
String key = customEntry.getKey();
|
||||||
|
@ -1258,7 +1290,9 @@ public class CreateDatasetForm extends Composite{
|
||||||
*/
|
*/
|
||||||
private String areProfileDataValid() {
|
private String areProfileDataValid() {
|
||||||
|
|
||||||
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
for (MetaDataField metaField : listOfMetadataFields) {
|
||||||
|
|
||||||
|
for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
|
||||||
|
|
||||||
field.removeError();
|
field.removeError();
|
||||||
|
|
||||||
|
@ -1268,6 +1302,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
return field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
|
return field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1447,10 +1482,13 @@ public class CreateDatasetForm extends Composite{
|
||||||
ce.freeze();
|
ce.freeze();
|
||||||
|
|
||||||
// disable profile fields
|
// disable profile fields
|
||||||
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
for (MetaDataField metaField : listOfMetadataFields) {
|
||||||
|
for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
|
||||||
field.freeze();
|
field.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// freeze table of resources
|
// freeze table of resources
|
||||||
if(resourcesTwinPanel != null)
|
if(resourcesTwinPanel != null)
|
||||||
resourcesTwinPanel.freeze();
|
resourcesTwinPanel.freeze();
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
|
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Label;
|
||||||
|
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.event.shared.HandlerManager;
|
||||||
|
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.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class MetaDataField.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jun 10, 2019
|
||||||
|
*/
|
||||||
|
public class MetaDataField extends Composite {
|
||||||
|
|
||||||
|
private static MetaDataFieldUiBinder uiBinder = GWT.create(MetaDataFieldUiBinder.class);
|
||||||
|
|
||||||
|
@UiField VerticalPanel panelMetaDataFieldsSkeleton;
|
||||||
|
|
||||||
|
@UiField Label repeatabilityLabel;
|
||||||
|
|
||||||
|
//@UiField ControlGroup cgMetaDataFieldSkeletonFields;
|
||||||
|
|
||||||
|
@UiField Button addFieldButton;
|
||||||
|
|
||||||
|
@UiField Button removeFieldButton;
|
||||||
|
|
||||||
|
private List<MetaDataFieldSkeleton> listOfMetadataFields = new ArrayList<MetaDataFieldSkeleton>();
|
||||||
|
|
||||||
|
private MetadataFieldWrapper fieldWrapper;
|
||||||
|
|
||||||
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface MetaDataFieldUiBinder.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jun 10, 2019
|
||||||
|
*/
|
||||||
|
interface MetaDataFieldUiBinder extends UiBinder<Widget, MetaDataField> {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new meta data field.
|
||||||
|
*
|
||||||
|
* @param field the field
|
||||||
|
* @param eventBus the event bus
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
this.fieldWrapper = field;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
addNewOccurrenceOfField();
|
||||||
|
checkAllowedAddField();
|
||||||
|
checkAllowedRemoveField();
|
||||||
|
|
||||||
|
addFieldButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
addNewOccurrenceOfField();
|
||||||
|
checkAllowedAddField();
|
||||||
|
checkAllowedRemoveField();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
removeFieldButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
removeLatestOccurrenceOfFiled();
|
||||||
|
checkAllowedAddField();
|
||||||
|
checkAllowedRemoveField();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//The field is repeatable
|
||||||
|
if(field.getMaxOccurs()>1) {
|
||||||
|
repeatabilityLabel.setVisible(true);
|
||||||
|
repeatabilityLabel.setText(field.getFieldName()+" repeatability");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check allowed remove field.
|
||||||
|
*/
|
||||||
|
private void checkAllowedRemoveField() {
|
||||||
|
boolean removeCond = fieldWrapper.getMaxOccurs()>1 && listOfMetadataFields.size()>1;
|
||||||
|
removeFieldButton.setVisible(removeCond);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is allowed add occurrence.
|
||||||
|
*/
|
||||||
|
private void checkAllowedAddField() {
|
||||||
|
|
||||||
|
boolean repeatibilityCond = fieldWrapper.getMaxOccurs()>1 && listOfMetadataFields.size()<fieldWrapper.getMaxOccurs();
|
||||||
|
addFieldButton.setVisible(repeatibilityCond);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the latest occurrence of filed.
|
||||||
|
*/
|
||||||
|
private void removeLatestOccurrenceOfFiled() {
|
||||||
|
int size = listOfMetadataFields.size();
|
||||||
|
MetaDataFieldSkeleton skeleton = listOfMetadataFields.get(size-1);
|
||||||
|
try {
|
||||||
|
panelMetaDataFieldsSkeleton.remove(skeleton);
|
||||||
|
listOfMetadataFields.remove(size-1);
|
||||||
|
}catch (Exception e) {
|
||||||
|
GWT.log("Error: ",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the new occurrence of field.
|
||||||
|
*/
|
||||||
|
private void addNewOccurrenceOfField() {
|
||||||
|
try {
|
||||||
|
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(fieldWrapper, eventBus);
|
||||||
|
listOfMetadataFields.add(fieldWidget);
|
||||||
|
panelMetaDataFieldsSkeleton.add(fieldWidget);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("Error: ",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of metadata fields.
|
||||||
|
*
|
||||||
|
* @return the list of metadata fields
|
||||||
|
*/
|
||||||
|
public List<MetaDataFieldSkeleton> getListOfMetadataFields() {
|
||||||
|
return listOfMetadataFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<!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;
|
||||||
|
}
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<g:VerticalPanel
|
||||||
|
ui:field="panelMetaDataFieldsSkeleton" width="100%">
|
||||||
|
</g:VerticalPanel>
|
||||||
|
<b:ControlGroup>
|
||||||
|
<b:Label ui:field="repeatabilityLabel" visible="false">Repeatability</b:Label>
|
||||||
|
<b:Button icon="MINUS_SIGN" title="Remove Latest Field"
|
||||||
|
ui:field="removeFieldButton" visible="false"></b:Button>
|
||||||
|
<b:Button icon="PLUS_SIGN" title="Add Another Field"
|
||||||
|
ui:field="addFieldButton" visible="false"></b:Button>
|
||||||
|
</b:ControlGroup>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -3,6 +3,8 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.MetaDataField;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.PageHeader;
|
import com.github.gwtbootstrap.client.ui.PageHeader;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Style.Float;
|
import com.google.gwt.dom.client.Style.Float;
|
||||||
|
@ -22,7 +24,9 @@ public class CategoryPanel extends Composite{
|
||||||
|
|
||||||
@UiField VerticalPanel fieldsPanel;
|
@UiField VerticalPanel fieldsPanel;
|
||||||
@UiField PageHeader categoryHeader;
|
@UiField PageHeader categoryHeader;
|
||||||
private List<MetaDataFieldSkeleton> fieldsForThisCategory;
|
//private List<MetaDataFieldSkeleton> fieldsForThisCategory;
|
||||||
|
|
||||||
|
private List<MetaDataField> fieldsForThisCategory;
|
||||||
|
|
||||||
public CategoryPanel() {
|
public CategoryPanel() {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
@ -48,7 +52,7 @@ public class CategoryPanel extends Composite{
|
||||||
* Add a field to this widget
|
* Add a field to this widget
|
||||||
* @param fieldWidget
|
* @param fieldWidget
|
||||||
*/
|
*/
|
||||||
public void addField(MetaDataFieldSkeleton fieldWidget) {
|
/*public void addField(MetaDataFieldSkeleton fieldWidget) {
|
||||||
if(fieldsForThisCategory == null){
|
if(fieldsForThisCategory == null){
|
||||||
fieldsForThisCategory = new ArrayList<MetaDataFieldSkeleton>();
|
fieldsForThisCategory = new ArrayList<MetaDataFieldSkeleton>();
|
||||||
fieldWidget.setVisible(true);
|
fieldWidget.setVisible(true);
|
||||||
|
@ -56,6 +60,21 @@ public class CategoryPanel extends Composite{
|
||||||
}
|
}
|
||||||
fieldsForThisCategory.add(fieldWidget);
|
fieldsForThisCategory.add(fieldWidget);
|
||||||
fieldsPanel.add(fieldWidget);
|
fieldsPanel.add(fieldWidget);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a field to this widget
|
||||||
|
* @param fieldWidget
|
||||||
|
*/
|
||||||
|
public void addField(MetaDataField fieldWidget) {
|
||||||
|
if(fieldsForThisCategory == null){
|
||||||
|
fieldsForThisCategory = new ArrayList<MetaDataField>();
|
||||||
|
fieldWidget.setVisible(true);
|
||||||
|
fieldsPanel.setVisible(true);
|
||||||
|
}
|
||||||
|
fieldsForThisCategory.add(fieldWidget);
|
||||||
|
fieldsPanel.add(fieldWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,24 @@ public class MetadataDiscovery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Added by Francesco
|
||||||
|
int maxOccurs = 1; //Default value is 1. A field should occur once.
|
||||||
|
if(metadataField.getMaxOccurs()!=null) {
|
||||||
|
try {
|
||||||
|
//the field can appear an unlimited number of times.
|
||||||
|
if(metadataField.getMaxOccurs().equals("*")) {
|
||||||
|
maxOccurs = Integer.MAX_VALUE;
|
||||||
|
}else {
|
||||||
|
//the field must appear N times;
|
||||||
|
maxOccurs = Integer.parseInt(metadataField.getMaxOccurs());
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
//silent
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapperObj.setMaxOccurs(maxOccurs);
|
||||||
|
}
|
||||||
|
|
||||||
fieldsWrapper.add(wrapperObj);
|
fieldsWrapper.add(wrapperObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* The Class MetadataFieldWrapper.
|
* The Class MetadataFieldWrapper.
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* @author francesco-mangiacrapa at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public class MetadataFieldWrapper implements Serializable{
|
public class MetadataFieldWrapper implements Serializable{
|
||||||
|
|
||||||
|
@ -24,6 +26,8 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
private FieldAsGroup asGroup;
|
private FieldAsGroup asGroup;
|
||||||
private FieldAsTag asTag;
|
private FieldAsTag asTag;
|
||||||
|
|
||||||
|
private Integer maxOccurs = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new metadata field.
|
* Instantiates a new metadata field.
|
||||||
*/
|
*/
|
||||||
|
@ -36,11 +40,12 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
*
|
*
|
||||||
* @param fieldName the field name
|
* @param fieldName the field name
|
||||||
* @param mandatory the mandatory
|
* @param mandatory the mandatory
|
||||||
* @param DataType the type
|
* @param type the type
|
||||||
* @param defaulValue the defaul 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
|
||||||
*/
|
*/
|
||||||
public MetadataFieldWrapper(
|
public MetadataFieldWrapper(
|
||||||
String fieldName, Boolean mandatory, DataTypeWrapper type,
|
String fieldName, Boolean mandatory, DataTypeWrapper type,
|
||||||
|
@ -57,6 +62,26 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
this.ownerCategory = category;
|
this.ownerCategory = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the max occurs.
|
||||||
|
*
|
||||||
|
* @return the max occurs
|
||||||
|
*/
|
||||||
|
public Integer getMaxOccurs() {
|
||||||
|
return maxOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the max occurs.
|
||||||
|
*
|
||||||
|
* @param maxOccurs the new max occurs
|
||||||
|
*/
|
||||||
|
public void setMaxOccurs(Integer maxOccurs) {
|
||||||
|
this.maxOccurs = maxOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the field name.
|
* Gets the field name.
|
||||||
*
|
*
|
||||||
|
@ -140,7 +165,7 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
/**
|
/**
|
||||||
* Sets the defaul value.
|
* Sets the defaul value.
|
||||||
*
|
*
|
||||||
* @param defaulValue the defaulValue to set
|
* @param defaultValue the new default value
|
||||||
*/
|
*/
|
||||||
public void setDefaultValue(String defaultValue) {
|
public void setDefaultValue(String defaultValue) {
|
||||||
|
|
||||||
|
@ -177,54 +202,117 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type.
|
||||||
|
*
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
public DataTypeWrapper getType() {
|
public DataTypeWrapper getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type.
|
||||||
|
*
|
||||||
|
* @param type the new type
|
||||||
|
*/
|
||||||
public void setType(DataTypeWrapper type) {
|
public void setType(DataTypeWrapper type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is multi selection.
|
||||||
|
*
|
||||||
|
* @return true, if is multi selection
|
||||||
|
*/
|
||||||
public boolean isMultiSelection() {
|
public boolean isMultiSelection() {
|
||||||
return multiSelection;
|
return multiSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the multi selection.
|
||||||
|
*
|
||||||
|
* @param multiSelection the new multi selection
|
||||||
|
*/
|
||||||
public void setMultiSelection(boolean multiSelection) {
|
public void setMultiSelection(boolean multiSelection) {
|
||||||
this.multiSelection = multiSelection;
|
this.multiSelection = multiSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the owner category.
|
||||||
|
*
|
||||||
|
* @return the owner category
|
||||||
|
*/
|
||||||
public CategoryWrapper getOwnerCategory() {
|
public CategoryWrapper getOwnerCategory() {
|
||||||
return ownerCategory;
|
return ownerCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the owner category.
|
||||||
|
*
|
||||||
|
* @param ownerCategory the new owner category
|
||||||
|
*/
|
||||||
public void setOwnerCategory(CategoryWrapper ownerCategory) {
|
public void setOwnerCategory(CategoryWrapper ownerCategory) {
|
||||||
this.ownerCategory = ownerCategory;
|
this.ownerCategory = ownerCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the field name from category.
|
||||||
|
*
|
||||||
|
* @return the field name from category
|
||||||
|
*/
|
||||||
public String getFieldNameFromCategory() {
|
public String getFieldNameFromCategory() {
|
||||||
return fieldNameFromCategory;
|
return fieldNameFromCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the field name from category.
|
||||||
|
*
|
||||||
|
* @param fieldNameFromCategory the new field name from category
|
||||||
|
*/
|
||||||
public void setFieldNameFromCategory(String fieldNameFromCategory) {
|
public void setFieldNameFromCategory(String fieldNameFromCategory) {
|
||||||
this.fieldNameFromCategory = fieldNameFromCategory;
|
this.fieldNameFromCategory = fieldNameFromCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the as group.
|
||||||
|
*
|
||||||
|
* @return the as group
|
||||||
|
*/
|
||||||
public FieldAsGroup getAsGroup() {
|
public FieldAsGroup getAsGroup() {
|
||||||
return asGroup;
|
return asGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the as group.
|
||||||
|
*
|
||||||
|
* @param asGroup the new as group
|
||||||
|
*/
|
||||||
public void setAsGroup(FieldAsGroup asGroup) {
|
public void setAsGroup(FieldAsGroup asGroup) {
|
||||||
this.asGroup = asGroup;
|
this.asGroup = asGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the as tag.
|
||||||
|
*
|
||||||
|
* @return the as tag
|
||||||
|
*/
|
||||||
public FieldAsTag getAsTag() {
|
public FieldAsTag getAsTag() {
|
||||||
return asTag;
|
return asTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the as tag.
|
||||||
|
*
|
||||||
|
* @param asTag the new as tag
|
||||||
|
*/
|
||||||
public void setAsTag(FieldAsTag asTag) {
|
public void setAsTag(FieldAsTag asTag) {
|
||||||
this.asTag = asTag;
|
this.asTag = asTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MetadataFieldWrapper ["
|
return "MetadataFieldWrapper ["
|
||||||
|
@ -232,6 +320,7 @@ public class MetadataFieldWrapper implements Serializable{
|
||||||
+ (fieldNameFromCategory != null ? "fieldNameFromCategory="
|
+ (fieldNameFromCategory != null ? "fieldNameFromCategory="
|
||||||
+ fieldNameFromCategory + ", " : "")
|
+ fieldNameFromCategory + ", " : "")
|
||||||
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
|
+ (mandatory != null ? "mandatory=" + mandatory + ", " : "")
|
||||||
|
+ (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
|
||||||
+ (type != null ? "type=" + type + ", " : "")
|
+ (type != null ? "type=" + type + ", " : "")
|
||||||
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", "
|
+ (defaultValue != null ? "defaultValue=" + defaultValue + ", "
|
||||||
: "")
|
: "")
|
||||||
|
|
Loading…
Reference in New Issue