() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
+
+ }
+
+ @Override
+ public void onSuccess(DatasetBean result) {
+ setAlertBlock("", null, null, false);
+ panelConfirm.setVisible(true);
+ selectedDataset = result;
+ deleteMessage.add(new HTML("
" + result.getTitle() + "
"));
+
+ }
+ });
+ } else {
+ setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.WARNING, true);
+ }
+ }
+
+ });
+ }
+
+ @UiHandler("buttonDelete")
+ void onClick(ClickEvent e) {
+
+ LoaderIcon loaderIcon = new LoaderIcon("Deleting the item....");
+ setAlertBlock(null, loaderIcon, AlertType.INFO, true);
+ panelConfirm.setVisible(false);
+ ckanServices.deleteItem(selectedDataset, new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock("Sorry, an error occurred on deleting the item. Error: " + caught.getMessage(), null,
+ AlertType.ERROR, true);
+
+ }
+
+ @Override
+ public void onSuccess(Boolean result) {
+ if (result) {
+ setAlertBlock("Item '" + selectedDataset.getTitle() + "' permanently deleted!", null,
+ AlertType.SUCCESS, true);
+ eventBusMainApplication.fireEvent(new ReloadDatasetPageEvent(null));
+ } else {
+ setAlertBlock("Sorry, I cannot delete the item. Refresh and retry or contact the support", null,
+ AlertType.INFO, true);
+ }
+
+ }
+ });
+ }
+
+ /**
+ * change alert block behavior.
+ *
+ * @param textToShow the text to show
+ * @param type the type
+ * @param visible the visible
+ */
+ private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
+
+ alertPanel.clear();
+
+ if (loader != null)
+ alertPanel.add(loader);
+
+ if (type != null)
+ infoBlock.setType(type);
+
+ if (textToShow != null)
+ alertPanel.add(new HTML(textToShow));
+
+ infoBlock.setVisible(visible);
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml
new file mode 100644
index 0000000..b636a80
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/action/DeleteItemPanel.ui.xml
@@ -0,0 +1,36 @@
+
+
+
+ .block-alert-style {
+ margin-top: 10px;
+ padding: 10px;
+ margin-bottom: 10px;
+ }
+
+ .float-right {
+ float: right;
+ }
+
+ .delete-message-panel {
+ margin: 20px;
+ padding: 5px;
+ margin-bottom: 30px;
+ font-size: 14px;
+ }
+
+
+
+
+
+ Do you want to permanently delete the item?
+
+ Permanently delete
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java
index 2317ead..4226293 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.java
@@ -11,28 +11,30 @@ import java.util.Map.Entry;
import java.util.Set;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
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.DeleteCustomFieldEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CategoryPanel;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEventHandler;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.MetaDataFieldSkeleton;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceContainer;
-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.tags.TagsPanel;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
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.workspace.SelectResourceByWEMainPanel;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.licenses.LicenseBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.CategoryWrapper;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetaDataProfileBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
+import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
+import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
+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.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
@@ -42,15 +44,12 @@ import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Popover;
-import com.github.gwtbootstrap.client.ui.Tab;
-import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
-import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SelectElement;
import com.google.gwt.dom.client.Style.Unit;
@@ -67,7 +66,9 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel;
+import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SimplePanel;
@@ -253,7 +254,7 @@ public class CreateDatasetForm extends Composite {
private Icon iconSpinner = new Icon(IconType.SPINNER);
// Create a remote service proxy to talk to the server-side ckan service.
- private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
+ private final CKanPublisherServiceAsync ckanServices = CKanPublisherServiceAsync.Util.getInstance();
// private static final String REGEX_TITLE_PRODUCT_SUBWORD = "[^a-zA-Z0-9_.-]";
private static final String REGEX_MAIL = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
@@ -265,17 +266,14 @@ public class CreateDatasetForm extends Composite {
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the item, please wait...";
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to publish on catalogue. Request it to the VRE manager or the portal administrator.";
- // tab panel
- private TabPanel tabPanel;
-
- // add resource form
- private AddResourceToDataset resourceForm;
-
// the licenses
private List licenseBean;
// event bus
- private HandlerManager eventBus;
+ private HandlerManager eventBusPublisherWidget = new HandlerManager(null);
+
+ // event bus of the principal application (it is the Catalogue Portlet)
+ private HandlerManager eventBusMainApplication;
// added custom field entries (by the user)
private List customFieldEntriesList = new ArrayList();
@@ -286,9 +284,6 @@ public class CreateDatasetForm extends Composite {
// dataset metadata bean
private DatasetBean receivedBean;
- // the owner
- private String owner;
-
// workspace request?
private boolean isWorkspaceRequest = false;
@@ -306,23 +301,34 @@ public class CreateDatasetForm extends Composite {
private WizardCreator wizCreator;
+ private FlowPanel alertPanel = new FlowPanel();
+
/**
* Invoked in the most general case
*
- * @param eventBus the event bus
+ * @param eventBusPublisherWidget the event bus
*/
- public CreateDatasetForm(HandlerManager eventBus) {
- createDatasetFormBody(false, null, eventBus);
+ public CreateDatasetForm(HandlerManager eventBusMainApplication) {
+ createDatasetFormBody(false, null, eventBusMainApplication, OPERATION.NEW);
+ }
+
+ /**
+ * Invoked in the most general case
+ *
+ * @param eventBusPublisherWidget the event bus
+ */
+ public CreateDatasetForm(HandlerManager eventBusMainApplication, OPERATION operation) {
+ createDatasetFormBody(false, null, eventBusMainApplication, operation);
}
/**
* Invoked when the workspace is used
*
* @param idFolderWorkspace
- * @param eventBus the event bus
+ * @param eventBusPublisherWidget the event bus
*/
- public CreateDatasetForm(String idFolderOrFileWorkspace, HandlerManager eventBus) {
- createDatasetFormBody(true, idFolderOrFileWorkspace, eventBus);
+ public CreateDatasetForm(String idFolderOrFileWorkspace, HandlerManager eventBusMainApplication) {
+ createDatasetFormBody(true, idFolderOrFileWorkspace, eventBusMainApplication, OPERATION.NEW);
}
/**
@@ -330,7 +336,7 @@ public class CreateDatasetForm extends Composite {
*/
private void bind() {
// when a custom field is removed, remove it from the list
- eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
+ eventBusPublisherWidget.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
@Override
public void onRemoveEntry(DeleteCustomFieldEvent event) {
@@ -340,12 +346,26 @@ public class CreateDatasetForm extends Composite {
});
// on close form
- eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
+ eventBusPublisherWidget.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
@Override
public void onClose(CloseCreationFormEvent event) {
InfoIconsLabels.closeDialogBox(popupOpenedIds);
}
});
+
+ eventBusPublisherWidget.addHandler(ReloadDatasetPageEvent.TYPE, new ReloadDatasetPageEventHandler() {
+
+ @Override
+ public void onReloadDatasetPage(ReloadDatasetPageEvent addResourceEvent) {
+
+ // Firing the event on the main application bus
+ if (addResourceEvent.getDatasetIDorName() != null) {
+ eventBusMainApplication
+ .fireEvent(new ReloadDatasetPageEvent(addResourceEvent.getDatasetIDorName()));
+ }
+
+ }
+ });
}
/**
@@ -354,24 +374,26 @@ public class CreateDatasetForm extends Composite {
* @param isWorkspaceRequest
* @param idFolderWorkspace
* @param owner
- * @param eventBus
+ * @param eventBusPublisherWidget
*/
private void createDatasetFormBody(final boolean isWorkspaceRequest, final String idFolderOrFileWorkspace,
- final HandlerManager eventBus) {
+ final HandlerManager eventBusMainApplication, final OPERATION operation) {
initWidget(uiBinder.createAndBindUi(this));
- this.eventBus = eventBus;
+ this.eventBusMainApplication = eventBusMainApplication;
this.isWorkspaceRequest = isWorkspaceRequest;
iconSpinner.setSpin(true);
iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
+ iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear");
+ infoBlock.add(alertPanel);
List listOfSteps = null;
if (isWorkspaceRequest) {
listOfSteps = Arrays.asList("Edit Common Metadata", "Select Item Resources",
"Edit Item Specific Metadata & Publish");
} else {
- listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Publish");
+ listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Publish", "Add Resources");
}
this.wizCreator = new WizardCreator(listOfSteps);
@@ -389,9 +411,10 @@ public class CreateDatasetForm extends Composite {
tagsPanel.setVisible(false);
// check if the user has publishing rights
- setAlertBlock("Checking your permissions, please wait...", AlertType.INFO, true);
+ LoaderIcon loader = new LoaderIcon("Checking your permissions, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
- ckanServices.isPublisherUser(isWorkspaceRequest, new AsyncCallback() {
+ ckanServices.isPublisherUser(new AsyncCallback() {
@Override
public void onSuccess(Boolean result) {
@@ -399,15 +422,16 @@ public class CreateDatasetForm extends Composite {
if (result) {
// set info block
- setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
+ LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
// get back the licenses and the metadata information
- ckanServices.getDatasetBean(idFolderOrFileWorkspace, new AsyncCallback() {
+ ckanServices.buildPartialDatasetBean(idFolderOrFileWorkspace, new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
- setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
}
@@ -415,8 +439,7 @@ public class CreateDatasetForm extends Composite {
public void onSuccess(final DatasetBean bean) {
if (bean == null) {
-
- setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
+ setAlertBlock("Error while retrieving information.", null, AlertType.ERROR, true);
} else {
// save it
@@ -431,7 +454,8 @@ public class CreateDatasetForm extends Composite {
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
- setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
+ LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
// vocabulary list of tags has preemption
List vocabularyTags = bean.getTagsVocabulary();
@@ -455,8 +479,8 @@ public class CreateDatasetForm extends Composite {
for (String value : values) {
// these are fixed key, variable value custom fields
- CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(),
- value, false);
+ CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget,
+ entry.getKey(), value, false);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
@@ -499,7 +523,7 @@ public class CreateDatasetForm extends Composite {
@Override
public void onChange(ChangeEvent event) {
event.preventDefault();
- organizationsListboxChangeHandlerBody();
+ organizationsListboxChangeHandlerBody(operation);
}
});
@@ -508,7 +532,8 @@ public class CreateDatasetForm extends Composite {
.get(organizationsListbox.getSelectedItemText());
// force tags
- setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
+ LoaderIcon loaderT = new LoaderIcon("Checking for tags vocabulary, please wait...");
+ setAlertBlock(null, loaderT, AlertType.INFO, true);
ckanServices.getTagsForOrganization(orgName, new AsyncCallback>() {
@Override
@@ -523,21 +548,21 @@ public class CreateDatasetForm extends Composite {
setAlertBlock(
"Error while checking if a vocabulary of tags is defined in the selected organization.",
- AlertType.ERROR, true);
+ null, AlertType.ERROR, true);
tagsPanel.setVisible(true);
}
});
- // try to retrieve the profiles
- setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
+ LoaderIcon loaderTyp = new LoaderIcon("Retrieving types, please wait...");
+ setAlertBlock(null, loaderTyp, AlertType.INFO, true);
// perform remote request of profiles for the selected organization
ckanServices.getProfiles(orgName, new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
- setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
}
@Override
@@ -545,7 +570,7 @@ public class CreateDatasetForm extends Composite {
if (profiles == null) {
setAlertBlock("An unknow error occurred while retrieving types, sorry",
- AlertType.ERROR, true);
+ null, AlertType.ERROR, true);
} else {
GWT.log("Profile returned are: " + profiles.size());
@@ -557,17 +582,20 @@ public class CreateDatasetForm extends Composite {
}
receivedBean.setMetadataList(profiles);
- prepareMetadataList(receivedBean);
+ prepareMetadataList(receivedBean, operation);
organizationsListbox.setEnabled(true);
metadataTypeListbox.setEnabled(true);
// try to retrieve the licenses
- setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true);
+ LoaderIcon loaderLic = new LoaderIcon(
+ "Retrieving licenses, please wait...");
+ setAlertBlock(null, loaderLic, AlertType.INFO, true);
+
ckanServices.getLicenses(new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
- setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
}
@Override
@@ -585,9 +613,10 @@ public class CreateDatasetForm extends Composite {
// set the url of the license, if any
showLicenseUrl();
- // try to retrieve the licenses
- setAlertBlock("Retrieving groups, please wait...",
- AlertType.INFO, true);
+ // try to retrieve groups
+ LoaderIcon loaderLic = new LoaderIcon(
+ "Retrieving groups, please wait...");
+ setAlertBlock(null, loaderLic, AlertType.INFO, true);
// request groups
ckanServices.getUserGroups(orgName,
@@ -599,7 +628,7 @@ public class CreateDatasetForm extends Composite {
if (groups == null) {
setAlertBlock(
"Error while retrieving groups",
- AlertType.ERROR, true);
+ null, AlertType.ERROR, true);
} else {
if (groups.isEmpty()) {
groupsControlGroup.setVisible(false);
@@ -614,7 +643,8 @@ public class CreateDatasetForm extends Composite {
hideGroupsAlreadyInProfile(profiles);
}
// everything went ok
- setAlertBlock("", AlertType.ERROR, false);
+ setAlertBlock("", null, AlertType.ERROR,
+ false);
continueButton.setEnabled(true);
resetButton.setEnabled(true);
}
@@ -622,13 +652,13 @@ public class CreateDatasetForm extends Composite {
@Override
public void onFailure(Throwable caught) {
- setAlertBlock(caught.getMessage(),
+ setAlertBlock(caught.getMessage(), null,
AlertType.ERROR, true);
}
});
} else {
- setAlertBlock("Error while retrieving licenses",
+ setAlertBlock("Error while retrieving licenses", null,
AlertType.ERROR, true);
}
}
@@ -641,14 +671,14 @@ public class CreateDatasetForm extends Composite {
});
} else {
- setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
+ setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
}
}
@Override
public void onFailure(Throwable caught) {
- setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
+ setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
}
});
@@ -658,7 +688,7 @@ public class CreateDatasetForm extends Composite {
* When the organization name is changed we need to retrieve the list of
* profiles and groups
*/
- private void organizationsListboxChangeHandlerBody() {
+ private void organizationsListboxChangeHandlerBody(final OPERATION operation) {
// remove any other product profiles
metadataTypeListbox.clear();
@@ -674,7 +704,8 @@ public class CreateDatasetForm extends Composite {
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
// try to retrieve the profiles
- setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
+ LoaderIcon loader = new LoaderIcon("Retrieving types, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
// disable the list of organizations name so that the user doesn't change it
// again
@@ -693,12 +724,13 @@ public class CreateDatasetForm extends Composite {
if (profiles != null) {
receivedBean.setMetadataList(profiles);
- prepareMetadataList(receivedBean);
+ prepareMetadataList(receivedBean, operation);
organizationsListbox.setEnabled(true);
metadataTypeListbox.setEnabled(true);
- // try to retrieve the licenses
- setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
+ // try to retrieve the groups
+ LoaderIcon loaderG = new LoaderIcon("Retrieving groups, please wait...");
+ setAlertBlock(null, loaderG, AlertType.INFO, true);
// request groups
ckanServices.getUserGroups(orgName, new AsyncCallback>() {
@@ -707,7 +739,8 @@ public class CreateDatasetForm extends Composite {
public void onSuccess(List groups) {
if (groups == null) {
- setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
+ setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
+ AlertType.ERROR, true);
} else {
if (groups.isEmpty()) {
groupsControlGroup.setVisible(false);
@@ -720,19 +753,22 @@ public class CreateDatasetForm extends Composite {
groupsListbox.setEnabled(true);
hideGroupsAlreadyInProfile(profiles);
}
- setAlertBlock("", AlertType.ERROR, false);
+ setAlertBlock("", null, AlertType.ERROR, false);
}
}
@Override
public void onFailure(Throwable caught) {
- setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
+ setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
+ AlertType.ERROR, true);
}
});
// check also for tags (if for that context there is a vocabulary or not)
tagsPanel.setVisible(false);
- setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
+ LoaderIcon loaderV = new LoaderIcon("Checking for tags vocabulary, please wait...");
+ setAlertBlock(null, loaderV, AlertType.INFO, true);
+
ckanServices.getTagsForOrganization(orgName, new AsyncCallback>() {
@Override
@@ -740,7 +776,7 @@ public class CreateDatasetForm extends Composite {
tagsPanel.setVocabulary(vocabulary);
tagsPanel.setVisible(true);
- setAlertBlock("", AlertType.ERROR, false);
+ setAlertBlock("", null, AlertType.ERROR, false);
}
@Override
@@ -748,7 +784,7 @@ public class CreateDatasetForm extends Composite {
setAlertBlock(
"Error while checking if a vocabulary of tags is defined in the selected organization.",
- AlertType.ERROR, true);
+ null, AlertType.ERROR, true);
tagsPanel.setVocabulary(null);
tagsPanel.setVisible(true);
@@ -756,14 +792,14 @@ public class CreateDatasetForm extends Composite {
});
} else
- setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true);
+ setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
}
@Override
public void onFailure(Throwable caught) {
- setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true);
+ setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
}
});
@@ -775,7 +811,7 @@ public class CreateDatasetForm extends Composite {
*
* @param receivedBean
*/
- private void prepareMetadataList(final DatasetBean receivedBean) {
+ private void prepareMetadataList(final DatasetBean receivedBean, final OPERATION operation) {
List profiles = receivedBean.getMetadataList();
@@ -797,7 +833,7 @@ public class CreateDatasetForm extends Composite {
receivedBean.setChosenType(null);
} else {
receivedBean.setChosenType(selectedItemText);
- addFields(selectedItemText);
+ addFields(selectedItemText, operation);
}
}
});
@@ -835,7 +871,7 @@ public class CreateDatasetForm extends Composite {
*
* @param selectedItem
*/
- protected void addFields(String selectedItem) {
+ protected void addFields(String selectedItem, OPERATION operation) {
for (MetaDataProfileBean bean : receivedBean.getMetadataList()) {
if (bean.getType().equals(selectedItem)) {
@@ -851,16 +887,10 @@ public class CreateDatasetForm extends Composite {
if (categories == null || categories.isEmpty()) {
for (MetadataFieldWrapper field : fields) {
- /*
- * MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
- * MetaDataFieldSkeleton(field, eventBus); metadataFieldsPanel.add(fieldWidget);
- * listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
- * GWT.log("Unable to build such widget", e); }
- */
MetaDataField fieldWidget;
try {
- fieldWidget = new MetaDataField(field, eventBus);
+ fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
metadataFieldsPanel.add(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@@ -882,16 +912,10 @@ public class CreateDatasetForm extends Composite {
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;
try {
- fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus);
+ fieldWidget = new MetaDataField(metadataFieldWrapper, eventBusPublisherWidget,
+ operation);
cp.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@@ -906,16 +930,9 @@ public class CreateDatasetForm extends Composite {
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
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;
try {
- fieldWidget = new MetaDataField(field, eventBus);
+ fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
extrasCategory.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@@ -932,7 +949,7 @@ public class CreateDatasetForm extends Composite {
@UiHandler("addCustomFieldButton")
void addCustomFieldEvent(ClickEvent e) {
- CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, "", "", true);
+ CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, "", "", true);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
@@ -1267,37 +1284,9 @@ public class CreateDatasetForm extends Composite {
// 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);
+ ManageResources manageResources = new ManageResources(eventBusPublisherWidget,
+ createdDatasetBean, datasetUrl);
+ createDatasetMainPanel.add(manageResources);
}
});
} catch (Exception e2) {
@@ -1305,6 +1294,9 @@ public class CreateDatasetForm extends Composite {
}
}
+ // firing the event to load the dataset in the Portlet
+ eventBusPublisherWidget.fireEvent(new ReloadDatasetPageEvent(createdDatasetBean.getId()));
+
} else {
alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
@@ -1615,7 +1607,7 @@ public class CreateDatasetForm extends Composite {
// disable profile fields
for (MetaDataField metaField : listOfMetadataFields) {
for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
- field.freeze();
+ field.freeze(true);
}
}
@@ -1625,19 +1617,42 @@ public class CreateDatasetForm extends Composite {
resourcesSelectByWEMainPanel.freeze();
}
+// /**
+// * change alert block behavior.
+// *
+// * @param textToShow
+// * @param type
+// * @param visible
+// */
+// private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
+//
+// infoBlock.setText(textToShow);
+// infoBlock.setType(type);
+// infoBlock.setVisible(visible);
+//
+// }
+
/**
* change alert block behavior.
- *
- * @param textToShow
- * @param type
- * @param visible
+ *
+ * @param textToShow the text to show
+ * @param type the type
+ * @param visible the visible
*/
- private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
+ private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
- infoBlock.setText(textToShow);
+ alertPanel.clear();
+
+ if (loader != null) {
+ alertPanel.add(loader);
+ }
infoBlock.setType(type);
infoBlock.setVisible(visible);
+ if (textToShow != null) {
+ alertPanel.add(new HTML(textToShow));
+ }
+
}
@UiHandler("licenseListbox")
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml
index f047f41..971dca9 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/CreateDatasetForm.ui.xml
@@ -2,7 +2,7 @@
+ xmlns:m="urn:import:org.gcube.portlets.widgets.mpformbuilder.client.ui.tags">
.form-main-style {
margin-left: 10px;
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java
deleted file mode 100644
index 69015ca..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.MetaDataFieldSkeleton;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
-
-import com.github.gwtbootstrap.client.ui.Button;
-import com.github.gwtbootstrap.client.ui.Label;
-import com.github.gwtbootstrap.client.ui.constants.LabelType;
-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.ui.Composite;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-
-/**
- * The Class MetaDataField.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
- *
- * Jun 10, 2019
- */
-public class MetaDataField extends Composite {
-
- private static MetaDataFieldUiBinder uiBinder = GWT.create(MetaDataFieldUiBinder.class);
-
- @UiField VerticalPanel panelMetaDataFieldsSkeleton;
-
- @UiField Label repeatabilityLabel;
-
- //@UiField ControlGroup cgMetaDataFieldSkeletonFields;
-
- @UiField Button addFieldButton;
-
- @UiField Button removeFieldButton;
-
- private List listOfMetadataFields = new ArrayList();
-
- private MetadataFieldWrapper fieldWrapper;
-
- private HandlerManager eventBus;
-
- /**
- * The Interface MetaDataFieldUiBinder.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
- *
- * Jun 10, 2019
- */
- interface MetaDataFieldUiBinder extends UiBinder {
- }
-
-
- /**
- * Instantiates a new meta data field.
- *
- * @param field the field
- * @param eventBus the event bus
- * @throws Exception the exception
- */
- public MetaDataField(final MetadataFieldWrapper field, HandlerManager eventBus) throws Exception {
- initWidget(uiBinder.createAndBindUi(this));
- this.fieldWrapper = field;
- this.eventBus = eventBus;
- addNewOccurrenceOfField();
- checkAllowedAddField();
- checkAllowedRemoveField();
-
- addFieldButton.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- addNewOccurrenceOfField();
- checkAllowedAddField();
- checkAllowedRemoveField();
- }
- });
-
- removeFieldButton.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- removeLatestOccurrenceOfFiled();
- checkAllowedAddField();
- checkAllowedRemoveField();
- }
- });
-
- //The field is repeatable
- if(field.getMaxOccurs()>1) {
- repeatabilityLabel.setVisible(true);
- repeatabilityLabel.setType(LabelType.INFO);
- addFieldButton.setTitle("Add another "+field.getFieldName());
- removeFieldButton.setTitle("Remove latest "+field.getFieldName());
-// String maxTxt = field.getMaxOccurs()==Integer.MAX_VALUE?"":"(max occurs declared are "+field.getMaxOccurs()+" times)";
- }
- }
-
-
- /**
- * Check allowed remove field.
- */
- private void checkAllowedRemoveField() {
- boolean removeCond = fieldWrapper.getMaxOccurs()>1 && listOfMetadataFields.size()>1;
- removeFieldButton.setVisible(removeCond);
- }
-
- /**
- * Checks if is allowed add occurrence.
- */
- private void checkAllowedAddField() {
-
- boolean repeatibilityCond = fieldWrapper.getMaxOccurs()>1 && listOfMetadataFields.size() getListOfMetadataFields() {
- return listOfMetadataFields;
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml
deleted file mode 100644
index eaf8b01..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/MetaDataField.ui.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- .margin-left-max-occurrs {
- padding-left: 50px;
- }
-
-
-
-
-
-
- Repeatable field
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java
new file mode 100644
index 0000000..29a1128
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.java
@@ -0,0 +1,1701 @@
+package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher;
+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.CloseCreationFormEventHandler;
+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.ReloadDatasetPageEvent;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEventHandler;
+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.ManageResources;
+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.shared.DatasetBean;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
+import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
+import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
+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.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
+
+import com.github.gwtbootstrap.client.ui.AlertBlock;
+import com.github.gwtbootstrap.client.ui.Button;
+import com.github.gwtbootstrap.client.ui.ControlGroup;
+import com.github.gwtbootstrap.client.ui.Form;
+import com.github.gwtbootstrap.client.ui.Icon;
+import com.github.gwtbootstrap.client.ui.ListBox;
+import com.github.gwtbootstrap.client.ui.NavPills;
+import com.github.gwtbootstrap.client.ui.Paragraph;
+import com.github.gwtbootstrap.client.ui.Popover;
+import com.github.gwtbootstrap.client.ui.TextArea;
+import com.github.gwtbootstrap.client.ui.TextBox;
+import com.github.gwtbootstrap.client.ui.constants.AlertType;
+import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
+import com.github.gwtbootstrap.client.ui.constants.IconType;
+import com.github.gwtbootstrap.client.ui.constants.ResizeType;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.SelectElement;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.DomEvent;
+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.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.FocusPanel;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Create metadata form for ckan product.
+ *
+ * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
+ */
+public class UpdateDatasetForm extends Composite {
+
+ private static EditMetadataFormUiBinder uiBinder = GWT.create(EditMetadataFormUiBinder.class);
+
+ /**
+ * The Interface EditMetadataFormUiBinder.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Feb 6, 2024
+ */
+ interface EditMetadataFormUiBinder extends UiBinder {
+ }
+
+ @UiField
+ HTMLPanel createDatasetMainPanel;
+ @UiField
+ TextBox titleTextBox;
+ @UiField
+ TextArea descriptionTextarea;
+ @UiField
+ ListBox licenseListbox;
+ @UiField
+ ListBox visibilityListbox;
+ @UiField
+ ListBox organizationsListbox;
+ @UiField
+ TextBox versionTextbox;
+ @UiField
+ TextBox authorTextbox;
+ @UiField
+ TextBox authorEmailTextbox;
+ @UiField
+ TextBox maintainerTextbox;
+ @UiField
+ TextBox maintainerEmailTextbox;
+ @UiField
+ ControlGroup customFields;
+ @UiField
+ Button addCustomFieldButton;
+ @UiField
+ Button updateButton;
+ @UiField
+ Button resetButton;
+ @UiField
+ AlertBlock infoBlock;
+ @UiField
+ AlertBlock alertNoResources;
+ @UiField
+ AlertBlock onContinueAlertBlock;
+ @UiField
+ AlertBlock onCreateAlertBlock;
+ @UiField
+ VerticalPanel metadataFieldsPanel;
+ @UiField
+ ListBox metadataTypeListbox;
+ @UiField
+ Form formFirstStep;
+ @UiField
+ Form formSecondStep;
+ @UiField
+ Form formThirdStep;
+ @UiField
+ Button continueButton;
+ @UiField
+ Button goBackButtonSecondStep;
+ @UiField
+ Paragraph selectedProfile;
+ @UiField
+ Button goToDatasetButton;
+ @UiField
+ HorizontalPanel goToDatasetButtonPanel;
+ @UiField
+ Button addResourcesButtonStep1;
+
+ @UiField
+ Button addResourcesButtonStep3;
+
+ @UiField
+ SimplePanel workspaceResourcesContainer;
+ @UiField
+ Button continueThirdStep;
+ @UiField
+ Button goBackButtonFirstStep;
+ @UiField
+ Anchor licenseUrlAnchor;
+ @UiField
+ Paragraph unavailableUrl;
+ @UiField
+ TagsPanel tagsPanel;
+ @UiField
+ ListBox groupsListbox;
+
+ // info panels
+ @UiField
+ Icon infoIconLicenses;
+ @UiField
+ FocusPanel focusPanelLicenses;
+ @UiField
+ Popover popoverLicenses;
+ @UiField
+ Icon infoIconVisibility;
+ @UiField
+ FocusPanel focusPanelVisibility;
+ @UiField
+ Popover popoverVisibility;
+ @UiField
+ Icon infoIconAuthor;
+ @UiField
+ FocusPanel focusPanelAuthor;
+ @UiField
+ Popover popoverAuthor;
+ @UiField
+ Icon infoIconMaintainerEmail;
+ @UiField
+ FocusPanel focusPanelMaintainerEmail;
+ @UiField
+ Popover popoverMaintainerEmail;
+ @UiField
+ Icon infoIconAuthorEmail;
+ @UiField
+ FocusPanel focusPanelAuthorEmail;
+ @UiField
+ Popover popoverAuthorEmail;
+ @UiField
+ Icon infoIconTypes;
+ @UiField
+ FocusPanel focusPanelTypes;
+ @UiField
+ Popover popoverTypes;
+ @UiField
+ Icon infoIconMaintainer;
+ @UiField
+ FocusPanel focusPanelMaintainer;
+ @UiField
+ Popover popoverMaintainer;
+ @UiField
+ Icon infoIconCustomFields;
+ @UiField
+ FocusPanel focusPanelCustomFields;
+ @UiField
+ Popover popoverCustomFields;
+ @UiField
+ Icon infoIconResources;
+ @UiField
+ FocusPanel focusPanelResources;
+ @UiField
+ Popover popoverResources;
+ @UiField
+ Icon infoIconTitle;
+ @UiField
+ FocusPanel focusPanelTitle;
+ @UiField
+ Popover popoverGroups;
+ @UiField
+ Icon infoIconGroups;
+ @UiField
+ FocusPanel focusPanelGroups;
+ @UiField
+ Popover popoverTitle;
+ @UiField
+ Icon infoIconDescription;
+ @UiField
+ Popover popoverDescription;
+ @UiField
+ FocusPanel focusPanelDescription;
+ @UiField
+ ControlGroup metadataTypesControlGroup;
+ @UiField
+ ControlGroup productTitleGroup;
+ @UiField
+ ControlGroup maintainerControlGroup;
+ @UiField
+ ControlGroup versionControlGroup;
+ @UiField
+ ControlGroup organizationsGroup;
+ @UiField
+ ControlGroup groupsControlGroup;
+
+ @UiField
+ HTMLPanel wizardCreatorPanel;
+
+ private Icon iconSpinner = new Icon(IconType.SPINNER);
+
+ // Create a remote service proxy to talk to the server-side ckan service.
+ private final CKanPublisherServiceAsync ckanServices = CKanPublisherServiceAsync.Util.getInstance();
+
+ // private static final String REGEX_TITLE_PRODUCT_SUBWORD = "[^a-zA-Z0-9_.-]";
+ private static final String REGEX_MAIL = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
+ private static final String NONE_PROFILE = "none";
+
+ // error/info messages
+ protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to update the item.";
+ protected static final String PRODUCT_UPDATED_OK = "Item correctly updated!";
+ private static final String TRYING_TO_UPDATE_PRODUCT = "Trying to update the item, please wait...";
+ protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to edit this item. Either you must be the author item or Catalogue Admininistrator in the organization";
+
+ // tab panel
+ private NavPills tabPanel;
+
+ // add resource form
+ private AddResourceToDataset resourceForm;
+
+ // the licenses
+ private List licenseBean;
+
+ // event bus of the principal application (it is the Catalogue Portlet)
+ private HandlerManager eventBusMainApplication;
+
+ private HandlerManager eventBusPublisherWidget = new HandlerManager(null);
+
+ // added custom field entries (by the user)
+ private List customFieldEntriesList = new ArrayList();
+
+ // the list of MetaDataField added
+ private List listOfMetadataFields = new ArrayList();
+
+ // dataset metadata bean
+ private DatasetBean theDatasetBean;
+
+ // resource table
+ //private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel;
+
+ // List of opened popup'ids
+ private List popupOpenedIds = new ArrayList();
+
+ // map of organization name title
+ private Map nameTitleOrganizationMap = new HashMap();
+
+ private WizardCreator wizCreator;
+
+ private boolean isWorkspaceRequest = false;
+
+ private String datasetIdOrName = null;
+
+ private FlowPanel alertPanel = new FlowPanel();
+
+ /**
+ * Instantiates a new update dataset form.
+ *
+ * @param eventBusMainApplication the event bus
+ * @param itemId the item id
+ */
+ public UpdateDatasetForm(HandlerManager mainApplicationBusRef, String itemId) {
+ updateDatasetFormBody(mainApplicationBusRef, itemId, OPERATION.UPDATE);
+ }
+
+ /**
+ * Bind on events.
+ */
+ private void bind() {
+ // when a custom field is removed, remove it from the list
+ eventBusPublisherWidget.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
+
+ @Override
+ public void onRemoveEntry(DeleteCustomFieldEvent event) {
+ customFieldEntriesList.remove(event.getRemovedEntry());
+ customFields.remove(event.getRemovedEntry());
+ }
+ });
+
+ // on close form
+ eventBusPublisherWidget.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
+ @Override
+ public void onClose(CloseCreationFormEvent event) {
+ InfoIconsLabels.closeDialogBox(popupOpenedIds);
+ }
+ });
+
+ eventBusPublisherWidget.addHandler(ReloadDatasetPageEvent.TYPE, new ReloadDatasetPageEventHandler() {
+
+ @Override
+ public void onReloadDatasetPage(ReloadDatasetPageEvent addResourceEvent) {
+
+ // Firing the event on the main application bus
+ if (addResourceEvent.getDatasetIDorName() != null) {
+ eventBusMainApplication
+ .fireEvent(new ReloadDatasetPageEvent(addResourceEvent.getDatasetIDorName()));
+ }
+
+ }
+ });
+ }
+
+ /**
+ * The real constructor.
+ *
+ * @param eventBusMainApplication the event bus
+ * @param datasetIdOrName the item id
+ * @param operation the operation
+ */
+ private void updateDatasetFormBody(final HandlerManager mainApplicationBusRef, final String datasetIdOrName,
+ final OPERATION operation) {
+
+ initWidget(uiBinder.createAndBindUi(this));
+
+ this.eventBusMainApplication = mainApplicationBusRef;
+ this.datasetIdOrName = datasetIdOrName;
+
+ iconSpinner.setSpin(true);
+ iconSpinner.getElement().getStyle().setMarginLeft(5, Unit.PX);
+ iconSpinner.getElement().getStyle().setProperty("animation", "spin 1s infinite linear");
+
+ infoBlock.add(alertPanel);
+
+ List listOfSteps = Arrays.asList("Edit Common Metadata", "Edit Item Specific Metadata & Update", "Manage Resources");
+
+ this.wizCreator = new WizardCreator(listOfSteps);
+ wizardCreatorPanel.add(wizCreator);
+
+ this.descriptionTextarea.setResize(ResizeType.VERTICAL);
+ bind();
+ prepareInfoIcons();
+
+ // disable continue button
+ continueButton.setEnabled(false);
+ resetButton.setEnabled(false);
+ addResourcesButtonStep1.setEnabled(false);
+
+ // hide reset button
+ resetButton.setVisible(false);
+
+ // hide tags panel
+ tagsPanel.setVisible(false);
+
+ // check if the user has publishing rights
+ LoaderIcon loader = new LoaderIcon("Checking your permissions, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
+
+ ckanServices.isPublisherOwnerOrAdminUser(this.datasetIdOrName, new AsyncCallback() {
+
+ @Override
+ public void onSuccess(Boolean result) {
+ GWT.log("isPublisherOwnerOrAdminUser: " + result);
+ if (result) {
+
+ // set info block
+
+ LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
+
+ // get back the licenses and the metadata information
+ ckanServices.getDatasetBeanForUpdate(datasetIdOrName, new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
+
+ }
+
+ @Override
+ public void onSuccess(final DatasetBean datasetBean) {
+ GWT.log("getDatasetBeanForUpdate returns: " + datasetBean);
+
+ if (datasetBean == null) {
+ setAlertBlock("Error while retrieving information.", null, AlertType.ERROR, true);
+ } else {
+ // save it
+ theDatasetBean = datasetBean;
+
+ // fill the form
+ titleTextBox.setText(datasetBean.getTitle());
+ descriptionTextarea.setText(datasetBean.getDescription());
+ versionTextbox.setText(String.valueOf(datasetBean.getVersion()));
+ authorTextbox.setText(datasetBean.getAuthorFullName());
+ authorEmailTextbox.setText(datasetBean.getAuthorEmail());
+ maintainerTextbox.setText(datasetBean.getMaintainer());
+ maintainerEmailTextbox.setText(datasetBean.getMaintainerEmail());
+
+ LoaderIcon loader = new LoaderIcon("Retrieving dataset information, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
+
+ // vocabulary list of tags has preemption
+ List vocabularyTags = datasetBean.getTagsVocabulary();
+ if (vocabularyTags != null) {
+ tagsPanel.setVocabulary(vocabularyTags);
+// if (datasetBean.getTags() != null) {
+// for (String tag : datasetBean.getTags()) {
+// tagsPanel.addTagElement(tag);
+// }
+//
+// }
+ }
+
+ // Settings the tags
+ if (datasetBean.getTags() != null) {
+ for (String tag : datasetBean.getTags()) {
+ tagsPanel.addTagElement(tag);
+ }
+
+ }
+
+ // THIS BLOCK is it required? Probably not.
+
+ // retrieve custom fields
+ Map> customFieldsMap = datasetBean.getCustomFields();
+ // TODO Check if these tags are ok for the vocabulary
+ if (customFieldsMap != null && vocabularyTags == null) {
+ // get the keys and put them as tags
+ Iterator>> iteratorOverCustomField = customFieldsMap
+ .entrySet().iterator();
+
+ while (iteratorOverCustomField.hasNext()) {
+ Map.Entry> entry = iteratorOverCustomField
+ .next();
+
+ List values = entry.getValue();
+
+ for (String value : values) {
+ // these are fixed key, variable value custom fields
+ CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget,
+ entry.getKey(), value, false);
+ customFieldEntriesList.add(toAdd);
+ customFields.add(toAdd);
+
+ // add as tag
+ tagsPanel.addTagElement(entry.getKey());
+ }
+ }
+ }
+ // END BLOCK
+
+ // set it as visible anyway
+ tagsPanel.setVisible(true);
+
+// // The resource root is the folder id. Es. ID of the Workspace Root folder.
+// if (datasetBean.getResourceRoot() != null) {
+// resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
+// datasetBean.getResourceRoot());
+// }
+
+ // set organizations
+ List organizations = datasetBean.getOrganizationList();
+
+ for (OrganizationBean organization : organizations) {
+ organizationsListbox.addItem(organization.getTitle());
+ nameTitleOrganizationMap.put(organization.getTitle(), organization.getName());
+ break; // expecting only one
+ }
+
+ // force the selection of the first one, and retrieve the list of profiles
+ organizationsListbox.setSelectedIndex(0);
+
+// // add change handler to dynamically retrieve the list of profiles
+// organizationsListbox.addChangeHandler(new ChangeHandler() {
+//
+// @Override
+// public void onChange(ChangeEvent event) {
+// event.preventDefault();
+// organizationsListboxChangeHandlerBody(operation);
+// }
+// });
+
+ // get the name of the organization from the title
+ final String orgName = nameTitleOrganizationMap
+ .get(organizationsListbox.getSelectedItemText());
+
+ // Putting the selected Organization into bena
+ theDatasetBean.setSelectedOrganization(orgName);
+
+ // try to retrieve the profiles
+ loader = new LoaderIcon("Retrieving types, please wait...");
+ setAlertBlock(null, loader, AlertType.INFO, true);
+
+ // perform remote request of profiles for the selected organization
+ ckanServices.getProfileForUpdate(orgName, datasetBean.getChosenType(),
+ datasetBean.getId(), new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
+ }
+
+ @Override
+ public void onSuccess(
+ final MetadataProfileBeanForUpdate metadataProfileForUpdate) {
+ setAlertBlock("", null, AlertType.ERROR, false);
+
+ List profiles = metadataProfileForUpdate
+ .getListProfileBean();
+
+ if (profiles == null) {
+ setAlertBlock(
+ "An unknow error occurred while retrieving types, sorry",
+ null, AlertType.ERROR, true);
+ } else {
+
+ GWT.log("Profile returned are: " + profiles.size());
+ if (!GWT.isProdMode()) {
+ for (MetaDataProfileBean profile : profiles) {
+ GWT.log("Profile title: " + profile.getTitle() + ", type: "
+ + profile.getType());
+ }
+ }
+
+ theDatasetBean.setMetadataList(profiles);
+ prepareMetadataList(theDatasetBean, operation);
+ addCustomField(metadataProfileForUpdate.getCustomFields());
+ organizationsListbox.setEnabled(true);
+ metadataTypeListbox.setEnabled(true);
+
+ // try to retrieve the licenses
+ LoaderIcon loaderLic = new LoaderIcon(
+ "Retrieving types, please wait...");
+ setAlertBlock(null, loaderLic, AlertType.INFO, true);
+
+ ckanServices.getLicenses(new AsyncCallback>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock(caught.getMessage(), null, AlertType.ERROR,
+ true);
+ }
+
+ @Override
+ public void onSuccess(List licenses) {
+ setAlertBlock("", null, AlertType.ERROR, false);
+
+ if (licenses != null && !licenses.isEmpty()) {
+
+ licenseBean = licenses;
+
+ // fill the listbox
+ for (int i = 0; i < licenses.size(); i++) {
+ licenseListbox.addItem(licenses.get(i).getTitle());
+ }
+
+ // set the url of the license, if any
+ showLicenseUrl();
+
+ LoaderIcon loaderLic = new LoaderIcon(
+ "Retrieving groups, please wait...");
+ setAlertBlock(null, loaderLic, AlertType.INFO, true);
+
+ // request groups
+ ckanServices.getUserGroups(orgName,
+ new AsyncCallback>() {
+
+ @Override
+ public void onSuccess(
+ List groups) {
+ if (groups == null) {
+ setAlertBlock(
+ "Error while retrieving groups",
+ null, AlertType.ERROR,
+ true);
+ } else {
+ if (groups.isEmpty()) {
+ groupsControlGroup
+ .setVisible(false);
+ } else {
+
+ // add groups
+ for (OrganizationBean group : groups) {
+ groupsListbox.addItem(
+ group.getTitle(),
+ group.getName());
+ }
+ hideGroupsAlreadyInProfile(
+ profiles);
+ }
+ // everything went ok
+ setAlertBlock("", null,
+ AlertType.ERROR, false);
+ continueButton.setEnabled(true);
+ resetButton.setEnabled(true);
+ addResourcesButtonStep1
+ .setEnabled(true);
+
+ bindManageResources(datasetBean,
+ datasetIdOrName, 1);
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock(caught.getMessage(), null,
+ AlertType.ERROR, true);
+ }
+ });
+
+ } else {
+ setAlertBlock("Error while retrieving licenses", null,
+ AlertType.ERROR, true);
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ });
+
+ } else {
+ setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.WARNING, true);
+ }
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
+ }
+ });
+
+ }
+
+ private void addCustomField(Map> customFieldsMap) {
+ // TODO Check if these tags are ok for the vocabulary
+ if (customFieldsMap != null) {
+
+ // get the keys and put them as tags
+ Iterator>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
+
+ while (iteratorOverCustomField.hasNext()) {
+ Map.Entry> entry = iteratorOverCustomField.next();
+
+ List values = entry.getValue();
+
+ for (String value : values) {
+ // these are fixed key, variable value custom fields
+ CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, entry.getKey(), value,
+ false);
+ customFieldEntriesList.add(toAdd);
+ customFields.add(toAdd);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add the items to the listbox and put data into the metadataPanel.
+ *
+ * @param theDatasetBean the received bean
+ * @param operation the operation
+ */
+ private void prepareMetadataList(final DatasetBean receivedBean, OPERATION operation) {
+
+ // the profile should be one
+ List profiles = receivedBean.getMetadataList();
+
+ if (profiles != null && !profiles.isEmpty()) {
+ for (final MetaDataProfileBean metadataBean : profiles) {
+
+ metadataTypeListbox.addItem(metadataBean.getType());
+
+ // add handler on select
+ metadataTypeListbox.addChangeHandler(new ChangeHandler() {
+
+ @Override
+ public void onChange(ChangeEvent event) {
+
+ String selectedItemText = metadataTypeListbox.getSelectedItemText();
+ metadataFieldsPanel.clear();
+ if (selectedItemText.equals(NONE_PROFILE)) {
+ metadataFieldsPanel.setVisible(false);
+ receivedBean.setChosenType(null);
+ } else {
+ receivedBean.setChosenType(selectedItemText);
+ addFields(selectedItemText, operation);
+ }
+ }
+ });
+ }
+
+ // hide elements or show them if needed (groups in profiles cannot be present
+ // again in groups listbox)
+ if (groupsControlGroup.isVisible()) {
+ List groupsToHide = new ArrayList();
+ for (MetaDataProfileBean profile : profiles)
+ groupsToHide.add(profile.getType().toString());
+
+ SelectElement se = groupsListbox.getElement().cast();
+
+ for (int i = 0; i < groupsListbox.getItemCount(); i++) {
+ if (groupsToHide.contains(groupsListbox.getItemText(i))) {
+ se.getOptions().getItem(i).getStyle().setProperty("display", "none");
+ } else
+ se.getOptions().getItem(i).getStyle().setProperty("display", "");
+ }
+ }
+
+ metadataTypesControlGroup.setVisible(true);
+ } else {
+ // just hide this listbox
+ metadataTypesControlGroup.setVisible(false);
+ metadataFieldsPanel.clear();
+ listOfMetadataFields.clear();
+ receivedBean.setChosenType(null);
+ }
+
+ Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ if (profiles.size() == 1) {
+ // showChooseProfileForm(false);
+ metadataTypeListbox.setSelectedValue(profiles.get(0).getType());
+ // customLegend.setText("Insert Information for: " + profiles.get(0).getType(),
+ // true);
+ DomEvent.fireNativeEvent(Document.get().createChangeEvent(), metadataTypeListbox);
+ }
+ }
+
+ });
+ }
+
+ /**
+ * Add fields of the selected metadata profile to the widget.
+ *
+ * @param selectedItem the selected item
+ * @param operation the operation
+ */
+ protected void addFields(String selectedItem, OPERATION operation) {
+
+ for (MetaDataProfileBean bean : theDatasetBean.getMetadataList()) {
+ if (bean.getType().equals(selectedItem)) {
+
+ // clear old data
+ listOfMetadataFields.clear();
+
+ // prepare the data
+ List fields = bean.getMetadataFields();
+ List categories = bean.getCategories();
+
+ GWT.log("There are " + categories.size() + " categories for profile " + bean.getTitle());
+
+ if (categories == null || categories.isEmpty()) {
+ for (MetadataFieldWrapper field : fields) {
+
+ MetaDataField fieldWidget;
+ try {
+ fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
+ metadataFieldsPanel.add(fieldWidget);
+ listOfMetadataFields.add(fieldWidget);
+ } catch (Exception e) {
+ GWT.log("Unable to build such widget", e);
+ }
+ }
+ } else {
+
+ // create the categories, then parse the fields. Fields do not belonging to a
+ // category are put at the end
+ for (CategoryWrapper categoryWrapper : categories) {
+ if (categoryWrapper.getFieldsForThisCategory() != null
+ && categoryWrapper.getFieldsForThisCategory().size() > 0) {
+ CategoryPanel cp = new CategoryPanel(categoryWrapper.getTitle(),
+ categoryWrapper.getDescription());
+ List fieldsForThisCategory = categoryWrapper
+ .getFieldsForThisCategory();
+ fields.removeAll(fieldsForThisCategory);
+
+ for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
+
+ MetaDataField fieldWidget;
+ try {
+ fieldWidget = new MetaDataField(metadataFieldWrapper, eventBusPublisherWidget,
+ operation);
+ cp.addField(fieldWidget);
+ listOfMetadataFields.add(fieldWidget);
+ } catch (Exception e) {
+ GWT.log("Unable to build such widget", e);
+ }
+ }
+ metadataFieldsPanel.add(cp);
+ }
+ }
+
+ // add the remaining one at the end of the categories
+ CategoryPanel extrasCategory = new CategoryPanel("Other", null);
+ for (MetadataFieldWrapper field : fields) {
+
+ MetaDataField fieldWidget;
+ try {
+ fieldWidget = new MetaDataField(field, eventBusPublisherWidget, operation);
+ extrasCategory.addField(fieldWidget);
+ listOfMetadataFields.add(fieldWidget);
+ } catch (Exception e) {
+ GWT.log("Unable to build such widget", e);
+ }
+ }
+ metadataFieldsPanel.add(extrasCategory);
+ }
+ metadataFieldsPanel.setVisible(true);
+ }
+ }
+ }
+
+ /**
+ * Adds the custom field event.
+ *
+ * @param e the e
+ */
+ @UiHandler("addCustomFieldButton")
+ void addCustomFieldEvent(ClickEvent e) {
+
+ CustomFieldEntry toAdd = new CustomFieldEntry(eventBusPublisherWidget, "", "", true);
+ customFieldEntriesList.add(toAdd);
+ customFields.add(toAdd);
+
+ }
+
+ /**
+ * On continue button.
+ *
+ * @param e the e
+ */
+ @UiHandler("continueButton")
+ void onContinueButton(ClickEvent e) {
+
+ // validate data
+ final String errorMsg = validateDataOnContinue();
+
+ if (errorMsg != null) {
+
+ alertOnContinue("Please check inserted data [" + errorMsg + "]", AlertType.ERROR);
+ return;
+
+ } else {
+
+ // better check for title (only if the dataset was not created.. if it is the
+ // case, fields are not frozen)
+ if (!titleTextBox.isEnabled())
+ actionsAfterOnContinue();
+ else {
+ actionsAfterOnContinue();
+ }
+ }
+ }
+
+ /**
+ * After onContinue ...
+ */
+ private void actionsAfterOnContinue() {
+
+ // check what to do
+ if (isWorkspaceRequest) {
+
+ // we need to show the page to handle resources one by one from the workspace
+ formFirstStep.setVisible(false);
+ boolean hideManageRes = hideManageResources();
+ int stepActive = -1;
+ if (hideManageRes) {
+ stepActive = 3;
+ } else {
+ stepActive = 2;
+ }
+
+ formSecondStep.setVisible(!hideManageRes);
+ formThirdStep.setVisible(hideManageRes);
+ activeWizardStep(stepActive);
+
+ // add the resources to the container panel
+ if (workspaceResourcesContainer.getWidget() == null) {
+ workspaceResourcesContainer.getElement().getStyle().setMarginLeft(20, Unit.PX);
+ //workspaceResourcesContainer.add(resourcesSelectByWEMainPanel);
+ }
+
+ } else {
+
+ // this is not a workspace request
+ formFirstStep.setVisible(false);
+ formThirdStep.setVisible(true);
+ activeWizardStep(2);
+
+ }
+
+ if (metadataTypeListbox.getSelectedItemText().equals(NONE_PROFILE))
+ selectedProfile.setText("");
+ else
+ selectedProfile.setText("Selected Type is " + metadataTypeListbox.getSelectedItemText());
+
+ }
+
+ /**
+ * Active wizard step.
+ *
+ * @param step the step
+ */
+ private void activeWizardStep(int step) {
+ if (wizCreator != null) {
+ wizCreator.activeStep(step);
+ }
+ }
+
+ /**
+ * On go back button first step.
+ *
+ * @param e the e
+ */
+ @UiHandler("goBackButtonFirstStep")
+ void onGoBackButtonFirstStep(ClickEvent e) {
+
+ // swap forms
+ formFirstStep.setVisible(true);
+ activeWizardStep(1);
+ formSecondStep.setVisible(false);
+ formThirdStep.setVisible(false);
+
+ }
+
+ /**
+ * On go back button.
+ *
+ * @param e the e
+ */
+ @UiHandler("goBackButtonSecondStep")
+ void onGoBackButton(ClickEvent e) {
+
+ // swap forms
+ if (isWorkspaceRequest) {
+ boolean hideManageRes = hideManageResources();
+ int stepActive = -1;
+ if (hideManageRes) {
+ stepActive = 1;
+ } else {
+ stepActive = 2;
+ }
+ formFirstStep.setVisible(hideManageRes);
+ formSecondStep.setVisible(!hideManageRes);
+ activeWizardStep(stepActive);
+ } else {
+
+ formFirstStep.setVisible(true);
+ formSecondStep.setVisible(false);
+ activeWizardStep(1);
+ }
+ formThirdStep.setVisible(false);
+
+ }
+
+ /**
+ * On continue third step.
+ *
+ * @param e the e
+ */
+ @UiHandler("continueThirdStep")
+ void onContinueThirdStep(ClickEvent e) {
+
+ // swap forms
+ formSecondStep.setVisible(false);
+ formThirdStep.setVisible(true);
+ activeWizardStep(3);
+
+ }
+
+ /**
+ * Creates the dataset event.
+ *
+ * @param e the e
+ */
+ @UiHandler("updateButton")
+ void updateDatasetEvent(ClickEvent e) {
+
+ String errorMessage = areProfileDataValid();
+
+ if (errorMessage != null) {
+ alertOnUpdated("Please check the inserted values and the mandatory fields [" + errorMessage + "]", false,
+ AlertType.ERROR, true);
+ } else {
+
+ String title = titleTextBox.getValue().trim();
+ String description = descriptionTextarea.getText().trim();
+ String selectedLicense = licenseListbox.getSelectedItemText();
+ String visibility = visibilityListbox.getSelectedItemText();
+ long version = Long.valueOf(versionTextbox.getValue().trim());
+ String author = authorTextbox.getValue();
+ String authorEmail = authorEmailTextbox.getValue();
+ String maintainer = maintainerTextbox.getValue().trim();
+ String maintainerEmail = maintainerEmailTextbox.getValue().trim();
+ String chosenOrganizationTitle = organizationsListbox.getSelectedItemText();
+ Set tags = new HashSet(tagsPanel.getTags());
+
+ // we need to retrieve the organization's name from this title
+ List orgs = theDatasetBean.getOrganizationList();
+ String chosenOrganization = null;
+ for (OrganizationBean organizationBean : orgs) {
+ if (chosenOrganizationTitle.equals(organizationBean.getTitle())) {
+ chosenOrganization = organizationBean.getName();
+ break;
+ }
+ }
+
+ List groups = new ArrayList();
+ List groupsToForceCreation = new ArrayList();
+
+ // get groups, if any
+ int items = groupsListbox.getItemCount();
+ for (int i = 0; i < items; i++) {
+ String groupTitle = groupsListbox.getItemText(i);
+ String groupName = groupsListbox.getValue(i);
+ if (groupsListbox.isItemSelected(i)) {
+ groups.add(new OrganizationBean(groupTitle, groupName, false));
+ }
+ }
+
+ Map> customFieldsMap = new HashMap>();
+
+ // prepare custom fields
+ for (MetaDataField metaField : listOfMetadataFields) {
+
+ for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
+
+ List valuesForField = field.getFieldCurrentValue();
+ if (!valuesForField.isEmpty()) {
+ String key = field.getFieldNameQualified();
+ List valuesForThisField = null;
+ if (customFieldsMap.containsKey(key))
+ valuesForThisField = customFieldsMap.get(key);
+ else
+ valuesForThisField = new ArrayList();
+
+ valuesForThisField.addAll(valuesForField);
+ customFieldsMap.put(key, valuesForThisField);
+
+ // get also tag/group if it is the case for this field
+ List tagsField = field.getTagFromThisField();
+ if (tagsField != null)
+ tags.addAll(tagsField);
+
+ List groupsTitle = field.getGroupTitleFromThisGroup();
+ if (groupsTitle != null) {
+ for (String groupTitle : groupsTitle) {
+ if (field.isGroupToForce())
+ groupsToForceCreation.add(
+ new OrganizationBean(groupTitle, groupTitle, false, field.isPropagateUp()));
+ else
+ groups.add(
+ new OrganizationBean(groupTitle, groupTitle, false, field.isPropagateUp()));
+ }
+ }
+ }
+ }
+ }
+
+ for (CustomFieldEntry customEntry : customFieldEntriesList) {
+ String key = customEntry.getKey();
+ String value = customEntry.getValue();
+ if (value != null && !value.isEmpty()) {
+ List valuesForThisField = null;
+ if (customFieldsMap.containsKey(key))
+ valuesForThisField = customFieldsMap.get(key);
+ else
+ valuesForThisField = new ArrayList();
+ valuesForThisField.add(value);
+ customFieldsMap.put(key, valuesForThisField);
+ }
+
+ }
+
+ // fill the bean
+ theDatasetBean.setAuthorFullName(author);
+ theDatasetBean.setAuthorEmail(authorEmail);
+ theDatasetBean.setDescription(description);
+ theDatasetBean.setLicense(selectedLicense);
+ theDatasetBean.setMaintainer(maintainer);
+ theDatasetBean.setMaintainerEmail(maintainerEmail);
+ theDatasetBean.setVersion(version);
+ theDatasetBean.setVisibile(visibility.equals("Public"));
+ theDatasetBean.setTitle(title);
+ theDatasetBean.setTags(new ArrayList(tags));
+ theDatasetBean.setSelectedOrganization(chosenOrganization);
+ theDatasetBean.setGroups(groups);
+ theDatasetBean.setGroupsForceCreation(groupsToForceCreation);
+
+// if (resourcesSelectByWEMainPanel != null) {
+// theDatasetBean.setResourceRoot(resourcesSelectByWEMainPanel.getResourcesToPublish());
+// }
+
+ theDatasetBean.setCustomFields(customFieldsMap);
+
+ // alert
+ alertOnUpdated(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
+
+ // invoke the create method
+ updateButton.setEnabled(false);
+ goBackButtonSecondStep.setEnabled(false);
+
+ ckanServices.updateCKANDataset(theDatasetBean, new AsyncCallback() {
+
+ @Override
+ public void onSuccess(final DatasetBean createdDatasetBean) {
+ CKanMetadataPublisher.printJs("createCKanDataset returned");
+
+ GWT.log("Updated the dataset: " + createdDatasetBean);
+
+ if (createdDatasetBean != null) {
+
+ CKanMetadataPublisher.printJs(createdDatasetBean.toString());
+
+ final String datasetUrl = createdDatasetBean.getSource();
+
+ alertOnUpdated(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false);
+
+ try {
+ // disable dataset fields
+ disableDatasetFields();
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
+ // disable reset
+ resetButton.setEnabled(false);
+
+ // show the go to dataset button
+
+ goToDatasetButtonPanel.setVisible(true);
+ goToDatasetButton.setVisible(true);
+
+ String title = createdDatasetBean.getTitle();
+ String link = "(click here) ";
+ link += title.length() > 90 ? title.substring(0, 90) + "..." : title;
+
+ goToDatasetButton.setTitle("Go to the item: " + title);
+
+ goToDatasetButton.setText(link);
+ goToDatasetButton.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ Window.open(datasetUrl, "_blank", "");
+ // Window.Location.assign(datasetUrl);
+ }
+ });
+
+ // set hidden the create button
+ updateButton.setVisible(false);
+
+ // if we are in the "general case" we need to show a form for adding resources
+ bindManageResources(createdDatasetBean, datasetUrl, 3);
+
+ eventBusPublisherWidget.fireEvent(new ReloadDatasetPageEvent(createdDatasetBean.getId()));
+
+ } else {
+
+ alertOnUpdated(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
+ }
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ alertOnUpdated(ERROR_PRODUCT_CREATION + " Error message is : " + caught.getMessage(), false,
+ AlertType.ERROR, true);
+ CKanMetadataPublisher.printJs(caught.toString());
+ }
+ });
+ }
+ }
+
+ private void bindManageResources(final DatasetBean theDatasetBean, final String datasetUrl, int step) {
+ GWT.log("bindManageResources on dataset: " + theDatasetBean.getCkanName());
+
+ if (step == 1) {
+ // addResourcesButtonStep1.clear();
+ addResourcesButtonStep1.setVisible(true);
+ addResourcesButtonStep3.setVisible(false);
+ addResourcesButtonStep1.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ GWT.log("Clicked addResourcesButtonStep1");
+
+ manageResourcesOnFire(theDatasetBean, datasetUrl);
+ }
+ });
+ }
+
+ if (step == 3) {
+ // addResourcesButtonStep3.clear();
+ addResourcesButtonStep3.setVisible(true);
+ addResourcesButtonStep3.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ GWT.log("Clicked addResourcesButtonStep3");
+
+ manageResourcesOnFire(theDatasetBean, datasetUrl);
+
+ }
+ });
+ }
+ }
+
+ private void manageResourcesOnFire(final DatasetBean theDatasetBean, String datasetUrl) {
+
+ // remove content of the main panel
+ createDatasetMainPanel.clear();
+
+ ManageResources manageResources = new ManageResources(eventBusPublisherWidget, theDatasetBean, datasetUrl);
+
+ // add the new content of the main panel
+ createDatasetMainPanel.add(manageResources);
+
+ final List resources = theDatasetBean.getCkanResources();
+
+ if (resources != null && resources.size() > 0) {
+ GWT.log("Executing are: " + resources);
+ for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
+ manageResources.getEventBus().fireEvent(new AddResourceEvent(reb));
+ }
+ }
+ }
+
+ /**
+ * Prepare the info icons of all core metadata info.
+ */
+ private void prepareInfoIcons() {
+
+ // tags
+ tagsPanel.prepareIcon(popupOpenedIds);
+
+ // licenses
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.LICENSES_INFO_ID_POPUP,
+ InfoIconsLabels.LICENSES_INFO_TEXT, InfoIconsLabels.LICENSES_INFO_CAPTION, infoIconLicenses,
+ popoverLicenses, focusPanelLicenses, popupOpenedIds);
+
+ // visibility
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.VISIBILITY_INFO_ID_POPUP,
+ InfoIconsLabels.VISIBILITY_INFO_TEXT, InfoIconsLabels.VISIBILITY_INFO_CAPTION, infoIconVisibility,
+ popoverVisibility, focusPanelVisibility, popupOpenedIds);
+
+ // author
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.AUTHOR_INFO_ID_POPUP,
+ InfoIconsLabels.AUTHOR_INFO_TEXT, InfoIconsLabels.AUTHOR_INFO_CAPTION, infoIconAuthor, popoverAuthor,
+ focusPanelAuthor, popupOpenedIds);
+
+ // author's email
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.AUTHOR_EMAIL_INFO_ID_POPUP,
+ InfoIconsLabels.AUTHOR_EMAIL_INFO_TEXT, InfoIconsLabels.AUTHOR_EMAIL_INFO_CAPTION, infoIconAuthorEmail,
+ popoverAuthorEmail, focusPanelAuthorEmail, popupOpenedIds);
+
+ // maintainer
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.MAINTAINER_INFO_ID_POPUP,
+ InfoIconsLabels.MAINTAINER_INFO_TEXT, InfoIconsLabels.MAINTAINER_INFO_CAPTION, infoIconMaintainer,
+ popoverMaintainer, focusPanelMaintainer, popupOpenedIds);
+
+ // maintainer's email
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.MAINTAINER_EMAIL_INFO_ID_POPUP,
+ InfoIconsLabels.MAINTAINER_EMAIL_INFO_TEXT, InfoIconsLabels.MAINTAINER_EMAIL_INFO_CAPTION,
+ infoIconMaintainerEmail, popoverMaintainerEmail, focusPanelMaintainerEmail, popupOpenedIds);
+
+ // profiles (or types)
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.PROFILES_INFO_ID_POPUP,
+ InfoIconsLabels.PROFILES_INFO_TEXT, InfoIconsLabels.PROFILES_INFO_CAPTION, infoIconTypes, popoverTypes,
+ focusPanelTypes, popupOpenedIds);
+
+ // custom fields
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP,
+ InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT, InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
+ infoIconCustomFields, popoverCustomFields, focusPanelCustomFields, popupOpenedIds);
+
+ // resources field
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.RESOURCES_INFO_ID_POPUP,
+ InfoIconsLabels.RESOURCES_INFO_TEXT, InfoIconsLabels.RESOURCES_INFO_CAPTION, infoIconResources,
+ popoverResources, focusPanelResources, popupOpenedIds);
+
+ // title
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.TITLE_INFO_ID_POPUP,
+ InfoIconsLabels.TITLE_INFO_TEXT, InfoIconsLabels.TITLE_INFO_CAPTION, infoIconTitle, popoverTitle,
+ focusPanelTitle, popupOpenedIds);
+
+ // description
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.DESCRIPTION_INFO_ID_POPUP,
+ InfoIconsLabels.DESCRIPTION_INFO_TEXT, InfoIconsLabels.DESCRIPTION_INFO_CAPTION, infoIconDescription,
+ popoverDescription, focusPanelDescription, popupOpenedIds);
+
+ // groups
+ InfoIconsLabels.preparePopupPanelAndPopover(InfoIconsLabels.GROUPS_INFO_ID_POPUP,
+ InfoIconsLabels.GROUPS_INFO_TEXT, InfoIconsLabels.GROUPS_INFO_CAPTION, infoIconGroups, popoverGroups,
+ focusPanelGroups, popupOpenedIds);
+ }
+
+ /**
+ * Test if profile data are valid.
+ *
+ * @return the string
+ */
+ private String areProfileDataValid() {
+
+ for (MetaDataField metaField : listOfMetadataFields) {
+
+ for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
+
+ field.removeError();
+
+ String error = field.isFieldValueValid();
+ if (error != null) {
+ field.showError();
+ return field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * On continue show alert box and enable buttons.
+ *
+ * @param text the text
+ * @param type the type
+ */
+ private void alertOnContinue(String text, AlertType type) {
+
+ onContinueAlertBlock.setText(text);
+ onContinueAlertBlock.setType(type);
+ onContinueAlertBlock.setVisible(true);
+ continueButton.setEnabled(true);
+ resetButton.setEnabled(true);
+
+ // hide after some seconds
+ Timer t = new Timer() {
+
+ @Override
+ public void run() {
+
+ onContinueAlertBlock.setVisible(false);
+
+ }
+ };
+
+ t.schedule(4000);
+ }
+
+ /**
+ * On continue show alert box and enable buttons.
+ *
+ * @param text the text
+ * @param showSpinner the show spinner
+ * @param type the type
+ * @param hideAfterAWhile the hide after A while
+ */
+ private void alertOnUpdated(String text, boolean showSpinner, AlertType type, boolean hideAfterAWhile) {
+
+ onCreateAlertBlock.clear();
+
+ try {
+ onCreateAlertBlock.remove(iconSpinner);
+ } catch (Exception e) {
+ }
+
+ if (showSpinner) {
+ onCreateAlertBlock.add(iconSpinner);
+ }
+
+ onCreateAlertBlock.setText(text);
+ onCreateAlertBlock.setType(type);
+ onCreateAlertBlock.setVisible(true);
+ updateButton.setEnabled(true);
+ goBackButtonSecondStep.setEnabled(true);
+
+ if (hideAfterAWhile) {
+ // hide after some seconds
+ Timer t = new Timer() {
+
+ @Override
+ public void run() {
+
+ onCreateAlertBlock.setVisible(false);
+
+ }
+ };
+ t.schedule(15000);
+ }
+ }
+
+ /**
+ * Validate data.
+ *
+ * @return true on success, false otherwise
+ */
+ private String validateDataOnContinue() {
+
+ // remove errors
+ productTitleGroup.setType(ControlGroupType.NONE);
+ maintainerControlGroup.setType(ControlGroupType.NONE);
+ versionControlGroup.setType(ControlGroupType.NONE);
+ metadataTypesControlGroup.setType(ControlGroupType.NONE);
+ organizationsGroup.setType(ControlGroupType.NONE);
+ tagsPanel.setGroupPanelType(ControlGroupType.NONE);
+
+ String title = titleTextBox.getText().trim();
+ if (title.isEmpty()) {
+ productTitleGroup.setType(ControlGroupType.ERROR);
+ return "Missing title";
+ }
+
+ if (title.length() < 2) {
+ productTitleGroup.setType(ControlGroupType.ERROR);
+ return "The field title is too short";
+ }
+
+ // better check for the title
+ // String[] splittedTitle = title.split(" ");
+
+ /*
+ * No check, see #20828 for (String word : splittedTitle) { String replaced =
+ * word.replaceAll(REGEX_TITLE_PRODUCT_SUBWORD, ""); if(!replaced.equals(word)){
+ * productTitleGroup.setType(ControlGroupType.ERROR); return
+ * "Please note not all characters are allowed for the title"; } }
+ */
+
+ // email reg expression
+ String maintainerMail = maintainerEmailTextbox.getText();
+ if (!maintainerMail.isEmpty() && !maintainerMail.matches(REGEX_MAIL)) {
+ maintainerControlGroup.setType(ControlGroupType.ERROR);
+ return "Not valid maintainer email";
+ }
+
+ // check if version is a number
+ try {
+ int number = Integer.valueOf(versionTextbox.getText().trim());
+ if (number <= 0)
+ throw new Exception();
+ } catch (Exception e) {
+ versionControlGroup.setType(ControlGroupType.ERROR);
+ return "Version must be a natural number greater than zero";
+ }
+
+ // check if metadata profile is different from none and its mandatory fields
+ // have been fulfilled
+ if (checkSelectedMetaDataProfile()) {
+ metadataTypesControlGroup.setType(ControlGroupType.ERROR);
+ return "You must select a Type different frome none";
+ }
+
+ if (organizationsListbox.getSelectedItemText() == null) {
+ organizationsGroup.setType(ControlGroupType.ERROR);
+ return "You must select an organization in which you want to publish";
+ }
+
+ // at least one tag..
+ if (tagsPanel.getTags().isEmpty()) {
+ tagsPanel.setGroupPanelType(ControlGroupType.ERROR);
+ return "Please add at least one meaningful tag for the item";
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks if a metadata profile has been chosen and its fields have been
+ * fulfilled.
+ *
+ * @return true, if successful
+ */
+ private boolean checkSelectedMetaDataProfile() {
+ return metadataTypeListbox.getSelectedItemText().equals(NONE_PROFILE)
+ && metadataTypeListbox.getItemCount() != 1;
+ }
+
+ /**
+ * Reset form event.
+ *
+ * @param e the e
+ */
+ @UiHandler("resetButton")
+ void resetFormEvent(ClickEvent e) {
+
+ // reset main fields
+ titleTextBox.setText("");
+ descriptionTextarea.setText("");
+ versionTextbox.setText("");
+ maintainerTextbox.setText("");
+ maintainerEmailTextbox.setText("");
+ tagsPanel.removeTags();
+
+ // unselect all groups
+ for (int i = 0; i < groupsListbox.getItemCount(); i++)
+ groupsListbox.setItemSelected(i, false);
+
+ // delete custom fields
+ for (CustomFieldEntry customField : customFieldEntriesList) {
+ customField.removeFromParent();
+ }
+ customFieldEntriesList.clear();
+ }
+
+ /**
+ * Disable dataset editable fields once the dataset has been successfully
+ * created.
+ */
+ protected void disableDatasetFields() {
+
+ titleTextBox.setEnabled(false);
+ descriptionTextarea.setEnabled(false);
+ versionTextbox.setEnabled(false);
+ maintainerTextbox.setEnabled(false);
+ maintainerEmailTextbox.setEnabled(false);
+ visibilityListbox.setEnabled(false);
+ tagsPanel.freeze();
+ licenseListbox.setEnabled(false);
+ organizationsListbox.setEnabled(false);
+ addCustomFieldButton.setEnabled(false);
+ metadataTypeListbox.setEnabled(false);
+ groupsListbox.setEnabled(false);
+
+ for (CustomFieldEntry ce : customFieldEntriesList)
+ ce.freeze();
+
+ // disable profile fields
+ for (MetaDataField metaField : listOfMetadataFields) {
+ for (MetaDataFieldSkeleton field : metaField.getListOfMetadataFields()) {
+ field.freeze(true);
+ }
+
+ }
+
+// // freeze table of resources
+// if (resourcesSelectByWEMainPanel != null)
+// resourcesSelectByWEMainPanel.freeze();
+ }
+
+ /**
+ * change alert block behavior.
+ *
+ * @param textToShow the text to show
+ * @param type the type
+ * @param visible the visible
+ */
+ private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
+
+ alertPanel.clear();
+
+ if (loader != null) {
+ alertPanel.add(loader);
+ }
+ infoBlock.setType(type);
+ infoBlock.setVisible(visible);
+
+ if (textToShow != null) {
+ alertPanel.add(new HTML(textToShow));
+ }
+
+ }
+
+ /**
+ * On selected license change.
+ *
+ * @param c the c
+ */
+ @UiHandler("licenseListbox")
+ void onSelectedLicenseChange(ChangeEvent c) {
+
+ showLicenseUrl();
+
+ }
+
+ /**
+ * The body of the onSelectedLicenseChange.
+ */
+ private void showLicenseUrl() {
+
+ String selectedLicense = licenseListbox.getSelectedItemText();
+ int index = -1;
+ if ((index = licenseBean.indexOf(new LicenseBean(selectedLicense, null))) >= 0) {
+ LicenseBean foundLicense = licenseBean.get(index);
+ licenseUrlAnchor.setText(foundLicense.getUrl());
+ licenseUrlAnchor.setHref(foundLicense.getUrl());
+ licenseUrlAnchor.setVisible(true);
+ unavailableUrl.setVisible(false);
+ } else {
+ licenseUrlAnchor.setVisible(false);
+ unavailableUrl.setVisible(true);
+ }
+ }
+
+ /**
+ * Hide the groups that are already listed in the profiles page.
+ *
+ * @param profiles the profiles
+ */
+ private void hideGroupsAlreadyInProfile(List profiles) {
+
+ List groupsToHide = new ArrayList();
+ for (MetaDataProfileBean profile : profiles)
+ groupsToHide.add(profile.getType());
+
+ SelectElement se = groupsListbox.getElement().cast();
+
+ int hiddenElements = 0;
+ for (int i = 0; i < groupsListbox.getItemCount(); i++) {
+ if (groupsToHide.contains(groupsListbox.getItemText(i))) {
+ se.getOptions().getItem(i).getStyle().setProperty("display", "none");
+ hiddenElements++;
+ }
+ }
+
+ if (hiddenElements == groupsListbox.getItemCount())
+ groupsControlGroup.setVisible(false);
+ else
+ groupsControlGroup.setVisible(true);
+
+ }
+
+ /**
+ * Check if resource(s) are missing.
+ *
+ * @return true, if successful
+ */
+ private boolean hideManageResources() {
+
+ return theDatasetBean.getResourceRoot() == null || theDatasetBean.getResourceRoot().isFolder()
+ && (theDatasetBean.getResourceRoot().getChildrenSize() == null
+ || theDatasetBean.getResourceRoot().getChildrenSize() == 0);
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml
new file mode 100644
index 0000000..fad55f6
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/form/UpdateDatasetForm.ui.xml
@@ -0,0 +1,447 @@
+
+
+
+ .form-main-style {
+ margin-left: 10px;
+ }
+
+ .fieldset-border-style {
+ border: 1px groove #444 !important;
+ box-shadow: 0px 0px 0px 0px #000 !important;
+ padding: 10px !important;
+ margin: 5px !important;
+ }
+
+ .legend-style {
+ width: auto !important;
+ padding: 10px !important;
+ margin-bottom: 0 !important;
+ border-bottom: 0 !important;
+ }
+
+ @external .form-horizontal .input-large;
+ .form-horizontal .input-large .input-prepend {
+ width: 95%;
+ }
+
+ .block-alert-style {
+ margin-top: 10px;
+ padding: 10px;
+ margin-bottom: 10px;
+ }
+
+ .tagsPanelStyle {
+ display: inline-block;
+ }
+
+ .selected-profile {
+ font-weight: bold;
+ }
+
+ .label-go-to-product {
+ display: inline-block;
+ vertical-align: middle;
+ font-weight: bold;
+ }
+
+ .the-margin-gotoitem {
+ margin-left: 5px;
+ margin-top: 10px;
+ margin-bottom: 10px;
+ }
+
+
+
+
+
+
+
+ Insert Item Information
+
+ *
+ is required
+
+
+
+
+
+
+
+
+ *
+ Title :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Description:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ License:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Selected
+ License Url:
+
+
+ Unavailable
+
+
+
+
+
+
+ Visibility:
+
+
+ Restricted
+ Public
+
+
+
+
+
+
+
+
+
+
+
+
+ Publish in:
+
+
+
+
+
+
+
+
+ Version:
+
+
+
+
+
+
+
+
+ *
+ Author:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ *
+ Author Email:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Maintainer:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Maintainer Email:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Types:
+
+
+ none
+
+
+
+
+
+
+
+
+
+
+
+
+ Item Groups:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Continue
+ Reset
+
+ Manage Resources
+
+
+
+
+
+
+
+
+ Select Item Resources
+
+
+
+
+
+
+
+
+
+
+
+
+ Continue
+
+ Go
+ Back
+
+
+
+
+
+
+
+
+ Insert Item Profile Information
+
+ *
+ is required
+
+
+
+
+
+
+
+
+
+
+ Custom Field(s):
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Go to the Item
+
+
+
+ Update
+
+ Go
+ Back
+
+ Manage Resources
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.java
deleted file mode 100644
index 4e5326b..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.MetaDataField;
-
-import com.github.gwtbootstrap.client.ui.PageHeader;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Style.Float;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-public class CategoryPanel extends Composite{
-
- private static CategoryPanelUiBinder uiBinder = GWT
- .create(CategoryPanelUiBinder.class);
-
- interface CategoryPanelUiBinder extends UiBinder {
- }
-
- @UiField VerticalPanel fieldsPanel;
- @UiField PageHeader categoryHeader;
- //private List fieldsForThisCategory;
-
- private List fieldsForThisCategory;
-
- public CategoryPanel() {
- initWidget(uiBinder.createAndBindUi(this));
- }
-
- /**
- *
- * @param fieldsForThisCategory
- * @param title
- * @param description
- */
- public CategoryPanel(String title, String description) {
- initWidget(uiBinder.createAndBindUi(this));
- title = title == null ? "" : title;
- description = description == null ? "" : description;
- categoryHeader.setTitle(title);
- categoryHeader.setText(title);
- categoryHeader.setSubtext(description);
- categoryHeader.getElement().getStyle().setFloat(Float.LEFT);
- }
-
- /**
- * Add a field to this widget
- * @param fieldWidget
- */
- /*public void addField(MetaDataFieldSkeleton fieldWidget) {
- if(fieldsForThisCategory == null){
- fieldsForThisCategory = new ArrayList();
- fieldWidget.setVisible(true);
- fieldsPanel.setVisible(true);
- }
- fieldsForThisCategory.add(fieldWidget);
- fieldsPanel.add(fieldWidget);
- }*/
-
-
- /**
- * Add a field to this widget
- * @param fieldWidget
- */
- public void addField(MetaDataField fieldWidget) {
- if(fieldsForThisCategory == null){
- fieldsForThisCategory = new ArrayList();
- fieldWidget.setVisible(true);
- fieldsPanel.setVisible(true);
- }
- fieldsForThisCategory.add(fieldWidget);
- fieldsPanel.add(fieldWidget);
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.ui.xml
deleted file mode 100644
index 68e9845..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CategoryPanel.ui.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CustomFieldEntry.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CustomFieldEntry.ui.xml
index 780c41a..7cae843 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CustomFieldEntry.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/CustomFieldEntry.ui.xml
@@ -1,13 +1,17 @@
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
-
+
-
+
-
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/MetaDataFieldSkeleton.java
deleted file mode 100644
index 3eb43ca..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/metadata/MetaDataFieldSkeleton.java
+++ /dev/null
@@ -1,906 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.openlayerwidget.GeoJsonAreaSelectionDialog;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.timeandreanges.DataTimeBox;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsGroup;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsTag;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.TaggingGroupingValue;
-
-import com.github.gwtbootstrap.client.ui.Alert;
-import com.github.gwtbootstrap.client.ui.Button;
-import com.github.gwtbootstrap.client.ui.CheckBox;
-import com.github.gwtbootstrap.client.ui.ControlGroup;
-import com.github.gwtbootstrap.client.ui.ControlLabel;
-import com.github.gwtbootstrap.client.ui.Controls;
-import com.github.gwtbootstrap.client.ui.Icon;
-import com.github.gwtbootstrap.client.ui.ListBox;
-import com.github.gwtbootstrap.client.ui.Popover;
-import com.github.gwtbootstrap.client.ui.TextArea;
-import com.github.gwtbootstrap.client.ui.TextBox;
-import com.github.gwtbootstrap.client.ui.constants.AlertType;
-import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
-import com.github.gwtbootstrap.client.ui.constants.IconType;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.SpanElement;
-import com.google.gwt.dom.client.Style.Cursor;
-import com.google.gwt.dom.client.Style.Display;
-import com.google.gwt.dom.client.Style.Unit;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.logical.shared.ResizeEvent;
-import com.google.gwt.event.logical.shared.ResizeHandler;
-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.uibinder.client.UiHandler;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.FocusPanel;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.SimplePanel;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-public class MetaDataFieldSkeleton extends Composite{
-
- private static MetaDataFieldSkeletonUiBinder uiBinder = GWT
- .create(MetaDataFieldSkeletonUiBinder.class);
-
- interface MetaDataFieldSkeletonUiBinder extends
- UiBinder {
- }
-
- @UiField Element mandatorySymbol;
- @UiField SpanElement name;
- @UiField SimplePanel elementPanel;
- @UiField FlowPanel noteFieldContainer;
- @UiField Popover noteFieldPopover;
- @UiField ControlLabel controlLabel;
- @UiField Controls controls;
- @UiField Icon infoIcon;
- @UiField FocusPanel focusPanelIconContainer;
- @UiField ControlGroup metafieldControlGroup;
-
- // private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
-
- // the element that holds the value (it could be a checkbox, textbox or listbox, textarea, calendar, two calendars, more calendars)
- private Widget holder;
-
- // the field this object represents
- private MetadataFieldWrapper field;
-
- // the dialog box for this metadata
- private GcubeDialogExtended dialog;
-
- // range list
- private List rangesList = new ArrayList();
-
- private List
- The URL of the resource you are
- publishing (only HTTPS URLs are allowed). If your resource is a
+
+ Select from Workspace
+
+ The URL of the resource you are
+ publishing (only HTTPS
+ URLs are allowed). If your resource is a
file that you own on your
desktop, please upload that file to your
workspace and generate a
@@ -108,7 +118,7 @@
Add
+ type="PRIMARY">Publish
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java
index 33e1ecc..f77cd8d 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.java
@@ -1,20 +1,26 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
+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.client.events.ReloadDatasetPageEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
import com.github.gwtbootstrap.client.ui.Accordion;
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.Paragraph;
+import com.github.gwtbootstrap.client.ui.Tab;
+import com.github.gwtbootstrap.client.ui.constants.AlertType;
+import com.github.gwtbootstrap.client.ui.constants.IconPosition;
+import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -23,48 +29,83 @@ 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.FlexTable;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTML;
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)
+ * The Class AddedResourcesSummary.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Feb 13, 2024
*/
-public class AddedResourcesSummary extends Composite{
+public class AddedResourcesSummary extends Composite {
- private static AddedResourcesSummaryUiBinder uiBinder = GWT
- .create(AddedResourcesSummaryUiBinder.class);
+ private static AddedResourcesSummaryUiBinder uiBinder = GWT.create(AddedResourcesSummaryUiBinder.class);
- interface AddedResourcesSummaryUiBinder extends
- UiBinder {
+ /**
+ * The Interface AddedResourcesSummaryUiBinder.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Feb 13, 2024
+ */
+ interface AddedResourcesSummaryUiBinder extends UiBinder {
}
- //Create a remote service proxy to talk to the server-side ckan service.
- private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
-
// Event bus
private HandlerManager eventBus;
// list of added resources (beans)
- List addedResources;
+ private List addedResources;
- @UiField VerticalPanel addResourcesPanel;
+ private LinkedHashMap mapAddedResources = new LinkedHashMap();
- public AddedResourcesSummary(HandlerManager eventBus) {
+ @UiField
+ VerticalPanel addResourcesPanel;
+
+ @UiField
+ Alert alertMessage;
+
+ @UiField
+ Alert alertNoResource;
+
+ private FlowPanel alertPanel = new FlowPanel();
+
+ private Tab tabAddedResources;
+
+ private IconType addedResourcesIcons;
+
+ /**
+ * Instantiates a new added resources summary.
+ *
+ * @param eventBus the event bus
+ */
+ public AddedResourcesSummary(HandlerManager eventBus, Tab tabAddedResources, IconType addedResourcesIcons) {
initWidget(uiBinder.createAndBindUi(this));
-
- // save bus
+ this.tabAddedResources = tabAddedResources;
+ this.addedResourcesIcons = addedResourcesIcons;
this.eventBus = eventBus;
+ alertMessage.setType(AlertType.ERROR);
+ alertMessage.setClose(true);
+ alertMessage.add(alertPanel);
+
+ alertNoResource.setType(AlertType.WARNING);
+ alertNoResource.setClose(false);
+ alertNoResource.setText("No Resources");
+ checkNoResources();
// bind on add resource event
bind();
-
// init list
addedResources = new ArrayList();
}
/**
- * Bind on add/delete resource event
+ * Bind on add/delete resource event.
*/
private void bind() {
@@ -73,45 +114,65 @@ public class AddedResourcesSummary extends Composite{
@Override
public void onAddedResource(AddResourceEvent addResourceEvent) {
+ GWT.log("Added resource event: " + addResourceEvent);
+ tabAddedResources.setIcon(addedResourcesIcons);
+ tabAddedResources.setIconPosition(IconPosition.RIGHT);
// get the resource
- final ResourceElementBean justAddedResource = addResourceEvent.getResource();
+ final ResourceElementBean addedResourceBean = addResourceEvent.getResource();
// Build an accordion to show resource info
- Accordion accordion = new Accordion();
+ final Accordion accordion = new Accordion();
AccordionGroup accordionGroup = new AccordionGroup();
- accordionGroup.setHeading("- " + justAddedResource.getName());
+ accordionGroup.setHeading("* " + addedResourceBean.getName());
+ accordionGroup.getHeading().addStyleName("accordion-resource-added");
accordion.add(accordionGroup);
+ FlexTable resourceTable = new FlexTable();
+ resourceTable.addStyleName("resource-table");
+
// 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());
+ // HTML htmlURL = new HTML();
+ if (addedResourceBean.getUrl() != null) {
+// htmlURL.setHTML(
+// "URL: " + addedResourceBean.getUrl() + "");
+ resourceTable.setWidget(0, 0, new HTML("URL"));
+ resourceTable.setWidget(0, 1, new HTML(
+ "" + addedResourceBean.getUrl() + ""));
+
+ }
+ // Paragraph pDescription = new Paragraph();
+ // pDescription.setText("Description : " + addedResourceBean.getDescription());
+
+ resourceTable.setWidget(1, 0, new HTML("Description"));
+ resourceTable.setWidget(1, 1, new HTML(addedResourceBean.getDescription()));
// button to delete the resource
- Button deleteButton = new Button();
+ final Button deleteButton = new Button();
deleteButton.setText("Delete");
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- eventBus.fireEvent(new DeleteResourceEvent(justAddedResource));
+ eventBus.fireEvent(new DeleteResourceEvent(deleteButton, addedResourceBean));
}
});
// fill accordion
- accordionGroup.add(pUrl);
- accordionGroup.add(pDescription);
+ // accordionGroup.add(htmlURL);
+ accordionGroup.add(resourceTable);
accordionGroup.add(deleteButton);
// add to the list
- addedResources.add(justAddedResource);
+ addedResources.add(addedResourceBean);
// add to the panel
addResourcesPanel.add(accordion);
+
+ mapAddedResources.put(addedResourceBean.getBeanID(), accordion);
+ checkNoResources();
}
});
@@ -119,42 +180,108 @@ public class AddedResourcesSummary extends Composite{
eventBus.addHandler(DeleteResourceEvent.TYPE, new DeleteResourceEventHandler() {
@Override
- public void onDeletedResource(DeleteResourceEvent deleteResourceEvent) {
+ public void onDeletedResource(final DeleteResourceEvent deleteResourceEvent) {
+ GWT.log("onDeletedResource resource event: " + deleteResourceEvent);
// to delete
- ResourceElementBean toDelete = deleteResourceEvent.getResource();
+ final ResourceElementBean toDelete = deleteResourceEvent.getResource();
+
+ final Button toDeleteButton = deleteResourceEvent.getDeleteButton();
+
+ toDeleteButton.setEnabled(false);
+
+ LoaderIcon loader = new LoaderIcon("Deleting resource, please wait...");
+ setAlertMessage(loader, null, AlertType.INFO, true);
// find it
- for(int i = 0; i < addedResources.size(); i++){
+ for (int i = 0; i < addedResources.size(); i++) {
+
+ if (addedResources.get(i).equals(toDelete)) {
- if(addedResources.get(i).getOriginalIdInWorkspace().equals(toDelete.getOriginalIdInWorkspace())){
-
// get the associated widget and remove it
- final Widget widget = addResourcesPanel.getWidget(i);
+ // final Widget widget = addResourcesPanel.getWidget(i);
+
+ final Accordion toDeleteAccordion = mapAddedResources.get(toDelete.getBeanID());
// remote call to remove it from the dataset
- ckanServices.deleteResourceFromDataset(toDelete, new AsyncCallback() {
+ CKanMetadataPublisher.ckanServices.deleteResourceFromDataset(toDelete,
+ new AsyncCallback() {
- @Override
- public void onSuccess(Boolean result) {
-
- if(result)
- widget.removeFromParent();
- }
+ @Override
+ public void onSuccess(Boolean result) {
+ if (result) {
+ setAlertMessage(null, "The resource described by '" + toDelete.getName()
+ + "' has been deleted!", AlertType.SUCCESS, true);
+ // remove from the list
+ addedResources.remove(toDelete);
+ addResourcesPanel.remove(toDeleteAccordion);
- @Override
- public void onFailure(Throwable caught) {
+ // Firing event to reload the dataset page
+ eventBus.fireEvent(new ReloadDatasetPageEvent(
+ deleteResourceEvent.getResource().getCkanDatasetId()));
+
+ checkNoResources();
+ } else {
+ setAlertMessage(null, "Sorry, the resource described by '"
+ + toDelete.getName() + "' cannot be deleted", AlertType.SUCCESS,
+ true);
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ toDeleteButton.setEnabled(false);
+ setAlertMessage(null, caught.getMessage(), AlertType.ERROR, true);
+ checkNoResources();
+ }
+ });
- }
- });
-
break;
}
}
-
- // remove from the list
- addedResources.remove(toDelete);
}
});
}
+
+ private void checkNoResources() {
+
+ if (addedResources != null && addedResources.size() > 0) {
+ alertNoResource.setVisible(false);
+ } else {
+ alertNoResource.setVisible(true);
+ }
+ }
+
+ /**
+ * Sets the alert message.
+ *
+ * @param loader the loader
+ * @param message the message
+ * @param type the type
+ * @param visible the visible
+ */
+ private void setAlertMessage(LoaderIcon loader, String message, AlertType type, boolean visible) {
+
+ alertPanel.clear();
+
+ alertMessage.setType(type);
+ alertMessage.setVisible(visible);
+
+ if (loader != null) {
+ alertPanel.add(loader);
+ }
+
+ if (message != null) {
+ alertPanel.add(new HTML(message));
+ }
+ }
+
+ /**
+ * Gets the event bus.
+ *
+ * @return the event bus
+ */
+ public HandlerManager getEventBus() {
+ return eventBus;
+ }
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.ui.xml
index fcce11a..c4631d1 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/AddedResourcesSummary.ui.xml
@@ -1,8 +1,16 @@
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
+
+
+
- Added Resources
-
+ Current Resources
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.java
new file mode 100644
index 0000000..1ecba44
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.java
@@ -0,0 +1,113 @@
+package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.WorkspaceItemSelectedEvent;
+import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
+import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectPanel;
+import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
+import org.gcube.portlets.widgets.wsexplorer.shared.Item;
+import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
+
+import com.github.gwtbootstrap.client.ui.Button;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+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.uibinder.client.UiHandler;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class DialogWorkspaceExplorer extends Composite {
+
+ private static DialogBoxWorkspaceUiBinder uiBinder = GWT.create(DialogBoxWorkspaceUiBinder.class);
+
+ interface DialogBoxWorkspaceUiBinder extends UiBinder {
+ }
+
+ @UiField
+ Button okButton;
+
+ @UiField
+ Button cancelButton;
+
+ @UiField
+ FlowPanel panelContainer;
+
+ private DialogBox dialogBox;
+
+ private Item selectedItem;
+
+ private HandlerManager eventBus;
+
+ public DialogWorkspaceExplorer(DialogBox dialog, HandlerManager eventBus) {
+ initWidget(uiBinder.createAndBindUi(this));
+ this.dialogBox = dialog;
+ this.eventBus = eventBus;
+
+ FilterCriteria filterCriteria = null;
+ List selectableTypes = Arrays.asList(ItemType.DOCUMENT, ItemType.EXTERNAL_IMAGE,
+ ItemType.EXTERNAL_FILE, ItemType.EXTERNAL_PDF_FILE, ItemType.EXTERNAL_URL, ItemType.REPORT_TEMPLATE,
+ ItemType.REPORT, ItemType.CSV, ItemType.MOVIE, ItemType.ZIP, ItemType.RAR, ItemType.HTML, ItemType.XML,
+ ItemType.TEXT_PLAIN, ItemType.DOCUMENT, ItemType.PRESENTATION, ItemType.SPREADSHEET, ItemType.METADATA,
+ ItemType.PDF_DOCUMENT, ItemType.IMAGE_DOCUMENT, ItemType.URL_DOCUMENT, ItemType.GCUBE_ITEM,
+ ItemType.TIME_SERIES
+
+ );
+
+ WorkspaceExplorerSelectPanel selectDialog = new WorkspaceExplorerSelectPanel("Select the file...",
+ filterCriteria, selectableTypes);
+ selectDialog.setWidth("700px");
+ selectDialog.setHeight("370px");
+
+ WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
+
+ @Override
+ public void onSelectedItem(Item item) {
+ GWT.log("onSelectedItem: " + item);
+ selectedItem = item;
+ }
+
+ @Override
+ public void onFailed(Throwable throwable) {
+ GWT.log("onFailed..");
+
+ }
+
+ @Override
+ public void onAborted() {
+ GWT.log("onAborted..");
+
+ }
+
+ @Override
+ public void onNotValidSelection() {
+ GWT.log("onNotValidSelection..");
+
+ }
+ };
+
+ selectDialog.addWorkspaceExplorerSelectNotificationListener(listener);
+
+ panelContainer.add(selectDialog);
+ }
+
+ @UiHandler("okButton")
+ void onOKClick(ClickEvent e) {
+
+ if(selectedItem!=null) {
+ eventBus.fireEvent(new WorkspaceItemSelectedEvent(selectedItem));
+ dialogBox.hide();
+ }
+ }
+
+ @UiHandler("cancelButton")
+ void onCancelClick(ClickEvent e) {
+ dialogBox.hide();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.ui.xml
new file mode 100644
index 0000000..8bf188b
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/DialogWorkspaceExplorer.ui.xml
@@ -0,0 +1,24 @@
+
+
+
+ .select_button {
+ margin: 5px;
+ float: right;
+ }
+
+ .cancel_button {
+ margin: 5px;
+ margin-left: 10px;
+ float: right;
+ }
+
+
+
+ Cancel
+ Select
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.java
new file mode 100644
index 0000000..3b7e4ab
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.java
@@ -0,0 +1,98 @@
+package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
+
+import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
+
+import com.github.gwtbootstrap.client.ui.Tab;
+import com.github.gwtbootstrap.client.ui.TabPanel;
+import com.github.gwtbootstrap.client.ui.constants.IconType;
+import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+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.ui.Composite;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class ManageResources extends Composite {
+
+ private static ManageResourcesUiBinder uiBinder = GWT.create(ManageResourcesUiBinder.class);
+
+ interface ManageResourcesUiBinder extends UiBinder {
+ }
+
+ @UiField
+ Tab addResources;
+
+ @UiField
+ Tab addedResources;
+
+ @UiField
+ TabPanel tabPanel;
+
+ @UiField
+ HTMLPanel manageResourceTitle;
+
+ @UiField
+ HTML manageResourceSubTitle;
+
+ private AddedResourcesSummary addedResourcesSummary;
+
+ private AddResourceToDataset addResourceForm;
+
+ private HandlerManager eventBus;
+
+ private IconType addedResourcesIcon = IconType.CIRCLE;
+
+ public ManageResources(HandlerManager eventBus, final DatasetBean theDatasetBean, String datasetUrl) {
+ initWidget(uiBinder.createAndBindUi(this));
+ this.eventBus = eventBus;
+
+ manageResourceSubTitle.setText(" "+theDatasetBean.getTitle());
+
+ addResourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
+ theDatasetBean.getSelectedOrganization(), datasetUrl);
+
+ addedResourcesSummary = new AddedResourcesSummary(eventBus, addedResources, addedResourcesIcon);
+
+ // tab for the form
+ addResources.add(addResourceForm);
+ addedResources.add(addedResourcesSummary);
+
+ bind();
+
+ tabPanel.setTabPosition(Tabs.ABOVE.name());
+ tabPanel.selectTab(0);
+
+ Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ tabPanel.selectTab(0);
+ }
+ });
+ }
+
+ private void bind() {
+
+ addedResources.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ addedResources.setIcon(null);
+ //addedResources.removeStyle(addedResourcesIcon);
+
+ }
+ });
+ }
+
+ public HandlerManager getEventBus() {
+ return eventBus;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.ui.xml
new file mode 100644
index 0000000..7f222b4
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/resources/ManageResources.ui.xml
@@ -0,0 +1,35 @@
+
+
+
+ .important {
+ font-weight: bold;
+ }
+
+ .manage_resource_title {
+ font-size: 16px;
+ font-weight: bold;
+ margin: 10px;
+ }
+
+ .manage_resource_subtitle {
+ font-size: 16px;
+ color: gray;
+ display: inline;
+ }
+
+
+
+ Manage Resources of
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.java
deleted file mode 100644
index 8fcc5ec..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.java
+++ /dev/null
@@ -1,279 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.tags;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
-
-import com.github.gwtbootstrap.client.ui.ControlGroup;
-import com.github.gwtbootstrap.client.ui.Icon;
-import com.github.gwtbootstrap.client.ui.ListBox;
-import com.github.gwtbootstrap.client.ui.Popover;
-import com.github.gwtbootstrap.client.ui.TextBox;
-import com.github.gwtbootstrap.client.ui.base.ListItem;
-import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
-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.dom.client.KeyCodes;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.uibinder.client.UiHandler;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.FocusPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * Panel for tags.
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class TagsPanel extends Composite{
-
- private static TagsPanelUiBinder uiBinder = GWT
- .create(TagsPanelUiBinder.class);
-
- interface TagsPanelUiBinder extends UiBinder {
- }
-
- @UiField TextBox tagsEnterTextBox;
- @UiField FlowPanel tagsPanel;
- @UiField Icon infoIconTags;
- @UiField FocusPanel focusPanelTags;
- @UiField Popover popoverTags;
- @UiField ControlGroup tagsInsertGroup;
- @UiField ListBox tagsEnterListBox;
-
- // regular expression for tags
- private static final String REGEX_TAG = "^[a-zA-Z0-9._-]*$";
-
- // tags list
- private List tagsList = new ArrayList();
-
- // vocabulary
- private List vocabulary;
-
- public TagsPanel() {
- initWidget(uiBinder.createAndBindUi(this));
- tagsEnterListBox.setVisible(false);
- tagsList.clear();
- tagsPanel.clear();
- }
-
-
- /**
- * Since we have a controlled vocabulary, we swap to a listbox with multiple selection
- * @param vocabularyTags
- */
- public void setVocabulary(List vocabularyTags) {
-
- GWT.log("Vocabulary of tags is " + vocabularyTags);
-
- if(vocabularyTags == null || vocabularyTags.isEmpty()){
- vocabulary = null;
- tagsEnterListBox.setVisible(false);
- tagsPanel.setVisible(true);
- tagsEnterTextBox.setVisible(true);
- }else{
- vocabulary = vocabularyTags;
- tagsEnterListBox.clear();
- tagsPanel.clear();
- tagsList.clear();
- for (String vocabularyTag : vocabularyTags) {
- tagsEnterListBox.addItem(vocabularyTag, vocabularyTag);
- }
- tagsPanel.setVisible(false);
- tagsEnterTextBox.setVisible(false);
- tagsEnterListBox.setVisible(true);
- }
- }
-
- /**
- * Prepare icons
- * @param popupOpenedIds
- */
- public void prepareIcon(List popupOpenedIds) {
- InfoIconsLabels.preparePopupPanelAndPopover(
- InfoIconsLabels.TAGS_INFO_ID_POPUP,
- InfoIconsLabels.TAGS_INFO_TEXT,
- InfoIconsLabels.TAGS_INFO_CAPTION,
- infoIconTags,
- popoverTags,
- focusPanelTags,
- popupOpenedIds
- );
- }
-
- @UiHandler("tagsEnterTextBox")
- void onAddTag(KeyDownEvent event){
-
- if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
- if (!tagsEnterTextBox.getValue().trim().isEmpty()) {
-
- addTagElement(tagsEnterTextBox);
-
- }
- }
- }
-
- /**
- * Add the tag as an element (inserted by the user)
- */
- private void addTagElement(TextBox itemBox){
-
- if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
-
- if(tagsList.contains(itemBox.getValue().trim())){
- itemBox.setValue("");
- return;
- }
-
- // ckan accepts only alphanumeric values
- String[] subTags = itemBox.getValue().trim().split(" ");
- if(subTags.length == 1){
- if(!subTags[0].matches(REGEX_TAG))
- return;
- if(subTags[0].length() <= 1)
- return;
- }else{
- for (int i = 0; i < subTags.length; i++) {
- String subTag = subTags[i];
- if(!subTag.matches(REGEX_TAG))
- return;
- }
- }
-
- final String value = itemBox.getValue().trim();
- final ListItem displayItem = new ListItem();
- displayItem.setStyleName("tag-style");
- Span tagText = new Span(itemBox.getValue());
-
- Span tagRemove = new Span("x");
- tagRemove.setTitle("Remove this tag");
- tagRemove.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- removeTag(displayItem, value);
- }
- });
-
- tagRemove.setStyleName("tag-style-x");
- displayItem.add(tagText);
- displayItem.add(tagRemove);
- itemBox.setValue("");
- itemBox.setFocus(true);
- tagsPanel.add(displayItem);
- tagsList.add(value);
- }
- }
-
- /**
- * Add the tag as an element (when publishing from workspace)
- */
- public void addTagElement(final String tag){
-
- if(tagsList.contains(tag))
- return;
-
- // ckan accepts only alphanumeric values
- String[] subTags = tag.trim().split(" ");
- if(subTags.length == 1){
- if(!subTags[0].matches(REGEX_TAG))
- return;
- if(subTags[0].length() <= 1)
- return;
- }else{
- for (int i = 0; i < subTags.length; i++) {
- String subTag = subTags[i];
- if(!subTag.matches(REGEX_TAG))
- return;
- }
- }
-
- final ListItem displayItem = new ListItem();
- displayItem.setStyleName("tag-style");
- Span p = new Span(tag);
-
- Span span = new Span("x");
- span.setTitle("Remove this tag");
- span.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- removeTag(displayItem, tag);
- }
- });
-
- span.setStyleName("tag-style-x");
- displayItem.add(p);
- displayItem.add(span);
- tagsPanel.add(displayItem);
- tagsList.add(tag);
- }
-
- /**
- * Remove a tag from the list
- * @param displayItem
- */
- private void removeTag(ListItem displayItem, String value) {
-
- tagsList.remove(value.trim());
- tagsPanel.remove(displayItem);
-
- }
-
- /**
- * Remove all inserted tags
- */
- public void removeTags(){
-
- tagsList.clear();
- tagsPanel.clear();
-
- }
-
- /**
- * Return the tag list
- * @return
- */
- public List getTags() {
-
- if(vocabulary == null){
- return tagsList;
- }else{
-
- List selected = new ArrayList();
- for(int i = 0; i < tagsEnterListBox.getItemCount(); i++){
- if(tagsEnterListBox.isItemSelected(i))
- selected.add(tagsEnterListBox.getItemText(i));
- }
- return selected;
- }
-
- }
-
- /**
- * Freeze tags
- */
- public void freeze() {
- tagsEnterTextBox.setEnabled(false);
- tagsEnterListBox.setEnabled(false);
- for(int i = 0; i < tagsList.size(); i++){
-
- // get tag widget
- ListItem tagWidget = (ListItem)tagsPanel.getWidget(i);
-
- // get the "x" span
- tagWidget.getWidget(1).removeFromParent();
-
- }
- }
-
- /**
- * Set the tag group panel type
- * @param none
- */
- public void setGroupPanelType(ControlGroupType type) {
- tagsInsertGroup.setType(type);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.ui.xml
deleted file mode 100644
index c304907..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/tags/TagsPanel.ui.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
- .tagsPanelStyle {
- display: inline-block;
- }
-
-
-
-
- *
- Tag:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java
deleted file mode 100644
index cdb67e7..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/GcubeDialogExtended.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
-
-import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.ResourceInfoForm;
-
-import com.github.gwtbootstrap.client.ui.Paragraph;
-import com.google.gwt.core.shared.GWT;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.EventTarget;
-import com.google.gwt.dom.client.Style.Cursor;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.DoubleClickEvent;
-import com.google.gwt.event.dom.client.DoubleClickHandler;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * Extended version of the GcubeDialog with close symbol on the caption
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class GcubeDialogExtended extends GCubeDialog {
-
- /**
- * For simple information
- * @param captionText
- * @param text
- */
- public GcubeDialogExtended(String captionText, String text){
-
- // add custom style
- addStyleName("metadata-popup-panel");
-
- // create an anchor to close the dialogbox
- final Anchor closeAnchor = new Anchor("x");
- closeAnchor.setTitle("Close");
-
- // create a panel that will be put into the caption
- FlexTable captionLayoutTable = new FlexTable();
- captionLayoutTable.setText(0, 0, captionText);
- captionLayoutTable.setWidget(0, 3, closeAnchor);
- captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
- captionLayoutTable.setWidth("100%");
- HTML caption = (HTML) getCaption();
- caption.getElement().getStyle().setCursor(Cursor.MOVE);
- caption.getElement().appendChild(captionLayoutTable.getElement());
- caption.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- // get the event
- EventTarget target = event.getNativeEvent().getEventTarget();
- Element targetElement = (Element) target.cast();
-
- // fire the event to the anchor
- if (targetElement == closeAnchor.getElement()) {
- closeAnchor.fireEvent(event);
- }
- }
- });
- closeAnchor.addClickHandler(new ClickHandler() {
-
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
- add(new Paragraph(text));
- }
-
- /**
- * For simple information
- * @param captionText
- * @param text
- */
- public GcubeDialogExtended(final ResourceInfoForm form){
-
- // add custom style
- addStyleName("metadata-popup-panel");
-
- // create an anchor to close the dialogbox
- final Anchor closeAnchor = new Anchor("x");
- closeAnchor.setTitle("Close");
- closeAnchor.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- hide();
- }
- });
-
- // create a panel that will be put into the caption
- FlexTable captionLayoutTable = new FlexTable();
- captionLayoutTable.setText(0, 0, "About Resource");
- captionLayoutTable.setWidget(0, 3, closeAnchor);
- captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_RIGHT);
- captionLayoutTable.setWidth("100%");
- HTML caption = (HTML) getCaption();
- caption.getElement().getStyle().setCursor(Cursor.MOVE);
- caption.getElement().appendChild(captionLayoutTable.getElement());
- caption.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- EventTarget target = event.getNativeEvent().getEventTarget();
- Element targetElement = (Element) target.cast();
- if (targetElement == closeAnchor.getElement()) {
- closeAnchor.fireEvent(event);
- }
- }
- });
-
- setWidget(form);
- Widget widget = getWidget();
-
- ClickHandler click = new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- EventTarget target = event.getNativeEvent().getEventTarget();
- Element targetElement = (Element) target.cast();
- GWT.log("Target elem is " + targetElement);
- if (targetElement == form.resourceDescription.getElement()) {
- GWT.log("Fired click");
- form.resourceDescription.fireEvent(event);
- }else if (targetElement == form.resourceName.getElement()) {
- GWT.log("Fired click");
- form.resourceName.fireEvent(event);
- }else if(targetElement == form.getElement()){
- form.fireEvent(event);
- }
- }
- };
- widget.addDomHandler(click, ClickEvent.getType());
-
- widget.addDomHandler(new DoubleClickHandler() {
-
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- EventTarget target = event.getNativeEvent().getEventTarget();
- Element targetElement = (Element) target.cast();
- GWT.log("Target elem is " + targetElement);
- if (targetElement == form.resourceDescription.getElement()) {
- GWT.log("Fired click");
- form.resourceDescription.fireEvent(event);
- }else if (targetElement == form.resourceName.getElement()) {
- GWT.log("Fired click");
- form.resourceName.fireEvent(event);
- }else if(targetElement == form.getElement()){
- form.fireEvent(event);
- }
- }
- }, DoubleClickEvent.getType());
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
index ebe779f..2151d85 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/InfoIconsLabels.java
@@ -2,6 +2,8 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
import java.util.List;
+import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.GcubeDialogExtended;
+
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.Popover;
import com.google.gwt.core.client.GWT;
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/LoaderIcon.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/LoaderIcon.java
deleted file mode 100644
index fd0ad9c..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/utils/LoaderIcon.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
-
-
-import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.icons.Images;
-
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-
-/**
- * The Class LoaderIcon.
- *
- * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
- * Feb 19, 2015
- */
-public class LoaderIcon extends HorizontalPanel{
-
-
- private Image imgLoading = new Image(Images.ICONS.loading());
- private HTML txtLoading = new HTML("");
-
- /**
- * Instantiates a new loader icon.
- *
- * @param txtHTML the txt html
- */
- public LoaderIcon(String txtHTML) {
- this();
- setText(txtHTML);
- }
-
- /**
- * Instantiates a new loader icon.
- */
- public LoaderIcon() {
- setStyleName("marginTop20");
- add(imgLoading);
- add(txtLoading);
- }
-
- /**
- * Sets the text.
- *
- * @param txtHTML the new text
- */
- public void setText(String txtHTML){
- txtLoading.setHTML(""+txtHTML+"");
- }
-
- /**
- * Show.
- *
- * @param bool the bool
- */
- public void show(boolean bool){
- this.setVisible(bool);
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.java
index 3e35839..0a1788f 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.java
@@ -16,7 +16,6 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -62,7 +61,7 @@ public class ResourceInfoForm extends Composite{
resourcePath.setText(resource.getFullPath());
closeButton.getElement().getStyle().setFloat(Float.RIGHT);
closeButton.setIcon(IconType.REMOVE_CIRCLE);
- commandPanel.setCellHorizontalAlignment(updateResourceButton, HasHorizontalAlignment.ALIGN_RIGHT);
+ //commandPanel.setCellHorizontalAlignment(updateResourceButton, HasHorizontalAlignment.ALIGN_RIGHT);
commandPanel.getElement().getStyle().setMarginTop(10, Unit.PX);
updateResourceButton.addClickHandler(new ClickHandler() {
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.ui.xml
index 98c045c..588c3e8 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/ResourceInfoForm.ui.xml
@@ -14,8 +14,8 @@
padding: 5px;
border: 1px solid #bbb;
border-radius: 5px;
- height: 320px;
- width: 700px;
+ height: 300px;
+ /*width: 700px;*/
margin-bottom: 20px;
}
@@ -32,11 +32,11 @@
}
.custom-input input {
- width: 350px;
+ width: 80%;
}
.custom-input textarea {
- width: 355px;
+ width: 81%;
}
@@ -45,7 +45,7 @@
Resource Information
+ title="Close details" visible="false">
- Update
+ Update
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml
index 54fb234..3c0b93e 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectResourceByWEMainPanel.ui.xml
@@ -40,14 +40,14 @@
Select
+ type="INFO" addStyleNames="{style.margin-top-10}">Select
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.java
index 3835c5a..2ec9915 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.java
@@ -7,9 +7,12 @@ import com.github.gwtbootstrap.client.ui.constants.ButtonType;
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.dom.client.MouseDownEvent;
+import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
@@ -19,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
- * Mar 12, 2021
+ * Mar 12, 2021
*/
public class SelectedResourceWidget extends Composite {
@@ -31,7 +34,7 @@ public class SelectedResourceWidget extends Composite {
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
- * Mar 12, 2021
+ * Mar 12, 2021
*/
interface SelectedResourceWidgetUiBinder extends UiBinder {
}
@@ -54,14 +57,22 @@ public class SelectedResourceWidget extends Composite {
/** The field name. */
@UiField
Label fieldName;
-
+
@UiField
Label fieldDescription;
-
+
/** The edit panel. */
@UiField
HTMLPanel editPanel;
+ @UiField
+ FlowPanel resourcePanel;
+
+ @UiField
+ FlowPanel selectedResourcesPanelTitle;
+
+ private boolean selectetResource = false;
+
/** The resource bean. */
private ResourceElementBean resourceBean;
@@ -79,46 +90,66 @@ public class SelectedResourceWidget extends Composite {
addHandlers();
}
-
+
private void updateFields() {
this.fieldName.setText(resourceBean.getEditableName());
-
- if(resourceBean.getDescription()!=null && !resourceBean.getDescription().isEmpty()) {
+
+ if (resourceBean.getDescription() != null && !resourceBean.getDescription().isEmpty()) {
this.fieldDescription.setVisible(true);
this.fieldDescription.setText(resourceBean.getDescription());
- }else
+ } else
this.fieldDescription.setVisible(false);
}
-
+
/**
* Adds the handlers.
*/
private void addHandlers() {
-
+
buttonEdit.addClickHandler(new ClickHandler() {
-
+
@Override
public void onClick(ClickEvent event) {
- editPanel.clear();
- ResourceInfoForm resourceInformationInfo = new ResourceInfoForm(resourceBean) {
- protected void onUnload() {
- super.onUnload();
- updateFields();
- };
- };
- editPanel.add(resourceInformationInfo);
-
+ manageEditOpenResource();
+
}
});
-
+
buttonDelete.addClickHandler(new ClickHandler() {
-
+
@Override
public void onClick(ClickEvent event) {
SelectResourceByWEMainPanel.eventBus.fireEvent(new RemovePublishingResourceEvent(resourceBean));
}
});
-
+
+ MouseDownHandler handler = new MouseDownHandler() {
+
+ @Override
+ public void onMouseDown(MouseDownEvent event) {
+ manageEditOpenResource();
+
+ }
+ };
+
+ selectedResourcesPanelTitle.addDomHandler(handler, MouseDownEvent.getType());
+ }
+
+ private void manageEditOpenResource() {
+
+ editPanel.clear();
+ if (selectetResource) {
+ selectetResource = false;
+ } else {
+ ResourceInfoForm resourceInformationInfo = new ResourceInfoForm(resourceBean) {
+ protected void onUnload() {
+ super.onUnload();
+ updateFields();
+ };
+ };
+ editPanel.add(resourceInformationInfo);
+ selectetResource = true;
+ }
}
/**
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.ui.xml
index 009dec0..bcb0df3 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.ui.xml
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/workspace/SelectedResourceWidget.ui.xml
@@ -7,14 +7,6 @@
font-weight: bold;
}
- .selected-resources {
-
- }
-
- .selected-resources td {
- vertical-align: middle !important;
- }
-
.margin-bottom-8 {
margin-bottom: 8px;
}
@@ -26,7 +18,7 @@
}
.title-text {
- font-weight: bold;
+ /*font-weight: bold;*/
font-size: 14px;
display: inline;
vertical-align: middle;
@@ -41,14 +33,18 @@
}
-
+
-
+
+
+
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/public/CKanMetadataPublisher.css b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/public/CKanMetadataPublisher.css
index 9180b9d..be2e4a6 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/public/CKanMetadataPublisher.css
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/public/CKanMetadataPublisher.css
@@ -62,6 +62,24 @@
padding: 4px 4px !important;
}
+.selected-resources-ws {
+ background-color: #f1f3f9 !important;
+ padding: 5px;
+ box-shadow: 0px 3px #888;
+ border-radius: 3px;
+}
+
+.selected-resources-ws td {
+ vertical-align: middle !important;
+}
+
+.selected-resources-ws-title {
+ display: inline;
+}
+.selected-resources-ws-title:hover {
+ cursor: pointer;
+}
+
/* WIZARD-CREATOR CLASSES */
.wizard-creator {
width: 100%;
@@ -133,3 +151,40 @@
.wizard-creator .current:after {
border-left-color: #007ACC;
}
+
+.accordion-resource-added {
+ background-color: #f1f3f9 !important;
+ padding: 2px;
+ box-shadow: 3px 3px #888;
+ border-radius: 3px;
+}
+
+.resource-table {
+ margin: 5px;
+ margin-bottom: 10px;
+ font-size: 14px;
+ max-width: 98%;
+ word-break: break-word;
+}
+
+.resource-table td {
+ padding: 3px;
+}
+
+.resource-table td:first-child {
+ color: gray;
+ width: 75px;
+}
+
+#selectWorkspaceDialog button {
+ width: 60px !important;
+ height: 22px !important;
+ padding: 0px !important;
+ margin: 0px !important;
+}
+
+#the_catalogue_nav_bar .btn.disabled {
+ /*background-color: #E6E6E6;*/
+ text-decoration: none !important;
+ color: #333333 !important;
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
index b2f1658..9eb5e71 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/CKANPublisherServicesImpl.java
@@ -5,11 +5,14 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import javax.servlet.http.HttpSession;
@@ -22,8 +25,14 @@ import org.gcube.datacatalogue.utillibrary.server.utils.CatalogueUtilMethods;
import org.gcube.datacatalogue.utillibrary.server.utils.SessionCatalogueAttributes;
import org.gcube.datacatalogue.utillibrary.shared.ResourceBean;
import org.gcube.datacatalogue.utillibrary.shared.RolesCkanGroupOrOrg;
+import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanGroup;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanLicense;
+import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanOrganization;
+import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
+import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanTag;
+import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
+import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.CatalogueRoleManager;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.DiscoverTagsList;
@@ -31,10 +40,12 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.GenericUt
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.MetadataDiscovery;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataProfileBeanForUpdate;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.licenses.LicenseBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
@@ -63,10 +74,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// private static final org.slf4j.Logger logger =
// LoggerFactory.getLogger(CKANPublisherServicesImpl.class);
private static final Logger logger = LoggerFactory.getLogger(CKANPublisherServicesImpl.class);
- private static final String ITEM_URL_FIELD = "Item URL";
- private static final String SYS_TYPE = "system:type";
- private static final String TAGS_VOCABULARY_KEY = "TAGS_VOCABULARY";
+ public static final String TAGS_VOCABULARY_KEY = "TAGS_VOCABULARY";
+
+ public static final String ITEM_URL_FIELD = "Item URL";
+ public static final String RELATED_IDENTIFIER_ZENODO = "relatedIdentifier:Zenodo";
+ public static final String SYSTEM_KEY_PREFIX = "system:";
+ //These fiels are not upgradable via Edit Facility. They are not returned to the client
+ public static final List NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES = Arrays.asList(ITEM_URL_FIELD, SYSTEM_KEY_PREFIX, RELATED_IDENTIFIER_ZENODO);
+
+ public static final String SYS_TYPE = SYSTEM_KEY_PREFIX + "type";
// map
private ConcurrentHashMap mapOrganizationScope = new ConcurrentHashMap();
@@ -196,13 +213,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String keyPerScope = CatalogueUtilMethods
.concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_LICENSES_KEY, scope);
-// if(!isWithinPortal()){
-// logger.info("DEV MODE returning funny licenses...");
-// List licenses = new ArrayList();
-// licenses.add(new LicenseBean("AFL-3.0", "https://opensource.org/licenses/AFL-3.0"));
-// return licenses;
-// }
-
List licensesBean = null;
if (httpSession.getAttribute(keyPerScope) != null) {
licensesBean = (List) httpSession.getAttribute(keyPerScope);
@@ -229,19 +239,19 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
/**
- * Gets the dataset bean.
+ * Builds the partial dataset bean.
*
* @param folderId the folder id
* @return the dataset bean
* @throws Exception the exception
*/
@Override
- public DatasetBean getDatasetBean(String folderId) throws Exception {
+ public DatasetBean buildPartialDatasetBean(String folderId) throws Exception {
DatasetBean bean = null;
String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
- logger.info("DatasetBean request for " + folderId + " and " + userName);
+ logger.info("DatasetBean request for folderId " + folderId + " and " + userName);
if (isWithinPortal()) {
try {
@@ -259,7 +269,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.debug("Building bean");
bean = new DatasetBean();
- bean.setId(folderId);
+ bean.setWSFolderId(folderId);
bean.setOwnerIdentifier(userName);
bean.setVersion(1);
bean.setAuthorName(userOwner.getFirstName());
@@ -320,6 +330,176 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return bean;
}
+ /**
+ * Gets the basic dataset bean.
+ *
+ * @param datasetIdOrName the dataset id or name
+ * @return the basic dataset bean
+ * @throws Exception the exception
+ */
+ @Override
+ public DatasetBean getBasicDatasetBean(String datasetIdOrName) throws Exception {
+ logger.debug("getBasicDatasetBean called for {}", datasetIdOrName);
+
+ DatasetBean bean = null;
+ String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
+
+ logger.info("DatasetBeanForUpdate request for " + datasetIdOrName + " and " + userName);
+
+ String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+
+ DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
+
+ CkanDataset dataset = utils.getDataset(datasetIdOrName, userName);
+
+ if (dataset == null) {
+ // the user cannot read the item, so he/she is not the owner nor the admin
+ throw new Exception("Dataset with id " + datasetIdOrName + " not found for user " + userName);
+ }
+
+ logger.debug("Building bean");
+ bean = new DatasetBean();
+
+ // Basic info
+ bean.setId(datasetIdOrName);
+ bean.setCkanName(dataset.getName());
+ bean.setTitle(dataset.getTitle());
+ bean.setDescription(dataset.getNotes());
+ bean.setLicense(dataset.getLicenseTitle());
+ bean.setVisibile(dataset.isPriv());
+
+ long version = 1;
+ try {
+ version = Long.parseLong(dataset.getVersion());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ bean.setVersion(version);
+
+ // Other basic info
+ bean.setOwnerIdentifier(dataset.getCreatorUserId());
+ bean.setAuthorFullName(dataset.getAuthor());
+ bean.setAuthorEmail(dataset.getAuthorEmail());
+ bean.setMaintainer(dataset.getMaintainer());
+ bean.setMaintainerEmail(dataset.getMaintainerEmail());
+
+ // Organization
+ CkanOrganization ckanOrganization = dataset.getOrganization();
+ final OrganizationBean ckanOrganizationBean = new OrganizationBean(ckanOrganization.getTitle(),
+ ckanOrganization.getName(), true);
+ bean.setOrganizationList(Arrays.asList(ckanOrganizationBean));
+ bean.setSelectedOrganization(ckanOrganization.getName());
+
+ logger.debug("Returning minimal bean " + bean);
+ logger.info("Returning minimal bean for dataset title: {}" + bean.getTitle());
+ return bean;
+ }
+
+ /**
+ * Gets the dataset bean for update.
+ *
+ * @param datasetIdOrName the dataset id or name
+ * @return the dataset bean for update
+ * @throws Exception the exception
+ */
+ @Override
+ public DatasetBean getDatasetBeanForUpdate(String datasetIdOrName) throws Exception {
+
+ DatasetBean bean = null;
+ String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
+
+ logger.info("DatasetBeanForUpdate request for " + datasetIdOrName + " and " + userName);
+
+ String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+
+ DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
+
+ CkanDataset dataset = utils.getDataset(datasetIdOrName, userName);
+
+ if (dataset == null) {
+ // the user cannot read the item, so he/she is not the owner nor the admin
+ throw new Exception("Dataset with id " + datasetIdOrName + " not found for user " + userName);
+ }
+
+ logger.debug("Building bean");
+ bean = new DatasetBean();
+
+ bean.setId(datasetIdOrName);
+ bean.setCkanName(dataset.getName());
+ bean.setTitle(dataset.getTitle());
+ bean.setDescription(dataset.getNotes());
+ bean.setLicense(dataset.getLicenseTitle());
+ bean.setVisibile(dataset.isPriv());
+
+ long version = 1;
+ try {
+ version = Long.parseLong(dataset.getVersion());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ bean.setVersion(version);
+
+ bean.setOwnerIdentifier(dataset.getCreatorUserId());
+
+ bean.setAuthorFullName(dataset.getAuthor());
+ bean.setAuthorEmail(dataset.getAuthorEmail());
+
+ bean.setMaintainer(dataset.getMaintainer());
+ bean.setMaintainerEmail(dataset.getMaintainerEmail());
+
+ CkanOrganization ckanOrganization = dataset.getOrganization();
+
+ // UPDATED By Francesco
+ final OrganizationBean ckanOrganizationBean = new OrganizationBean(ckanOrganization.getTitle(),
+ ckanOrganization.getName(), true);
+ bean.setOrganizationList(Arrays.asList(ckanOrganizationBean));
+
+ List listDatasetTags = dataset.getTags();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("List tags from CKAN are: ");
+ for (CkanTag ckanTag : listDatasetTags) {
+ // logger.debug("ckanTag: " + ckanTag.getDisplayName());
+ logger.debug("ckanTag: " + ckanTag.getName());
+ }
+ }
+
+ // selected tags into Dataset
+ if (listDatasetTags != null) {
+ List listTags = dataset.getTags().stream().map(t -> t.getName()).collect(Collectors.toList());
+ logger.info("setTags: {}", listTags);
+ bean.setTags(listTags);
+ }
+
+ // Vocabulary Tags from Generi Resources
+ bean.setTagsVocabulary(discoverTagsVocabulary(scopePerCurrentUrl));
+
+ // Settings the CKAN resources
+ List resources = dataset.getResources();
+ if (resources != null) {
+ List list = new ArrayList(resources.size());
+ for (CkanResource ckanResource : resources) {
+ ResourceElementBean reb = PublisherCatalogueConveter.toResourceElementBean(ckanResource,
+ ckanOrganizationBean.getName());
+ list.add(reb);
+ }
+ bean.setResources(list);
+ }
+
+ // Settings the dataset type
+ Map> extras = dataset.getListExtrasAsHashMap();
+ if (extras != null) {
+ List theDatasetType = extras.get(SYS_TYPE);
+ if (theDatasetType != null && theDatasetType.size() > 0) {
+ bean.setChosenType(theDatasetType.get(0));
+ }
+ }
+
+ logger.debug("Returning bean " + bean);
+ logger.info("Returning the bean for dataset title {} and type {}" + bean.getTitle(), bean.getChosenType());
+ return bean;
+ }
+
/**
* Discover from the IS the vocabulary of tags for this scope, if present.
*
@@ -367,7 +547,10 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
try {
devModeSetContexts();
- logger.info("Request for creating a dataset with these information " + toCreate);
+ logger.info("Request for creating a dataset with title: {} " + toCreate.getTitle());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dataset is: {} " + toCreate);
+ }
String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
String title = toCreate.getTitle();
String organizationNameOrId = toCreate.getSelectedOrganization();
@@ -455,16 +638,146 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
+ /**
+ * Update CKAN dataset.
+ *
+ * @param toUpdate the to create
+ * @return the dataset bean
+ * @throws Exception the exception
+ */
+ @Override
+ public DatasetBean updateCKANDataset(DatasetBean toUpdate) throws Exception {
+
+ try {
+ devModeSetContexts();
+ logger.info("Request for updating a dataset with title: {} " + toUpdate.getTitle());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Dataset is: {} " + toUpdate);
+ }
+
+ if (toUpdate.getCkanName() == null)
+ throw new Exception("Error on updating: the input parameter 'name' is null");
+
+ String userName = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
+ String title = toUpdate.getTitle();
+ String organizationNameOrId = toUpdate.getSelectedOrganization();
+ String author = toUpdate.getAuthorFullName();
+ String authorMail = toUpdate.getAuthorEmail();
+ String maintainer = toUpdate.getMaintainer();
+ String maintainerMail = toUpdate.getMaintainerEmail();
+ long version = toUpdate.getVersion();
+ String description = toUpdate.getDescription();
+ String chosenLicense = toUpdate.getLicense();
+ String licenseId = findLicenseIdByLicense(chosenLicense);
+ List listOfTags = toUpdate.getTags();
+ Map> customFields = toUpdate.getCustomFields();
+
+ // add Type for custom fields
+// if (toUpdate.getChosenType() != null) {
+// customFields.put(SYS_TYPE, Arrays.asList(toUpdate.getChosenType()));
+// }
+
+ // Reading the CKAN Dataset with extras in order to set the reserver system into
+ // update request
+ String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+ DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
+ CkanDataset currentDataset = utils.getDataset(toUpdate.getId(), userName);
+
+ Map> ckanExtras = currentDataset.getListExtrasAsHashMap();
+ Map> ckanReserverSystemExtras = getReserverdSystemFields(ckanExtras);
+ // putting all reserved system fields into customFields to update
+ customFields.putAll(ckanReserverSystemExtras);
+
+ // Settings the CKAN resources
+ List listCurrentResources = currentDataset.getResources();
+ List resources = null;
+ if (listCurrentResources != null) {
+ resources = new ArrayList(listCurrentResources.size());
+ for (CkanResource ckanResource : listCurrentResources) {
+ String orgName = null; // not required here
+ ResourceBean reb = PublisherCatalogueConveter.toResourceBean(ckanResource, orgName);
+ resources.add(reb);
+ }
+ }
+
+ boolean setPublic = toUpdate.getVisibility();
+
+ // get the list of resources and convert to ResourceBean from the Workspace
+ ResourceElementBean resourcesToAdd = toUpdate.getResourceRoot();
+ // converting to resources to be added
+ if (resourcesToAdd != null) {
+ Workspace workspace = getWorkspaceFromStorageHub();
+ resources.addAll(WorkspaceUtils.toResources(toUpdate, workspace, userName));
+ }
+
+ logger.debug("The user wants to publish in organization with name " + organizationNameOrId);
+ // String scope = getScopeFromOrgName(organizationNameOrId);
+
+ if (!isWithinPortal()) {
+ logger.debug("Should be added:");
+ for (String key : customFields.keySet()) {
+ logger.debug("Custom field with key: " + key + ", value: " + customFields.get(key));
+ }
+ }
+
+ String datasetId = utils.updateCkanDatasetMultipleCustomFields(userName, title, toUpdate.getCkanName(),
+ organizationNameOrId, author, authorMail, maintainer, maintainerMail, version, description,
+ licenseId, listOfTags, customFields, resources, setPublic, true, true);
+
+ if (datasetId != null) {
+
+ logger.info("Dataset updated!");
+ toUpdate.setId(datasetId);
+
+ // #23491 Building the go to the item to "Catalogue Portlet URL" (instead of URI
+ // Resolver URL)
+ String catalogueURL = utils.getPortletUrl();
+// logger.debug("Returning catalogueURL: "+catalogueURL);
+// logger.debug("Returning datasetId: "+datasetId);
+ toUpdate.setSource(String.format("%s?path=/dataset/%s", catalogueURL, datasetId));
+ logger.debug("Returning getSource(): " + toUpdate.getSource());
+ logger.debug("Returning dataset: " + toUpdate);
+
+ // #24744 Returning lazy object
+ toUpdate.setGroups(null);
+ toUpdate.setCustomFields(null);
+ toUpdate.setGroupsForceCreation(null);
+ toUpdate.setMetadataList(null);
+ toUpdate.setOrganizationList(null);
+
+ logger.info("Returning lazy dataset: " + toUpdate);
+
+ // createdDatasetBean.getSource();
+ // createdDatasetBean.getTitle();
+// resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(),
+// createdDatasetBean.getTitle(),
+// createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
+ return toUpdate;
+ } else {
+ logger.error("Failed to update the dataset");
+ }
+
+ } catch (Exception e) {
+ logger.error("Error while updating item ", e);
+ throw new Exception(e.getMessage());
+ }
+
+ return null;
+
+ }
+
/**
* Adds the resource to dataset.
*
- * @param resource the resource
- * @param datasetId the dataset id
+ * @param resource the resource
+ * @param organizationName the organization name
+ * @param datasetId the dataset id
* @return the resource element bean
* @throws Exception the exception
*/
@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");
devModeSetContexts();
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
@@ -479,14 +792,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// organization name in which the dataset was created
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
DataCatalogue catalogue = getCatalogue(scope);
- String resourceId = catalogue.addResourceToDataset(resourceBean, resource.getOrganizationNameDatasetParent(),
- username);
+ CkanResource theCreatedResource = catalogue.addResource(resourceBean, datasetId,
+ resource.getOrganizationNameDatasetParent(), username);
- if (resourceId != null) {
+ if (theCreatedResource != null) {
logger.info("Resource " + resource.getName() + " is now available");
- // set its id and turn it to the client
- resource.setOriginalIdInWorkspace(resourceId);
- return resource;
+
+ ResourceElementBean reb = PublisherCatalogueConveter.toResourceElementBean(theCreatedResource,
+ organizationName);
+
+ return reb;
}
logger.debug("No resource created");
@@ -511,14 +826,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String scope = getScopeFromOrgName(resource.getOrganizationNameDatasetParent());
DataCatalogue catalogue = getCatalogue(scope);
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
- deleted = catalogue.deleteResourceFromDataset(resource.getOriginalIdInWorkspace(), username);
+ deleted = catalogue.deleteResourceFromDataset(resource.getCkanResourceID(), username);
if (deleted) {
logger.info("Resource described by " + resource + " deleted");
} else
logger.error("Resource described by " + resource + " NOT deleted");
} catch (Exception e) {
- logger.error("Error while trying to delete resource described by " + resource, e);
- throw new Exception("Error while trying to delete resource." + e.getMessage());
+ String error = "Sorry, an error occurred while trying to delete resource described by "
+ + resource.getName();
+ logger.error(error, e);
+ throw new Exception(error + ". Error is: " + e.getMessage());
}
return deleted;
@@ -548,6 +865,156 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return toReturn;
}
+ /**
+ * Gets the profile for update.
+ *
+ * @param orgName the org name
+ * @param datasetType the dataset type
+ * @param datasedIdOrName the datased id or name
+ * @return the profile for update
+ * @throws Exception the exception
+ */
+ @Override
+ public MetadataProfileBeanForUpdate getProfileForUpdate(String orgName, String datasetType, String datasedIdOrName)
+ throws Exception {
+ logger.info("Called getProfileForUpdate for orgName {} and dataset type {} ", orgName, datasetType);
+ logger.debug("Requested profiles for products into orgName " + orgName);
+ List toRead = new ArrayList();
+
+ List toReturn = new ArrayList();
+ try {
+ String evaluatedScope = getScopeFromOrgName(orgName);
+ logger.debug("Evaluated scope is " + evaluatedScope);
+ toRead = MetadataDiscovery.getMetadataProfilesList(evaluatedScope, getThreadLocalRequest());
+
+ // Getting profile for datasetType, expecting only one
+ toReturn = toRead.stream().filter(tr -> tr.getType().compareTo(datasetType) == 0)
+ .collect(Collectors.toList());
+
+ } catch (Exception e) {
+ logger.error("Failed to retrieve profiles for scope coming from organization name " + orgName, e);
+ throw e;
+ }
+
+ // retrieve scope per current Portlet url
+ String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+ String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
+ DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
+ CkanDataset dataset = utils.getDataset(datasedIdOrName, username);
+
+ if (toReturn.isEmpty())
+ throw new Exception("No Profile found for dataset type: " + datasetType);
+
+ // Settings current values in the profile found
+ MetaDataProfileBean profileBean = toReturn.get(0);
+ if (logger.isTraceEnabled()) {
+ logger.trace("The source profile is: {}", profileBean);
+ logger.trace("The metadatafields into source profile are: {}", profileBean.getMetadataFields().size());
+ for (int i = 0; i < profileBean.getMetadataFields().size(); i++) {
+ MetadataFieldWrapper mw = profileBean.getMetadataFields().get(i);
+ logger.trace(i + " MetadataFieldWrapper : {}", mw);
+ }
+ }
+ Map> extras = dataset.getListExtrasAsHashMap();
+
+ Map> customFieldsMap = new HashMap>(extras);
+
+ logger.trace("Current extras are {}", extras);
+
+ List expandedListForMultipleOccurs = new ArrayList();
+
+ // Operating on the source cloned list
+ List clonedList = cloneList(profileBean.getMetadataFields());
+
+ // Creating bean to return
+ MetaDataProfileBean toReturnMetaDataProfileBean = new MetaDataProfileBean();
+ toReturnMetaDataProfileBean.setTitle(profileBean.getTitle());
+ toReturnMetaDataProfileBean.setType(profileBean.getType());
+ toReturnMetaDataProfileBean.setCategories(profileBean.getCategories());
+
+ for (MetadataFieldWrapper metadataFieldWrapper : clonedList) {
+ String fieldName = metadataFieldWrapper.getFieldNameFromCategory();
+ // removing profile key from the map
+
+ logger.trace("Searching field name '{}' in the profile", fieldName);
+ List currValuesOfExtraField = extras.get(fieldName);
+ logger.trace("Current value found is '{}' for field name '{}'", currValuesOfExtraField, fieldName);
+
+ // the profile field is set as extra field (it is not null), so going to set the
+ // current values
+ if (currValuesOfExtraField != null && !currValuesOfExtraField.isEmpty()) {
+
+ customFieldsMap.remove(fieldName);
+
+ if (currValuesOfExtraField.size() == 1) {
+ metadataFieldWrapper.setCurrentValues(currValuesOfExtraField.stream().toArray(String[]::new));
+ } else {
+ // Duplicating the fields with multiple occurrences
+ int dataSize = currValuesOfExtraField.size();
+ for (int j = 0; j < dataSize; j++) {
+ List cloned = cloneList(Arrays.asList(metadataFieldWrapper));
+ MetadataFieldWrapper mfw = cloned.get(0);
+
+ // Duplicating MetadataFieldWrapper for data list with isMultiSelection==false
+ if (!mfw.isMultiSelection()) {
+ mfw.setCurrentValues(currValuesOfExtraField.get(j) + "");
+ // In case of array, from the first to second-last one, repeated field is set to
+ // 'false'
+ // These properties are managed properly with the
+ // last one field
+ if (j < dataSize - 1) {
+ mfw.setMandatory(false);
+ mfw.setMaxOccurs(1);
+ }
+ expandedListForMultipleOccurs.add(mfw);
+ } else {
+ // Setting dataArray as list of current values when isMultiSelection is true
+ String[] toArray = (String[]) currValuesOfExtraField.toArray(new String[0]);
+ mfw.setCurrentValues(toArray);
+ expandedListForMultipleOccurs.add(mfw);
+ // Exit from for
+ break;
+ }
+ }
+ // returns to external for because the field with multiple occurrences has been
+ // added to list
+ continue;
+ }
+ }
+
+ // add field to list
+ expandedListForMultipleOccurs.add(metadataFieldWrapper);
+ }
+
+ toReturnMetaDataProfileBean.setMetadataFields(expandedListForMultipleOccurs);
+
+ logger.trace("CustomFieldsMap (extras) not matching metadata profile are {}", customFieldsMap);
+
+ int customFieldsSize = customFieldsMap.size();
+
+ // There are the Custom Fields not belonging to profile
+ logger.info("Custom fields founds # {}", customFieldsSize);
+
+ if (customFieldsSize > 0) {
+ customFieldsMap = purgeSystemFields(customFieldsMap);
+ }
+
+ logger.info("custom fields to return {}", customFieldsMap.keySet());
+
+ MetadataProfileBeanForUpdate mpfu = new MetadataProfileBeanForUpdate();
+ mpfu.setListProfileBean(Arrays.asList(toReturnMetaDataProfileBean));
+ mpfu.setCustomFields(customFieldsMap);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning filled profile {}", toReturnMetaDataProfileBean.getType());
+ logger.debug("with MetadataFields {}", toReturnMetaDataProfileBean.getMetadataFields());
+ logger.debug("Custom fields founds {}", customFieldsMap.keySet());
+ }
+
+ logger.info("returing the filled profile {}", profileBean.getType());
+ return mpfu;
+ }
+
/**
* Dataset id already exists.
*
@@ -572,10 +1039,39 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}
+ /**
+ * Delete item.
+ *
+ * @param datasetBean the dataset bean
+ * @return true, if successful
+ * @throws Exception the exception
+ */
+ @Override
+ public boolean deleteItem(DatasetBean datasetBean) throws Exception {
+ logger.debug("delete item called: {}" + datasetBean);
+
+ if (datasetBean == null)
+ throw new Exception("Error: the dataset is null");
+
+ try {
+ String scopeFromOrgName = getScopeFromOrgName(datasetBean.getSelectedOrganization());
+ logger.info("Going to delete dataset with name: {}", datasetBean.getCkanName());
+ boolean deleted = getCatalogue(scopeFromOrgName).deleteDataset(datasetBean.getCkanName());
+ logger.info("Dataset {} deleted? ", datasetBean.getCkanName(), deleted);
+ return deleted;
+ } catch (Exception e) {
+ logger.error("Unable to check if such a dataset id already exists", e);
+ throw new Exception("Unable to check if such a dataset id already exists " + e.getMessage());
+ }
+ }
+
/**
* The method tries to retrieve the scope related to the organization using the
* map first, if no match is found, it retrieves such information by using
- * liferay
+ * liferay.
+ *
+ * @param orgName the org name
+ * @return the scope from org name
*/
private String getScopeFromOrgName(String orgName) {
@@ -673,25 +1169,27 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.warn("Dev mode detected");
toReturn = Arrays.asList();
}
+
+ logger.info("Returning user's groups: " + toReturn);
return toReturn;
}
/**
* Checks if is publisher user.
*
- * @param isWorkspaceRequest the is workspace request
* @return true, if is publisher user
* @throws Exception the exception
*/
@Override
- public boolean isPublisherUser(boolean isWorkspaceRequest) throws Exception {
+ public Boolean isPublisherUser() throws Exception {
String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
logger.info("Checking if the user " + username + " can publish or not on the catalogue");
if (!isWithinPortal()) {
- logger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
- return true;
+ boolean isPublisherFunny = true;
+ logger.warn("OUT FROM PORTAL DETECTED RETURNING: "+isPublisherFunny);
+ return isPublisherFunny;
}
try {
@@ -759,6 +1257,60 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}
+ /**
+ * Checks if is publisher owner or admin user.
+ *
+ * @param datasetIdOrName the dataset id or name
+ * @return true, if is publisher owner or admin user
+ * @throws Exception the exception
+ */
+ @Override
+ public Boolean isPublisherOwnerOrAdminUser(String datasetIdOrName) throws Exception {
+
+ String username = GenericUtils.getCurrentUser(getThreadLocalRequest()).getUsername();
+ logger.info("Checking if the user " + username + " can publish or not on the catalogue");
+
+ boolean isPublisher = isPublisherUser();
+
+ if (isPublisher) {
+ RolesCkanGroupOrOrg role = null;
+ String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+
+ if (!isWithinPortal()) {
+ role = RolesCkanGroupOrOrg.EDITOR;
+ logger.warn("OUT FROM PORTAL SETTING HARD-CODED ROLE " + role);
+ } else {
+ String keyPerScopeRole = CatalogueUtilMethods
+ .concatenateSessionKeyScope(SessionCatalogueAttributes.CKAN_HIGHEST_ROLE, scopePerCurrentUrl);
+ HttpSession httpSession = this.getThreadLocalRequest().getSession();
+ role = (RolesCkanGroupOrOrg) httpSession.getAttribute(keyPerScopeRole);
+ }
+
+ // if the user is an EDITOT he/she must be also the owner of the dataset
+ if (role.equals(RolesCkanGroupOrOrg.EDITOR)) {
+ logger.info("The user {} is an {}", username, RolesCkanGroupOrOrg.EDITOR);
+ String loggedUserEmail = GenericUtils.getCurrentUser(getThreadLocalRequest()).getEmail();
+ logger.debug("Logged user email: {} ", loggedUserEmail);
+ DataCatalogue utils = getCatalogue(scopePerCurrentUrl);
+ CkanDataset dataset = utils.getDataset(datasetIdOrName, username);
+ String datasetOwnerEmail = dataset.getAuthorEmail();
+ logger.debug("Dataset Owner email: {} ", datasetOwnerEmail);
+
+ if (loggedUserEmail != null && datasetOwnerEmail != null
+ && datasetOwnerEmail.compareTo(loggedUserEmail) == 0) {
+ logger.info("The user {} is owner of the dataset id {}, returning isOwnerOrAdminUser true ",
+ username, dataset.getId());
+ return true;
+ }
+ } else if (role.equals(RolesCkanGroupOrOrg.ADMIN)) {
+ logger.info("The user {} is an {}", username, RolesCkanGroupOrOrg.ADMIN);
+ return true;
+ }
+ }
+ logger.info("The user {} does not have the rights to update the dataset with id {}", username, datasetIdOrName);
+ return false;
+ }
+
/**
* Checks if is geo JSON valid.
*
@@ -776,4 +1328,131 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
}
+ /**
+ * Purge system fields.
+ *
+ * @param extras the extras
+ * @return the map
+ */
+ public static Map> purgeSystemFields(Map> extras) {
+ logger.info("Purging extras from reserved fields {} ", NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES);
+ if (extras == null)
+ return null;
+
+ Map> extrasPop = new HashMap>(extras);
+ for (String key : extras.keySet()) {
+ List list = NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES.stream().filter(scf -> key.startsWith(scf))
+ .collect(Collectors.toList());
+
+ if (list.size() > 0)
+ extrasPop.remove(key);
+ }
+
+ logger.debug("returning purged extras {} ", extrasPop);
+ return extrasPop;
+
+ }
+
+ /**
+ * Gets the public link for file item id.
+ *
+ * @param itemId the item id
+ * @param shortenUrl the shorten url
+ * @return the public link for file item id
+ * @throws Exception the exception
+ */
+ @Override
+ public String getPublicLinkForFileItemId(String itemId, boolean shortenUrl) throws Exception {
+ logger.debug("get Public Link For ItemId: " + itemId);
+ // String scopePerCurrentUrl =
+ // GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
+ String theLink = null;
+ try {
+ GenericUtils.getCurrentContext(getThreadLocalRequest(), true);
+ UriResolverManager resolver = new UriResolverManager("SHUB");
+ Map params = new HashMap();
+ params.put("id", itemId);
+ theLink = resolver.getLink(params, true);
+ logger.info("Returning public link: " + theLink);
+ } catch (UriResolverMapException e) {
+ logger.error("UriResolverMapException", e);
+ throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
+ } catch (IllegalArgumentException e) {
+ logger.error("Failed to check the user's role", e);
+ throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
+ } catch (Exception e) {
+ logger.error("Failed to check the user's role", e);
+ throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
+ }
+
+ return theLink;
+
+ }
+
+ /**
+ * Gets the reserverd system fields.
+ *
+ * @param extras the extras
+ * @return the reserverd system fields
+ */
+ public static Map> getReserverdSystemFields(Map> extras) {
+ logger.info("Reading reserved fields from extras...");
+ if (extras == null)
+ return null;
+
+ Map> reserverSystemExtras = new HashMap>();
+ for (String key : extras.keySet()) {
+ List list = NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES.stream().filter(scf -> key.startsWith(scf))
+ .collect(Collectors.toList());
+
+ if (list.size() > 0)
+ reserverSystemExtras.put(key, extras.get(key));
+ }
+ logger.debug("returning reserverd extras {} ", reserverSystemExtras);
+ return reserverSystemExtras;
+
+ }
+
+ /**
+ * Clone list.
+ *
+ * @param list the list
+ * @return the list
+ */
+ public static List cloneList(List list) {
+ List listCloned = new ArrayList(list.size());
+
+ Function cloneWrapper = (mfw) -> {
+
+ MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
+ newMfw.setAsGroup(mfw.getAsGroup());
+ newMfw.setAsTag(mfw.getAsTag());
+ List listValues = mfw.getCurrentValues();
+ if (listValues != null) {
+ newMfw.setCurrentValues(listValues.stream().toArray(String[]::new));
+ }
+ newMfw.setDefaultValue(mfw.getDefaultValue());
+ newMfw.setFieldId(mfw.getFieldId());
+ newMfw.setFieldName(mfw.getFieldName());
+ newMfw.setFieldNameFromCategory(mfw.getFieldNameFromCategory());
+ newMfw.setMandatory(mfw.getMandatory());
+ newMfw.setMaxOccurs(mfw.getMaxOccurs());
+ newMfw.setMultiSelection(mfw.isMultiSelection());
+ newMfw.setNote(mfw.getNote());
+ newMfw.setOwnerCategory(mfw.getOwnerCategory());
+ newMfw.setType(mfw.getType());
+ newMfw.setValidator(mfw.getValidator());
+ newMfw.setVocabulary(mfw.getVocabulary());
+
+ return newMfw;
+
+ };
+
+ for (MetadataFieldWrapper item : list) {
+ MetadataFieldWrapper cloned = cloneWrapper.apply(item);
+ listCloned.add(cloned);
+ }
+ return listCloned;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/PublisherCatalogueConveter.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/PublisherCatalogueConveter.java
new file mode 100644
index 0000000..ee56908
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/PublisherCatalogueConveter.java
@@ -0,0 +1,55 @@
+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;
+
+/**
+ * The Class PublisherCatalogueConveter.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Feb 12, 2024
+ */
+public class PublisherCatalogueConveter {
+
+ /**
+ * To resource element bean.
+ *
+ * @param ckanResource the ckan resource
+ * @param orgNameParent the org name parent
+ * @return the resource element bean
+ */
+ public static ResourceElementBean toResourceElementBean(CkanResource ckanResource, String orgNameParent) {
+ ResourceElementBean reb = new ResourceElementBean();
+ reb.setCkanResourceID(ckanResource.getId());
+ reb.setName(ckanResource.getName());
+ reb.setDescription(ckanResource.getDescription());
+ reb.setEditableName(ckanResource.getName());
+ reb.setUrl(ckanResource.getUrl());
+ reb.setMimeType(ckanResource.getMimetype());
+ reb.setOrganizationNameDatasetParent(orgNameParent);
+ reb.setCkanDatasetId(ckanResource.getPackageId());
+ return reb;
+ }
+
+ /**
+ * To resource bean.
+ *
+ * @param ckanResource the ckan resource
+ * @param orgNameParent the org name parent
+ * @return the resource bean
+ */
+ public static ResourceBean toResourceBean(CkanResource ckanResource, String orgNameParent) {
+ 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;
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/AssociationToGroupAndNotifyThread.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/AssociationToGroupAndNotifyThread.java
deleted file mode 100644
index c252731..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/AssociationToGroupAndNotifyThread.java
+++ /dev/null
@@ -1,161 +0,0 @@
-//package org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads;
-//
-//import java.util.ArrayList;
-//import java.util.Iterator;
-//import java.util.List;
-//import java.util.Map;
-//
-//import javax.servlet.http.HttpServletRequest;
-//
-//import org.gcube.common.portal.mailing.EmailNotification;
-//import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
-//import org.gcube.datacatalogue.ckanutillibrary.server.utils.CatalogueUtilMethods;
-//import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
-//import org.gcube.datacatalogue.ckanutillibrary.shared.jackan.model.CkanGroup;
-//import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
-//import org.gcube.vomanagement.usermanagement.UserManager;
-//import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
-//
-//import com.liferay.portal.kernel.log.Log;
-//import com.liferay.portal.kernel.log.LogFactoryUtil;
-//
-//
-//
-///**
-// * Associate the dataset to a group and send notifications to group's admins.
-// * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
-// */
-//public class AssociationToGroupAndNotifyThread extends Thread {
-//
-// //private static final Logger logger = LoggerFactory.getLogger(AssociationToGroupAndNotifyThread.class);
-// private static final Log logger = LogFactoryUtil.getLog(AssociationToGroupAndNotifyThread.class);
-// private static final String PRODUCT_ASSOCIATED_TO_GROUP_SUBJECT = "Item $TITLE added to group $GROUP";
-// private static final String PRODUCT_ASSOCIATED_TO_GROUP_BODY = "Dear user,
a new item named '$TITLE' has been "
-// + "just published by $USER_FULLNAME in $GROUP .
"
-// + "You can find it here $DATASET_URL";
-//
-// private String groupTitle;
-// private String datasetId;
-// private String username;
-// private String datasetTitle;
-// private String userFullName;
-// private DataCatalogue catalogue;
-// // private String organization;
-// private List groups;
-// private HttpServletRequest request;
-// private String datasetUrl;
-// private List groupsForceCreation;
-//
-// /**
-// * @param list
-// * @param groupTitle
-// * @param datasetId
-// * @param username
-// * @param catalogue
-// */
-// public AssociationToGroupAndNotifyThread(List groups, List groupsForceCreation, String groupTitle, String datasetUrl, String datasetId, String datasetTitle, String userFullName,
-// String username, DataCatalogue catalogue, String organization, HttpServletRequest request) {
-// this.request = request;
-// this.groups = groups == null ? new ArrayList() : groups;
-// this.groupsForceCreation = groupsForceCreation;
-// this.groupTitle = groupTitle;
-// this.datasetId = datasetId;
-// this.username = username;
-// this.catalogue = catalogue;
-// // this.organization = organization;
-// this.datasetTitle = datasetTitle;
-// this.userFullName = userFullName;
-// this.datasetUrl = datasetUrl;
-// }
-//
-// @Override
-// public void run() {
-//
-// logger.info("Association thread started to put the dataset with id = "+ datasetId + " into group with title " + groupTitle + " for user " + username);
-//
-// // force creation of groups if needed
-// if(groupsForceCreation != null){
-// logger.info("Groups that must be created before association are " + groupsForceCreation);
-// for (OrganizationBean groupToForce : groupsForceCreation) {
-// try{
-// CkanGroup group = catalogue.createGroup(groupToForce.getName(), groupToForce.getTitle(), "");
-// if(group == null)
-// logger.error("Unable to retrieve or create group with name " + groupToForce);
-// else
-// groups.add(new OrganizationBean(group.getTitle(), group.getName(), false, groupToForce.isPropagateUp()));
-// }catch(Exception e){
-// logger.error("Failed to check if a group with this info " + groupToForce + " already exists or can be created");
-// }
-// }
-//
-// }
-//
-// logger.info("Other groups to which the product should be associate are " + groups);
-//
-// if(groups != null)
-// for (OrganizationBean groupBean : groups) {
-// boolean putIntoGroup = catalogue.assignDatasetToGroup(groupBean.getName(), datasetId, groupBean.isPropagateUp());
-// logger.info("Was product put into group" + groupBean.getTitle() + "? " + putIntoGroup);
-// if(putIntoGroup)
-// notifyGroupAdmins(catalogue, groupBean.getName() ,groupBean.getTitle(), username);
-// }
-//
-// }
-//
-// /**
-// * Send a notification to the group admin(s) about the just added product
-// * @param username
-// * @param groupTitle
-// * @param catalogue
-// */
-// private void notifyGroupAdmins(DataCatalogue catalogue, String groupName, String groupTitle, String username){
-//
-// // get the groups admin
-// Map> userAndRoles = catalogue.getRolesAndUsersGroup(groupName);
-//
-// if(userAndRoles.containsKey(RolesCkanGroupOrOrg.ADMIN)){
-//
-// List admins = userAndRoles.get(RolesCkanGroupOrOrg.ADMIN);
-// List adminsEmails = new ArrayList();
-//
-// for(int i = 0; i < admins.size(); i++){
-// String convertedName = CatalogueUtilMethods.fromCKanUsernameToUsername(admins.get(i));
-// admins.set(i, convertedName);
-// }
-//
-// // remove the same user who published the product if he/she is an admin of the group
-// int indexOfUser = admins.indexOf(username);
-// if(indexOfUser >= 0)
-// admins.remove(indexOfUser);
-//
-// // further cleaning of the list (for users that are only in ckan... sysadmin for example)
-// UserManager um = new LiferayUserManager();
-// Iterator adminIt = admins.iterator();
-//
-// while (adminIt.hasNext()) {
-// String admin = (String) adminIt.next();
-// try{
-// adminsEmails.add(um.getUserByUsername(admin).getEmail());
-// }catch(Exception e){
-// logger.error("User with username " + admin + " doesn't exist in Liferay");
-// adminIt.remove();
-// }
-// }
-//
-// logger.info("The list of admins for group " + groupTitle + " is " + admins);
-//
-// if(admins.isEmpty())
-// return;
-//
-// // send the email
-// EmailNotification mailToSend = new EmailNotification(
-// adminsEmails,
-// PRODUCT_ASSOCIATED_TO_GROUP_SUBJECT.replace("$TITLE", datasetTitle).replace("$GROUP", groupTitle),
-// PRODUCT_ASSOCIATED_TO_GROUP_BODY.replace("$TITLE", datasetTitle).replace("$GROUP", groupTitle).replace("$USER_FULLNAME", userFullName).replace("$DATASET_URL", datasetUrl),
-// request);
-// mailToSend.sendEmail();
-//
-// }else
-// logger.warn("It seems there is no user with role Admin in group " + groupTitle);
-// }
-//}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/WritePostCatalogueManagerThread.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/WritePostCatalogueManagerThread.java
deleted file mode 100644
index 8ab084e..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/threads/WritePostCatalogueManagerThread.java
+++ /dev/null
@@ -1,322 +0,0 @@
-//package org.gcube.portlets.widgets.ckandatapublisherwidget.server.threads;
-//
-//import java.io.IOException;
-//import java.net.HttpURLConnection;
-//import java.util.List;
-//
-//import org.apache.http.HttpEntity;
-//import org.apache.http.HttpResponse;
-//import org.apache.http.client.ClientProtocolException;
-//import org.apache.http.client.methods.HttpPost;
-//import org.apache.http.entity.StringEntity;
-//import org.apache.http.impl.client.CloseableHttpClient;
-//import org.apache.http.impl.client.HttpClientBuilder;
-//import org.apache.http.util.EntityUtils;
-//import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
-//import org.gcube.common.scope.api.ScopeProvider;
-//import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.GCoreEndPointReaderSocial;
-//import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.GenericUtils;
-//
-//import com.google.gwt.json.client.JSONParser;
-//import com.liferay.portal.kernel.log.Log;
-//import com.liferay.portal.kernel.log.LogFactoryUtil;
-//
-//
-///**
-// * Let the Product Catalogue Manager write a post in a VRE and alert there is a new product
-// * @author Costantino Perciante at ISTI-CNR
-// * (costantino.perciante@isti.cnr.it)
-// */
-//public class WritePostCatalogueManagerThread extends Thread {
-//
-// public static final String APPLICATION_ID_CATALOGUE_MANAGER = "org.gcube.datacatalogue.ProductCatalogue";
-// private static final String NOTIFICATION_MESSAGE = "Dear members,\n$USER_FULLNAME just published the item '$PRODUCT_TITLE'.\nYou can find it at: $PRODUCT_URL\n";
-// private static final String SOCIAL_SERVICE_APPLICATION_TOKEN = "2/tokens/generate-application-token";
-// private static final String SOCIAL_SERVICE_WRITE_APPLICATION_POST = "2/posts/write-post-app";
-// private static final String MEDIATYPE_JSON = "application/json";
-// private static final Log logger = LogFactoryUtil.getLog(WritePostCatalogueManagerThread.class);
-// private String username;
-// private String scope;
-// private String productTitle;
-// private String productUrl;
-// private boolean enableNotification;
-// private List hashtags;
-// private String userFullName;
-// private String userCurrentUrl;
-//
-// /**
-// * @param token
-// * @param scope
-// * @param productTitle
-// * @param productUrl
-// * @param enableNotification
-// * @param hashtags
-// * @param userFullName
-// */
-// public WritePostCatalogueManagerThread(
-// String username, String scope,
-// String productTitle, String productUrl, boolean enableNotification,
-// List hashtags, String userFullName, String userCurrentUrl) {
-// super();
-// this.username = username;
-// this.scope = scope;
-// this.productTitle = productTitle;
-// this.productUrl = productUrl;
-// this.enableNotification = enableNotification;
-// this.hashtags = hashtags;
-// this.userFullName = userFullName;
-// this.userCurrentUrl = userCurrentUrl;
-// }
-//
-// @Override
-// public void run() {
-//
-// try{
-// // evaluate user's token for this scope
-// String token = GenericUtils.tryGetElseCreateToken(username, scope);
-//
-// if(token == null){
-// logger.warn("Unable to proceed, user's token is not available");
-// return;
-// }
-//
-// logger.info("Started request to write application post "
-// + "for new product created. Scope is " + scope + " and "
-// + "token is " + token.substring(0, 10) + "****************");
-//
-// // set token and scope
-// ScopeProvider.instance.set(scope);
-// SecurityTokenProvider.instance.set(token);
-//
-// //see Feature #17577
-// /*final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + extractOrgFriendlyURL(userCurrentUrl) + GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
-//
-// userFullName = ""+userFullName+
-// " ";
-// */
-//
-// userFullName = "@"+username;
-//
-// // write
-// writeProductPost(
-// productTitle,
-// productUrl,
-// userFullName,
-// hashtags,
-// enableNotification
-// );
-//
-// }catch(Exception e){
-// logger.error("Failed to write the post because of the following error ", e);
-// }finally{
-// SecurityTokenProvider.instance.reset();
-// ScopeProvider.instance.reset();
-// }
-// }
-//
-// public static String extractOrgFriendlyURL(String portalURL) {
-// String groupRegEx = "/group/";
-// if (portalURL.contains(groupRegEx)) {
-// String[] splits = portalURL.split(groupRegEx);
-// String friendlyURL = splits[1];
-// if (friendlyURL.contains("/")) {
-// friendlyURL = friendlyURL.split("/")[0];
-// } else {
-// friendlyURL = friendlyURL.split("\\?")[0].split("\\#")[0];
-// }
-// return "/"+friendlyURL;
-// }
-// return null;
-// }
-//
-// /**
-// * Send notification to vre members about the created product by writing a post.
-// * @param productName the title of the product
-// * @param productUrl the url of the product
-// * @param hashtags a list of product's hashtags
-// */
-// private static void writeProductPost(String productName, String productUrl, String userFullname, List hashtags, boolean enablePostNotification){
-//
-// // discover service endpoint for the social networking library
-// String currentScope = ScopeProvider.instance.get();
-// String tokenUser = SecurityTokenProvider.instance.get();
-//
-// logger.info("Current scope for writeProductPost is " + currentScope + " and token is " + tokenUser.substring(0, 10) + "***************");
-// String basePath = new GCoreEndPointReaderSocial(currentScope).getBasePath();
-//
-// if(basePath == null){
-//
-// logger.error("Unable to write a post because there is no social networking service available");
-//
-// }else{
-//
-// // check base path form
-// basePath = basePath.endsWith("/") ? basePath : basePath + "/";
-//
-// try(CloseableHttpClient client = HttpClientBuilder.create().build();){
-//
-// String pathTokenApp = basePath + SOCIAL_SERVICE_APPLICATION_TOKEN + "?gcube-token=" + tokenUser;
-// String tokenApp = requireAppToken(client, pathTokenApp);
-// if(tokenApp != null){
-// String pathWritePost = basePath + SOCIAL_SERVICE_WRITE_APPLICATION_POST + "?gcube-token=" + tokenApp;
-// writePost(client, pathWritePost, productName, productUrl, userFullname, hashtags, enablePostNotification);
-// }
-//
-// }catch(Exception e){
-// logger.error("Failed to create a post", e);
-// }
-// }
-// }
-//
-// /**
-// * Require the application token
-// * @param tokenUser
-// * @param basePath
-// * @param client
-// * @return
-// */
-// private static String requireAppToken(CloseableHttpClient client, String path){
-//
-// String token = null;
-// try{
-//
-// JSONObject request = new JSONObject();
-// request.put("app_id", APPLICATION_ID_CATALOGUE_MANAGER);
-// HttpResponse response = performRequest(client, path, request.toJSONString());
-//
-// int statusTokenGenerate = response.getStatusLine().getStatusCode();
-//
-// if(statusTokenGenerate == HttpURLConnection.HTTP_CREATED){
-//
-// // extract token
-// JSONObject obj = getJSONObject(response);
-// if(((Boolean) obj.get("success")))
-// token = (String)obj.get("result");
-// else
-// return null;
-//
-// }else if(statusTokenGenerate == HttpURLConnection.HTTP_MOVED_TEMP
-// || statusTokenGenerate == HttpURLConnection.HTTP_MOVED_PERM
-// || statusTokenGenerate == HttpURLConnection.HTTP_SEE_OTHER){
-//
-// // re-execute
-// Header[] locations = response.getHeaders("Location");
-// Header lastLocation = locations[locations.length - 1];
-// String realLocation = lastLocation.getValue();
-// logger.debug("New location is " + realLocation);
-// token = requireAppToken(client, realLocation);
-//
-// }else
-// return null;
-//
-// }catch(Exception e){
-// logger.error("Failed to retrieve application token", e);
-// }
-//
-// logger.info("Returning app token " + (token != null ? token.substring(0, 10) + "*************************" : null));
-// return token;
-// }
-//
-// /**
-// * Write post request
-// * @param client
-// * @param applicationToken
-// * @param productName
-// * @param productUrl
-// * @param userFullname
-// * @param hashtags
-// */
-// private static void writePost(CloseableHttpClient client, String path, String productName, String productUrl, String userFullname, List hashtags,
-// boolean enablePostNotification) {
-//
-// try{
-//
-// // replace
-// String message = NOTIFICATION_MESSAGE.replace("$PRODUCT_TITLE", productName).replace("$PRODUCT_URL", productUrl).replace("$USER_FULLNAME", userFullname);
-//
-// if(hashtags != null && !hashtags.isEmpty())
-// for (String hashtag : hashtags) {
-// String modifiedHashtag = hashtag.replaceAll(" ", "_").replace("_+", "_");
-// if(modifiedHashtag.endsWith("_"))
-// modifiedHashtag = modifiedHashtag.substring(0, modifiedHashtag.length() - 1);
-// message += " #" + modifiedHashtag; // ckan accepts tag with empty spaces, we don't
-// }
-//
-// JSONObject request = new JSONObject();
-// request.put("text", message);
-// request.put("enable_notification", enablePostNotification);
-// logger.info("The post that is going to be written is ->\n" + request.toJSONString());
-// HttpResponse response = performRequest(client, path, request.toJSONString());
-// int statusWritePost = response.getStatusLine().getStatusCode();
-//
-// if(statusWritePost == HttpURLConnection.HTTP_CREATED){
-//
-// // extract token
-// JSONObject obj = getJSONObject(response);
-// if(((Boolean) obj.get("success")))
-// logger.info("Post written");
-// else
-// logger.info("Failed to write the post " + obj.get("message"));
-//
-// }else if(statusWritePost == HttpURLConnection.HTTP_MOVED_TEMP
-// || statusWritePost == HttpURLConnection.HTTP_MOVED_PERM
-// || statusWritePost == HttpURLConnection.HTTP_SEE_OTHER){
-//
-// // re-execute
-// Header[] locations = response.getHeaders("Location");
-// Header lastLocation = locations[locations.length - 1];
-// String realLocation = lastLocation.getValue();
-// logger.debug("New location is " + realLocation);
-// writePost(client, realLocation, productName, productUrl, userFullname, hashtags, enablePostNotification);
-//
-// }else
-// throw new RuntimeException("Failed to write the post ");
-//
-// }catch(Exception e){
-// logger.error("Failed to write the post ", e);
-// }
-//
-// }
-//
-// /**
-// * Convert the json response to a map
-// * @param response
-// * @return
-// */
-// private static JSONObject getJSONObject(HttpResponse response){
-//
-// JSONObject toReturn = null;
-// HttpEntity entity = response.getEntity();
-//
-// if (entity != null) {
-// try {
-// String jsonString = EntityUtils.toString(response.getEntity());
-// JSONParser parser = new JSONParser();
-// toReturn = (JSONObject)parser.parse(jsonString);
-// }catch(Exception e){
-// logger.error("Failed to read json object", e);
-// }
-// }
-//
-// logger.debug("Returning " + toReturn.toJSONString());
-// return toReturn;
-// }
-//
-// /**
-// * Perform an http request post request with json entity
-// * @throws IOException
-// * @throws ClientProtocolException
-// */
-// private static HttpResponse performRequest(CloseableHttpClient client, String path, String entity) throws ClientProtocolException, IOException{
-//
-// HttpPost request = new HttpPost(path);
-// StringEntity stringEntity = new StringEntity(entity);
-// stringEntity.setContentType(MEDIATYPE_JSON);
-// request.setEntity(stringEntity);
-// return client.execute(request);
-//
-// }
-//
-//}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java
index da8ff78..c94c7f0 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/CatalogueRoleManager.java
@@ -73,7 +73,8 @@ public class CatalogueRoleManager {
List listGroups = groupManager.listGroupsByUser(userid);
groups = new HashSet(listGroups);
}
-
+
+ //Used by Workspace?
// root (so check into the root, the VOs and the VRES)
if(groupManager.isRootVO(currentGroupId)){
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/MetadataDiscovery.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/MetadataDiscovery.java
index 1830ebf..fb92e3f 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/MetadataDiscovery.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/MetadataDiscovery.java
@@ -21,13 +21,13 @@ import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataVocabulary;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.NamespaceCategory;
import org.gcube.datacatalogue.utillibrary.server.utils.CatalogueUtilMethods;
import org.gcube.datacatalogue.utillibrary.server.utils.SessionCatalogueAttributes;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.CategoryWrapper;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.DataTypeWrapper;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsGroup;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsTag;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetaDataProfileBean;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetadataFieldWrapper;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.TaggingGroupingValue;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsGroup;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.FieldAsTag;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.TaggingGroupingValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
index 12a410c..4f40ab2 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/server/utils/WorkspaceUtils.java
@@ -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 childrenInTree = new ArrayList(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.
* There is no difference among a single-file-publish and a folder-publish.
@@ -425,89 +330,4 @@ public class WorkspaceUtils {
}
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 copyResourcesToUserCatalogueArea(String folderOrFileId, String userName, DatasetBean bean) throws Exception{
-//
-// logger.debug("Request to copy onto catalogue area....");
-// List resources = new ArrayList();
-// 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 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;
-// }
-
-
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/DatasetBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/DatasetBean.java
index 8c6652c..f604a69 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/DatasetBean.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/DatasetBean.java
@@ -4,18 +4,33 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
-import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
- * This bean will contain during ckan metadata creation information related to the future build.
+ * This bean will contain during ckan metadata creation information related to
+ * the future build.
+ *
+ * revisited by @author Francesco Mangiacrapa at ISTI-CNR
+ *
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
+ *
*/
@SuppressWarnings("serial")
public class DatasetBean implements Serializable, IsSerializable {
private String id;
+ private String ckanName;
+
+ public String getCkanName() {
+ return ckanName;
+ }
+
+ public void setCkanName(String ckanName) {
+ this.ckanName = ckanName;
+ }
+
private String title;
private String description;
private String license; // chosen by the user
@@ -31,47 +46,55 @@ public class DatasetBean implements Serializable, IsSerializable {
private String selectedOrganization;
private long version; // version 1, 2 ...
private boolean visible; // Private (false) or Public(true)
- private List organizationList; // list of organization in which the user is present and could create the dataset
- private ResourceElementBean resourceRoot; // in case of workspace, this is the directory root or the single file information
+ private List organizationList; // list of organization in which the user is present and could
+ // create the dataset
+ private ResourceElementBean resourceRoot; // in case of workspace, this is the directory root or the single file
+ // information
private List metadataList;
private List tags; // on retrieve, they are the keys of the product
private List tagsVocabulary; // when available
private Map> customFields;
private List groups;
private List groupsForceCreation;
+ private List resources;
+ private String wsFolderId;
- public DatasetBean(){
+ /**
+ * Instantiates a new dataset bean.
+ */
+ public DatasetBean() {
super();
}
- /** Create a metadata bean object.
- * @param id
- * @param title
- * @param description
- * @param customFields
- * @param tags
- * @param license
- * @param visibility
- * @param source
- * @param version
- * @param author
- * @param authorEmail
- * @param maintainer
- * @param maintainerEmail
- * @param ownerIdentifier
- * @param organizationList
- * @param selectedOrganization
- * @param resourcesIds
- * @param addResources
- * @param metadataList
+ /**
+ * Create a metadata bean object.
+ *
+ * @param id the id
+ * @param title the title
+ * @param description the description
+ * @param customFields the custom fields
+ * @param tags the tags
+ * @param license the license
+ * @param visible the visible
+ * @param source the source
+ * @param version the version
+ * @param authorName the author name
+ * @param authorSurname the author surname
+ * @param authorEmail the author email
+ * @param maintainer the maintainer
+ * @param maintainerEmail the maintainer email
+ * @param ownerIdentifier the owner identifier
+ * @param organizationList the organization list
+ * @param selectedOrganization the selected organization
+ * @param resourceRoot the resource root
+ * @param metadataList the metadata list
+ * @param groups the groups
+ * @param tagsVocabulary the tags vocabulary
*/
- public DatasetBean(String id, String title, String description,
- Map> customFields, List tags,
- String license, boolean visible, String source, long version,
- String authorName, String authorSurname, String authorEmail, String maintainer,
- String maintainerEmail, String ownerIdentifier,
- List organizationList, String selectedOrganization,
- ResourceElementBean resourceRoot,
+ public DatasetBean(String id, String title, String description, Map> customFields,
+ List tags, String license, boolean visible, String source, long version, String authorName,
+ String authorSurname, String authorEmail, String maintainer, String maintainerEmail, String ownerIdentifier,
+ List organizationList, String selectedOrganization, ResourceElementBean resourceRoot,
List metadataList, List groups, List tagsVocabulary) {
super();
this.id = id;
@@ -97,203 +120,472 @@ public class DatasetBean implements Serializable, IsSerializable {
this.tagsVocabulary = tagsVocabulary;
}
+ /**
+ * Gets the chosen type.
+ *
+ * @return the chosen type
+ */
public String getChosenType() {
return chosenType;
}
+ /**
+ * Sets the chosen type.
+ *
+ * @param chosenType the new chosen type
+ */
public void setChosenType(String chosenType) {
this.chosenType = chosenType;
}
+ /**
+ * Gets the metadata list.
+ *
+ * @return the metadata list
+ */
public List getMetadataList() {
return metadataList;
}
+ /**
+ * Sets the metadata list.
+ *
+ * @param metadataListTypes the new metadata list
+ */
public void setMetadataList(List metadataListTypes) {
this.metadataList = metadataListTypes;
}
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
public String getId() {
return id;
}
+ /**
+ * Sets the id.
+ *
+ * @param id the new id
+ */
public void setId(String id) {
this.id = id;
}
+ /**
+ * Gets the owner identifier.
+ *
+ * @return the owner identifier
+ */
public String getOwnerIdentifier() {
return ownerIdentifier;
}
+ /**
+ * Sets the owner identifier.
+ *
+ * @param ownerIdentifier the new owner identifier
+ */
public void setOwnerIdentifier(String ownerIdentifier) {
this.ownerIdentifier = ownerIdentifier;
}
+ /**
+ * Gets the title.
+ *
+ * @return the title
+ */
public String getTitle() {
return title;
}
+ /**
+ * Sets the title.
+ *
+ * @param title the new title
+ */
public void setTitle(String title) {
this.title = title;
}
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
public String getDescription() {
return description;
}
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
public void setDescription(String description) {
this.description = description;
}
+ /**
+ * Gets the custom fields.
+ *
+ * @return the custom fields
+ */
public Map> getCustomFields() {
return customFields;
}
+ /**
+ * Sets the custom fields.
+ *
+ * @param customFields the custom fields
+ */
public void setCustomFields(Map> customFields) {
this.customFields = customFields;
}
+ /**
+ * Gets the tags.
+ *
+ * @return the tags
+ */
public List getTags() {
return tags;
}
+ /**
+ * Sets the tags.
+ *
+ * @param tags the new tags
+ */
public void setTags(List tags) {
this.tags = tags;
}
+ /**
+ * Gets the license.
+ *
+ * @return the license
+ */
public String getLicense() {
return license;
}
+ /**
+ * Sets the license.
+ *
+ * @param license the new license
+ */
public void setLicense(String license) {
this.license = license;
}
+ /**
+ * Gets the visibility.
+ *
+ * @return the visibility
+ */
public boolean getVisibility() {
return visible;
}
+ /**
+ * Sets the visibile.
+ *
+ * @param visibile the new visibile
+ */
public void setVisibile(boolean visibile) {
this.visible = visibile;
}
+ /**
+ * Gets the source.
+ *
+ * @return the source
+ */
public String getSource() {
return source;
}
+ /**
+ * Sets the source.
+ *
+ * @param source the new source
+ */
public void setSource(String source) {
this.source = source;
}
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
public long getVersion() {
return version;
}
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
public void setVersion(long version) {
this.version = version;
}
+ /**
+ * Gets the author name.
+ *
+ * @return the author name
+ */
public String getAuthorName() {
return authorName;
}
+ /**
+ * Sets the author name.
+ *
+ * @param authorName the new author name
+ */
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
+ /**
+ * Gets the author surname.
+ *
+ * @return the author surname
+ */
public String getAuthorSurname() {
return authorSurname;
}
+ /**
+ * Sets the author surname.
+ *
+ * @param authorSurname the new author surname
+ */
public void setAuthorSurname(String authorSurname) {
this.authorSurname = authorSurname;
}
+ /**
+ * Gets the author email.
+ *
+ * @return the author email
+ */
public String getAuthorEmail() {
return authorEmail;
}
+ /**
+ * Sets the author email.
+ *
+ * @param authorEmail the new author email
+ */
public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
}
+ /**
+ * Gets the maintainer.
+ *
+ * @return the maintainer
+ */
public String getMaintainer() {
return maintainer;
}
+ /**
+ * Sets the maintainer.
+ *
+ * @param maintainer the new maintainer
+ */
public void setMaintainer(String maintainer) {
this.maintainer = maintainer;
}
+ /**
+ * Gets the maintainer email.
+ *
+ * @return the maintainer email
+ */
public String getMaintainerEmail() {
return maintainerEmail;
}
+ /**
+ * Sets the maintainer email.
+ *
+ * @param maintainerEmail the new maintainer email
+ */
public void setMaintainerEmail(String maintainerEmail) {
this.maintainerEmail = maintainerEmail;
}
+ /**
+ * Gets the organization list.
+ *
+ * @return the organization list
+ */
public List getOrganizationList() {
return organizationList;
}
+ /**
+ * Sets the organization list.
+ *
+ * @param organizationList the new organization list
+ */
public void setOrganizationList(List organizationList) {
this.organizationList = organizationList;
}
+ /**
+ * Gets the selected organization.
+ *
+ * @return the selected organization
+ */
public String getSelectedOrganization() {
return selectedOrganization;
}
+ /**
+ * Sets the selected organization.
+ *
+ * @param selectedOrganization the new selected organization
+ */
public void setSelectedOrganization(String selectedOrganization) {
this.selectedOrganization = selectedOrganization;
}
+ /**
+ * Gets the resource root.
+ *
+ * @return the resource root
+ */
public ResourceElementBean getResourceRoot() {
return resourceRoot;
}
+ /**
+ * Sets the resource root.
+ *
+ * @param resourceRoot the new resource root
+ */
public void setResourceRoot(ResourceElementBean resourceRoot) {
this.resourceRoot = resourceRoot;
}
+ /**
+ * Gets the author full name.
+ *
+ * @return the author full name
+ */
public String getAuthorFullName() {
return authorFullName;
}
+ /**
+ * Sets the author full name.
+ *
+ * @param authorFullName the new author full name
+ */
public void setAuthorFullName(String authorFullName) {
this.authorFullName = authorFullName;
}
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
public List getGroups() {
return groups;
}
+ /**
+ * Sets the groups.
+ *
+ * @param groups the new groups
+ */
public void setGroups(List groups) {
this.groups = groups;
}
+ /**
+ * Gets the tags vocabulary.
+ *
+ * @return the tags vocabulary
+ */
public List getTagsVocabulary() {
return tagsVocabulary;
}
+ /**
+ * Sets the tags vocabulary.
+ *
+ * @param tagsVocabulary the new tags vocabulary
+ */
public void setTagsVocabulary(List tagsVocabulary) {
this.tagsVocabulary = tagsVocabulary;
}
+ /**
+ * Gets the groups force creation.
+ *
+ * @return the groups force creation
+ */
public List getGroupsForceCreation() {
return groupsForceCreation;
}
+ /**
+ * Sets the groups force creation.
+ *
+ * @param groupsForceCreation the new groups force creation
+ */
public void setGroupsForceCreation(List groupsForceCreation) {
this.groupsForceCreation = groupsForceCreation;
}
+ /**
+ * Sets the resources.
+ *
+ * @param resources the new resources
+ */
+ public void setResources(List resources) {
+ this.resources = resources;
+ }
+
+ /**
+ * Gets the ckan resources.
+ *
+ * @return the ckan resources
+ */
+ public List getCkanResources() {
+ return resources;
+ }
+
+ public void setWSFolderId(String folderId) {
+ this.wsFolderId = folderId;
+
+ }
+
+ public String getWsFolderId() {
+ return wsFolderId;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("DatasetBean [id=");
builder.append(id);
+ builder.append(", ckanName=");
+ builder.append(ckanName);
builder.append(", title=");
builder.append(title);
builder.append(", description=");
@@ -326,6 +618,8 @@ public class DatasetBean implements Serializable, IsSerializable {
builder.append(visible);
builder.append(", organizationList=");
builder.append(organizationList);
+ builder.append(", resourceRoot=");
+ builder.append(resourceRoot);
builder.append(", metadataList=");
builder.append(metadataList);
builder.append(", tags=");
@@ -338,10 +632,10 @@ public class DatasetBean implements Serializable, IsSerializable {
builder.append(groups);
builder.append(", groupsForceCreation=");
builder.append(groupsForceCreation);
+ builder.append(", wsFolderId=");
+ builder.append(wsFolderId);
builder.append("]");
return builder.toString();
}
-
-
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/MetadataProfileBeanForUpdate.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/MetadataProfileBeanForUpdate.java
new file mode 100644
index 0000000..6f81836
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/MetadataProfileBeanForUpdate.java
@@ -0,0 +1,96 @@
+package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+
+/**
+ * The Class MetadataProfileBeanForUpdate.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Feb 8, 2024
+ */
+public class MetadataProfileBeanForUpdate implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -389855531761329707L;
+ private List listProfileBean;
+ private Map> customFields;
+
+ /**
+ * Instantiates a new metadata profile bean for update.
+ */
+ public MetadataProfileBeanForUpdate() {
+ super();
+ }
+
+ /**
+ * Instantiates a new metadata profile bean for update.
+ *
+ * @param listProfileBean the list profile bean
+ * @param customFields the custom fields
+ */
+ public MetadataProfileBeanForUpdate(List listProfileBean, Map> customFields) {
+ super();
+ this.listProfileBean = listProfileBean;
+ this.customFields = customFields;
+ }
+
+ /**
+ * Gets the list profile bean.
+ *
+ * @return the list profile bean
+ */
+ public List getListProfileBean() {
+ return listProfileBean;
+ }
+
+ /**
+ * Gets the custom fields.
+ *
+ * @return the custom fields
+ */
+ public Map> getCustomFields() {
+ return customFields;
+ }
+
+ /**
+ * Sets the list profile bean.
+ *
+ * @param listProfileBean the new list profile bean
+ */
+ public void setListProfileBean(List listProfileBean) {
+ this.listProfileBean = listProfileBean;
+ }
+
+ /**
+ * Sets the custom fields.
+ *
+ * @param customFields the custom fields
+ */
+ public void setCustomFields(Map> customFields) {
+ this.customFields = customFields;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("MetadataProfileBeanForUpdate [listProfileBean=");
+ builder.append(listProfileBean);
+ builder.append(", customFields=");
+ builder.append(customFields);
+ builder.append("]");
+ return builder.toString();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/OrganizationBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/OrganizationBean.java
index e1345c8..25857cf 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/OrganizationBean.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/OrganizationBean.java
@@ -10,25 +10,25 @@ import com.google.gwt.user.client.rpc.IsSerializable;
*/
public class OrganizationBean implements Serializable, IsSerializable{
- private static final long serialVersionUID = -6566519399945530602L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8014712837346722595L;
private String title;
private String name;
private boolean isOrganization;
private boolean propagateUp; // an item linked to this group has to be added on the whole hierarchy chain
public OrganizationBean(){
- super();
}
public OrganizationBean(String title, String name, boolean isOrganization) {
- super();
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
}
public OrganizationBean(String title, String name, boolean isOrganization, boolean propagateUp) {
- super();
this.title = title;
this.name = name;
this.isOrganization = isOrganization;
@@ -69,9 +69,17 @@ public class OrganizationBean implements Serializable, IsSerializable{
@Override
public String toString() {
- return "OrganizationBean [title=" + title + ", name=" + name
- + ", isOrganization=" + isOrganization + ", propagateUp="
- + propagateUp + "]";
+ StringBuilder builder = new StringBuilder();
+ builder.append("OrganizationBean [title=");
+ builder.append(title);
+ builder.append(", name=");
+ builder.append(name);
+ builder.append(", isOrganization=");
+ builder.append(isOrganization);
+ builder.append(", propagateUp=");
+ builder.append(propagateUp);
+ builder.append("]");
+ return builder.toString();
}
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
index a2c2148..e7ab5ee 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/ResourceElementBean.java
@@ -6,75 +6,79 @@ import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.google.gwt.view.client.ProvidesKey;
-
-// TODO: Auto-generated Javadoc
/**
- * 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 revisited by Francesco Mangiacrapa
*/
-public class ResourceElementBean implements Comparable, Serializable, IsSerializable{
+public class ResourceElementBean implements Comparable, Serializable, IsSerializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -1230871392599580669L;
-
+
/** The name. */
private String name;
-
+
/** The editable name. */
private String editableName;
-
+
/** The to be added. */
private boolean toBeAdded;
-
+
/** The is folder. */
private boolean isFolder;
-
+
/** The full path. */
private String fullPath;
-
+
/** The original id in workspace. */
private String originalIdInWorkspace;
-
+
private String rootIdInWorkspace;
-
+
/** The mime type. */
private String mimeType;
-
+
/** The url. */
private String url;
-
+
/** The description. */
private String description;
-
+
/** The organization name dataset parent. */
private String organizationNameDatasetParent; // the organization name in which the parent dataset was created
-
+
/** The parent. */
private ResourceElementBean parent;
-
+
/** The children size. */
private Integer childrenSize;
-
+
// /** The to publish. */
- private List toPublish; //Resources that must be published
+ private List toPublish; // Resources that must be published
/** The next id. */
// to generate the GWT identifiers
private static int nextId = 0;
-
+
/** The identifier GWT. */
// identifier of this instance
private int identifierGWT;
+ private String ckanResourceID;
+
+ private String ckanDatasetId;
+
/**
* The key provider that provides the unique ID of a bean.
*/
public static final ProvidesKey KEY_PROVIDER = new ProvidesKey() {
@Override
public Object getKey(ResourceElementBean item) {
- return item == null ? null : item.identifierGWT;
+ return item == null ? null : item.ckanResourceID;
}
};
@@ -98,7 +102,7 @@ public class ResourceElementBean implements Comparable, Ser
/**
* Default constructor.
*/
- public ResourceElementBean(){
+ public ResourceElementBean() {
super();
this.identifierGWT = nextId;
nextId++;
@@ -107,17 +111,13 @@ public class ResourceElementBean implements Comparable, Ser
/**
* Instantiates a new resource element bean.
*
- * @param parent the parent
- * @param name the name
- * @param isFolder the is folder
+ * @param parent the parent
+ * @param name the name
+ * @param isFolder the is folder
* @param childrenSize the children size
- * @param fullPath the full path
+ * @param fullPath the full path
*/
- public ResourceElementBean(
- ResourceElementBean parent,
- String name,
- boolean isFolder,
- Integer childrenSize,
+ public ResourceElementBean(ResourceElementBean parent, String name, boolean isFolder, Integer childrenSize,
String fullPath) {
this.identifierGWT = nextId;
nextId++;
@@ -131,22 +131,20 @@ public class ResourceElementBean implements Comparable, Ser
/**
* Instantiates a new resource element bean.
*
- * @param name the name
- * @param toBeAdded the to be added
- * @param isFolder the is folder
- * @param parent the parent
- * @param childrenSize the children size
- * @param fullPath the full path
- * @param originalIdInWorkspace the original id in workspace
- * @param mimeType the mime type
- * @param url the url
- * @param description the description
+ * @param name the name
+ * @param toBeAdded the to be added
+ * @param isFolder the is folder
+ * @param parent the parent
+ * @param childrenSize the children size
+ * @param fullPath the full path
+ * @param originalIdInWorkspace the original id in workspace
+ * @param mimeType the mime type
+ * @param url the url
+ * @param description the description
* @param organizationNameDatasetParent the organization name dataset parent
*/
- public ResourceElementBean(String name, boolean toBeAdded,
- boolean isFolder, ResourceElementBean parent,
- Integer childrenSize, String fullPath,
- String originalIdInWorkspace, String mimeType, String url,
+ public ResourceElementBean(String name, boolean toBeAdded, boolean isFolder, ResourceElementBean parent,
+ Integer childrenSize, String fullPath, String originalIdInWorkspace, String mimeType, String url,
String description, String organizationNameDatasetParent) {
super();
this.identifierGWT = nextId;
@@ -164,6 +162,33 @@ public class ResourceElementBean implements Comparable, Ser
this.organizationNameDatasetParent = organizationNameDatasetParent;
}
+ /**
+ * Gets the bean ID.
+ *
+ * @return the bean ID
+ */
+ public int getBeanID() {
+ 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.
*
@@ -286,8 +311,7 @@ public class ResourceElementBean implements Comparable, Ser
*
* @param organizationNameDatasetParent the new organization name dataset parent
*/
- public void setOrganizationNameDatasetParent(
- String organizationNameDatasetParent) {
+ public void setOrganizationNameDatasetParent(String organizationNameDatasetParent) {
this.organizationNameDatasetParent = organizationNameDatasetParent;
}
@@ -380,7 +404,7 @@ public class ResourceElementBean implements Comparable, Ser
public void setEditableName(String newName) {
this.editableName = newName;
}
-
+
/**
* Gets the to publish.
*
@@ -409,7 +433,7 @@ public class ResourceElementBean implements Comparable, Ser
public boolean equals(Object o) {
boolean toReturn = false;
if (o instanceof ResourceElementBean) {
- toReturn = identifierGWT == ((ResourceElementBean) o).identifierGWT;
+ toReturn = identifierGWT == ((ResourceElementBean) o).identifierGWT;
}
return toReturn;
@@ -426,16 +450,33 @@ public class ResourceElementBean implements Comparable, Ser
int toReturn = (o == null || o.fullPath == null) ? -1 : -o.fullPath.compareTo(fullPath);
return toReturn;
}
-
-
+
+ /**
+ * Gets the root id in workspace.
+ *
+ * @return the root id in workspace
+ */
public String getRootIdInWorkspace() {
return rootIdInWorkspace;
}
+ /**
+ * Sets the root id in workspace.
+ *
+ * @param rootIdInWorkspace the new root id in workspace
+ */
public void setRootIdInWorkspace(String rootIdInWorkspace) {
this.rootIdInWorkspace = rootIdInWorkspace;
}
+ public void setCkanDatasetId(String packageId) {
+ this.ckanDatasetId = packageId;
+ }
+
+ public String getCkanDatasetId() {
+ return ckanDatasetId;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -461,16 +502,16 @@ public class ResourceElementBean implements Comparable, Ser
builder.append(description);
builder.append(", organizationNameDatasetParent=");
builder.append(organizationNameDatasetParent);
- builder.append(", childrenSize=");
- builder.append(childrenSize);
builder.append(", toPublish=");
builder.append(toPublish);
+ builder.append(", identifierGWT=");
+ builder.append(identifierGWT);
+ builder.append(", ckanResourceID=");
+ builder.append(ckanResourceID);
+ builder.append(", ckanDatasetId=");
+ builder.append(ckanDatasetId);
builder.append("]");
return builder.toString();
}
-
-
-
-
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/licenses/LicenseBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/licenses/LicenseBean.java
deleted file mode 100644
index 2b368ed..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/licenses/LicenseBean.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.licenses;
-
-import java.io.Serializable;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * A license bean like the ckan's one.
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class LicenseBean implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = -2079275598877326206L;
- private String title;
- private String url;
-
- public LicenseBean() {
- super();
- }
-
- public LicenseBean(String title, String url) {
- super();
- this.title = title;
- this.url = url;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj.getClass().equals(this.getClass()) && ((LicenseBean)obj).getTitle().equals(this.title);
- }
-
- @Override
- public String toString() {
- return "LicenseBean [title=" + title + ", url=" + url + "]";
- }
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/CategoryWrapper.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/CategoryWrapper.java
deleted file mode 100644
index ad42404..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/CategoryWrapper.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-import java.io.Serializable;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * A wrapper for the MetadataCategory class.
- * @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataCategory
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class CategoryWrapper implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = -1949961285656672831L;
- private String id;
- private String title;
- private String description;
- private List fieldsForThisCategory;
-
- public CategoryWrapper() {
- super();
- }
-
- public CategoryWrapper(String id, String title, String description) {
- super();
- this.id = id;
- this.title = title;
- this.description = description;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List getFieldsForThisCategory() {
- return fieldsForThisCategory;
- }
-
- public void setFieldsForThisCategory(
- List fieldsForThisCategory) {
- this.fieldsForThisCategory = fieldsForThisCategory;
- }
-
- @Override
- public String toString() {
- return "CategoryWrapper ["
- + (id != null ? "id=" + id + ", " : "")
- + (title != null ? "title=" + title + ", " : "")
- + (description != null ? "description=" + description + ", "
- : "")
- + (fieldsForThisCategory != null ? "fieldsForThisCategory="
- + fieldsForThisCategory.size() : "") + "]";
- }
-
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/DataTypeWrapper.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/DataTypeWrapper.java
deleted file mode 100644
index 528022f..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/DataTypeWrapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-/**
- * Data type.
- * @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public enum DataTypeWrapper {
-
- String,
- Time,
- Time_Interval,
- Times_ListOf,
- Text,
- Boolean,
- Number,
- GeoJSON;
-
- /**
- * Value as String.
- * @return the string
- */
- public String value() {
- return name();
- }
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsGroup.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsGroup.java
deleted file mode 100644
index 311c745..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsGroup.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- *
- */
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-import java.io.Serializable;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * To be used when a field must be used to create a group.
- * @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataGrouping
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class FieldAsGroup implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = 8096886403417944385L;
- private boolean create;
- private boolean isPropagateUp;
- private TaggingGroupingValue groupingValue;
-
- public FieldAsGroup() {
- super();
- }
-
- public FieldAsGroup(boolean create, TaggingGroupingValue groupingValue, boolean isPropagateUp) {
- this.isPropagateUp = isPropagateUp;
- this.create = create;
- this.groupingValue = groupingValue;
- }
-
- public boolean getCreate() {
- return create;
- }
-
- public void setCreate(Boolean create) {
- this.create = create;
- }
-
- public TaggingGroupingValue getGroupingValue() {
- return groupingValue;
- }
-
- public void setGroupingValue(TaggingGroupingValue groupingValue) {
- this.groupingValue = groupingValue;
- }
-
- public boolean isPropagateUp() {
- return isPropagateUp;
- }
-
- public void setPropagateUp(boolean isPropagateUp) {
- this.isPropagateUp = isPropagateUp;
- }
-
- @Override
- public String toString() {
- return "FieldAsGroup [create=" + create + ", isPropagateUp="
- + isPropagateUp + ", groupingValue=" + groupingValue + "]";
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsTag.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsTag.java
deleted file mode 100644
index 243982b..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/FieldAsTag.java
+++ /dev/null
@@ -1,62 +0,0 @@
-
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-import java.io.Serializable;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * To be used when a field must be used to create a tag.
- * @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataTagging
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class FieldAsTag implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = 5414077853964288094L;
- public static final String DEFAULT_SEPARATOR = "-";
- private boolean create;
- private String separator = DEFAULT_SEPARATOR;
- private TaggingGroupingValue taggingValue;
-
- public FieldAsTag() {
- super();
- }
-
- public FieldAsTag(Boolean create, String separator, TaggingGroupingValue taggingValue) {
- super();
- this.create = create;
- this.separator = separator;
- this.taggingValue = taggingValue;
- }
-
- public boolean isCreate() {
- return create;
- }
-
- public void setCreate(boolean create) {
- this.create = create;
- }
-
- public String getSeparator() {
- return separator;
- }
-
- public void setSeparator(String separator) {
- this.separator = separator;
- }
-
- public TaggingGroupingValue getTaggingValue() {
- return taggingValue;
- }
-
- public void setTaggingValue(TaggingGroupingValue taggingValue) {
- this.taggingValue = taggingValue;
- }
-
- @Override
- public String toString() {
- return "FieldAsTag [create=" + create + ", separator=" + separator
- + ", taggingValue=" + taggingValue + "]";
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetaDataProfileBean.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetaDataProfileBean.java
deleted file mode 100644
index bad04db..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetaDataProfileBean.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-import java.io.Serializable;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * A MetaDataProfileBean with its children (MetaDataType, MetaDataFields, Categories)
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class MetaDataProfileBean implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = -7377022025375553568L;
-
- private String type;
- private String title;
- private List categories;
- private List metadataFields;
-
- public MetaDataProfileBean(){
- super();
- }
- public MetaDataProfileBean(String type,
- String title,
- List metadataFields,
- List categories) {
- super();
- this.type = type;
- this.title = title;
- this.categories = categories;
- this.metadataFields = metadataFields;
- }
-
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
- /**
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
- /**
- * @return the metadataFields
- */
- public List getMetadataFields() {
- return metadataFields;
- }
- /**
- * @param metadataFields the metadataFields to set
- */
- public void setMetadataFields(List metadataFields) {
- this.metadataFields = metadataFields;
- }
-
- public List getCategories() {
- return categories;
- }
-
- public void setCategories(List categories) {
- this.categories = categories;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- @Override
- public String toString() {
- final int maxLen = 10;
- return "MetaDataProfileBean [type="
- + type
- + ", title="
- + title
- + ", categories="
- + (categories != null ? categories.subList(0,
- Math.min(categories.size(), maxLen)) : null)
- + ", metadataFields="
- + (metadataFields != null ? metadataFields.subList(0,
- Math.min(metadataFields.size(), maxLen)) : null) + "]";
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetadataFieldWrapper.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetadataFieldWrapper.java
deleted file mode 100644
index c789a68..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/MetadataFieldWrapper.java
+++ /dev/null
@@ -1,341 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-
-import java.io.Serializable;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.IsSerializable;
-
-/**
- * The Class MetadataFieldWrapper.
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- *
- * @author francesco-mangiacrapa at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public class MetadataFieldWrapper implements Serializable, IsSerializable{
-
- private static final long serialVersionUID = -8476731365884466698L;
- private String fieldName;
- private String fieldNameFromCategory;
- private Boolean mandatory = false;
- private DataTypeWrapper type;
- private String defaultValue;
- private String note;
- private List vocabulary;
- private boolean multiSelection;
- private String validator;
- private CategoryWrapper ownerCategory;
- private FieldAsGroup asGroup;
- private FieldAsTag asTag;
-
- private Integer maxOccurs = 1;
-
- /**
- * Instantiates a new metadata field.
- */
- public MetadataFieldWrapper() {
- super();
- }
-
- /**
- * Instantiates a new metadata field.
- *
- * @param fieldName the field name
- * @param mandatory the mandatory
- * @param type the type
- * @param defaultValue the default value
- * @param note the note
- * @param vocabulary the vocabulary
- * @param validator the validator
- * @param category the category
- */
- public MetadataFieldWrapper(
- String fieldName, Boolean mandatory, DataTypeWrapper type,
- String defaultValue, String note, List vocabulary,
- String validator, CategoryWrapper category) {
- super();
- this.fieldName = fieldName;
- this.mandatory = mandatory;
- this.type = type;
- this.defaultValue = defaultValue;
- this.note = note;
- this.vocabulary = vocabulary;
- this.validator = validator;
- this.ownerCategory = category;
- }
-
-
-
- /**
- * Gets the max occurs.
- *
- * @return the max occurs
- */
- public Integer getMaxOccurs() {
- return maxOccurs;
- }
-
- /**
- * Sets the max occurs.
- *
- * @param maxOccurs the new max occurs
- */
- public void setMaxOccurs(Integer maxOccurs) {
- this.maxOccurs = maxOccurs;
- }
-
- /**
- * Gets the field name.
- *
- * @return the fieldName
- */
- public String getFieldName() {
-
- return fieldName;
- }
-
- /**
- * Gets the mandatory.
- *
- * @return the mandatory
- */
- public Boolean getMandatory() {
-
- return mandatory;
- }
-
- /**
- * Gets the defaul value.
- *
- * @return the defaulValue
- */
- public String getDefaultValue() {
-
- return defaultValue;
- }
-
- /**
- * Gets the note.
- *
- * @return the note
- */
- public String getNote() {
-
- return note;
- }
-
- /**
- * Gets the vocabulary.
- *
- * @return the vocabulary
- */
- public List getVocabulary() {
-
- return vocabulary;
- }
-
- /**
- * Gets the validator.
- *
- * @return the validator
- */
- public String getValidator() {
-
- return validator;
- }
-
- /**
- * Sets the field name.
- *
- * @param fieldName the fieldName to set
- */
- public void setFieldName(String fieldName) {
-
- this.fieldName = fieldName;
- }
-
- /**
- * Sets the mandatory.
- *
- * @param mandatory the mandatory to set
- */
- public void setMandatory(Boolean mandatory) {
-
- this.mandatory = mandatory;
- }
-
- /**
- * Sets the defaul value.
- *
- * @param defaultValue the new default value
- */
- public void setDefaultValue(String defaultValue) {
-
- this.defaultValue = defaultValue;
- }
-
- /**
- * Sets the note.
- *
- * @param note the note to set
- */
- public void setNote(String note) {
-
- this.note = note;
- }
-
- /**
- * Sets the vocabulary.
- *
- * @param vocabulary the vocabulary to set
- */
- public void setVocabulary(List vocabulary) {
-
- this.vocabulary = vocabulary;
- }
-
- /**
- * Sets the validator.
- *
- * @param validator the validator to set
- */
- public void setValidator(String validator) {
-
- this.validator = validator;
- }
-
- /**
- * Gets the type.
- *
- * @return the type
- */
- public DataTypeWrapper getType() {
- return type;
- }
-
- /**
- * Sets the type.
- *
- * @param type the new type
- */
- public void setType(DataTypeWrapper type) {
- this.type = type;
- }
-
- /**
- * Checks if is multi selection.
- *
- * @return true, if is multi selection
- */
- public boolean isMultiSelection() {
- return multiSelection;
- }
-
- /**
- * Sets the multi selection.
- *
- * @param multiSelection the new multi selection
- */
- public void setMultiSelection(boolean multiSelection) {
- this.multiSelection = multiSelection;
- }
-
- /**
- * Gets the owner category.
- *
- * @return the owner category
- */
- public CategoryWrapper getOwnerCategory() {
- return ownerCategory;
- }
-
- /**
- * Sets the owner category.
- *
- * @param ownerCategory the new owner category
- */
- public void setOwnerCategory(CategoryWrapper ownerCategory) {
- this.ownerCategory = ownerCategory;
- }
-
- /**
- * Gets the field name from category.
- *
- * @return the field name from category
- */
- public String getFieldNameFromCategory() {
- return fieldNameFromCategory;
- }
-
- /**
- * Sets the field name from category.
- *
- * @param fieldNameFromCategory the new field name from category
- */
- public void setFieldNameFromCategory(String fieldNameFromCategory) {
- this.fieldNameFromCategory = fieldNameFromCategory;
- }
-
- /**
- * Gets the as group.
- *
- * @return the as group
- */
- public FieldAsGroup getAsGroup() {
- return asGroup;
- }
-
- /**
- * Sets the as group.
- *
- * @param asGroup the new as group
- */
- public void setAsGroup(FieldAsGroup asGroup) {
- this.asGroup = asGroup;
- }
-
- /**
- * Gets the as tag.
- *
- * @return the as tag
- */
- public FieldAsTag getAsTag() {
- return asTag;
- }
-
- /**
- * Sets the as tag.
- *
- * @param asTag the new as tag
- */
- public void setAsTag(FieldAsTag asTag) {
- this.asTag = asTag;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "MetadataFieldWrapper ["
- + (fieldName != null ? "fieldName=" + fieldName + ", " : "")
- + (fieldNameFromCategory != null ? "fieldNameFromCategory="
- + fieldNameFromCategory + ", " : "")
- + (mandatory != null ? "mandatory=" + mandatory + ", " : "")
- + (maxOccurs != null ? "maxOccurs=" + maxOccurs + ", " : "")
- + (type != null ? "type=" + type + ", " : "")
- + (defaultValue != null ? "defaultValue=" + defaultValue + ", "
- : "")
- + (note != null ? "note=" + note + ", " : "")
- + (vocabulary != null ? "vocabulary=" + vocabulary + ", " : "")
- + "multiSelection="
- + multiSelection
- + ", "
- + (validator != null ? "validator=" + validator + ", " : "")
- + (ownerCategory != null ? "ownerCategory=" + ownerCategory.getId()
- + ", " : "")
- + (asGroup != null ? "asGroup=" + asGroup + ", " : "")
- + (asTag != null ? "asTag=" + asTag : "") + "]";
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/TaggingGroupingValue.java b/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/TaggingGroupingValue.java
deleted file mode 100644
index 24de09c..0000000
--- a/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/shared/metadata/TaggingGroupingValue.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata;
-
-import java.util.Arrays;
-import java.util.List;
-
-
-/**
- * Specifies the action to take when a tag or a group must be created from a field.
- * @see org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.TaggingGroupingValue
- * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
- */
-public enum TaggingGroupingValue {
-
- onFieldName,
- onValue,
- onFieldName_onValue,
- onValue_onFieldName;
-
- /**
- * Returns the composed value in case of tag
- * @param name
- * @param value
- * @param separator
- * @param action
- * @return
- */
- public static String getComposedValueTag(String name, String value, String separator, TaggingGroupingValue action){
-
- switch(action){
- case onFieldName:
- return name;
- case onValue:
- return value;
- case onFieldName_onValue:
- return name + separator + value;
- case onValue_onFieldName:
- return value + separator + name;
- default: return null;
- }
-
- }
-
- /**
- * Returns the composed value in case of group
- * @param name
- * @param value
- * @param separator
- * @param action
- * @return a list of group names
- */
- public static List getComposedValueGroup(String name, String value, TaggingGroupingValue action){
-
- switch(action){
- case onFieldName:
- return Arrays.asList(name);
- case onValue:
- return Arrays.asList(value);
- case onFieldName_onValue:
- case onValue_onFieldName:
- return Arrays.asList(value, name);
- default: return null;
- }
-
- }
-
-}
diff --git a/src/main/resources/org/gcube/portlets/widgets/ckandatapublisherwidget/CKanMetadataPublisher.gwt.xml b/src/main/resources/org/gcube/portlets/widgets/ckandatapublisherwidget/CKanMetadataPublisher.gwt.xml
index 55363b4..cf4f3cf 100644
--- a/src/main/resources/org/gcube/portlets/widgets/ckandatapublisherwidget/CKanMetadataPublisher.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/widgets/ckandatapublisherwidget/CKanMetadataPublisher.gwt.xml
@@ -6,17 +6,26 @@
-
-
+
+
-
-
-
-
+
+
-
+
-
+
+
+
+
+
org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl
+
+ metadataProfileFormBuilderUploadServlet
+ org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderUploadServlet
+
+
+
ckanpublisherservices
/CKanMetadataPublisher/ckanservices
@@ -27,6 +33,12 @@
+
+ metadataProfileFormBuilderUploadServlet
+ /CKanMetadataPublisher/metadataProfileFormBuilderUploadServlet
+
+
+
CKanMetadataPublisher.html
diff --git a/src/test/java/org/gcube/portlets/widgets/ckandatapublisherwidget/TestPublishingWidget.java b/src/test/java/org/gcube/portlets/widgets/ckandatapublisherwidget/TestPublishingWidget.java
index 0e85a4e..8963119 100644
--- a/src/test/java/org/gcube/portlets/widgets/ckandatapublisherwidget/TestPublishingWidget.java
+++ b/src/test/java/org/gcube/portlets/widgets/ckandatapublisherwidget/TestPublishingWidget.java
@@ -1,32 +1,35 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget;
-
import java.util.Arrays;
import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory;
+import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
+import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
+import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.WorkspaceUtils;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
import org.junit.Test;
import org.slf4j.LoggerFactory;
-
-
/**
* The Class TestDataCatalogueLib.
*
- * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
- * Jun 1, 2020
+ * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) Jun 1, 2020
*/
public class TestPublishingWidget {
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TestPublishingWidget.class);
private String scope = "/gcube";
- //private String testUser = "costantino_perciante";
+ // private String testUser = "costantino_perciante";
private String testUser = "francesco.mangiacrapa";
private String authorizationToken = "";
@@ -35,23 +38,50 @@ public class TestPublishingWidget {
*
* @throws Exception the exception
*/
- //@Before
- public void before() throws Exception{
+ // @Before
+ public void before() throws Exception {
}
+
+ //@Test
+ public void getDataset() {
+
+ try {
+ scope = "/d4science.research-infrastructures.eu/D4OS/Blue-Cloud2026Project";
+ authorizationToken = "8c3ce374-5482-422d-9542-97b1b9360747-843339462"; //Blue-Cloud2026Project
+
+ ScopeProvider.instance.set(scope);
+ SecurityTokenProvider.instance.set(authorizationToken);
+
+ String datasetId = "blue-cloud_2026_-_a_federated_european_fair_and_open_research_ecosystem_for_oceans_seas_coastal_and";
+
+ DataCatalogueFactory factory = DataCatalogueFactory.getFactory();
+
+ DataCatalogueImpl utils = factory.getUtilsPerScope(scope);
+
+ CkanDataset dataset = utils.getDataset(datasetId, testUser);
+ System.out.println("Dataset: "+dataset);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+ }
+
/**
* Factory test.
*
* @throws Exception the exception
*/
- //@Test
- public void factoryTest() throws Exception{
+ // @Test
+ public void factoryTest() throws Exception {
DataCatalogueFactory factory = DataCatalogueFactory.getFactory();
- while(true){
+ while (true) {
factory.getUtilsPerScope(scope);
- Thread.sleep(60* 1000 * 3);
+ Thread.sleep(60 * 1000 * 3);
factory.getUtilsPerScope(scope);
break;
}
@@ -62,16 +92,16 @@ public class TestPublishingWidget {
}
}
-
- //@Test
- public void getDatasetBeanTest() throws Exception{
+
+ // @Test
+ public void getDatasetBeanTest() throws Exception {
ScopeProvider.instance.set(scope);
String userName = testUser;
String token = authorizationToken;
-
+
String folderId = "6399daa7-2173-4314-b4f7-2afa24eae8f8";
DatasetBean bean;
- try{
+ try {
bean = new DatasetBean();
bean.setId(folderId);
bean.setDescription("This is a fantastic description");
@@ -84,24 +114,41 @@ public class TestPublishingWidget {
bean.setMaintainer("Francesco Mangiacrapa");
bean.setMaintainerEmail("francesco.mangiacrapa@isti.cnr.it");
- //UPDATED By Francesco
- String vreName = scope.substring(scope.lastIndexOf("/")+1,scope.length());
- LOG.debug("In dev mode using the scope: "+scope+" and VRE name: "+vreName);
+ // UPDATED By Francesco
+ String vreName = scope.substring(scope.lastIndexOf("/") + 1, scope.length());
+ LOG.debug("In dev mode using the scope: " + scope + " and VRE name: " + vreName);
bean.setOrganizationList(Arrays.asList(new OrganizationBean(vreName, vreName.toLowerCase(), true)));
bean.setOwnerIdentifier(userName);
- if(folderId != null && !folderId.isEmpty()){
+ if (folderId != null && !folderId.isEmpty()) {
StorageHubWrapper storageHubWrapper = new StorageHubWrapper(scope, token, false, false, true);
WorkspaceUtils.toWorkspaceResource(folderId, userName, bean, storageHubWrapper.getWorkspace());
}
- }catch(Exception e){
+ } catch (Exception e) {
LOG.error("Error while building bean into dev mode", e);
throw new Exception("Error while retrieving basic information " + e.getMessage());
}
-
- LOG.info("Got dataset: "+bean);
+
+ LOG.info("Got dataset: " + bean);
}
+ //@Test
+ public void extrasManage() {
+ Map> extras = new HashMap>();
+
+ extras.put("ciao", Arrays.asList("ciao value"));
+ extras.put(CKANPublisherServicesImpl.NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES.get(0), Arrays.asList("rem value 1"));
+ extras.put(CKANPublisherServicesImpl.NOT_UPGRADABLE_CUSTOM_FIELDS_PREFIXES.get(1), Arrays.asList("rem value 2"));
+ extras.put(CKANPublisherServicesImpl.SYS_TYPE, Arrays.asList("ciao value"));
+ extras.put("ultimo value", Arrays.asList("ultimo value"));
+
+ Map> pop = CKANPublisherServicesImpl.purgeSystemFields(extras);
+ System.out.println("POP: " + pop);
+
+ Map> push = CKANPublisherServicesImpl.getReserverdSystemFields(extras);
+ System.out.println("PUSH: " + push);
+ }
+
}