Dataset creation is divided into three steps now (in the case in which the request doesn't come from the workspace)
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129049 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ef81439445
commit
f5dfd39e20
|
@ -22,9 +22,9 @@ public class CKanMetadataPublisher implements EntryPoint {
|
||||||
|
|
||||||
private void startExample() {
|
private void startExample() {
|
||||||
|
|
||||||
String idFolderWorkspace = "8b67fc1f-940d-4512-b783-105fba11c270";
|
String idFolderWorkspace = "d3a37eb9-1589-4c95-a9d0-c473a02d4f0f";
|
||||||
String owner = "costantino.perciante";
|
String owner = "costantino_perciante";
|
||||||
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(owner));
|
RootPanel.get("ckan-metadata-publisher-div").add(new CreateDatasetForm(idFolderWorkspace, owner));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ public interface CKanPublisherService extends RemoteService {
|
||||||
* 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.
|
||||||
* @param toCreate
|
* @param toCreate
|
||||||
* @param isWorkspaceRequest if the call comes from the workspace
|
* @param isWorkspaceRequest if the call comes from the workspace
|
||||||
* @return the identifier of the created dataset or null on error
|
* @return the sent bean full filled with the needed information
|
||||||
*/
|
*/
|
||||||
String createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest);
|
DatasetMetadataBean createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this resource to the dataset whose id is datasetId
|
* Add this resource to the dataset whose id is datasetId
|
||||||
|
|
|
@ -32,10 +32,10 @@ public interface CKanPublisherServiceAsync {
|
||||||
* 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.
|
||||||
* @param toCreate
|
* @param toCreate
|
||||||
* @param isWorkspaceRequest if the call comes from the workspace
|
* @param isWorkspaceRequest if the call comes from the workspace
|
||||||
* @return <b>true</b> on success, <b>false</b> otherwise
|
* @return the sent bean full filled with the needed information
|
||||||
*/
|
*/
|
||||||
void createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest,
|
void createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<DatasetMetadataBean> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this resource to the dataset whose id is datasetId
|
* Add this resource to the dataset whose id is datasetId
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
|
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.uibinder.client.UiBinder;
|
||||||
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container for the third phase (add resource to dataset)
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class AddResourceContainer extends Composite{
|
||||||
|
|
||||||
|
private static AddResourceContainerUiBinder uiBinder = GWT
|
||||||
|
.create(AddResourceContainerUiBinder.class);
|
||||||
|
|
||||||
|
interface AddResourceContainerUiBinder extends
|
||||||
|
UiBinder<Widget, AddResourceContainer> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField VerticalPanel resourcesPanel;
|
||||||
|
@UiField Button goToDatasetButton;
|
||||||
|
|
||||||
|
public AddResourceContainer(final String datasetUrl) {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
goToDatasetButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
Window.Location.assign(datasetUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the form to this panel
|
||||||
|
* @param w
|
||||||
|
*/
|
||||||
|
public void add(TabPanel w){
|
||||||
|
resourcesPanel.add(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
|
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<b:Button title="Go to dataset" ui:field="goToDatasetButton"
|
||||||
|
block="true" visible="true">Go to Dataset</b:Button>
|
||||||
|
<!-- Here will be placed the form for the resources -->
|
||||||
|
<g:VerticalPanel ui:field="resourcesPanel" width="100%"></g:VerticalPanel>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -3,6 +3,6 @@
|
||||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<h3>Added Resources</h3>
|
<h3>Added Resources</h3>
|
||||||
<g:VerticalPanel ui:field="addResourcesPanel" width="97%"></g:VerticalPanel>
|
<g:VerticalPanel ui:field="addResourcesPanel" width="100%"></g:VerticalPanel>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -30,6 +30,7 @@ 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.client.ui.base.ListItem;
|
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
|
@ -39,14 +40,15 @@ import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyCodes;
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
import com.google.gwt.event.dom.client.KeyDownEvent;
|
import com.google.gwt.event.dom.client.KeyDownEvent;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.regexp.shared.RegExp;
|
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
import com.google.gwt.user.client.Timer;
|
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.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
UiBinder<Widget, CreateDatasetForm> {
|
UiBinder<Widget, CreateDatasetForm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiField HTMLPanel createDatasetMainPanel;
|
||||||
@UiField TextBox titleTextBox;
|
@UiField TextBox titleTextBox;
|
||||||
@UiField TextArea descriptionTextarea;
|
@UiField TextArea descriptionTextarea;
|
||||||
@UiField TextBox tagsEnterTextBox;
|
@UiField TextBox tagsEnterTextBox;
|
||||||
|
@ -85,12 +88,10 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField CheckBox addResourcesCheckBox;
|
@UiField CheckBox addResourcesCheckBox;
|
||||||
@UiField ControlGroup resourcesControlGroup;
|
@UiField ControlGroup resourcesControlGroup;
|
||||||
@UiField Button createButton;
|
@UiField Button createButton;
|
||||||
@UiField Button addResourcesButton;
|
|
||||||
@UiField Button resetButton;
|
@UiField Button resetButton;
|
||||||
@UiField AlertBlock infoBlock;
|
@UiField AlertBlock infoBlock;
|
||||||
@UiField AlertBlock onContinueAlertBlock;
|
@UiField AlertBlock onContinueAlertBlock;
|
||||||
@UiField AlertBlock onCreateAlertBlock;
|
@UiField AlertBlock onCreateAlertBlock;
|
||||||
@UiField VerticalPanel resourcesPanel;
|
|
||||||
@UiField VerticalPanel metadataFieldsPanel;
|
@UiField VerticalPanel metadataFieldsPanel;
|
||||||
@UiField ListBox metadataProfilesFormatListbox;
|
@UiField ListBox metadataProfilesFormatListbox;
|
||||||
@UiField Form formFirstStep;
|
@UiField Form formFirstStep;
|
||||||
|
@ -98,6 +99,8 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField Button continueButton;
|
@UiField Button continueButton;
|
||||||
@UiField Button goBackButton;
|
@UiField Button goBackButton;
|
||||||
@UiField Paragraph selectedProfile;
|
@UiField Paragraph selectedProfile;
|
||||||
|
@UiField Button goToDatasetButton;
|
||||||
|
@UiField Button addResourcesButton;
|
||||||
|
|
||||||
// tab panel
|
// tab panel
|
||||||
private TabPanel tabPanel;
|
private TabPanel tabPanel;
|
||||||
|
@ -251,6 +254,9 @@ public class CreateDatasetForm extends Composite{
|
||||||
continueButton.setEnabled(false);
|
continueButton.setEnabled(false);
|
||||||
resetButton.setEnabled(false);
|
resetButton.setEnabled(false);
|
||||||
|
|
||||||
|
// set to visible the checkbox to add resources of the workspace
|
||||||
|
resourcesControlGroup.setVisible(true);
|
||||||
|
|
||||||
// get back the licenses and the metadata information from the workspace
|
// get back the licenses and the metadata information from the workspace
|
||||||
ckanServices.getDatasetBean(idFolderWorkspace, owner, new AsyncCallback<DatasetMetadataBean>() {
|
ckanServices.getDatasetBean(idFolderWorkspace, owner, new AsyncCallback<DatasetMetadataBean>() {
|
||||||
|
|
||||||
|
@ -525,40 +531,63 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
alertOnCreate("Trying to create dataset, please wait", AlertType.INFO);
|
alertOnCreate("Trying to create dataset, please wait", AlertType.INFO);
|
||||||
|
|
||||||
ckanServices.createCKanDataset(receivedBean, isWorkspaceRequest, new AsyncCallback<String>() {
|
ckanServices.createCKanDataset(receivedBean, isWorkspaceRequest, new AsyncCallback<DatasetMetadataBean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final String datasetId) {
|
public void onSuccess(final DatasetMetadataBean createdDatasetBean) {
|
||||||
|
|
||||||
if(datasetId != null){
|
if(createdDatasetBean != null){
|
||||||
|
|
||||||
alertOnCreate("Dataset correctly created!", AlertType.SUCCESS);
|
alertOnCreate("Dataset correctly created!", AlertType.SUCCESS);
|
||||||
|
|
||||||
// disable dataset fields
|
// disable dataset fields
|
||||||
disableDatasetFields();
|
disableDatasetFields();
|
||||||
|
|
||||||
// if we are in the "general case" we need to show a form for adding resources
|
// show the go to dataset button
|
||||||
if(!resourcesControlGroup.isVisible()){
|
final String datasetUrl = createdDatasetBean.getSource();
|
||||||
|
goToDatasetButton.setVisible(true);
|
||||||
|
goToDatasetButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
createButton.setVisible(false);
|
@Override
|
||||||
goBackButton.setVisible(false);
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
Window.Location.assign(datasetUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// if we are in the "general case" we need to show a form for adding resources
|
||||||
|
if(isWorkspaceRequest)
|
||||||
|
{
|
||||||
|
|
||||||
|
// leave to back button, but remove create and add go to dataset
|
||||||
|
createButton.removeFromParent();
|
||||||
|
resetButton.setEnabled(false);
|
||||||
|
|
||||||
|
// set go to dataset as primary
|
||||||
|
goToDatasetButton.setType(ButtonType.PRIMARY);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// remove create button
|
||||||
|
createButton.removeFromParent();
|
||||||
|
|
||||||
// show the add resources button
|
// show the add resources button
|
||||||
addResourcesButton.setVisible(true);
|
addResourcesButton.setVisible(true);
|
||||||
|
|
||||||
addResourcesButton.addClickHandler(new ClickHandler() {
|
addResourcesButton.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
// hide the button
|
// remove content of the main panel
|
||||||
addResourcesButton.setVisible(false);
|
createDatasetMainPanel.clear();
|
||||||
|
|
||||||
// TabPanel
|
// TabPanel
|
||||||
tabPanel = new TabPanel(Tabs.ABOVE);
|
tabPanel = new TabPanel(Tabs.ABOVE);
|
||||||
tabPanel.setWidth("100%");
|
tabPanel.setWidth("100%");
|
||||||
|
|
||||||
// add the form
|
// add the form
|
||||||
resourceForm = new AddResourceToDataset(eventBus, datasetId, owner);
|
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(), owner);
|
||||||
|
|
||||||
// tab for the form
|
// tab for the form
|
||||||
Tab formContainer = new Tab();
|
Tab formContainer = new Tab();
|
||||||
|
@ -574,16 +603,21 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
// add tabs to resources panel
|
// add tabs to resources panel
|
||||||
tabPanel.selectTab(0);
|
tabPanel.selectTab(0);
|
||||||
resourcesPanel.add(tabPanel);
|
|
||||||
resourcesPanel.setVisible(true);
|
|
||||||
|
|
||||||
|
|
||||||
|
// form container
|
||||||
|
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
|
container.add(tabPanel);
|
||||||
|
|
||||||
|
// add the new content of the main panel
|
||||||
|
createDatasetMainPanel.add(container);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
alertOnCreate("Unable to create this dataset, please retry later", AlertType.ERROR);
|
alertOnCreate("Unable to create this dataset, maybe it exists?", AlertType.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -591,13 +625,13 @@ public class CreateDatasetForm extends Composite{
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
alertOnCreate("Unable to create this dataset, please retry later", AlertType.ERROR);
|
alertOnCreate("Unable to create this dataset, maybe it exists?", AlertType.ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
alertOnCreate("Please check the inserted values", AlertType.ERROR);
|
alertOnCreate("Please check the inserted values and the mandatory fields", AlertType.ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,13 +718,6 @@ public class CreateDatasetForm extends Composite{
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// email reg expression
|
|
||||||
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
|
||||||
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
|
|
||||||
errorMessage = "Not valid maintainer email";
|
|
||||||
return errorMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
// name reg expression
|
// name reg expression
|
||||||
String regexName = "^[a-zA-Z\\s]+";
|
String regexName = "^[a-zA-Z\\s]+";
|
||||||
if(!validateByRegExpression(maintainerTextbox.getText(), regexName)){
|
if(!validateByRegExpression(maintainerTextbox.getText(), regexName)){
|
||||||
|
@ -698,6 +725,13 @@ public class CreateDatasetForm extends Composite{
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// email reg expression
|
||||||
|
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
||||||
|
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
|
||||||
|
errorMessage = "Not valid maintainer email";
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
||||||
if(checkSelectedMetaDataProfile()){
|
if(checkSelectedMetaDataProfile()){
|
||||||
errorMessage = "You must select a metadata profile different frome none";
|
errorMessage = "You must select a metadata profile different frome none";
|
||||||
|
@ -721,8 +755,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean validateByRegExpression(String textToValidate, String regex){
|
private boolean validateByRegExpression(String textToValidate, String regex){
|
||||||
RegExp pattern = RegExp.compile(regex);
|
return textToValidate.matches(regex);
|
||||||
return pattern.test(textToValidate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("resetButton")
|
@UiHandler("resetButton")
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel ui:field="createDatasetMainPanel">
|
||||||
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
||||||
ui:field="formFirstStep" visible="true">
|
ui:field="formFirstStep" visible="true">
|
||||||
<b:Fieldset styleName="{style.fieldset-border-style}">
|
<b:Fieldset styleName="{style.fieldset-border-style}">
|
||||||
|
@ -249,7 +249,8 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup ui:field="resourcesControlGroup" visible="false">
|
<b:ControlGroup ui:field="resourcesControlGroup"
|
||||||
|
visible="false">
|
||||||
<b:Controls>
|
<b:Controls>
|
||||||
<b:CheckBox
|
<b:CheckBox
|
||||||
title="Automatically add the folder content to the dataset as resource"
|
title="Automatically add the folder content to the dataset as resource"
|
||||||
|
@ -258,7 +259,7 @@
|
||||||
</b:CheckBox>
|
</b:CheckBox>
|
||||||
<span style="float:right; width:256px; color: #aaaaaa;">
|
<span style="float:right; width:256px; color: #aaaaaa;">
|
||||||
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
|
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
|
||||||
Automatically add folder' files as resources of the dataset
|
Automatically add folder content as resources of the dataset
|
||||||
</span>
|
</span>
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
@ -269,17 +270,16 @@
|
||||||
</b:AlertBlock>
|
</b:AlertBlock>
|
||||||
|
|
||||||
<b:Button title="Add resources to the just created dataset"
|
<b:Button title="Add resources to the just created dataset"
|
||||||
type="PRIMARY" visible="false" ui:field="addResourcesButton">Add Resources</b:Button>
|
block="true" type="PRIMARY" visible="false" ui:field="addResourcesButton">Add Resources</b:Button>
|
||||||
|
|
||||||
<!-- Here will be placed the form for the resources -->
|
|
||||||
<g:VerticalPanel ui:field="resourcesPanel" visible="false"
|
|
||||||
width="100%"></g:VerticalPanel>
|
|
||||||
|
|
||||||
<b:Button title="Create dataset" ui:field="createButton"
|
<b:Button title="Create dataset" ui:field="createButton"
|
||||||
type="PRIMARY" block="true">Create</b:Button>
|
type="PRIMARY" block="true">Create</b:Button>
|
||||||
<b:Button title="Go Back" ui:field="goBackButton" block="true">Go
|
<b:Button title="Go Back" ui:field="goBackButton" block="true">Go
|
||||||
Back</b:Button>
|
Back</b:Button>
|
||||||
|
|
||||||
|
<b:Button title="Go to dataset" ui:field="goToDatasetButton"
|
||||||
|
block="true" visible="false">Go to Dataset</b:Button>
|
||||||
|
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
|
|
|
@ -11,7 +11,6 @@ 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;
|
||||||
import com.google.gwt.dom.client.Style.Display;
|
import com.google.gwt.dom.client.Style.Display;
|
||||||
import com.google.gwt.regexp.shared.RegExp;
|
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
@ -122,7 +121,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
String validator = field.getValidator();
|
String validator = field.getValidator();
|
||||||
|
|
||||||
// if validator is not present and it is not a textbox
|
// if validator is not present and it is not a textbox
|
||||||
if((validator == null || validator.isEmpty()) && !holder.getClass().equals(TextBox.class))
|
if((validator == null || validator.isEmpty()) && !(holder.getClass().equals(TextBox.class) && field.getMandatory()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// current value
|
// current value
|
||||||
|
@ -145,10 +144,9 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true; // it's a checkbox
|
return true; // it's a checkbox (the value doesn't matter)
|
||||||
|
|
||||||
RegExp pattern = RegExp.compile(validator);
|
return value.matches(validator);
|
||||||
return pattern.test(value);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest) {
|
public DatasetMetadataBean createCKanDataset(DatasetMetadataBean toCreate, boolean isWorkspaceRequest) {
|
||||||
|
|
||||||
// retrieve ckan's catalog url
|
// retrieve ckan's catalog url
|
||||||
String ckanPortalUrl = getCatalogueUrl();
|
String ckanPortalUrl = getCatalogueUrl();
|
||||||
|
@ -510,6 +510,10 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
res = client.createDataset(dataset);
|
res = client.createDataset(dataset);
|
||||||
|
|
||||||
|
// add source and id to the incoming bean
|
||||||
|
toCreate.setId(res.getId());
|
||||||
|
toCreate.setSource(getCatalogueUrl() + "/dataset/" + res.getName());
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|
||||||
// try to update
|
// try to update
|
||||||
|
@ -524,7 +528,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.getId();
|
return toCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,9 +537,9 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String nameFromTitle(String title) {
|
private String nameFromTitle(String title) {
|
||||||
String convertedName = title.replaceAll(" ", "-");
|
String convertedName = title.replaceAll(" ", "_").replaceAll(".", "_");
|
||||||
convertedName = convertedName.toLowerCase();
|
convertedName = convertedName.toLowerCase();
|
||||||
if(convertedName.endsWith("-"))
|
if(convertedName.endsWith("_"))
|
||||||
convertedName = convertedName.substring(0, convertedName.length() - 2);
|
convertedName = convertedName.substring(0, convertedName.length() - 2);
|
||||||
|
|
||||||
return convertedName;
|
return convertedName;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class Tests {
|
public class Tests {
|
||||||
|
|
||||||
//@Test
|
@Test
|
||||||
public void test() throws WorkspaceFolderNotFoundException, InternalErrorException, HomeNotFoundException, UserNotFoundException, ItemNotFoundException{
|
public void test() throws WorkspaceFolderNotFoundException, InternalErrorException, HomeNotFoundException, UserNotFoundException, ItemNotFoundException{
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube");
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
@ -28,7 +28,7 @@ public class Tests {
|
||||||
List<WorkspaceItem> childrens = ws.getRoot().getChildren();
|
List<WorkspaceItem> childrens = ws.getRoot().getChildren();
|
||||||
|
|
||||||
for (WorkspaceItem workspaceItem : childrens) {
|
for (WorkspaceItem workspaceItem : childrens) {
|
||||||
if(workspaceItem.getName().equals("CkanTest1137")){
|
if(workspaceItem.getName().equals("test-ckan-folder")){
|
||||||
|
|
||||||
System.out.println("Dir has id " + workspaceItem.getId());
|
System.out.println("Dir has id " + workspaceItem.getId());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue