edit_facility_26115 #3
|
@ -59,11 +59,12 @@ public interface CKanPublisherService extends RemoteService {
|
||||||
* Add this resource to the dataset whose id is datasetId.
|
* Add this resource to the dataset whose id is datasetId.
|
||||||
*
|
*
|
||||||
* @param resource the resource
|
* @param resource the resource
|
||||||
|
* @param organizationName the organization name
|
||||||
* @param datasetId the dataset id
|
* @param datasetId the dataset id
|
||||||
* @return the resource element bean
|
* @return the resource element bean
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
ResourceElementBean addResourceToDataset(ResourceElementBean resource, String datasetId) throws Exception;
|
ResourceElementBean addResourceToDataset(ResourceElementBean resource, String organizationName, String datasetId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete this resource from the dataset with id datasetId.
|
* Delete this resource from the dataset with id datasetId.
|
||||||
|
|
|
@ -49,10 +49,11 @@ public interface CKanPublisherServiceAsync {
|
||||||
* Add this resource to the dataset whose id is datasetId.
|
* Add this resource to the dataset whose id is datasetId.
|
||||||
*
|
*
|
||||||
* @param resource the resource
|
* @param resource the resource
|
||||||
|
* @param organizationName the organization name
|
||||||
* @param datasetId the dataset id
|
* @param datasetId the dataset id
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
*/
|
*/
|
||||||
void addResourceToDataset(ResourceElementBean resource, String datasetId,
|
void addResourceToDataset(ResourceElementBean resource, String organizationName, String datasetId,
|
||||||
AsyncCallback<ResourceElementBean> callback);
|
AsyncCallback<ResourceElementBean> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,10 +2,12 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deleted resource event.
|
* Deleted resource event.
|
||||||
|
*
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public class DeleteResourceEvent extends GwtEvent<DeleteResourceEventHandler> {
|
public class DeleteResourceEvent extends GwtEvent<DeleteResourceEventHandler> {
|
||||||
|
@ -13,8 +15,11 @@ public class DeleteResourceEvent extends GwtEvent<DeleteResourceEventHandler> {
|
||||||
|
|
||||||
private ResourceElementBean resource;
|
private ResourceElementBean resource;
|
||||||
|
|
||||||
public DeleteResourceEvent(ResourceElementBean resource) {
|
private Button deleteButton;
|
||||||
|
|
||||||
|
public DeleteResourceEvent(Button deleteButton, ResourceElementBean resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
|
this.deleteButton = deleteButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceElementBean getResource() {
|
public ResourceElementBean getResource() {
|
||||||
|
@ -31,4 +36,19 @@ public class DeleteResourceEvent extends GwtEvent<DeleteResourceEventHandler> {
|
||||||
handler.onDeletedResource(this);
|
handler.onDeletedResource(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Button getDeleteButton() {
|
||||||
|
return deleteButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("DeleteResourceEvent [resource=");
|
||||||
|
builder.append(resource);
|
||||||
|
builder.append(", deleteButton=");
|
||||||
|
builder.append(deleteButton);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1301,15 +1301,15 @@ public class CreateDatasetForm extends Composite {
|
||||||
addedResources.setHeading("Added Resource");
|
addedResources.setHeading("Added Resource");
|
||||||
tabPanel.add(addedResources);
|
tabPanel.add(addedResources);
|
||||||
|
|
||||||
// add tabs to resources panel
|
|
||||||
tabPanel.selectTab(0);
|
|
||||||
|
|
||||||
// form container
|
// form container
|
||||||
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
container.add(tabPanel);
|
container.add(tabPanel);
|
||||||
|
|
||||||
// add the new content of the main panel
|
// add the new content of the main panel
|
||||||
createDatasetMainPanel.add(container);
|
createDatasetMainPanel.add(container);
|
||||||
|
|
||||||
|
// add tabs to resources panel
|
||||||
|
tabPanel.selectTab(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
|
|
|
@ -161,7 +161,11 @@ public class UpdateDatasetForm extends Composite {
|
||||||
@UiField
|
@UiField
|
||||||
HorizontalPanel goToDatasetButtonPanel;
|
HorizontalPanel goToDatasetButtonPanel;
|
||||||
@UiField
|
@UiField
|
||||||
Button addResourcesButton;
|
Button addResourcesButtonStep1;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Button addResourcesButtonStep3;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
SimplePanel workspaceResourcesContainer;
|
SimplePanel workspaceResourcesContainer;
|
||||||
@UiField
|
@UiField
|
||||||
|
@ -323,7 +327,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
private WizardCreator wizCreator;
|
private WizardCreator wizCreator;
|
||||||
|
|
||||||
private boolean isWorkspaceRequest = false;
|
private boolean isWorkspaceRequest = false;
|
||||||
private String datasetIdOrName;
|
private String datasetIdOrName = null;
|
||||||
|
private DatasetBean theDataset = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new update dataset form.
|
* Instantiates a new update dataset form.
|
||||||
|
@ -387,6 +392,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// disable continue button
|
// disable continue button
|
||||||
continueButton.setEnabled(false);
|
continueButton.setEnabled(false);
|
||||||
resetButton.setEnabled(false);
|
resetButton.setEnabled(false);
|
||||||
|
addResourcesButtonStep1.setEnabled(false);
|
||||||
|
|
||||||
// hide tags panel
|
// hide tags panel
|
||||||
tagsPanel.setVisible(false);
|
tagsPanel.setVisible(false);
|
||||||
|
@ -415,34 +421,35 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final DatasetBean bean) {
|
public void onSuccess(final DatasetBean datasetBean) {
|
||||||
GWT.log("getDatasetBeanForUpdate returns: " + bean);
|
GWT.log("getDatasetBeanForUpdate returns: " + datasetBean);
|
||||||
|
theDataset = datasetBean;
|
||||||
|
|
||||||
if (bean == null) {
|
if (datasetBean == null) {
|
||||||
|
|
||||||
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
|
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// save it
|
// save it
|
||||||
receivedBean = bean;
|
receivedBean = datasetBean;
|
||||||
|
|
||||||
// fill the form
|
// fill the form
|
||||||
titleTextBox.setText(bean.getTitle());
|
titleTextBox.setText(datasetBean.getTitle());
|
||||||
descriptionTextarea.setText(bean.getDescription());
|
descriptionTextarea.setText(datasetBean.getDescription());
|
||||||
versionTextbox.setText(String.valueOf(bean.getVersion()));
|
versionTextbox.setText(String.valueOf(datasetBean.getVersion()));
|
||||||
authorTextbox.setText(bean.getAuthorFullName());
|
authorTextbox.setText(datasetBean.getAuthorFullName());
|
||||||
authorEmailTextbox.setText(bean.getAuthorEmail());
|
authorEmailTextbox.setText(datasetBean.getAuthorEmail());
|
||||||
maintainerTextbox.setText(bean.getMaintainer());
|
maintainerTextbox.setText(datasetBean.getMaintainer());
|
||||||
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
|
maintainerEmailTextbox.setText(datasetBean.getMaintainerEmail());
|
||||||
|
|
||||||
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// vocabulary list of tags has preemption
|
// vocabulary list of tags has preemption
|
||||||
List<String> vocabularyTags = bean.getTagsVocabulary();
|
List<String> vocabularyTags = datasetBean.getTagsVocabulary();
|
||||||
if (vocabularyTags != null) {
|
if (vocabularyTags != null) {
|
||||||
tagsPanel.setVocabulary(vocabularyTags);
|
tagsPanel.setVocabulary(vocabularyTags);
|
||||||
if (bean.getTags() != null) {
|
if (datasetBean.getTags() != null) {
|
||||||
for (String tag : bean.getTags()) {
|
for (String tag : datasetBean.getTags()) {
|
||||||
tagsPanel.addTagElement(tag);
|
tagsPanel.addTagElement(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +459,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// THIS BLOCK is it required? Probably not.
|
// 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 = datasetBean.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
|
||||||
|
@ -496,13 +503,13 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// The resource root is the folder id. Es. ID of the Workspace Root folder.
|
// The resource root is the folder id. Es. ID of the Workspace Root folder.
|
||||||
if (bean.getResourceRoot() != null) {
|
if (datasetBean.getResourceRoot() != null) {
|
||||||
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
||||||
bean.getResourceRoot());
|
datasetBean.getResourceRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
// set organizations
|
// set organizations
|
||||||
List<OrganizationBean> organizations = bean.getOrganizationList();
|
List<OrganizationBean> organizations = datasetBean.getOrganizationList();
|
||||||
|
|
||||||
for (OrganizationBean organization : organizations) {
|
for (OrganizationBean organization : organizations) {
|
||||||
organizationsListbox.addItem(organization.getTitle());
|
organizationsListbox.addItem(organization.getTitle());
|
||||||
|
@ -526,6 +533,9 @@ public class UpdateDatasetForm extends Composite {
|
||||||
final String orgName = nameTitleOrganizationMap
|
final String orgName = nameTitleOrganizationMap
|
||||||
.get(organizationsListbox.getSelectedItemText());
|
.get(organizationsListbox.getSelectedItemText());
|
||||||
|
|
||||||
|
//Putting the selected Organization into bena
|
||||||
|
theDataset.setSelectedOrganization(orgName);
|
||||||
|
|
||||||
// force tags
|
// force tags
|
||||||
// setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
|
// setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
|
||||||
// ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
|
// ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
|
||||||
|
@ -552,7 +562,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// 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, datasetBean.getChosenType(), datasetBean.getId(),
|
||||||
new AsyncCallback<MetadataProfileBeanForUpdate>() {
|
new AsyncCallback<MetadataProfileBeanForUpdate>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -649,8 +659,9 @@ public class UpdateDatasetForm extends Composite {
|
||||||
false);
|
false);
|
||||||
continueButton.setEnabled(true);
|
continueButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
resetButton.setEnabled(true);
|
||||||
|
addResourcesButtonStep1.setEnabled(true);
|
||||||
|
|
||||||
manageAddResources(bean,
|
manageAddResources(datasetBean,
|
||||||
datasetIdOrName);
|
datasetIdOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,6 +745,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
||||||
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
||||||
|
|
||||||
|
theDataset.setSelectedOrganization(orgName);
|
||||||
|
|
||||||
// try to retrieve the profiles
|
// try to retrieve the profiles
|
||||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
|
@ -955,13 +968,6 @@ public class UpdateDatasetForm extends Composite {
|
||||||
|
|
||||||
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
||||||
|
|
||||||
/*
|
|
||||||
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
|
|
||||||
* MetaDataFieldSkeleton(metadataFieldWrapper, eventBus);
|
|
||||||
* cp.addField(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch
|
|
||||||
* (Exception e) { GWT.log("Unable to build such widget", e); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
||||||
|
@ -979,13 +985,6 @@ public class UpdateDatasetForm extends Composite {
|
||||||
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
||||||
for (MetadataFieldWrapper field : fields) {
|
for (MetadataFieldWrapper field : fields) {
|
||||||
|
|
||||||
/*
|
|
||||||
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
|
|
||||||
* MetaDataFieldSkeleton(field, eventBus); extrasCategory.addField(fieldWidget);
|
|
||||||
* listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
|
|
||||||
* GWT.log("Unable to build such widget", e); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||||
|
@ -1382,56 +1381,62 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageAddResources(final DatasetBean theDatasetBean, String datasetUrl) {
|
private void manageAddResources(final DatasetBean theDatasetBean, final String datasetUrl) {
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// show the add resources button
|
// show the add resources button
|
||||||
addResourcesButton.setVisible(true);
|
addResourcesButtonStep1.setVisible(true);
|
||||||
|
addResourcesButtonStep3.setVisible(true);
|
||||||
|
|
||||||
final AddedResourcesSummary addedResourcesSummary = initTabManageResourcePanel(theDatasetBean, datasetUrl);
|
final AddedResourcesSummary addedResourcesSummary = initTabManageResourcePanel(theDatasetBean,
|
||||||
|
datasetUrl);
|
||||||
|
|
||||||
final List<ResourceElementBean> resources = theDatasetBean.getCkanResources();
|
final List<ResourceElementBean> resources = theDatasetBean.getCkanResources();
|
||||||
GWT.log("Resources are: " + resources);
|
GWT.log("Resources are: " + resources);
|
||||||
|
|
||||||
if (resources != null
|
if (resources != null && resources.size() > 0) {
|
||||||
&& resources.size() > 0) {
|
|
||||||
GWT.log("Executing are: " + resources);
|
GWT.log("Executing are: " + resources);
|
||||||
for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
||||||
eventBus.fireEvent(new AddResourceEvent(reb));
|
addedResourcesSummary.getEventBus().fireEvent(new AddResourceEvent(reb));
|
||||||
//addedResourcesSummary.getEventBus().fireEvent(new AddResourceEvent(reb));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB!!! addResourcesButton must be clicked once
|
addResourcesButtonStep1.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
// 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
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
manageResourcesOnFire(datasetUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addResourcesButtonStep3.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
manageResourcesOnFire(datasetUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Exception e2) {
|
||||||
|
// silent
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void manageResourcesOnFire(String datasetUrl) {
|
||||||
|
|
||||||
// remove content of the main panel
|
// remove content of the main panel
|
||||||
createDatasetMainPanel.clear();
|
createDatasetMainPanel.clear();
|
||||||
|
|
||||||
tabPanel.selectTab(0);
|
|
||||||
|
|
||||||
// form container
|
// form container
|
||||||
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
container.add(tabPanel);
|
container.add(tabPanel);
|
||||||
|
@ -1439,14 +1444,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// add the new content of the main panel
|
// add the new content of the main panel
|
||||||
createDatasetMainPanel.add(container);
|
createDatasetMainPanel.add(container);
|
||||||
|
|
||||||
}
|
tabPanel.selectTab(0);
|
||||||
});
|
|
||||||
} catch (Exception e2) {
|
|
||||||
// silent
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AddedResourcesSummary initTabManageResourcePanel(final DatasetBean theDatasetBean, String datasetUrl) {
|
private AddedResourcesSummary initTabManageResourcePanel(final DatasetBean theDatasetBean, String datasetUrl) {
|
||||||
|
@ -1460,8 +1458,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
|
|
||||||
// add the form
|
// add the form
|
||||||
|
|
||||||
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(),
|
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
|
||||||
theDatasetBean.getTitle(), theDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
theDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
||||||
|
|
||||||
// tab for the form
|
// tab for the form
|
||||||
Tab formContainer = new Tab();
|
Tab formContainer = new Tab();
|
||||||
|
@ -1477,13 +1475,6 @@ public class UpdateDatasetForm extends Composite {
|
||||||
tabPanel.add(addedResources);
|
tabPanel.add(addedResources);
|
||||||
|
|
||||||
return addedResourcesSummary;
|
return addedResourcesSummary;
|
||||||
|
|
||||||
// add tabs to resources panel
|
|
||||||
// tabPanel.selectTab(0);
|
|
||||||
|
|
||||||
// // form container
|
|
||||||
// AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
|
||||||
// container.add(tabPanel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -338,6 +338,10 @@
|
||||||
type="PRIMARY" block="true">Continue</b:Button>
|
type="PRIMARY" block="true">Continue</b:Button>
|
||||||
<b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button>
|
<b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button>
|
||||||
|
|
||||||
|
<b:Button title="Manage resources of the item"
|
||||||
|
block="true" type="INFO" visible="true"
|
||||||
|
ui:field="addResourcesButtonStep1">Manage Resources</b:Button>
|
||||||
|
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
|
|
||||||
|
@ -368,6 +372,7 @@
|
||||||
<b:Button title="Go Back" ui:field="goBackButtonFirstStep"
|
<b:Button title="Go Back" ui:field="goBackButtonFirstStep"
|
||||||
block="true">Go
|
block="true">Go
|
||||||
Back</b:Button>
|
Back</b:Button>
|
||||||
|
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
|
|
||||||
|
@ -425,17 +430,17 @@
|
||||||
styleName="{style.the-margin-gotoitem}"></b:Button>
|
styleName="{style.the-margin-gotoitem}"></b:Button>
|
||||||
</g:HorizontalPanel>
|
</g:HorizontalPanel>
|
||||||
|
|
||||||
<b:Button title="Manage resources of the item"
|
|
||||||
block="true" type="PRIMARY" visible="false"
|
|
||||||
ui:field="addResourcesButton">Manage Resources</b:Button>
|
|
||||||
|
|
||||||
<b:Button title="Update Item" ui:field="updateButton"
|
<b:Button title="Update Item" ui:field="updateButton"
|
||||||
type="PRIMARY" block="true">Create</b:Button>
|
type="PRIMARY" block="true">Update</b:Button>
|
||||||
|
|
||||||
<b:Button title="Go Back" ui:field="goBackButtonSecondStep"
|
<b:Button title="Go Back" ui:field="goBackButtonSecondStep"
|
||||||
block="true">Go
|
block="true">Go
|
||||||
Back</b:Button>
|
Back</b:Button>
|
||||||
|
|
||||||
|
<b:Button title="Manage resources of the item"
|
||||||
|
block="true" type="INFO" visible="true"
|
||||||
|
ui:field="addResourcesButtonStep3">Manage Resources</b:Button>
|
||||||
|
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class AddResourceToDataset extends Composite{
|
||||||
@UiField ControlGroup nameControlGroup;
|
@UiField ControlGroup nameControlGroup;
|
||||||
@UiField FlowPanel infoPanel;
|
@UiField FlowPanel infoPanel;
|
||||||
|
|
||||||
public AddResourceToDataset(HandlerManager eventBus, String datasetId, String datasetTitle, String datasetOrg, String owner, final String datasetUrl) {
|
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle, final String datasetOrg, String owner, final String datasetUrl) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
// save bus
|
// save bus
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
@ -137,7 +137,7 @@ public class AddResourceToDataset extends Composite{
|
||||||
infoPanel.add(loader);
|
infoPanel.add(loader);
|
||||||
|
|
||||||
// try to create
|
// try to create
|
||||||
ckanServices.addResourceToDataset(resource, datasetId, new AsyncCallback<ResourceElementBean>() {
|
ckanServices.addResourceToDataset(resource, datasetOrg, datasetId, new AsyncCallback<ResourceElementBean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ResourceElementBean result) {
|
public void onSuccess(ResourceElementBean result) {
|
||||||
|
|
|
@ -12,8 +12,10 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElement
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Accordion;
|
import com.github.gwtbootstrap.client.ui.Accordion;
|
||||||
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
@ -22,6 +24,7 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -46,8 +49,14 @@ public class AddedResourcesSummary extends Composite {
|
||||||
@UiField
|
@UiField
|
||||||
VerticalPanel addResourcesPanel;
|
VerticalPanel addResourcesPanel;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Alert alertMessage;
|
||||||
|
|
||||||
public AddedResourcesSummary(HandlerManager eventBus) {
|
public AddedResourcesSummary(HandlerManager eventBus) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
|
alertMessage.setType(AlertType.ERROR);
|
||||||
|
alertMessage.setClose(true);
|
||||||
// save bus
|
// save bus
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
// bind on add resource event
|
// bind on add resource event
|
||||||
|
@ -75,23 +84,31 @@ public class AddedResourcesSummary extends Composite {
|
||||||
Accordion accordion = new Accordion();
|
Accordion accordion = new Accordion();
|
||||||
AccordionGroup accordionGroup = new AccordionGroup();
|
AccordionGroup accordionGroup = new AccordionGroup();
|
||||||
accordionGroup.setHeading("* " + justAddedResource.getName());
|
accordionGroup.setHeading("* " + justAddedResource.getName());
|
||||||
|
accordionGroup.getHeading().getElement().getStyle().setBackgroundColor("#FFEDBE");
|
||||||
accordion.add(accordionGroup);
|
accordion.add(accordionGroup);
|
||||||
|
|
||||||
// add sub-info such as url and description
|
// add sub-info such as url and description
|
||||||
Paragraph pUrl = new Paragraph();
|
Paragraph pUrl = new Paragraph();
|
||||||
pUrl.setText("URL : " + justAddedResource.getUrl());
|
if (justAddedResource.getUrl() != null) {
|
||||||
|
pUrl.setText("URL:");
|
||||||
|
HTML htmlLink = new HTML();
|
||||||
|
htmlLink.setHTML(
|
||||||
|
"<a href=" + justAddedResource.getUrl() + ">" + justAddedResource.getUrl() + "</a>");
|
||||||
|
// pUrl.add(pUrl);
|
||||||
|
pUrl.add(htmlLink);
|
||||||
|
}
|
||||||
Paragraph pDescription = new Paragraph();
|
Paragraph pDescription = new Paragraph();
|
||||||
pDescription.setText("Description : " + justAddedResource.getDescription());
|
pDescription.setText("Description : " + justAddedResource.getDescription());
|
||||||
|
|
||||||
// button to delete the resource
|
// button to delete the resource
|
||||||
Button deleteButton = new Button();
|
final Button deleteButton = new Button();
|
||||||
deleteButton.setText("Delete");
|
deleteButton.setText("Delete");
|
||||||
deleteButton.addClickHandler(new ClickHandler() {
|
deleteButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
eventBus.fireEvent(new DeleteResourceEvent(justAddedResource));
|
eventBus.fireEvent(new DeleteResourceEvent(deleteButton, justAddedResource));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -113,11 +130,15 @@ public class AddedResourcesSummary extends Composite {
|
||||||
eventBus.addHandler(DeleteResourceEvent.TYPE, new DeleteResourceEventHandler() {
|
eventBus.addHandler(DeleteResourceEvent.TYPE, new DeleteResourceEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeletedResource(DeleteResourceEvent deleteResourceEvent) {
|
public void onDeletedResource(final DeleteResourceEvent deleteResourceEvent) {
|
||||||
GWT.log("onDeletedResource resource event: " + deleteResourceEvent);
|
GWT.log("onDeletedResource resource event: " + deleteResourceEvent);
|
||||||
|
|
||||||
// to delete
|
// to delete
|
||||||
ResourceElementBean toDelete = deleteResourceEvent.getResource();
|
final ResourceElementBean toDelete = deleteResourceEvent.getResource();
|
||||||
|
|
||||||
|
Button toDeleteButton = deleteResourceEvent.getDeleteButton();
|
||||||
|
|
||||||
|
toDeleteButton.setEnabled(false);
|
||||||
|
|
||||||
// find it
|
// find it
|
||||||
for (int i = 0; i < addedResources.size(); i++) {
|
for (int i = 0; i < addedResources.size(); i++) {
|
||||||
|
@ -135,16 +156,24 @@ public class AddedResourcesSummary extends Composite {
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
widget.removeFromParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove from the list
|
// remove from the list
|
||||||
addedResources.remove(toDelete);
|
addedResources.remove(toDelete);
|
||||||
|
alertMessage.setType(AlertType.SUCCESS);
|
||||||
|
alertMessage.setHTML("The resource described by " + toDelete.getName()
|
||||||
|
+ " has been deleted!");
|
||||||
|
widget.removeFromParent();
|
||||||
|
} else {
|
||||||
|
alertMessage.setVisible(true);
|
||||||
|
alertMessage.setHTML("Sorry, the resource described by "
|
||||||
|
+ toDelete.getName() + " cannot be deleted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
toDeleteButton.setEnabled(false);
|
||||||
|
alertMessage.setVisible(true);
|
||||||
|
alertMessage.setHTML(caught.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
|
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<h3>Added Resources</h3>
|
<h3>Added Resources</h3>
|
||||||
<g:VerticalPanel ui:field="addResourcesPanel" width="100%"></g:VerticalPanel>
|
<g:VerticalPanel ui:field="addResourcesPanel"
|
||||||
|
width="100%">
|
||||||
|
<b:Alert visible="false" ui:field="alertMessage"></b:Alert>
|
||||||
|
</g:VerticalPanel>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -389,8 +389,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// UPDATED By Francesco
|
// UPDATED By Francesco
|
||||||
// String vreName = scope.substring(scope.lastIndexOf("/") + 1, scope.length());
|
// String vreName = scope.substring(scope.lastIndexOf("/") + 1, scope.length());
|
||||||
// logger.debug("In dev mode using the scope: " + scope + " and VRE name: " + vreName);
|
// logger.debug("In dev mode using the scope: " + scope + " and VRE name: " + vreName);
|
||||||
bean.setOrganizationList(
|
final OrganizationBean ckanOrganizationBean = new OrganizationBean(ckanOrganization.getTitle(),
|
||||||
Arrays.asList(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName(), true)));
|
ckanOrganization.getName(), true);
|
||||||
|
bean.setOrganizationList(Arrays.asList(ckanOrganizationBean));
|
||||||
|
|
||||||
List<CkanTag> listDatasetTags = dataset.getTags();
|
List<CkanTag> listDatasetTags = dataset.getTags();
|
||||||
|
|
||||||
|
@ -426,7 +427,8 @@ 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 = PublisherCatalogueConveter.toResourceElementBean(ckanResource);
|
ResourceElementBean reb = PublisherCatalogueConveter.toResourceElementBean(ckanResource,
|
||||||
|
ckanOrganizationBean.getName());
|
||||||
list.add(reb);
|
list.add(reb);
|
||||||
}
|
}
|
||||||
bean.setResources(list);
|
bean.setResources(list);
|
||||||
|
@ -640,7 +642,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
if (listCurrentResources != null) {
|
if (listCurrentResources != null) {
|
||||||
resources = new ArrayList<ResourceBean>(listCurrentResources.size());
|
resources = new ArrayList<ResourceBean>(listCurrentResources.size());
|
||||||
for (CkanResource ckanResource : listCurrentResources) {
|
for (CkanResource ckanResource : listCurrentResources) {
|
||||||
ResourceBean reb = PublisherCatalogueConveter.toResourceBean(ckanResource);
|
String orgName = null; // not required here
|
||||||
|
ResourceBean reb = PublisherCatalogueConveter.toResourceBean(ckanResource, orgName);
|
||||||
resources.add(reb);
|
resources.add(reb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,12 +718,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* Adds the resource to dataset.
|
* Adds the resource to dataset.
|
||||||
*
|
*
|
||||||
* @param resource the resource
|
* @param resource the resource
|
||||||
|
* @param organizationName the organization name
|
||||||
* @param datasetId the dataset id
|
* @param datasetId the dataset id
|
||||||
* @return the resource element bean
|
* @return the resource element bean
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ResourceElementBean addResourceToDataset(ResourceElementBean resource, String datasetId) throws Exception {
|
public ResourceElementBean addResourceToDataset(ResourceElementBean resource, String organizationName,
|
||||||
|
String datasetId) throws Exception {
|
||||||
logger.info("called addResourceToDataset");
|
logger.info("called addResourceToDataset");
|
||||||
devModeSetContexts();
|
devModeSetContexts();
|
||||||
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
|
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
|
@ -735,14 +740,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
// organization name in which the dataset was created
|
// organization name in which the dataset was created
|
||||||
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
|
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
|
||||||
DataCatalogue catalogue = getCatalogue(scope);
|
DataCatalogue catalogue = getCatalogue(scope);
|
||||||
String resourceId = catalogue.addResourceToDataset(resourceBean, resource.getOrganizationNameDatasetParent(),
|
CkanResource theCreatedResource = catalogue.addResource(resourceBean, datasetId,
|
||||||
username);
|
resource.getOrganizationNameDatasetParent(), username);
|
||||||
|
|
||||||
if (resourceId != null) {
|
if (theCreatedResource != null) {
|
||||||
logger.info("Resource " + resource.getName() + " is now available");
|
logger.info("Resource " + resource.getName() + " is now available");
|
||||||
// set its id and turn it to the client
|
|
||||||
resource.setOriginalIdInWorkspace(resourceId);
|
ResourceElementBean reb = PublisherCatalogueConveter.toResourceElementBean(theCreatedResource,
|
||||||
return resource;
|
organizationName);
|
||||||
|
|
||||||
|
return reb;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("No resource created");
|
logger.debug("No resource created");
|
||||||
|
@ -767,14 +774,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
|
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
|
||||||
DataCatalogue catalogue = getCatalogue(scope);
|
DataCatalogue catalogue = getCatalogue(scope);
|
||||||
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
|
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
|
||||||
deleted = catalogue.deleteResourceFromDataset(resource.getOriginalIdInWorkspace(), username);
|
deleted = catalogue.deleteResourceFromDataset(resource.getCkanResourceID(), username);
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
logger.info("Resource described by " + resource + " deleted");
|
logger.info("Resource described by " + resource + " deleted");
|
||||||
} else
|
} else
|
||||||
logger.error("Resource described by " + resource + " NOT deleted");
|
logger.error("Resource described by " + resource + " NOT deleted");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error while trying to delete resource described by " + resource, e);
|
String error = "Sorry, an error occurred while trying to delete resource described by "
|
||||||
throw new Exception("Error while trying to delete resource." + e.getMessage());
|
+ resource.getName();
|
||||||
|
logger.error(error, e);
|
||||||
|
throw new Exception(error + ". Error is: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return deleted;
|
return deleted;
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,31 @@ import org.gcube.datacatalogue.utillibrary.shared.ResourceBean;
|
||||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class PublisherCatalogueConveter.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Feb 12, 2024
|
||||||
|
*/
|
||||||
public class PublisherCatalogueConveter {
|
public class PublisherCatalogueConveter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To resource element bean.
|
* To resource element bean.
|
||||||
*
|
*
|
||||||
* @param ckanResource the ckan resource
|
* @param ckanResource the ckan resource
|
||||||
|
* @param orgNameParent the org name parent
|
||||||
* @return the resource element bean
|
* @return the resource element bean
|
||||||
*/
|
*/
|
||||||
public static ResourceElementBean toResourceElementBean(CkanResource ckanResource) {
|
public static ResourceElementBean toResourceElementBean(CkanResource ckanResource, String orgNameParent) {
|
||||||
ResourceElementBean reb = new ResourceElementBean();
|
ResourceElementBean reb = new ResourceElementBean();
|
||||||
|
reb.setCkanResourceID(ckanResource.getId());
|
||||||
reb.setName(ckanResource.getName());
|
reb.setName(ckanResource.getName());
|
||||||
reb.setDescription(ckanResource.getDescription());
|
reb.setDescription(ckanResource.getDescription());
|
||||||
reb.setEditableName(ckanResource.getName());
|
reb.setEditableName(ckanResource.getName());
|
||||||
reb.setUrl(ckanResource.getUrl());
|
reb.setUrl(ckanResource.getUrl());
|
||||||
reb.setMimeType(ckanResource.getMimetype());
|
reb.setMimeType(ckanResource.getMimetype());
|
||||||
|
reb.setOrganizationNameDatasetParent(orgNameParent);
|
||||||
return reb;
|
return reb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +36,10 @@ public class PublisherCatalogueConveter {
|
||||||
* To resource bean.
|
* To resource bean.
|
||||||
*
|
*
|
||||||
* @param ckanResource the ckan resource
|
* @param ckanResource the ckan resource
|
||||||
|
* @param orgNameParent the org name parent
|
||||||
* @return the resource bean
|
* @return the resource bean
|
||||||
*/
|
*/
|
||||||
public static ResourceBean toResourceBean(CkanResource ckanResource) {
|
public static ResourceBean toResourceBean(CkanResource ckanResource, String orgNameParent) {
|
||||||
ResourceBean reb = new ResourceBean();
|
ResourceBean reb = new ResourceBean();
|
||||||
reb.setName(ckanResource.getName());
|
reb.setName(ckanResource.getName());
|
||||||
reb.setDescription(ckanResource.getDescription());
|
reb.setDescription(ckanResource.getDescription());
|
||||||
|
|
|
@ -6,9 +6,10 @@ import java.util.List;
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
import com.google.gwt.view.client.ProvidesKey;
|
import com.google.gwt.view.client.ProvidesKey;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A resource element bean. Contains part of the logic used into the TwinColumn widget
|
* A resource element bean. Contains part of the logic used into the TwinColumn
|
||||||
|
* widget
|
||||||
|
*
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* @author revisited by Francesco Mangiacrapa
|
* @author revisited by Francesco Mangiacrapa
|
||||||
|
@ -67,13 +68,15 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
// identifier of this instance
|
// identifier of this instance
|
||||||
private int identifierGWT;
|
private int identifierGWT;
|
||||||
|
|
||||||
|
private String ckanResourceID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key provider that provides the unique ID of a bean.
|
* The key provider that provides the unique ID of a bean.
|
||||||
*/
|
*/
|
||||||
public static final ProvidesKey<ResourceElementBean> KEY_PROVIDER = new ProvidesKey<ResourceElementBean>() {
|
public static final ProvidesKey<ResourceElementBean> KEY_PROVIDER = new ProvidesKey<ResourceElementBean>() {
|
||||||
@Override
|
@Override
|
||||||
public Object getKey(ResourceElementBean item) {
|
public Object getKey(ResourceElementBean item) {
|
||||||
return item == null ? null : item.identifierGWT;
|
return item == null ? null : item.ckanResourceID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,11 +115,7 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
* @param childrenSize the children size
|
* @param childrenSize the children size
|
||||||
* @param fullPath the full path
|
* @param fullPath the full path
|
||||||
*/
|
*/
|
||||||
public ResourceElementBean(
|
public ResourceElementBean(ResourceElementBean parent, String name, boolean isFolder, Integer childrenSize,
|
||||||
ResourceElementBean parent,
|
|
||||||
String name,
|
|
||||||
boolean isFolder,
|
|
||||||
Integer childrenSize,
|
|
||||||
String fullPath) {
|
String fullPath) {
|
||||||
this.identifierGWT = nextId;
|
this.identifierGWT = nextId;
|
||||||
nextId++;
|
nextId++;
|
||||||
|
@ -142,10 +141,8 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
* @param description the description
|
* @param description the description
|
||||||
* @param organizationNameDatasetParent the organization name dataset parent
|
* @param organizationNameDatasetParent the organization name dataset parent
|
||||||
*/
|
*/
|
||||||
public ResourceElementBean(String name, boolean toBeAdded,
|
public ResourceElementBean(String name, boolean toBeAdded, boolean isFolder, ResourceElementBean parent,
|
||||||
boolean isFolder, ResourceElementBean parent,
|
Integer childrenSize, String fullPath, String originalIdInWorkspace, String mimeType, String url,
|
||||||
Integer childrenSize, String fullPath,
|
|
||||||
String originalIdInWorkspace, String mimeType, String url,
|
|
||||||
String description, String organizationNameDatasetParent) {
|
String description, String organizationNameDatasetParent) {
|
||||||
super();
|
super();
|
||||||
this.identifierGWT = nextId;
|
this.identifierGWT = nextId;
|
||||||
|
@ -163,10 +160,33 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bean ID.
|
||||||
|
*
|
||||||
|
* @return the bean ID
|
||||||
|
*/
|
||||||
public int getBeanID() {
|
public int getBeanID() {
|
||||||
return identifierGWT;
|
return identifierGWT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ckan resource ID.
|
||||||
|
*
|
||||||
|
* @return the ckan resource ID
|
||||||
|
*/
|
||||||
|
public String getCkanResourceID() {
|
||||||
|
return ckanResourceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ckan resource ID.
|
||||||
|
*
|
||||||
|
* @param ckanResourceID the new ckan resource ID
|
||||||
|
*/
|
||||||
|
public void setCkanResourceID(String ckanResourceID) {
|
||||||
|
this.ckanResourceID = ckanResourceID;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the parent.
|
* Gets the parent.
|
||||||
*
|
*
|
||||||
|
@ -289,8 +309,7 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
*
|
*
|
||||||
* @param organizationNameDatasetParent the new organization name dataset parent
|
* @param organizationNameDatasetParent the new organization name dataset parent
|
||||||
*/
|
*/
|
||||||
public void setOrganizationNameDatasetParent(
|
public void setOrganizationNameDatasetParent(String organizationNameDatasetParent) {
|
||||||
String organizationNameDatasetParent) {
|
|
||||||
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
this.organizationNameDatasetParent = organizationNameDatasetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,15 +449,29 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the root id in workspace.
|
||||||
|
*
|
||||||
|
* @return the root id in workspace
|
||||||
|
*/
|
||||||
public String getRootIdInWorkspace() {
|
public String getRootIdInWorkspace() {
|
||||||
return rootIdInWorkspace;
|
return rootIdInWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the root id in workspace.
|
||||||
|
*
|
||||||
|
* @param rootIdInWorkspace the new root id in workspace
|
||||||
|
*/
|
||||||
public void setRootIdInWorkspace(String rootIdInWorkspace) {
|
public void setRootIdInWorkspace(String rootIdInWorkspace) {
|
||||||
this.rootIdInWorkspace = rootIdInWorkspace;
|
this.rootIdInWorkspace = rootIdInWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -472,8 +505,4 @@ public class ResourceElementBean implements Comparable<ResourceElementBean>, Ser
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue