added code to retrieve the tag or group value from a field if it has to be used that way as well
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@147133 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b13612460a
commit
755191ad50
|
@ -2,10 +2,12 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
||||
|
@ -858,9 +860,7 @@ public class CreateDatasetForm extends Composite{
|
|||
String errorMessage = areProfileDataValid();
|
||||
|
||||
if(errorMessage != null){
|
||||
|
||||
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage +"]", AlertType.ERROR, true);
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
|
@ -874,6 +874,7 @@ public class CreateDatasetForm extends Composite{
|
|||
String maintainer = maintainerTextbox.getValue().trim();
|
||||
String maintainerEmail = maintainerEmailTextbox.getValue().trim();
|
||||
String chosenOrganizationTitle = organizationsListbox.getSelectedItemText();
|
||||
Set<String> tags = new HashSet<String>(tagsPanel.getTags());
|
||||
|
||||
//we need to retrieve the organization's name from this title
|
||||
List<OrganizationBean> orgs = receivedBean.getOrganizationList();
|
||||
|
@ -897,22 +898,6 @@ public class CreateDatasetForm extends Composite{
|
|||
}
|
||||
}
|
||||
|
||||
// fill the bean
|
||||
receivedBean.setAuthorFullName(author);
|
||||
receivedBean.setAuthorEmail(authorEmail);
|
||||
receivedBean.setDescription(description);
|
||||
receivedBean.setLicense(selectedLicense);
|
||||
receivedBean.setMaintainer(maintainer);
|
||||
receivedBean.setMaintainerEmail(maintainerEmail);
|
||||
receivedBean.setVersion(version);
|
||||
receivedBean.setVisibile(visibility.equals("Public"));
|
||||
receivedBean.setTitle(title);
|
||||
receivedBean.setTags(tagsPanel.getTags());
|
||||
receivedBean.setSelectedOrganization(chosenOrganization);
|
||||
receivedBean.setGroups(groups);
|
||||
if(resourcesTwinPanel != null)
|
||||
receivedBean.setResourceRoot(resourcesTwinPanel.getResourcesToPublish());
|
||||
|
||||
Map<String, List<String>> customFieldsMap = new HashMap<String, List<String>>();
|
||||
|
||||
// prepare custom fields
|
||||
|
@ -929,8 +914,17 @@ public class CreateDatasetForm extends Composite{
|
|||
valuesForThisField = new ArrayList<String>();
|
||||
|
||||
valuesForThisField.add(value);
|
||||
|
||||
customFieldsMap.put(key, valuesForThisField);
|
||||
|
||||
// get also tag/group if it is the case for this field
|
||||
String tag = field.getTagFromThisField();
|
||||
if(tag != null)
|
||||
tags.add(tag);
|
||||
|
||||
String groupTitle = field.getGroupTitleFromThisGroup();
|
||||
if(groupTitle != null)
|
||||
groups.add(new OrganizationBean(groupTitle, groupTitle, false));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -954,6 +948,21 @@ public class CreateDatasetForm extends Composite{
|
|||
|
||||
}
|
||||
|
||||
// fill the bean
|
||||
receivedBean.setAuthorFullName(author);
|
||||
receivedBean.setAuthorEmail(authorEmail);
|
||||
receivedBean.setDescription(description);
|
||||
receivedBean.setLicense(selectedLicense);
|
||||
receivedBean.setMaintainer(maintainer);
|
||||
receivedBean.setMaintainerEmail(maintainerEmail);
|
||||
receivedBean.setVersion(version);
|
||||
receivedBean.setVisibile(visibility.equals("Public"));
|
||||
receivedBean.setTitle(title);
|
||||
receivedBean.setTags(new ArrayList<String>(tags));
|
||||
receivedBean.setSelectedOrganization(chosenOrganization);
|
||||
receivedBean.setGroups(groups);
|
||||
if(resourcesTwinPanel != null)
|
||||
receivedBean.setResourceRoot(resourcesTwinPanel.getResourcesToPublish());
|
||||
receivedBean.setCustomFields(customFieldsMap);
|
||||
|
||||
// alert
|
||||
|
|
|
@ -7,7 +7,10 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCre
|
|||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.timeandreanges.DataTimeBox;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsGroup;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsTag;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.TaggingGroupingValue;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||
|
@ -92,7 +95,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|||
private static final String UPPER_RANGE_NOT_SPECIFIED = "Not specified";
|
||||
// time range separator
|
||||
public static final String RANGE_SEPARATOR = ",";
|
||||
private static final String TOOLTIP_MULTISELECTION = "Hold down the Control (CTRL) or Command button to select multiple options";
|
||||
private static final String TOOLTIP_MULTISELECTION = "Hold down the Control (CTRL) or Command (CMD) button to select multiple options";
|
||||
|
||||
public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception{
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
@ -595,6 +598,8 @@ public class MetaDataFieldSkeleton extends Composite{
|
|||
*/
|
||||
public String getFieldName(){
|
||||
|
||||
if(field.getFieldNameFromCategory() != null)
|
||||
return field.getFieldNameFromCategory();
|
||||
return field.getFieldName();
|
||||
|
||||
}
|
||||
|
@ -695,4 +700,31 @@ public class MetaDataFieldSkeleton extends Composite{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name and the value of this field, return a tag if it is the case.
|
||||
* @return a tag as string
|
||||
*/
|
||||
public String getTagFromThisField(){
|
||||
|
||||
FieldAsTag asTag = field.getAsTag();
|
||||
if(asTag != null){
|
||||
return TaggingGroupingValue.getComposedValue(field.getFieldName(), getFieldCurrentValue(), asTag.getSeparator(), asTag.getTaggingValue());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name and the value of this field, return a group title if it is the case.
|
||||
* @return a tag as string
|
||||
*/
|
||||
public String getGroupTitleFromThisGroup(){
|
||||
|
||||
FieldAsGroup asGroup = field.getAsGroup();
|
||||
if(asGroup != null){
|
||||
return TaggingGroupingValue.getComposedValue(field.getFieldName(), getFieldCurrentValue(), " ", asGroup.getGroupingValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -64,6 +64,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
|||
private static final Log logger = LogFactoryUtil.getLog(CKANPublisherServicesImpl.class);
|
||||
private static final String ITEM_URL_FIELD = "Item URL";
|
||||
private static final String SYS_TYPE = "system:type";
|
||||
private static final String TAGS_VOCABULARY_KEY = "TAGS_VOCABULARY";
|
||||
|
||||
// map <orgName, scope>
|
||||
private ConcurrentHashMap<String, String> mapOrganizationScope = new ConcurrentHashMap<String, String>();
|
||||
|
@ -261,7 +262,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
|||
private List<String> discoverTagsVocabulary(String context) {
|
||||
|
||||
logger.debug("Looking for vocabulary of tags in this context " + context);
|
||||
String keyPerVocabulary = UtilMethods.concatenateSessionKeyScope("TAGS_VOCABULARY", context); // TODO REMOVE
|
||||
String keyPerVocabulary = UtilMethods.concatenateSessionKeyScope(TAGS_VOCABULARY_KEY, context);
|
||||
|
||||
List<String> vocabulary = (List<String>) getThreadLocalRequest().getSession().getAttribute(keyPerVocabulary);
|
||||
if(vocabulary == null){
|
||||
|
@ -283,7 +284,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
|||
public DatasetBean createCKanDataset(DatasetBean toCreate) throws Exception{
|
||||
|
||||
try{
|
||||
logger.debug("Request for creating a dataset with these information " + toCreate);
|
||||
logger.info("Request for creating a dataset with these information " + toCreate);
|
||||
String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||
String title = toCreate.getTitle();
|
||||
String organizationNameOrId = toCreate.getSelectedOrganization();
|
||||
|
|
|
@ -51,10 +51,6 @@ public class FieldAsTag implements Serializable{
|
|||
this.taggingValue = taggingValue;
|
||||
}
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FieldAsTag [create=" + create + ", separator=" + separator
|
||||
|
|
Loading…
Reference in New Issue