in progress...

This commit is contained in:
Francesco Mangiacrapa 2024-02-08 17:46:24 +01:00
parent 87a4211301
commit c7f0e908f0
8 changed files with 697 additions and 80 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean; import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
@ -140,14 +141,24 @@ public interface CKanPublisherService extends RemoteService {
*/ */
DatasetBean getDatasetBeanForUpdate(String itemID) throws Exception; DatasetBean getDatasetBeanForUpdate(String itemID) throws Exception;
/** /**
* Gets the profile for update. * Gets the profile for update.
* *
* @param orgName the org name * @param orgName the org name
* @param datasetType the dataset type * @param datasetType the dataset type
* @param datasedIdOrName the datased id or name * @param datasedIdOrName the datased id or name
* @return the profile for update * @return the profile for update
* @throws Exception the exception * @throws Exception the exception
*/ */
List<MetaDataProfileBean> getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName) throws Exception; MetadataProfileBeanForUpdate getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName) throws Exception;
/**
* Update CKAN dataset.
*
* @param toUpdate the to create
* @return the dataset bean
* @throws Exception the exception
*/
DatasetBean updateCKANDataset(DatasetBean toUpdate) throws Exception;
} }

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean; import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
@ -131,7 +132,7 @@ public interface CKanPublisherServiceAsync {
* Checks if is owner or admin user. * Checks if is owner or admin user.
* *
* @param datasetIdOrName the dataset id or name * @param datasetIdOrName the dataset id or name
* @param callback the callback * @param callback the callback
* @return true, if is owner or admin user * @return true, if is owner or admin user
*/ */
void isPublisherOwnerOrAdminUser(String datasetIdOrName, AsyncCallback<Boolean> callback); void isPublisherOwnerOrAdminUser(String datasetIdOrName, AsyncCallback<Boolean> callback);
@ -148,11 +149,21 @@ public interface CKanPublisherServiceAsync {
/** /**
* Gets the profile for update. * Gets the profile for update.
* *
* @param orgName the org name * @param orgName the org name
* @param datasetType the dataset type * @param datasetType the dataset type
* @param datasedIdOrName the datased id or name * @param datasedIdOrName the datased id or name
* @param callaback the callaback * @param callaback the callaback
* @return the profile for update * @return the profile for update
*/ */
void getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName, AsyncCallback<List<MetaDataProfileBean>> callaback); void getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName,
AsyncCallback<MetadataProfileBeanForUpdate> callaback);
/**
* Update CKAN dataset.
*
* @param toUpdate the to update
* @param callaback the callaback
* @throws Exception the exception
*/
void updateCKANDataset(DatasetBean toUpdate, AsyncCallback<DatasetBean> callaback);
} }

View File

