Resources selected from workspace are now copied just before dataset creation. Added support for new metadata reader library and types. When the act of publishing starts from ws, the resource table is always shown.

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@131303 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-12 15:58:50 +00:00
parent 43bd1566c8
commit 73c34f634c
16 changed files with 320 additions and 266 deletions

View File

@ -20,6 +20,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="${webappDirectory}/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="${webappDirectory}/WEB-INF/classes" path="src/main/resources">

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
@ -17,9 +18,11 @@ public class CKanMetadataPublisher implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
// remove comment to the below line for testing the widget // remove comment to the below line for testing the widget
//startExample(); startExample();
} }
private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void startExample() { private void startExample() {
@ -27,7 +30,7 @@ public class CKanMetadataPublisher implements EntryPoint {
String idFolderWorkspace = "d3a37eb9-1589-4c95-a9d0-c473a02d4f0f"; String idFolderWorkspace = "d3a37eb9-1589-4c95-a9d0-c473a02d4f0f";
String owner = "costantino.perciante"; String owner = "costantino.perciante";
HandlerManager eventBus = new HandlerManager(null); HandlerManager eventBus = new HandlerManager(null);
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(idFolderWorkspace ,owner, eventBus )); RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(idFolderWorkspace ,owner, eventBus));
} }
} }

View File

@ -33,10 +33,9 @@ public interface CKanPublisherService extends RemoteService {
/** /**
* Retrieve a partially filled bean given a folder id and its owner. * Retrieve a partially filled bean given a folder id and its owner.
* @param folderId * @param folderId
* @param owner
* @return @return a DatasetMetadataBean on success, <b>null</b> on error. * @return @return a DatasetMetadataBean on success, <b>null</b> on error.
*/ */
DatasetMetadataBean getDatasetBean(String folderId, String owner); DatasetMetadataBean getDatasetBean(String folderId);
/** /**
* Try to create such dataset starting from the information contained into the toCreate bean. * Try to create such dataset starting from the information contained into the toCreate bean.
@ -50,17 +49,15 @@ public interface CKanPublisherService extends RemoteService {
* Add this resource to the dataset whose id is datasetId * Add this resource to the dataset whose id is datasetId
* @param resource * @param resource
* @param datasetId * @param datasetId
* @param owner of the dataset
*/ */
ResourceBeanWrapper addResourceToDataset(ResourceBeanWrapper resource, String datasetId, String owner); ResourceBeanWrapper addResourceToDataset(ResourceBeanWrapper resource, String datasetId);
/** /**
* Delete this resource from the dataset with id datasetId * Delete this resource from the dataset with id datasetId
* @param resource * @param resource
* @param datasetId * @param datasetId
* @param owner of the dataset
* @return <b>true</b> on success, false otherwise * @return <b>true</b> on success, false otherwise
*/ */
boolean deleteResourceFromDataset(ResourceBeanWrapper resource, String owner); boolean deleteResourceFromDataset(ResourceBeanWrapper resource);
} }

View File

@ -25,10 +25,9 @@ public interface CKanPublisherServiceAsync {
/** /**
* Retrieve a partially filled bean given a folder id and its owner. * Retrieve a partially filled bean given a folder id and its owner.
* @param folderId * @param folderId
* @param owner
* @return @return a DatasetMetadataBean on success, <b>null</b> on error. * @return @return a DatasetMetadataBean on success, <b>null</b> on error.
*/ */
void getDatasetBean(String folderId, String owner, void getDatasetBean(String folderId,
AsyncCallback<DatasetMetadataBean> callback); AsyncCallback<DatasetMetadataBean> callback);
/** /**
@ -44,20 +43,17 @@ public interface CKanPublisherServiceAsync {
* Add this resource to the dataset whose id is datasetId * Add this resource to the dataset whose id is datasetId
* @param resource * @param resource
* @param datasetId * @param datasetId
* @param owner of the dataset
* @param callback * @param callback
*/ */
void addResourceToDataset(ResourceBeanWrapper resource, String datasetId, String owner, void addResourceToDataset(ResourceBeanWrapper resource, String datasetId,
AsyncCallback<ResourceBeanWrapper> callback); AsyncCallback<ResourceBeanWrapper> callback);
/** /**
* Delete this resource from the dataset with id datasetId * Delete this resource from the dataset with id datasetId
* @param resource * @param resource
* @param owner of the dataset
* @return <b>true</b> on success, false otherwise * @return <b>true</b> on success, false otherwise
*/ */
void deleteResourceFromDataset(ResourceBeanWrapper resource, void deleteResourceFromDataset(ResourceBeanWrapper resource, AsyncCallback<Boolean> callback);
String owner, AsyncCallback<Boolean> callback);
/** /**
* Retrieve the list of profiles for a given organization name . * Retrieve the list of profiles for a given organization name .

View File

@ -45,10 +45,6 @@ public class AddResourceToDataset extends Composite{
// the dataset organization // the dataset organization
private String datasetOrg; private String datasetOrg;
// the owner
private String owner;
//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 = GWT.create(CKanPublisherService.class);
@UiField TextBox resourceUrlTextBox; @UiField TextBox resourceUrlTextBox;
@ -69,9 +65,6 @@ public class AddResourceToDataset extends Composite{
this.datasetOrg = datasetOrg; this.datasetOrg = datasetOrg;
// the owner of the dataset/files
this.owner = owner;
goToDatasetButton.addClickHandler(new ClickHandler() { goToDatasetButton.addClickHandler(new ClickHandler() {
@Override @Override
@ -103,14 +96,13 @@ public class AddResourceToDataset extends Composite{
null, null,
true, true,
null, null,
owner,
datasetOrg); datasetOrg);
// disable add button // disable add button
addResourceButton.setEnabled(false); addResourceButton.setEnabled(false);
// try to create // try to create
ckanServices.addResourceToDataset(resource, datasetId, owner, new AsyncCallback<ResourceBeanWrapper>() { ckanServices.addResourceToDataset(resource, datasetId, new AsyncCallback<ResourceBeanWrapper>() {
@Override @Override
public void onSuccess(ResourceBeanWrapper result) { public void onSuccess(ResourceBeanWrapper result) {

View File

@ -48,20 +48,14 @@ public class AddedResourcesSummary extends Composite{
// list of added resources (beans) // list of added resources (beans)
List<ResourceBeanWrapper> addedResources; List<ResourceBeanWrapper> addedResources;
// the owner
private String owner;
@UiField VerticalPanel addResourcesPanel; @UiField VerticalPanel addResourcesPanel;
public AddedResourcesSummary(HandlerManager eventBus, String owner) { public AddedResourcesSummary(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
// save bus // save bus
this.eventBus = eventBus; this.eventBus = eventBus;
// save owner
this.owner = owner;
// bind on add resource event // bind on add resource event
bind(); bind();
@ -139,7 +133,7 @@ public class AddedResourcesSummary extends Composite{
final Widget widget = addResourcesPanel.getWidget(i); final Widget widget = addResourcesPanel.getWidget(i);
// remote call to remove it from the dataset // remote call to remove it from the dataset
ckanServices.deleteResourceFromDataset(toDelete, owner, new AsyncCallback<Boolean>() { ckanServices.deleteResourceFromDataset(toDelete, new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {

View File

@ -115,12 +115,11 @@ public class CreateDatasetForm extends Composite{
@UiField Form formSecondStep; @UiField Form formSecondStep;
@UiField Form formThirdStep; @UiField Form formThirdStep;
@UiField Button continueButton; @UiField Button continueButton;
@UiField Button goBackButtonFirstOrSecondStep; @UiField Button goBackButtonSecondStep;
@UiField Paragraph selectedProfile; @UiField Paragraph selectedProfile;
@UiField Button goToDatasetButton; @UiField Button goToDatasetButton;
@UiField Button addResourcesButton; @UiField Button addResourcesButton;
@UiField CheckBox addResourcesCheckBox; @UiField CheckBox addResourcesCheckBox;
@UiField ControlGroup resourcesControlGroup;
@UiField SimplePanel workspaceResourcesContainer; @UiField SimplePanel workspaceResourcesContainer;
@UiField Button continueThirdStep; @UiField Button continueThirdStep;
@UiField Button goBackButtonFirstStep; @UiField Button goBackButtonFirstStep;
@ -213,7 +212,7 @@ public class CreateDatasetForm extends Composite{
} }
/** /**
* Invoked when the workspace is used. * Invoked when the workspace is used
* @param idFolderWorkspace * @param idFolderWorkspace
* @param owner * @param owner
*/ */
@ -257,7 +256,7 @@ public class CreateDatasetForm extends Composite{
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true); setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
// get back the licenses and the metadata information // get back the licenses and the metadata information
ckanServices.getDatasetBean(idFolderWorkspace, owner, new AsyncCallback<DatasetMetadataBean>() { ckanServices.getDatasetBean(idFolderWorkspace, new AsyncCallback<DatasetMetadataBean>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -313,16 +312,15 @@ public class CreateDatasetForm extends Composite{
if(isWorkspaceRequest){ if(isWorkspaceRequest){
// enable manage resources checkbox // enable manage resources checkbox
resourcesControlGroup.setVisible(true);
addResourcesCheckBox.getElement().getStyle().setDisplay(Display.INLINE_BLOCK); addResourcesCheckBox.getElement().getStyle().setDisplay(Display.INLINE_BLOCK);
resourcesTable = new ResourcesTable(bean.getResources()); resourcesTable = new ResourcesTable(bean.getResources());
// if there are not resources, for now just checked it ( and hide so that the step will be skipped) TODO // if there are not resources, for now just checked it ( and hide so that the step will be skipped) TODO
if(bean.getResources() == null || bean.getResources().isEmpty()){ if(bean.getResources() == null || bean.getResources().isEmpty()){
resourcesControlGroup.setVisible(false);
alertNoResources.setType(AlertType.WARNING); alertNoResources.setType(AlertType.WARNING);
alertNoResources.setVisible(true); alertNoResources.setVisible(true);
} }
} }
@ -605,7 +603,6 @@ public class CreateDatasetForm extends Composite{
if(errorMsg == null){ if(errorMsg == null){
// check what to do // check what to do
if(isWorkspaceRequest){ if(isWorkspaceRequest){
if(!addResourcesCheckBox.getValue()){
// we need to show the page to handle resources one by one from the workspace // we need to show the page to handle resources one by one from the workspace
formFirstStep.setVisible(false); formFirstStep.setVisible(false);
@ -616,12 +613,6 @@ public class CreateDatasetForm extends Composite{
if(workspaceResourcesContainer.getWidget() == null) if(workspaceResourcesContainer.getWidget() == null)
workspaceResourcesContainer.add(resourcesTable); workspaceResourcesContainer.add(resourcesTable);
}else{
// resources will be added automatically and we can show the page of the profiles
formFirstStep.setVisible(false);
formThirdStep.setVisible(true);
}
}else{ }else{
// this is not a workspace request // this is not a workspace request
@ -653,11 +644,11 @@ public class CreateDatasetForm extends Composite{
} }
@UiHandler("goBackButtonFirstOrSecondStep") @UiHandler("goBackButtonSecondStep")
void onGoBackButton(ClickEvent e){ void onGoBackButton(ClickEvent e){
// swap forms // swap forms
if(isWorkspaceRequest && !addResourcesCheckBox.getValue()){ if(isWorkspaceRequest){
formFirstStep.setVisible(false); formFirstStep.setVisible(false);
formSecondStep.setVisible(true); formSecondStep.setVisible(true);
}else{ }else{
@ -748,7 +739,7 @@ public class CreateDatasetForm extends Composite{
// invoke the create method // invoke the create method
createButton.setEnabled(false); createButton.setEnabled(false);
goBackButtonFirstOrSecondStep.setEnabled(false); goBackButtonSecondStep.setEnabled(false);
ckanServices.createCKanDataset(receivedBean, isWorkspaceRequest, new AsyncCallback<DatasetMetadataBean>() { ckanServices.createCKanDataset(receivedBean, isWorkspaceRequest, new AsyncCallback<DatasetMetadataBean>() {
@ -817,7 +808,7 @@ public class CreateDatasetForm extends Composite{
// tab for the added resources // tab for the added resources
Tab addedResources = new Tab(); Tab addedResources = new Tab();
addedResources.add(new AddedResourcesSummary(eventBus, owner)); addedResources.add(new AddedResourcesSummary(eventBus));
addedResources.setHeading("Added Resource"); addedResources.setHeading("Added Resource");
tabPanel.add(addedResources); tabPanel.add(addedResources);
@ -1011,7 +1002,7 @@ public class CreateDatasetForm extends Composite{
onCreateAlertBlock.setType(type); onCreateAlertBlock.setType(type);
onCreateAlertBlock.setVisible(true); onCreateAlertBlock.setVisible(true);
createButton.setEnabled(true); createButton.setEnabled(true);
goBackButtonFirstOrSecondStep.setEnabled(true); goBackButtonSecondStep.setEnabled(true);
// hide after some seconds // hide after some seconds
Timer t = new Timer() { Timer t = new Timer() {

View File

@ -271,30 +271,6 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<!-- If the user checks this box, the resources will be automatically
added, otherwise he has to manage them -->
<b:ControlGroup ui:field="resourcesControlGroup"
visible="false">
<b:ControlLabel for="resourcesAddCheckBox"
title="Automatically add all resources to product">Product
Resources:</b:ControlLabel>
<b:Controls>
<b:CheckBox b:id="resourcesAddCheckBox" width="60%"
title="Automatically add the folder content to the product as resource"
checked="true" ui:field="addResourcesCheckBox">
<b>Add folder content as resources</b>
</b:CheckBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverResources" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelResources">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconResources" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<!-- Alert block on continue --> <!-- Alert block on continue -->
<b:AlertBlock animation="true" visible="false" <b:AlertBlock animation="true" visible="false"
ui:field="alertNoResources" ui:field="alertNoResources"
@ -320,6 +296,30 @@
<b:Legend styleName="{style.legend-style}"> <b:Legend styleName="{style.legend-style}">
Manage Resources Manage Resources
</b:Legend> </b:Legend>
<!-- If the user checks this box, the resources will be automatically
added, otherwise he has to manage them -->
<b:ControlGroup>
<b:ControlLabel for="resourcesAddCheckBox"
title="Automatically add all resources to product">Product
Resources:</b:ControlLabel>
<b:Controls>
<b:CheckBox b:id="resourcesAddCheckBox" width="60%"
title="Automatically add the folder content to the product as resource"
checked="true" ui:field="addResourcesCheckBox">
<b>Add folder content as resources</b>
</b:CheckBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverResources" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelResources">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconResources" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<g:SimplePanel ui:field="workspaceResourcesContainer" <g:SimplePanel ui:field="workspaceResourcesContainer"
visible="true"></g:SimplePanel> visible="true"></g:SimplePanel>
@ -381,7 +381,7 @@
<b:Button title="Create product" ui:field="createButton" <b:Button title="Create product" ui:field="createButton"
type="PRIMARY" block="true">Create</b:Button> type="PRIMARY" block="true">Create</b:Button>
<b:Button title="Go Back" ui:field="goBackButtonFirstOrSecondStep" <b:Button title="Go Back" ui:field="goBackButtonSecondStep"
block="true">Go block="true">Go
Back</b:Button> Back</b:Button>

View File

@ -13,7 +13,9 @@ import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.Icon; import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Popover; 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.TextBox;
import com.github.gwtbootstrap.datetimepicker.client.ui.DateTimeBox;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.SpanElement;
@ -53,7 +55,7 @@ public class MetaDataFieldSkeleton extends Composite{
@UiField Icon infoIcon; @UiField Icon infoIcon;
@UiField FocusPanel focusPanelIconContainer; @UiField FocusPanel focusPanelIconContainer;
// the element that holds the value (it could be a checkbox, textbox or listbox) // the element that holds the value (it could be a checkbox, textbox or listbox, textarea, calendar)
private Widget holder; private Widget holder;
// the field this object represents // the field this object represents
@ -61,8 +63,8 @@ public class MetaDataFieldSkeleton extends Composite{
// the dialog box for this metadata // the dialog box for this metadata
private GcubeDialogExtended dialog; private GcubeDialogExtended dialog;
// save event bus referene // save event bus reference
private HandlerManager eventBus; private HandlerManager eventBus;
public MetaDataFieldSkeleton(MetadataFieldWrapper field, HandlerManager eventBus) { public MetaDataFieldSkeleton(MetadataFieldWrapper field, HandlerManager eventBus) {
@ -70,10 +72,10 @@ public class MetaDataFieldSkeleton extends Composite{
// prepare information // prepare information
this.field = field; this.field = field;
// event bus // event bus
this.eventBus = eventBus; this.eventBus = eventBus;
// bind // bind
bind(); bind();
@ -88,18 +90,47 @@ public class MetaDataFieldSkeleton extends Composite{
if(!field.getMandatory()) if(!field.getMandatory())
mandatorySymbol.getStyle().setDisplay(Display.NONE); mandatorySymbol.getStyle().setDisplay(Display.NONE);
if(field.getIsBoolean()){ switch(field.getType()){
case Boolean :
// its a checkbox // its a checkbox
holder = new CheckBox(); holder = new CheckBox();
if(field.getDefaulValue() != null) if(field.getDefaulValue() != null)
((CheckBox)holder).setValue(Boolean.valueOf(field.getDefaulValue())); ((CheckBox)holder).setValue(Boolean.valueOf(field.getDefaulValue()));
break;
// add to the elementPanel case Text:
elementPanel.add(holder);
}else{ holder = new TextArea();
if(field.getDefaulValue() != null)
((TextArea)holder).setText(field.getDefaulValue());
break;
case Date:
holder = new DateTimeBox();
if(field.getDefaulValue() != null)
((DateTimeBox)holder).setFormat(field.getValidator());
else // the default one
((DateTimeBox)holder).setFormat("yyyy/mm/dd hh:ii");
break;
case Number:
holder = new TextBox();
if(field.getDefaulValue() != null)
((TextBox)holder).setText(field.getDefaulValue());
break;
case String:
// it could be a listbox or a textbox according to the vocabulary fields // it could be a listbox or a textbox according to the vocabulary fields
if(field.getVocabulary() == null || field.getVocabulary().isEmpty()){ if(field.getVocabulary() == null || field.getVocabulary().isEmpty()){
@ -110,10 +141,6 @@ public class MetaDataFieldSkeleton extends Composite{
if(field.getDefaulValue() != null) if(field.getDefaulValue() != null)
((TextBox)holder).setText(field.getDefaulValue()); ((TextBox)holder).setText(field.getDefaulValue());
// add to the elementPanel
elementPanel.add(holder);
}else{ }else{
// listbox // listbox
@ -138,16 +165,21 @@ public class MetaDataFieldSkeleton extends Composite{
// set default value // set default value
if(field.getDefaulValue() != null) if(field.getDefaulValue() != null)
((ListBox)holder).setSelectedValue(field.getDefaulValue()); ((ListBox)holder).setSelectedValue(field.getDefaulValue());
// check if multiple selection is allowed TODO
boolean isMultipleSelection = false; //field.isMultipleSelection();
((ListBox)holder).setMultipleSelect(isMultipleSelection);
// add to the elementPanel // check if multiple selection is allowed
elementPanel.add(holder); ((ListBox)holder).setMultipleSelect(field.isMultiSelection());
} }
break;
default: return;
} }
// add to the elementPanel
elementPanel.add(holder);
// set holder width // set holder width
if(holder.getClass().equals(ListBox.class)) if(holder.getClass().equals(ListBox.class))
holder.setWidth("96%"); holder.setWidth("96%");
@ -183,19 +215,19 @@ public class MetaDataFieldSkeleton extends Composite{
* Bind on events * Bind on events
*/ */
private void bind() { private void bind() {
// on close form // on close form
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() { eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
@Override @Override
public void onClose(CloseCreationFormEvent event) { public void onClose(CloseCreationFormEvent event) {
if(dialog != null) if(dialog != null)
dialog.hide(); dialog.hide();
} }
}); });
} }
@UiHandler("focusPanelIconContainer") @UiHandler("focusPanelIconContainer")
@ -268,16 +300,16 @@ public class MetaDataFieldSkeleton extends Composite{
// we validate only listbox and textbox // we validate only listbox and textbox
if(holder.getClass().equals(ListBox.class)){ if(holder.getClass().equals(ListBox.class)){
boolean first = true; boolean first = true;
for(int i = 0; i < ((ListBox)holder).getItemCount(); i++){ for(int i = 0; i < ((ListBox)holder).getItemCount(); i++){
if(((ListBox)holder).isItemSelected(i)){ if(((ListBox)holder).isItemSelected(i)){
value += first ? ((ListBox)holder).getItemText(i) : ", " + ((ListBox)holder).getItemText(i); value += first ? ((ListBox)holder).getItemText(i) : ", " + ((ListBox)holder).getItemText(i);
first = false; first = false;
} }
} }
// if it was not mandatory but there was no choice, returning empty string // if it was not mandatory but there was no choice, returning empty string
if(!field.getMandatory()) if(!field.getMandatory())
if(value.equals("Select " + field.getFieldName())) if(value.equals("Select " + field.getFieldName()))

View File

@ -1,6 +1,7 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:b2="urn:import:com.github.gwtbootstrap.datetimepicker.client.ui">
<ui:style> <ui:style>
.note-container { .note-container {

View File

@ -12,10 +12,11 @@ import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.catalogue.WorkspaceCatalogue;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils; import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
import org.gcube.datacatalogue.ckanutillibrary.CkanUtilsFactory; import org.gcube.datacatalogue.ckanutillibrary.CkanUtilsFactory;
import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean; import org.gcube.datacatalogue.ckanutillibrary.models.ResourceBean;
import org.gcube.datacatalogue.ckanutillibrary.utils.ApplicationProfileScopePerUrlReader;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService; import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.Utils; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.Utils;
@ -53,8 +54,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
private static final String CKAN_LICENSES_KEY = "ckanLicenses"; // licenses private static final String CKAN_LICENSES_KEY = "ckanLicenses"; // licenses
private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish private static final String CKAN_ORGANIZATIONS_PUBLISH_KEY = "ckanOrganizationsPublish"; // here he can publish
private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles private static final String CKAN_PROFILES_KEY = "ckanProfiles"; // product profiles
private final static String CLIENT_PORTLET_URL = "currentClientUrlPortlet"; // set by the ckan portlet in session according private final static String SCOPE_CLIENT_PORTLET_URL = "currentClientUrlPortletScope"; // set by the ckan portlet in session according the user's current url location
// the user's current url location
/** /**
* Retrieve an instance of the library for the scope * Retrieve an instance of the library for the scope
@ -96,7 +96,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
*/ */
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = TEST_USER; String user = TEST_USER;
//user = "costantino.perciante"; user = "costantino.perciante";
return user; return user;
} }
@ -204,25 +204,22 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
* @return * @return
*/ */
private String findLicenseIdByLicense(String chosenLicense) { private String findLicenseIdByLicense(String chosenLicense) {
return getCkanUtilsObj(null).findLicenseIdByLicense(chosenLicense); String scope = (String)getThreadLocalRequest().getSession().getAttribute(SCOPE_CLIENT_PORTLET_URL);
return getCkanUtilsObj(scope).findLicenseIdByLicenseTitle(chosenLicense);
} }
@Override @Override
// TODO this method will be changed because the list of license can vary according the scope
public LicensesBean getLicenses() { public LicensesBean getLicenses() {
logger.info("Request for CKAN licenses for scope ");
ASLSession session = getASLSession(); ASLSession session = getASLSession();
String username = session.getUsername(); String username = session.getUsername();
logger.debug("User in session is " + username);
// get http session // get http session
HttpSession httpSession = getThreadLocalRequest().getSession(); HttpSession httpSession = getThreadLocalRequest().getSession();
String currentUrl = (String)httpSession.getAttribute(CLIENT_PORTLET_URL); String scope = (String)httpSession.getAttribute(SCOPE_CLIENT_PORTLET_URL);
logger.info("Request for CKAN licenses for scope " + scope);
String scope = new ApplicationProfileScopePerUrlReader().getScopePerUrl(currentUrl);
// get key per scope // get key per scope
String keyPerScope = Utils.concatenateSessionKeyScope(CKAN_LICENSES_KEY, scope); String keyPerScope = Utils.concatenateSessionKeyScope(CKAN_LICENSES_KEY, scope);
@ -237,7 +234,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
List<String> urls = new ArrayList<String>(); List<String> urls = new ArrayList<String>();
for (CkanLicense license : titlesLicenses) { for (CkanLicense license : titlesLicenses) {
titles.add(license.getTitle()); titles.add(license.getTitle());
String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : ""; String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : "";
urls.add(url); urls.add(url);
} }
@ -250,76 +246,54 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
@Override @Override
public DatasetMetadataBean getDatasetBean(String folderId, String owner){ public DatasetMetadataBean getDatasetBean(String folderId){
DatasetMetadataBean bean = null; DatasetMetadataBean bean = null;
logger.info("DatasetBean request for " + folderId + " and " + owner);
ASLSession aslSession = getASLSession(); ASLSession aslSession = getASLSession();
String user = aslSession.getUsername(); String userName = aslSession.getUsername();
logger.info("DatasetBean request for " + folderId + " and " + userName);
HttpSession httpSession = this.getThreadLocalRequest().getSession(); HttpSession httpSession = this.getThreadLocalRequest().getSession();
String currentUrl = (String)httpSession.getAttribute(CLIENT_PORTLET_URL); String scope = (String)httpSession.getAttribute(SCOPE_CLIENT_PORTLET_URL);
String scope = new ApplicationProfileScopePerUrlReader().getScopePerUrl(currentUrl);
logger.debug("Scope recovered from session is " + scope);
if(isWithinPortal()){ if(isWithinPortal()){
try{ try{
// check if session expired // check if session expired
if(user.equals(TEST_USER)){ if(userName.equals(TEST_USER)){
logger.debug("SESSION EXPIRED"); logger.debug("SESSION EXPIRED");
return null; return null;
} }
logger.debug("Request dataset metadata bean for folder with id " + folderId logger.debug("Request dataset metadata bean for folder with id " + folderId
+ " whose owner is " + owner); + " whose owner is " + userName);
// get usermanager (liferay) // get usermanager (liferay)
UserManager liferUserManager = new LiferayUserManager(); UserManager liferUserManager = new LiferayUserManager();
GCubeUser userOwner = liferUserManager.getUserByUsername(owner); GCubeUser userOwner = liferUserManager.getUserByUsername(userName);
// build bean // build bean
logger.debug("Building bean"); logger.debug("Building bean");
bean = new DatasetMetadataBean(); bean = new DatasetMetadataBean();
bean.setId(folderId); bean.setId(folderId);
bean.setOwnerIdentifier(owner); bean.setOwnerIdentifier(userName);
bean.setVersion(1); bean.setVersion(1);
bean.setAuthorName(userOwner.getFirstName()); bean.setAuthorName(userOwner.getFirstName());
bean.setAuthorSurname(userOwner.getLastName()); bean.setAuthorSurname(userOwner.getLastName());
bean.setAuthorEmail(userOwner.getEmail()); bean.setAuthorEmail(userOwner.getEmail());
bean.setMaintainer(userOwner.getFullname()); bean.setMaintainer(userOwner.getFullname());
bean.setMaintainerEmail(userOwner.getEmail()); bean.setMaintainerEmail(userOwner.getEmail());
bean.setOrganizationList(getUserOrganizationsListAdmin(owner, scope)); bean.setOrganizationList(getUserOrganizationsListAdmin(userName, scope));
// if the request comes from the workspace // if the request comes from the workspace
if(folderId != null && !folderId.isEmpty()){ if(folderId != null && !folderId.isEmpty()){
Workspace ws = HomeLibrary handleWorkspaceResources(folderId, userName, bean);
.getHomeManagerFactory()
.getHomeManager()
.getHome(owner).getWorkspace();
WorkspaceItem retrievedItem = ws.getItem(folderId);
// set some info
String onlyAlphanumeric = retrievedItem.getName().replaceAll("[^A-Za-z0-9]", "");
bean.setTitle(onlyAlphanumeric);
bean.setDescription(retrievedItem.getDescription());
// retrieve gcube items of the folder
Map<String, String> folderItems = Utils.getGcubeItemProperties(retrievedItem);
bean.setCustomFields(folderItems);
// check the resources within the folder (skip subdirectories)
List<String> childrenIds = new ArrayList<String>();
for (WorkspaceItem file : retrievedItem.getChildren()) {
if(!file.isFolder()) // ok, it's a file
childrenIds.add(file.getId());
}
List<ResourceBeanWrapper> listOfResources = Utils.getWorkspaceResourcesInformation(childrenIds, ws, user);
bean.setResources(listOfResources);
} }
}catch(Exception e){ }catch(Exception e){
@ -340,31 +314,13 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean.setAuthorEmail("costantino.perciante@isti.cnr.it"); bean.setAuthorEmail("costantino.perciante@isti.cnr.it");
bean.setMaintainer("Costantino Perciante"); bean.setMaintainer("Costantino Perciante");
bean.setMaintainerEmail("costantino.perciante@isti.cnr.it"); bean.setMaintainerEmail("costantino.perciante@isti.cnr.it");
bean.setOrganizationList(getUserOrganizationsListAdmin(owner, TEST_SCOPE)); bean.setOrganizationList(getUserOrganizationsListAdmin(userName, TEST_SCOPE));
bean.setOwnerIdentifier(owner); bean.setOwnerIdentifier(userName);
if(folderId != null && !folderId.isEmpty()){ if(folderId != null && !folderId.isEmpty()){
Workspace ws = HomeLibrary handleWorkspaceResources(folderId, userName, bean);
.getHomeManagerFactory()
.getHomeManager()
.getHome(owner).getWorkspace();
WorkspaceItem retrievedItem = ws.getItem(folderId);
// retrieve gcube items of the folder
Map<String, String> folderItems = Utils.getGcubeItemProperties(retrievedItem);
bean.setCustomFields(folderItems);
// check the resources within the folder (skip subdirectories)
List<String> childrenIds = new ArrayList<String>();
for (WorkspaceItem file : retrievedItem.getChildren()) {
if(!file.isFolder()) // ok, it's a file
childrenIds.add(file.getId());
}
List<ResourceBeanWrapper> listOfResources = Utils.getWorkspaceResourcesInformation(childrenIds, ws, user);
bean.setResources(listOfResources);
} }
}catch(Exception e){ }catch(Exception e){
@ -375,19 +331,110 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
return bean; return bean;
} }
/**
* This method receives a folder id within the user's workspace and set the list of resources in the dataset bean to be returned
* @param folderId
* @param owner
* @param bean
* @param userName
* @throws Exception
*/
private void handleWorkspaceResources(String folderId, String userName,
DatasetMetadataBean bean) throws Exception {
// get workspace
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(userName).getWorkspace();
WorkspaceItem originalFolder = ws.getItem(folderId);
// set some info
String onlyAlphanumeric = originalFolder.getName().replaceAll("[^A-Za-z0-9]", ""); // that is, remove characters different than A-Z,a-z,0-9
bean.setTitle(onlyAlphanumeric);
bean.setDescription(originalFolder.getDescription());
// Create the folder in the catalogue
Map<String, String> folderItems = Utils.getGcubeItemProperties(originalFolder);
bean.setCustomFields(folderItems);
// check the resources within the folder (skip subdirectories for now TODO)
List<String> childrenIds = new ArrayList<String>();
for (WorkspaceItem file : originalFolder.getChildren()) {
if(!file.isFolder()){
childrenIds.add(file.getId());
}
}
List<ResourceBeanWrapper> listOfResources = Utils.getWorkspaceResourcesInformation(childrenIds, ws, userName);
bean.setResources(listOfResources);
}
/**
* Copy into the .catalogue area folder the checked resources
* @param resourcesToAdd
* @param folderId
* @param userName
* @param bean
* @return
*/
private List<ResourceBean> copyResourcesToUserCatalogueArea(
List<ResourceBeanWrapper> resourcesToAdd, String folderId, String userName, DatasetMetadataBean bean) throws Exception{
// in to the .catalogue area of the user's workspace
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(userName).getWorkspace();
WorkspaceItem originalFolder = ws.getItem(folderId);
// Retrieve the catalogue of the user
WorkspaceCatalogue userCatalogue = ws.getCatalogue();
// Create the folder in the catalogue
WorkspaceItem copiedFolder = userCatalogue.addWorkspaceItem(originalFolder.getPath(), null); // add to .catalogue root
List<ResourceBean> resources = new ArrayList<ResourceBean>();
// copy only the selected ones
for(ResourceBeanWrapper resourceBeanWrapper : resourcesToAdd){
if (resourceBeanWrapper.isToBeAdded()) {
// ok it is a file, so copy it into the copiedFolder
WorkspaceItem copiedFile = userCatalogue.addWorkspaceItem(resourceBeanWrapper.getId(), copiedFolder.getId());
resources.add(new ResourceBean(
copiedFile.getPublicLink(true),
copiedFile.getName(),
copiedFile.getDescription(),
copiedFile.getId(),
userName,
null, // to be set
((FolderItem)copiedFile).getMimeType()));
}
}
return resources;
}
@Override @Override
public DatasetMetadataBean createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest) { public DatasetMetadataBean createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest) {
logger.debug("Request for creating a dataset with these information " + toCreate); logger.debug("Request for creating a dataset with these information " + toCreate);
ASLSession aslSession = getASLSession(); ASLSession aslSession = getASLSession();
String user = aslSession.getUsername(); String userName = aslSession.getUsername();
try{ try{
// check if session expired // check if session expired
if(user.equals(TEST_USER)){ if(userName.equals(TEST_USER)){
logger.debug("SESSION EXPIRED"); logger.debug("SESSION EXPIRED");
return null; return null;
} }
@ -407,31 +454,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
boolean setPublic = toCreate.getVisibility(); boolean setPublic = toCreate.getVisibility();
// get the list of resources and convert to ResourceBean // get the list of resources and convert to ResourceBean
List<ResourceBean> resources = new ArrayList<ResourceBean>(); List<ResourceBean> resources = null;
List<ResourceBeanWrapper> resourcesToAdd = toCreate.getResources(); List<ResourceBeanWrapper> resourcesToAdd = toCreate.getResources();
if(resourcesToAdd != null && !resourcesToAdd.isEmpty()) // we need to copy such resource in the .catalogue area of the user's ws
for (ResourceBeanWrapper resourceBeanWrapper : resourcesToAdd) { if(resourcesToAdd != null && !resourcesToAdd.isEmpty()){
if(resourceBeanWrapper.isToBeAdded()){ resources = copyResourcesToUserCatalogueArea(resourcesToAdd, toCreate.getId(), userName, toCreate);
resources.add(new ResourceBean(
resourceBeanWrapper.getUrl(),
resourceBeanWrapper.getName(),
resourceBeanWrapper.getDescription(),
resourceBeanWrapper.getId(),
resourceBeanWrapper.getOwner(),
null,
resourceBeanWrapper.getMimeType()));
} }
}
// TODO this code must be checked against Auth 2.0
// The ckan instance in which we will publish is the expressed by the organization name (scope)
// This means that if we are in root (e.g. /gcube) and the user choose to publish into vreY
// the ckan in which we will publish is the one in scope vreY
logger.debug("The user wants to publish in organization with name " + organizationNameOrId + " and current scope name is " + aslSession.getScopeName()); logger.debug("The user wants to publish in organization with name " + organizationNameOrId + " and current scope name is " + aslSession.getScopeName());
String scope = Utils.retrieveScopeFromOrganizationName(organizationNameOrId); String scope = Utils.retrieveScopeFromOrganizationName(organizationNameOrId);
CKanUtils utils = getCkanUtilsObj(scope); CKanUtils utils = getCkanUtilsObj(scope);
@ -447,7 +479,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// retrieve the url // retrieve the url
String datasetUrl = utils.getPortletUrl() + "?path=" + utils.getUrlFromDatasetIdOrName(getUserCKanTokenFromSession(scope), datasetId, true); String datasetUrl = utils.getPortletUrl() + "?path=" + utils.getUrlFromDatasetIdOrName(getUserCKanTokenFromSession(scope), datasetId, true);
toCreate.setSource(datasetUrl); toCreate.setSource(datasetUrl);
return toCreate; return toCreate;
@ -465,10 +496,14 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
@Override @Override
public ResourceBeanWrapper addResourceToDataset(ResourceBeanWrapper resource, String datasetId, String owner) { public ResourceBeanWrapper addResourceToDataset(ResourceBeanWrapper resource, String datasetId) {
ASLSession session = getASLSession();
String username = session.getUsername();
logger.debug("Incoming request for creating new resource for dataset with id " + datasetId + " and organization name of the dataset is " + resource.getOrganizationNameDatasetParent()); logger.debug("Incoming request for creating new resource for dataset with id " + datasetId + " and organization name of the dataset is " + resource.getOrganizationNameDatasetParent());
logger.debug("Owner is " + owner + " and resource is " + resource); logger.debug("Owner is " + username + " and resource is " + resource);
if(!isWithinPortal()){ if(!isWithinPortal()){
@ -477,9 +512,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}else{ }else{
ASLSession session = getASLSession();
String username = session.getUsername();
if(username.equals(TEST_USER)){ if(username.equals(TEST_USER)){
logger.warn("SESSION EXPIRED! "); logger.warn("SESSION EXPIRED! ");
@ -493,7 +525,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
resource.getName(), resource.getName(),
resource.getDescription(), resource.getDescription(),
null, null,
owner, username,
datasetId, datasetId,
null); null);
@ -517,8 +549,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
} }
@Override @Override
public boolean deleteResourceFromDataset(ResourceBeanWrapper resource, public boolean deleteResourceFromDataset(ResourceBeanWrapper resource) {
String owner) {
logger.debug("Request for deleting resource " + resource); logger.debug("Request for deleting resource " + resource);
boolean deleted = false; boolean deleted = false;
@ -554,7 +585,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
@Override @Override
public List<MetaDataProfileBean> getProfiles(String orgName) { public List<MetaDataProfileBean> getProfiles(String orgName) {
logger.debug("Requested profiles for products into orgName " + orgName); logger.debug("Requested profiles for products into orgName " + orgName);
List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>(); List<MetaDataProfileBean> toReturn = new ArrayList<MetaDataProfileBean>();

View File

@ -24,6 +24,7 @@ import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataValidator; import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataValidator;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataVocabulary; import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataVocabulary;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl; import org.gcube.portlets.widgets.ckandatapublisherwidget.server.CKANPublisherServicesImpl;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DataType;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper; import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
@ -91,7 +92,6 @@ public class Utils {
newResource.setName(item.getName()); newResource.setName(item.getName());
newResource.setToBeAdded(true); // default is true newResource.setToBeAdded(true); // default is true
newResource.setMimeType(((FolderItem)item).getMimeType()); newResource.setMimeType(((FolderItem)item).getMimeType());
newResource.setOwner(username);
toReturn.add(newResource); toReturn.add(newResource);
} }
@ -359,7 +359,7 @@ public class Utils {
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper(); MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
wrapperObj.setDefaulValue(metadataField.getDefaulValue()); wrapperObj.setDefaulValue(metadataField.getDefaulValue());
wrapperObj.setFieldName(metadataField.getFieldName()); wrapperObj.setFieldName(metadataField.getFieldName());
wrapperObj.setIsBoolean(metadataField.getIsBoolean()); wrapperObj.setType(DataType.valueOf(metadataField.getDataType().toString()));
wrapperObj.setMandatory(metadataField.getMandatory()); wrapperObj.setMandatory(metadataField.getMandatory());
wrapperObj.setNote(metadataField.getNote()); wrapperObj.setNote(metadataField.getNote());
@ -370,6 +370,9 @@ public class Utils {
MetadataVocabulary vocabulary = metadataField.getVocabulary(); MetadataVocabulary vocabulary = metadataField.getVocabulary();
if(vocabulary != null) if(vocabulary != null)
wrapperObj.setVocabulary(vocabulary.getVocabularyFields()); wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
// multi selection?
wrapperObj.setMultiSelection(metadataField.getVocabulary().isMultiSelection());
// add to the list // add to the list
wrapperList.add(wrapperObj); wrapperList.add(wrapperObj);

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
/**
* The Enum DataType.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 12, 2016
*/
public enum DataType {
String,
Date,
Text,
Boolean,
Number;
/**
* Value.
*
* @return the string
*/
public String value() {
return name();
}
}

View File

@ -13,10 +13,11 @@ public class MetadataFieldWrapper implements Serializable{
private static final long serialVersionUID = -8476731365884466698L; private static final long serialVersionUID = -8476731365884466698L;
private String fieldName; private String fieldName;
private Boolean mandatory = false; private Boolean mandatory = false;
private Boolean isBoolean = false; private DataType type;
private String defaulValue; private String defaulValue;
private String note; private String note;
private List<String> vocabulary; private List<String> vocabulary;
private boolean multiSelection;
private String validator; private String validator;
/** /**
@ -31,20 +32,20 @@ public class MetadataFieldWrapper implements Serializable{
* *
* @param fieldName the field name * @param fieldName the field name
* @param mandatory the mandatory * @param mandatory the mandatory
* @param isBoolean the is boolean * @param DataType the type
* @param defaulValue the defaul value * @param defaulValue the defaul value
* @param note the note * @param note the note
* @param vocabulary the vocabulary * @param vocabulary the vocabulary
* @param validator the validator * @param validator the validator
*/ */
public MetadataFieldWrapper( public MetadataFieldWrapper(
String fieldName, Boolean mandatory, Boolean isBoolean, String fieldName, Boolean mandatory, DataType type,
String defaulValue, String note, List<String> vocabulary, String defaulValue, String note, List<String> vocabulary,
String validator) { String validator) {
super(); super();
this.fieldName = fieldName; this.fieldName = fieldName;
this.mandatory = mandatory; this.mandatory = mandatory;
this.isBoolean = isBoolean; this.type = type;
this.defaulValue = defaulValue; this.defaulValue = defaulValue;
this.note = note; this.note = note;
this.vocabulary = vocabulary; this.vocabulary = vocabulary;
@ -71,16 +72,6 @@ public class MetadataFieldWrapper implements Serializable{
return mandatory; return mandatory;
} }
/**
* Gets the checks if is boolean.
*
* @return the isBoolean
*/
public Boolean getIsBoolean() {
return isBoolean;
}
/** /**
* Gets the defaul value. * Gets the defaul value.
* *
@ -141,16 +132,6 @@ public class MetadataFieldWrapper implements Serializable{
this.mandatory = mandatory; this.mandatory = mandatory;
} }
/**
* Sets the checks if is boolean.
*
* @param isBoolean the isBoolean to set
*/
public void setIsBoolean(Boolean isBoolean) {
this.isBoolean = isBoolean;
}
/** /**
* Sets the defaul value. * Sets the defaul value.
* *
@ -191,15 +172,29 @@ public class MetadataFieldWrapper implements Serializable{
this.validator = validator; this.validator = validator;
} }
/* (non-Javadoc) public DataType getType() {
* @see java.lang.Object#toString() return type;
*/ }
public void setType(DataType type) {
this.type = type;
}
public boolean isMultiSelection() {
return multiSelection;
}
public void setMultiSelection(boolean multiSelection) {
this.multiSelection = multiSelection;
}
@Override @Override
public String toString() { public String toString() {
return "MetadataFieldWrapper [fieldName=" + fieldName + ", mandatory=" return "MetadataFieldWrapper [fieldName=" + fieldName + ", mandatory="
+ mandatory + ", isBoolean=" + isBoolean + ", defaulValue=" + mandatory + ", type=" + type + ", defaulValue=" + defaulValue
+ defaulValue + ", note=" + note + ", vocabulary=" + vocabulary + ", note=" + note + ", vocabulary=" + vocabulary
+ ", validator=" + validator + "]"; + ", multiSelection=" + multiSelection + ", validator="
+ validator + "]";
} }
} }

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared; package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* A dataset's resource bean * A dataset's resource bean
@ -15,8 +16,8 @@ public class ResourceBeanWrapper implements Serializable{
private String id; private String id;
private boolean toBeAdded; private boolean toBeAdded;
private String mimeType; private String mimeType;
private String owner;
private String organizationNameDatasetParent; // the organization name in which the parent dataset was created private String organizationNameDatasetParent; // the organization name in which the parent dataset was created
private List<ResourceBeanWrapper> subResources; // a list of sub resources TODO
public ResourceBeanWrapper(){ public ResourceBeanWrapper(){
super(); super();
@ -29,10 +30,9 @@ public class ResourceBeanWrapper implements Serializable{
* @param id * @param id
* @param toBeAdded * @param toBeAdded
* @param mimeType * @param mimeType
* @param owner
*/ */
public ResourceBeanWrapper(String url, String name, String description, public ResourceBeanWrapper(String url, String name, String description,
String id, boolean toBeAdded, String mimeType, String owner, String organizationNameDatasetParent) { String id, boolean toBeAdded, String mimeType, String organizationNameDatasetParent) {
super(); super();
this.url = url; this.url = url;
this.name = name; this.name = name;
@ -40,7 +40,6 @@ public class ResourceBeanWrapper implements Serializable{
this.id = id; this.id = id;
this.toBeAdded = toBeAdded; this.toBeAdded = toBeAdded;
this.mimeType = mimeType; this.mimeType = mimeType;
this.owner = owner;
this.organizationNameDatasetParent = organizationNameDatasetParent; this.organizationNameDatasetParent = organizationNameDatasetParent;
} }
@ -127,21 +126,7 @@ public class ResourceBeanWrapper implements Serializable{
public void setMimeType(String mimeType) { public void setMimeType(String mimeType) {
this.mimeType = mimeType; this.mimeType = mimeType;
} }
/**
* @return the owner
*/
public String getOwner() {
return owner;
}
/**
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
}
/** /**
* @return the organizationNameDatasetParent * @return the organizationNameDatasetParent
*/ */
@ -156,16 +141,23 @@ public class ResourceBeanWrapper implements Serializable{
String organizationNameDatasetParent) { String organizationNameDatasetParent) {
this.organizationNameDatasetParent = organizationNameDatasetParent; this.organizationNameDatasetParent = organizationNameDatasetParent;
} }
public List<ResourceBeanWrapper> getSubResources() {
return subResources;
}
public void setSubResources(List<ResourceBeanWrapper> subResources) {
this.subResources = subResources;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
return "ResourceBeanWrapper [url=" + url + ", name=" + name return "ResourceBeanWrapper [url=" + url + ", name=" + name
+ ", description=" + description + ", id=" + id + ", description=" + description + ", id=" + id
+ ", toBeAdded=" + toBeAdded + ", mimeType=" + mimeType + ", toBeAdded=" + toBeAdded + ", mimeType=" + mimeType
+ ", owner=" + owner + ", organizationNameDatasetParent=" + ", organizationNameDatasetParent="
+ organizationNameDatasetParent + "]"; + organizationNameDatasetParent + ", subResources="
+ subResources + "]";
} }
} }

View File

@ -8,9 +8,10 @@
<!-- Responsive design --> <!-- Responsive design -->
<set-property name="bootstrap.responsiveDesign" value="true" /> <set-property name="bootstrap.responsiveDesign" value="true" />
<inherits name='com.github.gwtbootstrap.datetimepicker.Datetimepicker' />
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point <entry-point
class='org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher' /> class='org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanMetadataPublisher' />