refactored some classes
This commit is contained in:
parent
111889b6d0
commit
d562070704
|
@ -2,10 +2,20 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler associated to the DeleteCustomFieldEvent
|
* The Interface DeleteCustomFieldEventHandler.
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Feb 12, 2024
|
||||||
*/
|
*/
|
||||||
public interface DeleteCustomFieldEventHandler extends EventHandler {
|
public interface DeleteCustomFieldEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On remove entry.
|
||||||
|
*
|
||||||
|
* @param event the event
|
||||||
|
*/
|
||||||
void onRemoveEntry(DeleteCustomFieldEvent event);
|
void onRemoveEntry(DeleteCustomFieldEvent event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCu
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddedResourcesSummary;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
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;
|
||||||
|
@ -29,7 +30,6 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddedResourcesSummary;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
||||||
|
@ -1280,7 +1280,7 @@ public class CreateDatasetForm extends Composite {
|
||||||
createDatasetMainPanel.clear();
|
createDatasetMainPanel.clear();
|
||||||
|
|
||||||
// TabPanelException
|
// TabPanelException
|
||||||
tabPanel = new TabPanel(Tabs.ABOVE);
|
tabPanel = new TabPanel(Tabs.LEFT);
|
||||||
tabPanel.setWidth("100%");
|
tabPanel.setWidth("100%");
|
||||||
|
|
||||||
// add the form
|
// add the form
|
||||||
|
|
|
@ -13,25 +13,26 @@ import java.util.Set;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddedResourcesSummary;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
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.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.mpformbuilder.client.form.MetaDataField;
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddedResourcesSummary;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
||||||
|
@ -364,7 +365,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 updateDatasetFormBody(final HandlerManager eventBus, String datasetIdOrName,
|
private void updateDatasetFormBody(final HandlerManager eventBus, final String datasetIdOrName,
|
||||||
final OPERATION operation) {
|
final OPERATION operation) {
|
||||||
|
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
@ -374,7 +375,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
iconSpinner.setSpin(true);
|
iconSpinner.setSpin(true);
|
||||||
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
|
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
|
||||||
|
|
||||||
List<String> listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Publish");
|
List<String> listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Update");
|
||||||
|
|
||||||
this.wizCreator = new WizardCreator(listOfSteps);
|
this.wizCreator = new WizardCreator(listOfSteps);
|
||||||
wizardCreatorPanel.add(wizCreator);
|
wizardCreatorPanel.add(wizCreator);
|
||||||
|
@ -494,9 +495,11 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// bean.getResourceRoot());
|
// bean.getResourceRoot());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (bean.getResourceRoot() != null)
|
// The resource root is the folder id. Es. ID of the Workspace Root folder.
|
||||||
|
if (bean.getResourceRoot() != null) {
|
||||||
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
||||||
bean.getResourceRoot());
|
bean.getResourceRoot());
|
||||||
|
}
|
||||||
|
|
||||||
// set organizations
|
// set organizations
|
||||||
List<OrganizationBean> organizations = bean.getOrganizationList();
|
List<OrganizationBean> organizations = bean.getOrganizationList();
|
||||||
|
@ -646,6 +649,9 @@ public class UpdateDatasetForm extends Composite {
|
||||||
false);
|
false);
|
||||||
continueButton.setEnabled(true);
|
continueButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
resetButton.setEnabled(true);
|
||||||
|
|
||||||
|
manageAddResources(bean,
|
||||||
|
datasetIdOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,8 +717,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
*
|
*
|
||||||
* @param operation the operation
|
* @param operation the operation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//NEVER USED IN UPDATE MODE
|
// 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
|
||||||
|
@ -832,7 +838,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();
|
||||||
|
|
||||||
|
@ -898,6 +904,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), metadataTypeListbox);
|
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), metadataTypeListbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1356,57 +1363,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
updateButton.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) {
|
manageAddResources(createdDatasetBean, datasetUrl);
|
||||||
|
|
||||||
try {
|
|
||||||
// show the add resources button
|
|
||||||
addResourcesButton.setVisible(true);
|
|
||||||
|
|
||||||
addResourcesButton.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
|
|
||||||
// remove content of the main panel
|
|
||||||
createDatasetMainPanel.clear();
|
|
||||||
|
|
||||||
// TabPanelException
|
|
||||||
tabPanel = new TabPanel(Tabs.ABOVE);
|
|
||||||
tabPanel.setWidth("100%");
|
|
||||||
|
|
||||||
// add the form
|
|
||||||
|
|
||||||
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(),
|
|
||||||
createdDatasetBean.getTitle(),
|
|
||||||
createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
|
||||||
|
|
||||||
// tab for the form
|
|
||||||
Tab formContainer = new Tab();
|
|
||||||
formContainer.add(resourceForm);
|
|
||||||
formContainer.setHeading("Add New Resource");
|
|
||||||
tabPanel.add(formContainer);
|
|
||||||
|
|
||||||
// tab for the added resources
|
|
||||||
Tab addedResources = new Tab();
|
|
||||||
addedResources.add(new AddedResourcesSummary(eventBus));
|
|
||||||
addedResources.setHeading("Added Resource");
|
|
||||||
tabPanel.add(addedResources);
|
|
||||||
|
|
||||||
// add tabs to resources panel
|
|
||||||
tabPanel.selectTab(0);
|
|
||||||
|
|
||||||
// form container
|
|
||||||
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
|
||||||
container.add(tabPanel);
|
|
||||||
|
|
||||||
// add the new content of the main panel
|
|
||||||
createDatasetMainPanel.add(container);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e2) {
|
|
||||||
// silent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1425,6 +1382,110 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void manageAddResources(final DatasetBean theDatasetBean, String datasetUrl) {
|
||||||
|
|
||||||
|
// if we are in the "general case" we need to show a form for adding resources
|
||||||
|
if (!isWorkspaceRequest) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// show the add resources button
|
||||||
|
addResourcesButton.setVisible(true);
|
||||||
|
|
||||||
|
final AddedResourcesSummary addedResourcesSummary = initTabManageResourcePanel(theDatasetBean, datasetUrl);
|
||||||
|
|
||||||
|
final List<ResourceElementBean> resources = theDatasetBean.getCkanResources();
|
||||||
|
GWT.log("Resources are: " + resources);
|
||||||
|
|
||||||
|
if (resources != null
|
||||||
|
&& resources.size() > 0) {
|
||||||
|
GWT.log("Executing are: " + resources);
|
||||||
|
for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
||||||
|
eventBus.fireEvent(new AddResourceEvent(reb));
|
||||||
|
//addedResourcesSummary.getEventBus().fireEvent(new AddResourceEvent(reb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NB!!! addResourcesButton must be clicked once
|
||||||
|
|
||||||
|
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
// @Override
|
||||||
|
// public void execute() {
|
||||||
|
// GWT.log("Executing are: " + resources);
|
||||||
|
//
|
||||||
|
// if (resources != null
|
||||||
|
// && resources.size() > 0) {
|
||||||
|
//
|
||||||
|
// for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
||||||
|
// addedResourcesSummary.getEventBus().fireEvent(new AddResourceEventProfile(reb));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
addResourcesButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
// remove content of the main panel
|
||||||
|
createDatasetMainPanel.clear();
|
||||||
|
|
||||||
|
tabPanel.selectTab(0);
|
||||||
|
|
||||||
|
// form container
|
||||||
|
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
|
container.add(tabPanel);
|
||||||
|
|
||||||
|
// add the new content of the main panel
|
||||||
|
createDatasetMainPanel.add(container);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e2) {
|
||||||
|
// silent
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private AddedResourcesSummary initTabManageResourcePanel(final DatasetBean theDatasetBean, String datasetUrl) {
|
||||||
|
// TabPanelException
|
||||||
|
|
||||||
|
if(tabPanel!=null)
|
||||||
|
tabPanel.clear();
|
||||||
|
|
||||||
|
tabPanel = new TabPanel(Tabs.LEFT);
|
||||||
|
tabPanel.setWidth("100%");
|
||||||
|
|
||||||
|
// add the form
|
||||||
|
|
||||||
|
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(),
|
||||||
|
theDatasetBean.getTitle(), theDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
||||||
|
|
||||||
|
// tab for the form
|
||||||
|
Tab formContainer = new Tab();
|
||||||
|
formContainer.add(resourceForm);
|
||||||
|
formContainer.setHeading("Add New Resource");
|
||||||
|
tabPanel.add(formContainer);
|
||||||
|
|
||||||
|
// tab for the added resources
|
||||||
|
Tab addedResources = new Tab();
|
||||||
|
AddedResourcesSummary addedResourcesSummary = new AddedResourcesSummary(eventBus);
|
||||||
|
addedResources.add(addedResourcesSummary);
|
||||||
|
addedResources.setHeading("Added Resource");
|
||||||
|
tabPanel.add(addedResources);
|
||||||
|
|
||||||
|
return addedResourcesSummary;
|
||||||
|
|
||||||
|
// add tabs to resources panel
|
||||||
|
// tabPanel.selectTab(0);
|
||||||
|
|
||||||
|
// // form container
|
||||||
|
// AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
|
// container.add(tabPanel);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the info icons of all core metadata info.
|
* Prepare the info icons of all core metadata info.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEvent;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEvent;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteResourceEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Accordion;
|
||||||
|
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
|
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.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A summary of the resources added by the user.
|
||||||
|
*
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class AddedResourcesSummary extends Composite {
|
||||||
|
|
||||||
|
private static AddedResourcesSummaryUiBinder uiBinder = GWT.create(AddedResourcesSummaryUiBinder.class);
|
||||||
|
|
||||||
|
interface AddedResourcesSummaryUiBinder extends UiBinder<Widget, AddedResourcesSummary> {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event bus
|
||||||
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
// list of added resources (beans)
|
||||||
|
List<ResourceElementBean> addedResources;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
VerticalPanel addResourcesPanel;
|
||||||
|
|
||||||
|
public AddedResourcesSummary(HandlerManager eventBus) {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
// save bus
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
// bind on add resource event
|
||||||
|
bind();
|
||||||
|
// init list
|
||||||
|
addedResources = new ArrayList<ResourceElementBean>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind on add/delete resource event
|
||||||
|
*/
|
||||||
|
private void bind() {
|
||||||
|
|
||||||
|
// when a new resource is added
|
||||||
|
eventBus.addHandler(AddResourceEvent.TYPE, new AddResourceEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAddedResource(AddResourceEvent addResourceEvent) {
|
||||||
|
GWT.log("Added resource event: " + addResourceEvent);
|
||||||
|
|
||||||
|
// get the resource
|
||||||
|
final ResourceElementBean justAddedResource = addResourceEvent.getResource();
|
||||||
|
|
||||||
|
// Build an accordion to show resource info
|
||||||
|
Accordion accordion = new Accordion();
|
||||||
|
AccordionGroup accordionGroup = new AccordionGroup();
|
||||||
|
accordionGroup.setHeading("* " + justAddedResource.getName());
|
||||||
|
accordion.add(accordionGroup);
|
||||||
|
|
||||||
|
// add sub-info such as url and description
|
||||||
|
Paragraph pUrl = new Paragraph();
|
||||||
|
pUrl.setText("URL : " + justAddedResource.getUrl());
|
||||||
|
Paragraph pDescription = new Paragraph();
|
||||||
|
pDescription.setText("Description : " + justAddedResource.getDescription());
|
||||||
|
|
||||||
|
// button to delete the resource
|
||||||
|
Button deleteButton = new Button();
|
||||||
|
deleteButton.setText("Delete");
|
||||||
|
deleteButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
eventBus.fireEvent(new DeleteResourceEvent(justAddedResource));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// fill accordion
|
||||||
|
accordionGroup.add(pUrl);
|
||||||
|
accordionGroup.add(pDescription);
|
||||||
|
accordionGroup.add(deleteButton);
|
||||||
|
|
||||||
|
// add to the list
|
||||||
|
addedResources.add(justAddedResource);
|
||||||
|
|
||||||
|
// add to the panel
|
||||||
|
addResourcesPanel.add(accordion);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// when the user wants to delete a resource
|
||||||
|
eventBus.addHandler(DeleteResourceEvent.TYPE, new DeleteResourceEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeletedResource(DeleteResourceEvent deleteResourceEvent) {
|
||||||
|
GWT.log("onDeletedResource resource event: " + deleteResourceEvent);
|
||||||
|
|
||||||
|
// to delete
|
||||||
|
ResourceElementBean toDelete = deleteResourceEvent.getResource();
|
||||||
|
|
||||||
|
// find it
|
||||||
|
for (int i = 0; i < addedResources.size(); i++) {
|
||||||
|
|
||||||
|
if (addedResources.get(i).equals(toDelete)) {
|
||||||
|
|
||||||
|
// get the associated widget and remove it
|
||||||
|
final Widget widget = addResourcesPanel.getWidget(i);
|
||||||
|
|
||||||
|
// remote call to remove it from the dataset
|
||||||
|
CKanMetadataPublisher.ckanServices.deleteResourceFromDataset(toDelete,
|
||||||
|
new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean result) {
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
widget.removeFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove from the list
|
||||||
|
addedResources.remove(toDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerManager getEventBus() {
|
||||||
|
return eventBus;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<!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">
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<h3>Added Resources</h3>
|
||||||
|
<g:VerticalPanel ui:field="addResourcesPanel" width="100%"></g:VerticalPanel>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -6,7 +6,6 @@ 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.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
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;
|
||||||
|
@ -427,7 +426,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
List<ResourceElementBean> list = new ArrayList<ResourceElementBean>(resources.size());
|
List<ResourceElementBean> list = new ArrayList<ResourceElementBean>(resources.size());
|
||||||
for (CkanResource ckanResource : resources) {
|
for (CkanResource ckanResource : resources) {
|
||||||
ResourceElementBean reb = toResourceBean(ckanResource);
|
ResourceElementBean reb = PublisherCatalogueConveter.toResourceElementBean(ckanResource);
|
||||||
list.add(reb);
|
list.add(reb);
|
||||||
}
|
}
|
||||||
bean.setResources(list);
|
bean.setResources(list);
|
||||||
|
@ -447,22 +446,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To resource bean.
|
|
||||||
*
|
|
||||||
* @param ckanResource the ckan resource
|
|
||||||
* @return the resource element bean
|
|
||||||
*/
|
|
||||||
public ResourceElementBean toResourceBean(CkanResource ckanResource) {
|
|
||||||
ResourceElementBean reb = new ResourceElementBean();
|
|
||||||
reb.setName(ckanResource.getName());
|
|
||||||
reb.setDescription(ckanResource.getDescription());
|
|
||||||
reb.setEditableName(ckanResource.getName());
|
|
||||||
reb.setUrl(ckanResource.getUrl());
|
|
||||||
reb.setMimeType(ckanResource.getMimetype());
|
|
||||||
return reb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discover from the IS the vocabulary of tags for this scope, if present.
|
* Discover from the IS the vocabulary of tags for this scope, if present.
|
||||||
*
|
*
|
||||||
|
@ -651,16 +634,25 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// putting all reserved system fields into customFields to update
|
// putting all reserved system fields into customFields to update
|
||||||
customFields.putAll(ckanReserverSystemExtras);
|
customFields.putAll(ckanReserverSystemExtras);
|
||||||
|
|
||||||
|
// Settings the CKAN resources
|
||||||
|
List<CkanResource> listCurrentResources = currentDataset.getResources();
|
||||||
|
List<ResourceBean> resources = null;
|
||||||
|
if (listCurrentResources != null) {
|
||||||
|
resources = new ArrayList<ResourceBean>(listCurrentResources.size());
|
||||||
|
for (CkanResource ckanResource : listCurrentResources) {
|
||||||
|
ResourceBean reb = PublisherCatalogueConveter.toResourceBean(ckanResource);
|
||||||
|
resources.add(reb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean setPublic = toUpdate.getVisibility();
|
boolean setPublic = toUpdate.getVisibility();
|
||||||
|
|
||||||
// get the list of resources and convert to ResourceBean
|
// get the list of resources and convert to ResourceBean from the Workspace
|
||||||
List<ResourceBean> resources = null;
|
|
||||||
ResourceElementBean resourcesToAdd = toUpdate.getResourceRoot();
|
ResourceElementBean resourcesToAdd = toUpdate.getResourceRoot();
|
||||||
|
|
||||||
// converting to resources to be added
|
// converting to resources to be added
|
||||||
if (resourcesToAdd != null) {
|
if (resourcesToAdd != null) {
|
||||||
Workspace workspace = getWorkspaceFromStorageHub();
|
Workspace workspace = getWorkspaceFromStorageHub();
|
||||||
resources = WorkspaceUtils.toResources(toUpdate, workspace, userName);
|
resources.addAll(WorkspaceUtils.toResources(toUpdate, workspace, userName));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("The user wants to publish in organization with name " + organizationNameOrId);
|
logger.debug("The user wants to publish in organization with name " + organizationNameOrId);
|
||||||
|
@ -1246,6 +1238,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge system fields.
|
||||||
|
*
|
||||||
|
* @param extras the extras
|
||||||
|
* @return the map
|
||||||
|
*/
|
||||||
public static Map<String, List<String>> purgeSystemFields(Map<String, List<String>> extras) {
|
public static Map<String, List<String>> purgeSystemFields(Map<String, List<String>> extras) {
|
||||||
logger.info("Purging extras from reserved fields {} ", SYSTEM_CUSTOM_FIELDS_PREFIXES);
|
logger.info("Purging extras from reserved fields {} ", SYSTEM_CUSTOM_FIELDS_PREFIXES);
|
||||||
if (extras == null)
|
if (extras == null)
|
||||||
|
@ -1265,6 +1263,12 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the reserverd system fields.
|
||||||
|
*
|
||||||
|
* @param extras the extras
|
||||||
|
* @return the reserverd system fields
|
||||||
|
*/
|
||||||
public static Map<String, List<String>> getReserverdSystemFields(Map<String, List<String>> extras) {
|
public static Map<String, List<String>> getReserverdSystemFields(Map<String, List<String>> extras) {
|
||||||
logger.info("Reading reserved fields from extras...");
|
logger.info("Reading reserved fields from extras...");
|
||||||
if (extras == null)
|
if (extras == null)
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.server;
|
||||||
|
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.ResourceBean;
|
||||||
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
||||||
|
|
||||||
|
public class PublisherCatalogueConveter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To resource element bean.
|
||||||
|
*
|
||||||
|
* @param ckanResource the ckan resource
|
||||||
|
* @return the resource element bean
|
||||||
|
*/
|
||||||
|
public static ResourceElementBean toResourceElementBean(CkanResource ckanResource) {
|
||||||
|
ResourceElementBean reb = new ResourceElementBean();
|
||||||
|
reb.setName(ckanResource.getName());
|
||||||
|
reb.setDescription(ckanResource.getDescription());
|
||||||
|
reb.setEditableName(ckanResource.getName());
|
||||||
|
reb.setUrl(ckanResource.getUrl());
|
||||||
|
reb.setMimeType(ckanResource.getMimetype());
|
||||||
|
return reb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To resource bean.
|
||||||
|
*
|
||||||
|
* @param ckanResource the ckan resource
|
||||||
|
* @return the resource bean
|
||||||
|
*/
|
||||||
|
public static ResourceBean toResourceBean(CkanResource ckanResource) {
|
||||||
|
ResourceBean reb = new ResourceBean();
|
||||||
|
reb.setName(ckanResource.getName());
|
||||||
|
reb.setDescription(ckanResource.getDescription());
|
||||||
|
reb.setId(ckanResource.getId());
|
||||||
|
reb.setUrl(ckanResource.getUrl());
|
||||||
|
reb.setMimeType(ckanResource.getMimetype());
|
||||||
|
reb.setOwner(ckanResource.getOwner());
|
||||||
|
reb.setDatasetId(ckanResource.getPackageId());
|
||||||
|
return reb;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -252,101 +252,6 @@ public class WorkspaceUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Returns ResourceElementBean corresponding to workspaceFolderId
|
|
||||||
// *
|
|
||||||
// * @param workspaceFolderId the workspace folder id
|
|
||||||
// * @param workspace the workspace
|
|
||||||
// * @return ResourceElementBean a tree object
|
|
||||||
// * @throws Exception the exception
|
|
||||||
// */
|
|
||||||
// public static ResourceElementBean toResourceEBFromFolder(String workspaceFolderId, Workspace workspace) throws Exception{
|
|
||||||
//
|
|
||||||
// ResourceElementBean rootElem = new ResourceElementBean();
|
|
||||||
// String pathSeparator = "/";
|
|
||||||
//
|
|
||||||
// //String pathSeparator = ws.getPathSeparator();
|
|
||||||
//
|
|
||||||
// WorkspaceItem initialItem = workspace.getItem(workspaceFolderId);
|
|
||||||
// String fullPathBase = initialItem.getPath();
|
|
||||||
// fullPathBase = fullPathBase.endsWith(pathSeparator) ? fullPathBase : fullPathBase + pathSeparator;
|
|
||||||
// rootElem.setFolder(initialItem.isFolder());
|
|
||||||
// rootElem.setFullPath(initialItem.getPath().replace(fullPathBase, ""));
|
|
||||||
// rootElem.setName(initialItem.getName());
|
|
||||||
// rootElem.setOriginalIdInWorkspace(initialItem.getId());
|
|
||||||
// rootElem.setDescription(initialItem.getDescription());
|
|
||||||
// extractEditableNameFromPath(rootElem, pathSeparator);
|
|
||||||
//
|
|
||||||
// // recursive visiting
|
|
||||||
//// if(initialItem.isFolder())
|
|
||||||
//// visit(rootElem, initialItem, workspace, fullPathBase, pathSeparator);
|
|
||||||
//
|
|
||||||
// logger.debug("Tree that is going to be returned is " + rootElem);
|
|
||||||
// return rootElem;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Recursive visit of a workspace item.
|
|
||||||
// *
|
|
||||||
// * @param parent the parent
|
|
||||||
// * @param initialItemWS the initial item WS
|
|
||||||
// * @param workspace the ws
|
|
||||||
// * @param fullPathBase the full path base
|
|
||||||
// * @param pathSeparator the path separator
|
|
||||||
// * @throws Exception the exception
|
|
||||||
// */
|
|
||||||
// private static void visit(ResourceElementBean parent, WorkspaceItem initialItemWS, Workspace workspace, String fullPathBase, String pathSeparator) throws Exception {
|
|
||||||
// //List<? extends WorkspaceItem> children = initialItemWS.getChildren();
|
|
||||||
//
|
|
||||||
// List<? extends WorkspaceItem> children = workspace.getChildren(initialItemWS.getId());
|
|
||||||
//
|
|
||||||
// ArrayList<ResourceElementBean> childrenInTree = new ArrayList<ResourceElementBean>(children.size());
|
|
||||||
// for (WorkspaceItem item : children) {
|
|
||||||
// // logger.debug("Path BEFORE REPLACE is " + item.getPath());
|
|
||||||
// // logger.debug("Path AFTER REPLACE is " + item.getPath().replace(fullPathBase, ""));
|
|
||||||
// // logger.debug("Name is " + item.getName());
|
|
||||||
// // logger.debug("id is " + item.getId());
|
|
||||||
// ResourceElementBean elem = new ResourceElementBean();
|
|
||||||
// elem.setFolder(item.isFolder());
|
|
||||||
// elem.setOriginalIdInWorkspace(item.getId());
|
|
||||||
// elem.setFullPath(item.getPath().replace(fullPathBase, ""));
|
|
||||||
// elem.setParent(parent);
|
|
||||||
// elem.setName(item.getName());
|
|
||||||
// elem.setDescription(item.getDescription());
|
|
||||||
// extractEditableNameFromPath(elem, pathSeparator);
|
|
||||||
// childrenInTree.add(elem);
|
|
||||||
// logger.trace("Elem is " + elem);
|
|
||||||
// if(item.isFolder())
|
|
||||||
// visit(elem, item, workspace, fullPathBase, pathSeparator);
|
|
||||||
// }
|
|
||||||
// // add these list as child of the rootElem
|
|
||||||
// parent.setChildren(childrenInTree);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Replaces the "/" char with a custom one and return an editable name for the user.
|
|
||||||
// *
|
|
||||||
// * @param rootElem the root elem
|
|
||||||
// * @param pathSeparatorInWs the path separator in ws
|
|
||||||
// */
|
|
||||||
// public static void extractEditableNameFromPath(ResourceElementBean rootElem, String pathSeparatorInWs) {
|
|
||||||
//
|
|
||||||
// if(rootElem == null)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// String elemName = rootElem.getName();
|
|
||||||
// String fullPath = rootElem.getFullPath();
|
|
||||||
// logger.info("Element original is " + rootElem);
|
|
||||||
//
|
|
||||||
// int lastIndex = rootElem.getFullPath().lastIndexOf(elemName);
|
|
||||||
// fullPath = rootElem.getFullPath().substring(0, lastIndex);
|
|
||||||
// fullPath = fullPath.replaceAll(pathSeparatorInWs, RESOURCES_NAME_SEPARATOR) + elemName;
|
|
||||||
// rootElem.setEditableName(fullPath);
|
|
||||||
// logger.info("Editable name for resource name: "+rootElem.getName()+", is: " + rootElem.getEditableName());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy into the .catalogue area folder the checked resources.
|
* Copy into the .catalogue area folder the checked resources.
|
||||||
* There is no difference among a single-file-publish and a folder-publish.
|
* There is no difference among a single-file-publish and a folder-publish.
|
||||||
|
@ -425,89 +330,4 @@ public class WorkspaceUtils {
|
||||||
}
|
}
|
||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
// //MOVED TO GCAT
|
|
||||||
// /**
|
|
||||||
// * Copy into the .catalogue area folder the checked resources.
|
|
||||||
// * There is no difference among a single-file-publish and a folder-publish.
|
|
||||||
// * @param folderId
|
|
||||||
// * @param userName
|
|
||||||
// * @param bean
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public static List<ResourceBean> copyResourcesToUserCatalogueArea(String folderOrFileId, String userName, DatasetBean bean) throws Exception{
|
|
||||||
//
|
|
||||||
// logger.debug("Request to copy onto catalogue area....");
|
|
||||||
// List<ResourceBean> resources = new ArrayList<ResourceBean>();
|
|
||||||
// WorkspaceItem copiedFolder = null;
|
|
||||||
// WorkspaceCatalogue userCatalogue = null;
|
|
||||||
// ResourceElementBean rootResource = bean.getResourceRoot();
|
|
||||||
//
|
|
||||||
// // into the .catalogue area of the user's workspace
|
|
||||||
// Workspace ws = HomeLibrary
|
|
||||||
// .getHomeManagerFactory()
|
|
||||||
// .getHomeManager()
|
|
||||||
// .getHome()
|
|
||||||
// .getWorkspace();
|
|
||||||
//
|
|
||||||
// // Retrieve the catalogue of the user
|
|
||||||
// userCatalogue = ws.getCatalogue();
|
|
||||||
//
|
|
||||||
// // get workspace item (it could be a file or a folder)
|
|
||||||
// WorkspaceItem originalItem = ws.getItem(folderOrFileId);
|
|
||||||
//
|
|
||||||
// // copy the folder in the catalogue if it is a folder, or create a new folder
|
|
||||||
// long referenceTime = System.currentTimeMillis();
|
|
||||||
// if(originalItem.isFolder()){
|
|
||||||
// copiedFolder = userCatalogue.addWorkspaceItem(folderOrFileId, userCatalogue.getId()); // add to .catalogue root area
|
|
||||||
// copiedFolder.setDescription(bean.getDescription());
|
|
||||||
// ((WorkspaceFolder)copiedFolder).rename(CatalogueUtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + referenceTime);
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// copiedFolder = userCatalogue.createFolder(CatalogueUtilMethods.fromProductTitleToName(bean.getTitle()) + "_" + referenceTime, bean.getDescription());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // retrieve the children
|
|
||||||
// List<ResourceElementBean> resourcesToAdd = rootResource.getChildren();
|
|
||||||
//
|
|
||||||
// // copy only the selected ones
|
|
||||||
// for(ResourceElementBean resource : resourcesToAdd){
|
|
||||||
//
|
|
||||||
// if (resource.isToBeAdded()) {
|
|
||||||
//
|
|
||||||
// logger.debug("Resource to add is " + resource);
|
|
||||||
//
|
|
||||||
// // ok it is a file, so copy it into the copiedFolder
|
|
||||||
// WorkspaceItem copiedFile = userCatalogue.addWorkspaceItem(resource.getOriginalIdInWorkspace(), copiedFolder.getId());
|
|
||||||
//
|
|
||||||
// // name and description could have been edited
|
|
||||||
// copiedFile.setDescription(resource.getDescription());
|
|
||||||
//
|
|
||||||
// // check if it is an external url
|
|
||||||
// String externalUrl = null;
|
|
||||||
// try{
|
|
||||||
// boolean isExternalUrl = ((FolderItem)copiedFile).getFolderItemType().equals(FolderItemType.EXTERNAL_URL);
|
|
||||||
// externalUrl = isExternalUrl ? ((ExternalUrl)copiedFile).getUrl() : null;
|
|
||||||
// }catch(Exception e){
|
|
||||||
// logger.warn("Unable to check if it is an external url file ", e);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// resources.add(new ResourceBean(
|
|
||||||
// externalUrl != null ? externalUrl : copiedFile.getPublicLink(true),
|
|
||||||
// resource.getEditableName(),
|
|
||||||
// copiedFile.getDescription(),
|
|
||||||
// copiedFile.getId(),
|
|
||||||
// userName,
|
|
||||||
// null, // dataset id, to be set
|
|
||||||
// ((FolderItem)copiedFile).getMimeType()));
|
|
||||||
//
|
|
||||||
// // postpone rename operation
|
|
||||||
// copiedFile.rename(resource.getEditableName());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// return resources;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -162,6 +162,10 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBeanID(){
|
||||||
|
return identifierGWT;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the parent.
|
* Gets the parent.
|
||||||
|
|
Loading…
Reference in New Issue