minor fixes on loading and on number fields validation

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@147230 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-04-27 15:22:04 +00:00
parent f73277c929
commit b4ea5e79c6
4 changed files with 39 additions and 22 deletions

16
pom.xml
View File

@ -55,11 +55,11 @@
</dependencyManagement>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>xerces</groupId> -->
<!-- <artifactId>xercesImpl</artifactId> -->
<!-- <version>2.9.1</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>xerces</groupId> -->
<!-- <artifactId>xercesImpl</artifactId> -->
<!-- <version>2.9.1</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
@ -215,7 +215,11 @@
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
<!-- <configuration> -->
<!-- <draftCompile>true</draftCompile> -->
<!-- <localWorkers>8</localWorkers> -->
<!-- </configuration> -->
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->

View File

@ -318,15 +318,18 @@ public class CreateDatasetForm extends Composite{
authorEmailTextbox.setText(bean.getAuthorEmail());
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
// retrieve custom fields
Map<String, List<String>> customFieldsMap = bean.getCustomFields();
List<String> vocabularyTags = bean.getTagsVocabulary();
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
// vocabulary list of tags has preemption
List<String> vocabularyTags = bean.getTagsVocabulary();
tagsPanel.setVocabulary(vocabularyTags);
// retrieve custom fields
Map<String, List<String>> customFieldsMap = bean.getCustomFields();
if(customFieldsMap != null){
// TODO Check if these tags are ok for the vocabulary
if(customFieldsMap != null && vocabularyTags == null){
// get the keys and put them as tags
Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
@ -382,9 +385,6 @@ public class CreateDatasetForm extends Composite{
}
});
// try to retrieve the profiles
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
// get the name of the organization from the title
final String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText());
@ -397,7 +397,6 @@ public class CreateDatasetForm extends Composite{
tagsPanel.setVocabulary(vocabulary);
tagsPanel.setVisible(true);
setAlertBlock("", AlertType.ERROR, false);
}
@Override
@ -410,6 +409,8 @@ public class CreateDatasetForm extends Composite{
}
});
// try to retrieve the profiles
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
// perform remote request of profiles for the selected organization
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
@ -492,7 +493,7 @@ public class CreateDatasetForm extends Composite{
});
}else{
setAlertBlock("Error while retrieving licenses, try later", AlertType.ERROR, true);
setAlertBlock("Error while retrieving licenses", AlertType.ERROR, true);
}
}
});

View File

@ -2,7 +2,7 @@
<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">
<g:HTMLPanel>
<g:VerticalPanel>
<g:VerticalPanel width="100%">
<b:PageHeader ui:field="categoryHeader"></b:PageHeader>
<!-- Here will be placed the metadata fields formats -->
<g:VerticalPanel ui:field="fieldsPanel" visible="false"

View File

@ -66,7 +66,7 @@ public class MetaDataFieldSkeleton extends Composite{
@UiField FocusPanel focusPanelIconContainer;
@UiField ControlGroup metafieldControlGroup;
private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
// private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
// the element that holds the value (it could be a checkbox, textbox or listbox, textarea, calendar, two calendars, more calendars)
private Widget holder;
@ -428,7 +428,7 @@ public class MetaDataFieldSkeleton extends Composite{
if(!numberValue.trim().isEmpty())
if(field.getValidator() == null || field.getValidator().isEmpty())
return checkValidator(numberValue, REGEX_IS_NUMBER) ? null : MALFORMED_ATTRIBUTE;
return isANumber(numberValue) ? null : MALFORMED_ATTRIBUTE;
else return checkValidator(numberValue, field.getValidator()) ? null : MALFORMED_ATTRIBUTE;
else return " a mandatory attribute cannot be empty";
@ -437,8 +437,11 @@ public class MetaDataFieldSkeleton extends Composite{
if(numberValue.trim().isEmpty())
return null;
else {
String validatorToUse = field.getValidator() == null || field.getValidator().isEmpty() ? REGEX_IS_NUMBER : field.getValidator();
return checkValidator(numberValue, validatorToUse) ? null : MALFORMED_ATTRIBUTE;
String validatorToUse = field.getValidator();
if(validatorToUse != null && !validatorToUse.isEmpty())
return checkValidator(numberValue, validatorToUse) ? null : MALFORMED_ATTRIBUTE;
else
return isANumber(numberValue) ? null : MALFORMED_ATTRIBUTE;
}
}
@ -486,6 +489,15 @@ public class MetaDataFieldSkeleton extends Composite{
}
}
/**
* Check if this string is a number
* @param numberValue
* @return
*/
private boolean isANumber(String numberValue) {
return numberValue.matches("-?\\d+(\\.\\d+)?");
}
/**
* Check if value matches validator (regex). In case validator is null, true is returned.
* @param value
@ -737,7 +749,7 @@ public class MetaDataFieldSkeleton extends Composite{
}
return null;
}
/**
* Check if the group associated (if it exists) should be forced
* @return