Tags fixed

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@130346 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-14 09:26:43 +00:00
parent 08a2d1b8cd
commit 43a50b1492
3 changed files with 31 additions and 12 deletions

View File

@ -72,7 +72,7 @@ import com.google.gwt.user.client.ui.Widget;
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/ */
public class CreateDatasetForm extends Composite{ public class CreateDatasetForm extends Composite{
/** /**
* Create a remote service proxy to talk to the server-side ckan service. * Create a remote service proxy to talk to the server-side ckan service.
*/ */
@ -152,7 +152,7 @@ public class CreateDatasetForm extends Composite{
@UiField Icon infoIconResources; @UiField Icon infoIconResources;
@UiField FocusPanel focusPanelResources; @UiField FocusPanel focusPanelResources;
@UiField Popover popoverResources; @UiField Popover popoverResources;
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later"; protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later";
// tab panel // tab panel
@ -1139,21 +1139,28 @@ public class CreateDatasetForm extends Composite{
} }
/** /**
* Add the tag as an element * Add the tag as an element (inserted by the user)
*/ */
private void addTagElement(TextBox itemBox){ private void addTagElement(TextBox itemBox){
GWT.log("value is " + itemBox.getValue());
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) { if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
if(tagsList.contains(itemBox.getValue())) if(tagsList.contains(itemBox.getValue())){
itemBox.setValue("");
return; return;
}
// ckan accepts only alphanumeric values // ckan accepts only alphanumeric values
if(!itemBox.getValue().matches("^[a-zA-Z0-9]*$")) String[] subTags = itemBox.getValue().split(" ");
return; for (int i = 0; i < subTags.length; i++) {
String subTag = subTags[i];
if(itemBox.getValue().length() <= 1) if(!subTag.matches("^[a-zA-Z0-9]*$"))
return; return;
if(subTag.length() <= 1)
return;
}
final String value = itemBox.getValue(); final String value = itemBox.getValue();
final ListItem displayItem = new ListItem(); final ListItem displayItem = new ListItem();
@ -1179,13 +1186,23 @@ public class CreateDatasetForm extends Composite{
} }
/** /**
* Add the tag as an element * Add the tag as an element (when publishing from workspace)
*/ */
private void addTagElement(final String tag){ private void addTagElement(final String tag){
if(tagsList.contains(tag)) if(tagsList.contains(tag))
return; return;
// ckan accepts only alphanumeric values
String[] subTags = tag.split(" ");
for (int i = 0; i < subTags.length; i++) {
String subTag = subTags[i];
if(!subTag.matches("^[a-zA-Z0-9]*$"))
return;
if(subTag.length() <= 1)
return;
}
final ListItem displayItem = new ListItem(); final ListItem displayItem = new ListItem();
displayItem.setStyleName("tag-style"); displayItem.setStyleName("tag-style");
Span p = new Span(tag); Span p = new Span(tag);

View File

@ -9,7 +9,9 @@ public class InfoIconsLabels {
// TAGS // TAGS
public static final String TAGS_INFO_ID_POPUP = "tags-popup-panel-info"; public static final String TAGS_INFO_ID_POPUP = "tags-popup-panel-info";
public static final String TAGS_INFO_CAPTION = "Tags"; public static final String TAGS_INFO_CAPTION = "Tags";
public static final String TAGS_INFO_TEXT = "Tags are meaningful information that can be associated to the product and by means of them it can be retrieved. A tag cannot contain white spaces and can contain only alphanumeric characters. It must be at least of two characters."; public static final String TAGS_INFO_TEXT = "Tags are meaningful information that can be associated to the "
+ "product and by means of them it can be retrieved. A tag can contain only alphanumeric characters. "
+ "Any string of the tag must be at least of two characters. Examples of good tags: \"This is my sample tag\", \"tagY\". Examples of bad tags: \"This is a tag\", \"c\".";
// VISIBILITY // VISIBILITY
public static final String VISIBILITY_INFO_ID_POPUP = "visibility-popup-panel-info"; public static final String VISIBILITY_INFO_ID_POPUP = "visibility-popup-panel-info";

View File

@ -560,7 +560,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
String datasetId = utils.createCKanDataset(getUserCKanTokenFromSession(), null, title, organizationNameOrId, author, String datasetId = utils.createCKanDataset(getUserCKanTokenFromSession(), title, organizationNameOrId, author,
authorMail, maintainer, maintainerMail, version, description, licenseId, authorMail, maintainer, maintainerMail, version, description, licenseId,
listOfTags, customFields, resources, setPublic); listOfTags, customFields, resources, setPublic);