@ -23,6 +23,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIc
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField; import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION; import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
@ -126,7 +127,7 @@ public class UpdateDatasetForm extends Composite {
@UiField @UiField
Button addCustomFieldButton; Button addCustomFieldButton;
@UiField @UiField
Button createButton; Button updateButton;
@UiField @UiField
Button resetButton; Button resetButton;
@UiField @UiField
@ -273,9 +274,9 @@ public class UpdateDatasetForm extends Composite {
private static final String NONE_PROFILE = "none"; private static final String NONE_PROFILE = "none";
// error/info messages // error/info messages
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your item."; protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to update the item.";
protected static final String PRODUCT_CREATED_OK = "Item correctly published!"; protected static final String PRODUCT_UPDATED_OK = "Item correctly updated!";
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the item, please wait..."; private static final String TRYING_TO_UPDATE_PRODUCT = "Trying to update the item, please wait...";
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to edit this item. Either you must be the author item or Catalogue Admininistrator in the organization"; protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to edit this item. Either you must be the author item or Catalogue Admininistrator in the organization";
// tab panel // tab panel
@ -329,7 +330,7 @@ public class UpdateDatasetForm extends Composite {
* @param itemId the item id * @param itemId the item id
*/ */
public UpdateDatasetForm(HandlerManager eventBus, String itemId) { public UpdateDatasetForm(HandlerManager eventBus, String itemId) {
createDatasetFormBody(eventBus, itemId, OPERATION.UPDATE); updateDatasetFormBody(eventBus, itemId, OPERATION.UPDATE);
} }
/** /**
@ -362,7 +363,7 @@ public class UpdateDatasetForm extends Composite {
* @param datasetIdOrName the item id * @param datasetIdOrName the item id
* @param operation the operation * @param operation the operation
*/ */
private void createDatasetFormBody(final HandlerManager eventBus, String datasetIdOrName, private void updateDatasetFormBody(final HandlerManager eventBus, String datasetIdOrName,
final OPERATION operation) { final OPERATION operation) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
@ -446,12 +447,12 @@ public class UpdateDatasetForm extends Composite {
} }
} }
// THIS BLOCK is it required? Probably not.
// retrieve custom fields // retrieve custom fields
Map<String, List<String>> customFieldsMap = bean.getCustomFields(); Map<String, List<String>> customFieldsMap = bean.getCustomFields();
// TODO Check if these tags are ok for the vocabulary // TODO Check if these tags are ok for the vocabulary
if (customFieldsMap != null && vocabularyTags == null) { if (customFieldsMap != null && vocabularyTags == null) {
// get the keys and put them as tags // get the keys and put them as tags
Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap
.entrySet().iterator(); .entrySet().iterator();
@ -474,6 +475,7 @@ public class UpdateDatasetForm extends Composite {
} }
} }
} }
// END BLOCK
// set it as visible anyway // set it as visible anyway
tagsPanel.setVisible(true); tagsPanel.setVisible(true);
@ -547,7 +549,7 @@ public class UpdateDatasetForm extends Composite {
// perform remote request of profiles for the selected organization // perform remote request of profiles for the selected organization
ckanServices.getProfileForUpdate(orgName, bean.getChosenType(), bean.getId(), ckanServices.getProfileForUpdate(orgName, bean.getChosenType(), bean.getId(),
new AsyncCallback<List<MetaDataProfileBean>>() { new AsyncCallback<MetadataProfileBeanForUpdate>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -555,8 +557,13 @@ public class UpdateDatasetForm extends Composite {
} }
@Override @Override
public void onSuccess(final List<MetaDataProfileBean> profiles) { public void onSuccess(
final MetadataProfileBeanForUpdate metadataProfileForUpdate) {
setAlertBlock("", AlertType.ERROR, false); setAlertBlock("", AlertType.ERROR, false);
List<MetaDataProfileBean> profiles = metadataProfileForUpdate
.getListProfileBean();
if (profiles == null) { if (profiles == null) {
setAlertBlock( setAlertBlock(
"An unknow error occurred while retrieving types, sorry", "An unknow error occurred while retrieving types, sorry",
@ -573,6 +580,7 @@ public class UpdateDatasetForm extends Composite {
receivedBean.setMetadataList(profiles); receivedBean.setMetadataList(profiles);
prepareMetadataList(receivedBean, operation); prepareMetadataList(receivedBean, operation);
addCustomField(metadataProfileForUpdate.getCustomFields());
organizationsListbox.setEnabled(true); organizationsListbox.setEnabled(true);
metadataTypeListbox.setEnabled(true); metadataTypeListbox.setEnabled(true);
@ -674,12 +682,36 @@ public class UpdateDatasetForm extends Composite {
} }
private void addCustomField(Map<String, List<String>> customFieldsMap) {
// TODO Check if these tags are ok for the vocabulary
if (customFieldsMap != null) {
// get the keys and put them as tags
Iterator<Entry<String, List<String>>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
while (iteratorOverCustomField.hasNext()) {
Map.Entry<java.lang.String, java.util.List<java.lang.String>> entry = iteratorOverCustomField.next();
List<String> values = entry.getValue();
for (String value : values) {
// these are fixed key, variable value custom fields
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(), value, false);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
}
}
}
}
/** /**
* When the organization name is changed we need to retrieve the list of * When the organization name is changed we need to retrieve the list of
* profiles and groups. * profiles and groups.
* *
* @param operation the operation * @param operation the operation
*/ */
//NEVER USED IN UPDATE MODE
private void organizationsListboxChangeHandlerBody(OPERATION operation) { private void organizationsListboxChangeHandlerBody(OPERATION operation) {
// remove any other product profiles // remove any other product profiles
@ -799,6 +831,7 @@ public class UpdateDatasetForm extends Composite {
* @param operation the operation * @param operation the operation
*/ */
private void prepareMetadataList(final DatasetBean receivedBean, OPERATION operation) { private void prepareMetadataList(final DatasetBean receivedBean, OPERATION operation) {
// the profile should be one // the profile should be one
List<MetaDataProfileBean> profiles = receivedBean.getMetadataList(); List<MetaDataProfileBean> profiles = receivedBean.getMetadataList();
@ -890,12 +923,6 @@ public class UpdateDatasetForm extends Composite {
if (categories == null || categories.isEmpty()) { if (categories == null || categories.isEmpty()) {
for (MetadataFieldWrapper field : fields) { for (MetadataFieldWrapper field : fields) {
/*
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
* MetaDataFieldSkeleton(field, eventBus); metadataFieldsPanel.add(fieldWidget);
* listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
* GWT.log("Unable to build such widget", e); }
*/
MetaDataField fieldWidget; MetaDataField fieldWidget;
try { try {
@ -1151,8 +1178,8 @@ public class UpdateDatasetForm extends Composite {
* *
* @param e the e * @param e the e
*/ */
@UiHandler("createButton") @UiHandler("updateButton")
void createDatasetEvent(ClickEvent e) { void updateDatasetEvent(ClickEvent e) {
String errorMessage = areProfileDataValid(); String errorMessage = areProfileDataValid();
@ -1272,19 +1299,19 @@ public class UpdateDatasetForm extends Composite {
receivedBean.setCustomFields(customFieldsMap); receivedBean.setCustomFields(customFieldsMap);
// alert // alert
alertOnCreate(TRYING_TO_CREATE_PRODUCT, true, AlertType.INFO, false); alertOnCreate(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
// invoke the create method // invoke the create method
createButton.setEnabled(false); updateButton.setEnabled(false);
goBackButtonSecondStep.setEnabled(false); goBackButtonSecondStep.setEnabled(false);
ckanServices.createCKanDataset(receivedBean, new AsyncCallback<DatasetBean>() { ckanServices.updateCKANDataset(receivedBean, new AsyncCallback<DatasetBean>() {
@Override @Override
public void onSuccess(final DatasetBean createdDatasetBean) { public void onSuccess(final DatasetBean createdDatasetBean) {
CKanMetadataPublisher.printJs("createCKanDataset returned"); CKanMetadataPublisher.printJs("createCKanDataset returned");
GWT.log("Created the dataset: " + createdDatasetBean); GWT.log("Updated the dataset: " + createdDatasetBean);
if (createdDatasetBean != null) { if (createdDatasetBean != null) {
@ -1292,7 +1319,7 @@ public class UpdateDatasetForm extends Composite {
final String datasetUrl = createdDatasetBean.getSource(); final String datasetUrl = createdDatasetBean.getSource();
alertOnCreate(PRODUCT_CREATED_OK, false, AlertType.SUCCESS, false); alertOnCreate(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false);
try { try {
// disable dataset fields // disable dataset fields
@ -1326,7 +1353,7 @@ public class UpdateDatasetForm extends Composite {
}); });
// set hidden the create button // set hidden the create button
createButton.setVisible(false); updateButton.setVisible(false);
// if we are in the "general case" we need to show a form for adding resources // if we are in the "general case" we need to show a form for adding resources
if (!isWorkspaceRequest) { if (!isWorkspaceRequest) {
@ -1543,7 +1570,7 @@ public class UpdateDatasetForm extends Composite {
onCreateAlertBlock.setText(text); onCreateAlertBlock.setText(text);
onCreateAlertBlock.setType(type); onCreateAlertBlock.setType(type);
onCreateAlertBlock.setVisible(true); onCreateAlertBlock.setVisible(true);
createButton.setEnabled(true); updateButton.setEnabled(true);
goBackButtonSecondStep.setEnabled(true); goBackButtonSecondStep.setEnabled(true);
if (hideAfterAWhile) { if (hideAfterAWhile) {

View File

@ -425,11 +425,11 @@
styleName="{style.the-margin-gotoitem}"></b:Button> styleName="{style.the-margin-gotoitem}"></b:Button>
</g:HorizontalPanel> </g:HorizontalPanel>
<b:Button title="Add resources to the just created item" <b:Button title="Manage resources of the item"
block="true" type="PRIMARY" visible="false" block="true" type="PRIMARY" visible="false"
ui:field="addResourcesButton">Add Resources</b:Button> ui:field="addResourcesButton">Manage Resources</b:Button>
<b:Button title="Create Item" ui:field="createButton" <b:Button title="Update Item" ui:field="updateButton"
type="PRIMARY" block="true">Create</b:Button> type="PRIMARY" block="true">Create</b:Button>
<b:Button title="Go Back" ui:field="goBackButtonSecondStep" <b:Button title="Go Back" ui:field="goBackButtonSecondStep"

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -36,6 +37,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.GenericUt
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.MetadataDiscovery; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.MetadataDiscovery;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean; import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
@ -69,9 +71,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// private static final org.slf4j.Logger logger = // private static final org.slf4j.Logger logger =
// LoggerFactory.getLogger(CKANPublisherServicesImpl.class); // LoggerFactory.getLogger(CKANPublisherServicesImpl.class);
private static final Logger logger = LoggerFactory.getLogger(CKANPublisherServicesImpl.class); private static final Logger logger = LoggerFactory.getLogger(CKANPublisherServicesImpl.class);
private static final String ITEM_URL_FIELD = "Item URL"; public static final String ITEM_URL_FIELD = "Item URL";
private static final String SYS_TYPE = "system:type"; public static final String SYSTEM_KEY_PREFIX = "system:";
private static final String TAGS_VOCABULARY_KEY = "TAGS_VOCABULARY"; public static final String SYS_TYPE = SYSTEM_KEY_PREFIX + "type";
public static final String TAGS_VOCABULARY_KEY = "TAGS_VOCABULARY";
public static final List<String> SYSTEM_CUSTOM_FIELDS_PREFIXES = Arrays.asList(ITEM_URL_FIELD, SYSTEM_KEY_PREFIX);
// map <orgName, scope> // map <orgName, scope>
private ConcurrentHashMap<String, String> mapOrganizationScope = new ConcurrentHashMap<String, String>(); private ConcurrentHashMap<String, String> mapOrganizationScope = new ConcurrentHashMap<String, String>();
@ -356,6 +361,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean = new DatasetBean(); bean = new DatasetBean();
bean.setId(datasetIdOrName); bean.setId(datasetIdOrName);
bean.setCkanName(dataset.getName());
bean.setTitle(dataset.getTitle()); bean.setTitle(dataset.getTitle());
bean.setDescription(dataset.getNotes()); bean.setDescription(dataset.getNotes());
bean.setLicense(dataset.getLicenseTitle()); bean.setLicense(dataset.getLicenseTitle());
@ -386,20 +392,19 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
Arrays.asList(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName(), true))); Arrays.asList(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName(), true)));
List<CkanTag> listDatasetTags = dataset.getTags(); List<CkanTag> listDatasetTags = dataset.getTags();
if (logger.isDebugEnabled()) {
if(logger.isDebugEnabled()) {
logger.debug("List tags from CKAN are: "); logger.debug("List tags from CKAN are: ");
for (CkanTag ckanTag : listDatasetTags) { for (CkanTag ckanTag : listDatasetTags) {
logger.debug("ckanTag: "+ckanTag.getDisplayName()); // logger.debug("ckanTag: " + ckanTag.getDisplayName());
logger.debug("ckanTag: "+ckanTag.getName()); logger.debug("ckanTag: " + ckanTag.getName());
} }
} }
// selected tags into Dataset // selected tags into Dataset
if (listDatasetTags != null) { if (listDatasetTags != null) {
List<String> listTags = dataset.getTags().stream().map(t -> t.getName()).collect(Collectors.toList()); List<String> listTags = dataset.getTags().stream().map(t -> t.getName()).collect(Collectors.toList());
logger.info("setTags: {}",listTags); logger.info("setTags: {}", listTags);
bean.setTags(listTags); bean.setTags(listTags);
} }
@ -427,10 +432,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
// Settings the dataset type // Settings the dataset type
Map<String, String> extras = dataset.getExtrasAsHashMap(); Map<String, List<String>> extras = dataset.getExtrasAsHashMap();
if (extras != null) { if (extras != null) {
String theDatasetType = extras.get(SYS_TYPE); List<String> theDatasetType = extras.get(SYS_TYPE);
bean.setChosenType(theDatasetType); if (theDatasetType != null && theDatasetType.size() > 0) {
bean.setChosenType(theDatasetType.get(0));
}
} }
logger.debug("Returning bean " + bean); logger.debug("Returning bean " + bean);
@ -442,6 +449,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
* To resource bean. * To resource bean.
* *
* @param ckanResource the ckan resource * @param ckanResource the ckan resource
* @return the resource element bean
*/ */
public ResourceElementBean toResourceBean(CkanResource ckanResource) { public ResourceElementBean toResourceBean(CkanResource ckanResource) {
ResourceElementBean reb = new ResourceElementBean(); ResourceElementBean reb = new ResourceElementBean();
@ -500,7 +508,10 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
try { try {
devModeSetContexts(); devModeSetContexts();
logger.info("Request for creating a dataset with these information " + toCreate); logger.info("Request for creating a dataset with title: {} " + toCreate.getTitle());
if (logger.isDebugEnabled()) {
logger.debug("Dataset is: {} " + toCreate);
}
String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
String title = toCreate.getTitle(); String title = toCreate.getTitle();
String organizationNameOrId = toCreate.getSelectedOrganization(); String organizationNameOrId = toCreate.getSelectedOrganization();
@ -588,6 +599,113 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
/**
* Update CKAN dataset.
*
* @param toUpdate the to create
* @return the dataset bean
* @throws Exception the exception
*/
@Override
public DatasetBean updateCKANDataset(DatasetBean toUpdate) throws Exception {
try {
devModeSetContexts();
logger.info("Request for updating a dataset with title: {} " + toUpdate.getTitle());
if (logger.isDebugEnabled()) {
logger.debug("Dataset is: {} " + toUpdate);
}
if (toUpdate.getCkanName() == null)
throw new Exception("Error on updating: the input parameter 'name' is null");
String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
String title = toUpdate.getTitle();
String organizationNameOrId = toUpdate.getSelectedOrganization();
String author = toUpdate.getAuthorFullName();
String authorMail = toUpdate.getAuthorEmail();
String maintainer = toUpdate.getMaintainer();
String maintainerMail = toUpdate.getMaintainerEmail();
long version = toUpdate.getVersion();
String description = toUpdate.getDescription();
String chosenLicense = toUpdate.getLicense();
String licenseId = findLicenseIdByLicense(chosenLicense);
List<String> listOfTags = toUpdate.getTags();
Map<String, List<String>> customFields = toUpdate.getCustomFields();
// add Type for custom fields
if (toUpdate.getChosenType() != null)
customFields.put(SYS_TYPE, Arrays.asList(toUpdate.getChosenType()));
boolean setPublic = toUpdate.getVisibility();
// get the list of resources and convert to ResourceBean
List<ResourceBean> resources = null;
ResourceElementBean resourcesToAdd = toUpdate.getResourceRoot();
// converting to resources to be added
if (resourcesToAdd != null) {
Workspace workspace = getWorkspaceFromStorageHub();
resources = WorkspaceUtils.toResources(toUpdate, workspace, userName);
}
logger.debug("The user wants to publish in organization with name " + organizationNameOrId);
String scope = getScopeFromOrgName(organizationNameOrId);
DataCatalogue utils = getCatalogue(scope);
if (!isWithinPortal()) {
logger.debug("Should be added:");
for (String key : customFields.keySet()) {
logger.debug("Custom field with key: " + key + ", value: " + customFields.get(key));
}
}
String datasetId = utils.updateCkanDatasetMultipleCustomFields(userName, title, toUpdate.getCkanName(),
organizationNameOrId, author, authorMail, maintainer, maintainerMail, version, description,
licenseId, listOfTags, customFields, resources, setPublic, true, true);
if (datasetId != null) {
logger.info("Dataset updated!");
toUpdate.setId(datasetId);
// #23491 Building the go to the item to "Catalogue Portlet URL" (instead of URI
// Resolver URL)
String catalogueURL = utils.getPortletUrl();
// logger.debug("Returning catalogueURL: "+catalogueURL);
// logger.debug("Returning datasetId: "+datasetId);
toUpdate.setSource(String.format("%s?path=/dataset/%s", catalogueURL, datasetId));
logger.debug("Returning getSource(): " + toUpdate.getSource());
logger.debug("Returning dataset: " + toUpdate);
// #24744 Returning lazy object
toUpdate.setGroups(null);
toUpdate.setCustomFields(null);
toUpdate.setGroupsForceCreation(null);
toUpdate.setMetadataList(null);
toUpdate.setOrganizationList(null);
logger.info("Returning lazy dataset: " + toUpdate);
// createdDatasetBean.getSource();
// createdDatasetBean.getTitle();
// resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(),
// createdDatasetBean.getTitle(),
// createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
return toUpdate;
} else {
logger.error("Failed to update the dataset");
}
} catch (Exception e) {
logger.error("Error while updating item ", e);
throw new Exception(e.getMessage());
}
return null;
}
/** /**
* Adds the resource to dataset. * Adds the resource to dataset.
* *
@ -691,7 +809,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public List<MetaDataProfileBean> getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName) public MetadataProfileBeanForUpdate getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName)
throws Exception { throws Exception {
logger.info("Called getProfileForUpdate for orgName {} and dataset type {} ", orgName, datasetType); logger.info("Called getProfileForUpdate for orgName {} and dataset type {} ", orgName, datasetType);
logger.debug("Requested profiles for products into orgName " + orgName); logger.debug("Requested profiles for products into orgName " + orgName);
@ -715,7 +833,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
throw e; throw e;
} }
HttpSession httpSession = this.getThreadLocalRequest().getSession();
// retrieve scope per current portlet url // retrieve scope per current portlet url
String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest()); String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername(); String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
@ -728,23 +845,49 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// Settings current values in the profile found // Settings current values in the profile found
MetaDataProfileBean profileBean = toReturn.get(0); MetaDataProfileBean profileBean = toReturn.get(0);
logger.trace("The profile is {}", profileBean); logger.trace("The profile is {}", profileBean);
Map<String, String> extras = dataset.getExtrasAsHashMap(); Map<String, List<String>> extras = dataset.getExtrasAsHashMap();
HashMap<String, List<String>> customFieldsMap = new HashMap<String, List<String>>(extras);
logger.trace("Current extras are {}", extras); logger.trace("Current extras are {}", extras);
for (MetadataFieldWrapper metadataFieldWrapper : profileBean.getMetadataFields()) { for (MetadataFieldWrapper metadataFieldWrapper : profileBean.getMetadataFields()) {
String fieldName = metadataFieldWrapper.getFieldName(); String fieldName = metadataFieldWrapper.getFieldName();
logger.trace("Searching field name {} in the profile", fieldName); // removing profile key from the map
String currValueOfExtraField = extras.get(metadataFieldWrapper.getFieldName()); customFieldsMap.remove(fieldName);
logger.trace("Current value found is {} for field name {}", currValueOfExtraField, fieldName); logger.trace("Searching field name '{}' in the profile", fieldName);
metadataFieldWrapper.setCurrentValues(currValueOfExtraField); List<String> currValuesOfExtraField = extras.get(metadataFieldWrapper.getFieldName());
logger.trace("Current value found is '{}' for field name '{}'", currValuesOfExtraField, fieldName);
metadataFieldWrapper.setCurrentValues(currValuesOfExtraField.stream().toArray(String[]::new));
} }
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Returning filled profile {}", profileBean.getType()); logger.debug("Returning filled profile {}", profileBean.getType());
logger.debug("with MetadataFields {}", profileBean.getMetadataFields()); logger.debug("with MetadataFields {}", profileBean.getMetadataFields());
logger.debug("Custom fields founds {}", customFieldsMap.keySet());
} }
int customFieldsSize = customFieldsMap.size();
// There are the Custom Fields not belonging to profile
logger.info("Custom fields founds # {}", customFieldsSize);
if (customFieldsSize > 0) {
logger.info("Purging extras with prefix 'system:' from custom fields..");
for (String key : customFieldsMap.keySet()) {
if (key.startsWith(SYSTEM_KEY_PREFIX)) {
customFieldsMap.remove(key);
}
}
}
logger.info("custom fields to return {}", customFieldsMap.keySet());
MetadataProfileBeanForUpdate mpfu = new MetadataProfileBeanForUpdate();
mpfu.setListProfileBean(Arrays.asList(profileBean));
mpfu.setCustomFields(customFieldsMap);
logger.info("returing the filled profile {}", profileBean.getType()); logger.info("returing the filled profile {}", profileBean.getType());
return Arrays.asList(profileBean); return mpfu;
} }
/** /**
@ -1030,5 +1173,42 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
throw new Exception("GeoJSON field with value '" + geoJson + "' seems not valid!"); throw new Exception("GeoJSON field with value '" + geoJson + "' seems not valid!");
} }
} }
public static Map<String, List<String>> purgeSystemFields(Map<String, List<String>> extras) {
if (extras == null)
return null;
Map<String, List<String>> extrasPop = new HashMap<String, List<String>>(extras);
for (String key : extras.keySet()) {
List<String> list = SYSTEM_CUSTOM_FIELDS_PREFIXES.stream().filter(scf -> key.startsWith(scf))
.collect(Collectors.toList());
if (list.size() > 0)
extrasPop.remove(key);
}
return extrasPop;
}
public static Map<String, List<String>> getSystemFields(Map<String, List<String>> extras) {
if (extras == null)
return null;
Map<String, List<String>> systemExtras = new HashMap<String, List<String>>();
for (String key : extras.keySet()) {
List<String> list = SYSTEM_CUSTOM_FIELDS_PREFIXES.stream().filter(scf -> key.startsWith(scf))
.collect(Collectors.toList());
if (list.size() > 0)
systemExtras.put(key, extras.get(key));
}
return systemExtras;
}
} }

View File

@ -12,12 +12,25 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* This bean will contain during ckan metadata creation information related to * This bean will contain during ckan metadata creation information related to
* the future build. * the future build.
* *
* revisited by @author Francesco Mangiacrapa at ISTI-CNR
*
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class DatasetBean implements Serializable, IsSerializable { public class DatasetBean implements Serializable, IsSerializable {
private String id; private String id;
private String ckanName;
public String getCkanName() {
return ckanName;
}
public void setCkanName(String ckanName) {
this.ckanName = ckanName;
}
private String title; private String title;
private String description; private String description;
private String license; // chosen by the user private String license; // chosen by the user
@ -45,32 +58,37 @@ public class DatasetBean implements Serializable, IsSerializable {
private List<OrganizationBean> groupsForceCreation; private List<OrganizationBean> groupsForceCreation;
private List<ResourceElementBean> resources; private List<ResourceElementBean> resources;
/**
* Instantiates a new dataset bean.
*/
public DatasetBean() { public DatasetBean() {
super(); super();
} }
/** /**
* Create a metadata bean object. * Create a metadata bean object.
* *
* @param id * @param id the id
* @param title * @param title the title
* @param description * @param description the description
* @param customFields * @param customFields the custom fields
* @param tags * @param tags the tags
* @param license * @param license the license
* @param visibility * @param visible the visible
* @param source * @param source the source
* @param version * @param version the version
* @param author * @param authorName the author name
* @param authorEmail * @param authorSurname the author surname
* @param maintainer * @param authorEmail the author email
* @param maintainerEmail * @param maintainer the maintainer
* @param ownerIdentifier * @param maintainerEmail the maintainer email
* @param organizationList * @param ownerIdentifier the owner identifier
* @param selectedOrganization * @param organizationList the organization list
* @param resourcesIds * @param selectedOrganization the selected organization
* @param addResources * @param resourceRoot the resource root
* @param metadataList * @param metadataList the metadata list
* @param groups the groups
* @param tagsVocabulary the tags vocabulary
*/ */
public DatasetBean(String id, String title, String description, Map<String, List<String>> customFields, public DatasetBean(String id, String title, String description, Map<String, List<String>> customFields,
List<String> tags, String license, boolean visible, String source, long version, String authorName, List<String> tags, String license, boolean visible, String source, long version, String authorName,
@ -101,202 +119,452 @@ public class DatasetBean implements Serializable, IsSerializable {
this.tagsVocabulary = tagsVocabulary; this.tagsVocabulary = tagsVocabulary;
} }
/**
* Gets the chosen type.
*
* @return the chosen type
*/
public String getChosenType() { public String getChosenType() {
return chosenType; return chosenType;
} }
/**
* Sets the chosen type.
*
* @param chosenType the new chosen type
*/
public void setChosenType(String chosenType) { public void setChosenType(String chosenType) {
this.chosenType = chosenType; this.chosenType = chosenType;
} }
/**
* Gets the metadata list.
*
* @return the metadata list
*/
public List<MetaDataProfileBean> getMetadataList() { public List<MetaDataProfileBean> getMetadataList() {
return metadataList; return metadataList;
} }
/**
* Sets the metadata list.
*
* @param metadataListTypes the new metadata list
*/
public void setMetadataList(List<MetaDataProfileBean> metadataListTypes) { public void setMetadataList(List<MetaDataProfileBean> metadataListTypes) {
this.metadataList = metadataListTypes; this.metadataList = metadataListTypes;
} }
/**
* Gets the id.
*
* @return the id
*/
public String getId() { public String getId() {
return id; return id;
} }
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
/**
* Gets the owner identifier.
*
* @return the owner identifier
*/
public String getOwnerIdentifier() { public String getOwnerIdentifier() {
return ownerIdentifier; return ownerIdentifier;
} }
/**
* Sets the owner identifier.
*
* @param ownerIdentifier the new owner identifier
*/
public void setOwnerIdentifier(String ownerIdentifier) { public void setOwnerIdentifier(String ownerIdentifier) {
this.ownerIdentifier = ownerIdentifier; this.ownerIdentifier = ownerIdentifier;
} }
/**
* 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;
} }
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() { public String getDescription() {
return description; return description;
} }
/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
/**
* Gets the custom fields.
*
* @return the custom fields
*/
public Map<String, List<String>> getCustomFields() { public Map<String, List<String>> getCustomFields() {
return customFields; return customFields;
} }
/**
* Sets the custom fields.
*
* @param customFields the custom fields
*/
public void setCustomFields(Map<String, List<String>> customFields) { public void setCustomFields(Map<String, List<String>> customFields) {
this.customFields = customFields; this.customFields = customFields;
} }
/**
* Gets the tags.
*
* @return the tags
*/
public List<String> getTags() { public List<String> getTags() {
return tags; return tags;
} }
/**
* Sets the tags.
*
* @param tags the new tags
*/
public void setTags(List<String> tags) { public void setTags(List<String> tags) {
this.tags = tags; this.tags = tags;
} }
/**
* Gets the license.
*
* @return the license
*/
public String getLicense() { public String getLicense() {
return license; return license;
} }
/**
* Sets the license.
*
* @param license the new license
*/
public void setLicense(String license) { public void setLicense(String license) {
this.license = license; this.license = license;
} }
/**
* Gets the visibility.
*
* @return the visibility
*/
public boolean getVisibility() { public boolean getVisibility() {
return visible; return visible;
} }
/**
* Sets the visibile.
*
* @param visibile the new visibile
*/
public void setVisibile(boolean visibile) { public void setVisibile(boolean visibile) {
this.visible = visibile; this.visible = visibile;
} }
/**
* Gets the source.
*
* @return the source
*/
public String getSource() { public String getSource() {
return source; return source;
} }
/**
* Sets the source.
*
* @param source the new source
*/
public void setSource(String source) { public void setSource(String source) {
this.source = source; this.source = source;
} }
/**
* Gets the version.
*
* @return the version
*/
public long getVersion() { public long getVersion() {
return version; return version;
} }
/**
* Sets the version.
*
* @param version the new version
*/
public void setVersion(long version) { public void setVersion(long version) {
this.version = version; this.version = version;
} }
/**
* Gets the author name.
*
* @return the author name
*/
public String getAuthorName() { public String getAuthorName() {
return authorName; return authorName;
} }
/**
* Sets the author name.
*
* @param authorName the new author name
*/
public void setAuthorName(String authorName) { public void setAuthorName(String authorName) {
this.authorName = authorName; this.authorName = authorName;
} }
/**
* Gets the author surname.
*
* @return the author surname
*/
public String getAuthorSurname() { public String getAuthorSurname() {
return authorSurname; return authorSurname;
} }
/**
* Sets the author surname.
*
* @param authorSurname the new author surname
*/
public void setAuthorSurname(String authorSurname) { public void setAuthorSurname(String authorSurname) {
this.authorSurname = authorSurname; this.authorSurname = authorSurname;
} }
/**
* Gets the author email.
*
* @return the author email
*/
public String getAuthorEmail() { public String getAuthorEmail() {
return authorEmail; return authorEmail;
} }
/**
* Sets the author email.
*
* @param authorEmail the new author email
*/
public void setAuthorEmail(String authorEmail) { public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail; this.authorEmail = authorEmail;
} }
/**
* Gets the maintainer.
*
* @return the maintainer
*/
public String getMaintainer() { public String getMaintainer() {
return maintainer; return maintainer;
} }
/**
* Sets the maintainer.
*
* @param maintainer the new maintainer
*/
public void setMaintainer(String maintainer) { public void setMaintainer(String maintainer) {
this.maintainer = maintainer; this.maintainer = maintainer;
} }
/**
* Gets the maintainer email.
*
* @return the maintainer email
*/
public String getMaintainerEmail() { public String getMaintainerEmail() {
return maintainerEmail; return maintainerEmail;
} }
/**
* Sets the maintainer email.
*
* @param maintainerEmail the new maintainer email
*/
public void setMaintainerEmail(String maintainerEmail) { public void setMaintainerEmail(String maintainerEmail) {
this.maintainerEmail = maintainerEmail; this.maintainerEmail = maintainerEmail;
} }
/**
* Gets the organization list.
*
* @return the organization list
*/
public List<OrganizationBean> getOrganizationList() { public List<OrganizationBean> getOrganizationList() {
return organizationList; return organizationList;
} }
/**
* Sets the organization list.
*
* @param organizationList the new organization list
*/
public void setOrganizationList(List<OrganizationBean> organizationList) { public void setOrganizationList(List<OrganizationBean> organizationList) {
this.organizationList = organizationList; this.organizationList = organizationList;
} }
/**
* Gets the selected organization.
*
* @return the selected organization
*/
public String getSelectedOrganization() { public String getSelectedOrganization() {
return selectedOrganization; return selectedOrganization;
} }
/**
* Sets the selected organization.
*
* @param selectedOrganization the new selected organization
*/
public void setSelectedOrganization(String selectedOrganization) { public void setSelectedOrganization(String selectedOrganization) {
this.selectedOrganization = selectedOrganization; this.selectedOrganization = selectedOrganization;
} }
/**
* Gets the resource root.
*
* @return the resource root
*/
public ResourceElementBean getResourceRoot() { public ResourceElementBean getResourceRoot() {
return resourceRoot; return resourceRoot;
} }
/**
* Sets the resource root.
*
* @param resourceRoot the new resource root
*/
public void setResourceRoot(ResourceElementBean resourceRoot) { public void setResourceRoot(ResourceElementBean resourceRoot) {
this.resourceRoot = resourceRoot; this.resourceRoot = resourceRoot;
} }
/**
* Gets the author full name.
*
* @return the author full name
*/
public String getAuthorFullName() { public String getAuthorFullName() {
return authorFullName; return authorFullName;
} }
/**
* Sets the author full name.
*
* @param authorFullName the new author full name
*/
public void setAuthorFullName(String authorFullName) { public void setAuthorFullName(String authorFullName) {
this.authorFullName = authorFullName; this.authorFullName = authorFullName;
} }
/**
* Gets the groups.
*
* @return the groups
*/
public List<OrganizationBean> getGroups() { public List<OrganizationBean> getGroups() {
return groups; return groups;
} }
/**
* Sets the groups.
*
* @param groups the new groups
*/
public void setGroups(List<OrganizationBean> groups) { public void setGroups(List<OrganizationBean> groups) {
this.groups = groups; this.groups = groups;
} }
/**
* Gets the tags vocabulary.
*
* @return the tags vocabulary
*/
public List<String> getTagsVocabulary() { public List<String> getTagsVocabulary() {
return tagsVocabulary; return tagsVocabulary;
} }
/**
* Sets the tags vocabulary.
*
* @param tagsVocabulary the new tags vocabulary
*/
public void setTagsVocabulary(List<String> tagsVocabulary) { public void setTagsVocabulary(List<String> tagsVocabulary) {
this.tagsVocabulary = tagsVocabulary; this.tagsVocabulary = tagsVocabulary;
} }
/**
* Gets the groups force creation.
*
* @return the groups force creation
*/
public List<OrganizationBean> getGroupsForceCreation() { public List<OrganizationBean> getGroupsForceCreation() {
return groupsForceCreation; return groupsForceCreation;
} }
/**
* Sets the groups force creation.
*
* @param groupsForceCreation the new groups force creation
*/
public void setGroupsForceCreation(List<OrganizationBean> groupsForceCreation) { public void setGroupsForceCreation(List<OrganizationBean> groupsForceCreation) {
this.groupsForceCreation = groupsForceCreation; this.groupsForceCreation = groupsForceCreation;
} }
/**
* Sets the resources.
*
* @param resources the new resources
*/
public void setResources(List<ResourceElementBean> resources) { public void setResources(List<ResourceElementBean> resources) {
this.resources = resources; this.resources = resources;
} }
/**
* Gets the ckan resources.
*
* @return the ckan resources
*/
public List<ResourceElementBean> getCkanResources() { public List<ResourceElementBean> getCkanResources() {
return resources; return resources;
} }
@ -306,6 +574,8 @@ public class DatasetBean implements Serializable, IsSerializable {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("DatasetBean [id="); builder.append("DatasetBean [id=");
builder.append(id); builder.append(id);
builder.append(", ckanName=");
builder.append(ckanName);
builder.append(", title="); builder.append(", title=");
builder.append(title); builder.append(title);
builder.append(", description="); builder.append(", description=");
@ -338,6 +608,8 @@ public class DatasetBean implements Serializable, IsSerializable {
builder.append(visible); builder.append(visible);
builder.append(", organizationList="); builder.append(", organizationList=");
builder.append(organizationList); builder.append(organizationList);
builder.append(", resourceRoot=");
builder.append(resourceRoot);
builder.append(", metadataList="); builder.append(", metadataList=");
builder.append(metadataList); builder.append(metadataList);
builder.append(", tags="); builder.append(", tags=");
@ -354,6 +626,4 @@ public class DatasetBean implements Serializable, IsSerializable {
return builder.toString(); return builder.toString();
} }
} }

View File

@ -0,0 +1,96 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
/**
* The Class MetadataProfileBeanForUpdate.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 8, 2024
*/
public class MetadataProfileBeanForUpdate implements Serializable {
/**
*
*/
private static final long serialVersionUID = -389855531761329707L;
private List<MetaDataProfileBean> listProfileBean;
private Map<String, List<String>> customFields;
/**
* Instantiates a new metadata profile bean for update.
*/
public MetadataProfileBeanForUpdate() {
super();
}
/**
* Instantiates a new metadata profile bean for update.
*
* @param listProfileBean the list profile bean
* @param customFields the custom fields
*/
public MetadataProfileBeanForUpdate(List<MetaDataProfileBean> listProfileBean, Map<String, List<String>> customFields) {
super();
this.listProfileBean = listProfileBean;
this.customFields = customFields;
}
/**
* Gets the list profile bean.
*
* @return the list profile bean
*/
public List<MetaDataProfileBean> getListProfileBean() {
return listProfileBean;
}
/**
* Gets the custom fields.
*
* @return the custom fields
*/
public Map<String, List<String>> getCustomFields() {
return customFields;
}
/**
* Sets the list profile bean.
*
* @param listProfileBean the new list profile bean
*/
public void setListProfileBean(List<MetaDataProfileBean> listProfileBean) {
this.listProfileBean = listProfileBean;
}
/**
* Sets the custom fields.
*
* @param customFields the custom fields
*/
public void setCustomFields(Map<String, List<String>> customFields) {
this.customFields = customFields;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("MetadataProfileBeanForUpdate [listProfileBean=");
builder.append(listProfileBean);
builder.append(", customFields=");
builder.append(customFields);
builder.append("]");
return builder.toString();
}
}

View File

@ -2,6 +2,9 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
@ -9,6 +12,7 @@ import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory; import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl; import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
@ -38,7 +42,7 @@ public class TestPublishingWidget {
public void before() throws Exception { public void before() throws Exception {
} }
@Test //@Test
public void getDataset() { public void getDataset() {
try { try {
@ -128,5 +132,23 @@ public class TestPublishingWidget {
LOG.info("Got dataset: " + bean); LOG.info("Got dataset: " + bean);
} }
//@Test
public void extrasManage() {
Map<String, List<String>> extras = new HashMap<String, List<String>>();
extras.put("ciao", Arrays.asList("ciao value"));
extras.put(CKANPublisherServicesImpl.SYSTEM_CUSTOM_FIELDS_PREFIXES.get(0), Arrays.asList("rem value 1"));
extras.put(CKANPublisherServicesImpl.SYSTEM_CUSTOM_FIELDS_PREFIXES.get(1), Arrays.asList("rem value 2"));
extras.put(CKANPublisherServicesImpl.SYS_TYPE, Arrays.asList("ciao value"));
extras.put("ultimo value", Arrays.asList("ultimo value"));
Map<String, List<String>> pop = CKANPublisherServicesImpl.purgeSystemFields(extras);
System.out.println("POP: " + pop);
Map<String, List<String>> push = CKANPublisherServicesImpl.getSystemFields(extras);
System.out.println("PUSH: " + push);
}
} }