The widget is almost finished. Profile information are also shown now.
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129045 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1a2cf0db7b
commit
ef81439445
|
@ -5,6 +5,9 @@
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
<dependent-module archiveName="ckan-util-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ckan-util-library/ckan-util-library">
|
||||||
|
<dependency-type>uses</dependency-type>
|
||||||
|
</dependent-module>
|
||||||
<property name="context-root" value="ckan-metadata-publisher-widget"/>
|
<property name="context-root" value="ckan-metadata-publisher-widget"/>
|
||||||
<property name="java-output-path" value="/ckan-metadata-publisher-widget/target/ckan-metadata-publisher-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/ckan-metadata-publisher-widget/target/ckan-metadata-publisher-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.models.MetaDataBean;
|
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
||||||
|
@ -15,12 +14,16 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCu
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Form;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
import com.github.gwtbootstrap.client.ui.Tab;
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
|
@ -29,12 +32,13 @@ 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.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.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
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.MatchResult;
|
|
||||||
import com.google.gwt.regexp.shared.RegExp;
|
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;
|
||||||
|
@ -47,7 +51,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit metadata form for ckan dataset.
|
* Create metadata form for ckan dataset.
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
public class CreateDatasetForm extends Composite{
|
public class CreateDatasetForm extends Composite{
|
||||||
|
@ -84,10 +88,16 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField Button addResourcesButton;
|
@UiField Button addResourcesButton;
|
||||||
@UiField Button resetButton;
|
@UiField Button resetButton;
|
||||||
@UiField AlertBlock infoBlock;
|
@UiField AlertBlock infoBlock;
|
||||||
|
@UiField AlertBlock onContinueAlertBlock;
|
||||||
@UiField AlertBlock onCreateAlertBlock;
|
@UiField AlertBlock onCreateAlertBlock;
|
||||||
@UiField VerticalPanel resourcesPanel;
|
@UiField VerticalPanel resourcesPanel;
|
||||||
@UiField VerticalPanel metadataPanel;
|
@UiField VerticalPanel metadataFieldsPanel;
|
||||||
@UiField ListBox metadataFormatListbox;
|
@UiField ListBox metadataProfilesFormatListbox;
|
||||||
|
@UiField Form formFirstStep;
|
||||||
|
@UiField Form formSecondStep;
|
||||||
|
@UiField Button continueButton;
|
||||||
|
@UiField Button goBackButton;
|
||||||
|
@UiField Paragraph selectedProfile;
|
||||||
|
|
||||||
// tab panel
|
// tab panel
|
||||||
private TabPanel tabPanel;
|
private TabPanel tabPanel;
|
||||||
|
@ -116,6 +126,9 @@ public class CreateDatasetForm extends Composite{
|
||||||
// workspace request?
|
// workspace request?
|
||||||
private boolean isWorkspaceRequest = false;
|
private boolean isWorkspaceRequest = false;
|
||||||
|
|
||||||
|
// the list of MetaDataFieldSkeleton added
|
||||||
|
List<MetaDataFieldSkeleton> listOfMetadataFields = new ArrayList<MetaDataFieldSkeleton>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked in the most general case
|
* Invoked in the most general case
|
||||||
* @param owner
|
* @param owner
|
||||||
|
@ -131,8 +144,8 @@ public class CreateDatasetForm extends Composite{
|
||||||
// set info block
|
// set info block
|
||||||
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// disable create button
|
// disable continue/reset button
|
||||||
createButton.setEnabled(false);
|
continueButton.setEnabled(false);
|
||||||
resetButton.setEnabled(false);
|
resetButton.setEnabled(false);
|
||||||
|
|
||||||
// get back the licenses and the metadata information
|
// get back the licenses and the metadata information
|
||||||
|
@ -179,7 +192,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
// everything went ok
|
// everything went ok
|
||||||
setAlertBlock("", AlertType.ERROR, false);
|
setAlertBlock("", AlertType.ERROR, false);
|
||||||
createButton.setEnabled(true);
|
continueButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
resetButton.setEnabled(true);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -211,23 +224,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
});
|
});
|
||||||
|
|
||||||
// hide the Add resources checkbox
|
// hide the Add resources checkbox
|
||||||
resourcesControlGroup.setVisible(false);
|
resourcesControlGroup.removeFromParent();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the items to the listbox and put data into the metadataPanel
|
|
||||||
* @param receivedBean
|
|
||||||
*/
|
|
||||||
protected void prepareMetadataList(DatasetMetadataBean receivedBean) {
|
|
||||||
|
|
||||||
List<MetaDataBean> beans = receivedBean.getMetadataList();
|
|
||||||
|
|
||||||
for(MetaDataBean metadataBean: beans){
|
|
||||||
|
|
||||||
//metadataFormatListbox.addItem(metadataBean.getType().getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +247,8 @@ public class CreateDatasetForm extends Composite{
|
||||||
// set info block
|
// set info block
|
||||||
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// disable create button
|
// disable continue button
|
||||||
createButton.setEnabled(false);
|
continueButton.setEnabled(false);
|
||||||
resetButton.setEnabled(false);
|
resetButton.setEnabled(false);
|
||||||
|
|
||||||
// get back the licenses and the metadata information from the workspace
|
// get back the licenses and the metadata information from the workspace
|
||||||
|
@ -287,8 +284,6 @@ public class CreateDatasetForm extends Composite{
|
||||||
// retrieve custom fields
|
// retrieve custom fields
|
||||||
Map<String, String> customFieldsMap = bean.getCustomFields();
|
Map<String, String> customFieldsMap = bean.getCustomFields();
|
||||||
|
|
||||||
GWT.log("Custom fields is " + customFieldsMap);
|
|
||||||
|
|
||||||
if(customFieldsMap != null){
|
if(customFieldsMap != null){
|
||||||
|
|
||||||
// get the keys and put them as tags
|
// get the keys and put them as tags
|
||||||
|
@ -329,7 +324,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
// everything went ok
|
// everything went ok
|
||||||
setAlertBlock("", AlertType.ERROR, false);
|
setAlertBlock("", AlertType.ERROR, false);
|
||||||
createButton.setEnabled(true);
|
continueButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
resetButton.setEnabled(true);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -362,6 +357,63 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the items to the listbox and put data into the metadataPanel
|
||||||
|
* @param receivedBean
|
||||||
|
*/
|
||||||
|
protected void prepareMetadataList(DatasetMetadataBean receivedBean) {
|
||||||
|
|
||||||
|
List<MetaDataProfileBean> beans = receivedBean.getMetadataList();
|
||||||
|
|
||||||
|
for(MetaDataProfileBean metadataBean: beans){
|
||||||
|
|
||||||
|
metadataProfilesFormatListbox.addItem(metadataBean.getType().getName());
|
||||||
|
|
||||||
|
// add handler on select
|
||||||
|
metadataProfilesFormatListbox.addChangeHandler(new ChangeHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChange(ChangeEvent event) {
|
||||||
|
|
||||||
|
String selectedItem = metadataProfilesFormatListbox.getSelectedItemText();
|
||||||
|
|
||||||
|
if(selectedItem.equals("none")){
|
||||||
|
// hide the panel
|
||||||
|
metadataFieldsPanel.clear();
|
||||||
|
metadataFieldsPanel.setVisible(false);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
metadataFieldsPanel.clear();
|
||||||
|
addFields(selectedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFields(String selectedItem) {
|
||||||
|
|
||||||
|
for(MetaDataProfileBean bean: receivedBean.getMetadataList()){
|
||||||
|
|
||||||
|
if(bean.getType().getName().equals(selectedItem)){
|
||||||
|
|
||||||
|
// prepare the data
|
||||||
|
List<MetadataFieldWrapper> fields = bean.getMetadataFields();
|
||||||
|
|
||||||
|
// clear old data
|
||||||
|
listOfMetadataFields.clear();
|
||||||
|
|
||||||
|
for (MetadataFieldWrapper field : fields) {
|
||||||
|
MetaDataFieldSkeleton fieldWidget = new MetaDataFieldSkeleton(field);
|
||||||
|
metadataFieldsPanel.add(fieldWidget);
|
||||||
|
listOfMetadataFields.add(fieldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
metadataFieldsPanel.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind on events
|
* Bind on events
|
||||||
*/
|
*/
|
||||||
|
@ -390,19 +442,37 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiHandler("continueButton")
|
||||||
|
void onContinueButton(ClickEvent e){
|
||||||
|
|
||||||
|
// validate data
|
||||||
|
String errorMsg = validateDataOnContinue();
|
||||||
|
|
||||||
|
if(errorMsg == null){
|
||||||
|
formFirstStep.setVisible(false);
|
||||||
|
formSecondStep.setVisible(true);
|
||||||
|
selectedProfile.setText("Selected Profile is " + metadataProfilesFormatListbox.getSelectedItemText());
|
||||||
|
}else{
|
||||||
|
alertOnContinue("Please check inserted data [" + errorMsg + "]", AlertType.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiHandler("goBackButton")
|
||||||
|
void onGoBackButton(ClickEvent e){
|
||||||
|
|
||||||
|
// swap forms
|
||||||
|
formFirstStep.setVisible(true);
|
||||||
|
formSecondStep.setVisible(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@UiHandler("createButton")
|
@UiHandler("createButton")
|
||||||
void createDatasetEvent(ClickEvent e){
|
void createDatasetEvent(ClickEvent e){
|
||||||
|
|
||||||
// validate data
|
boolean profileDataValid = areProfileDataValid();
|
||||||
boolean areDataValid = validateData();
|
|
||||||
|
|
||||||
// Collect current data and send them to the server
|
if(profileDataValid){
|
||||||
if(!areDataValid){
|
|
||||||
|
|
||||||
alertOnCreate("Please check inserted data ", AlertType.ERROR);
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
String title = titleTextBox.getValue();
|
String title = titleTextBox.getValue();
|
||||||
String description = descriptionTextarea.getText();
|
String description = descriptionTextarea.getText();
|
||||||
|
@ -433,6 +503,12 @@ public class CreateDatasetForm extends Composite{
|
||||||
Map<String, String> customFieldsMap = new HashMap<String, String>();
|
Map<String, String> customFieldsMap = new HashMap<String, String>();
|
||||||
|
|
||||||
// prepare custom fields
|
// prepare custom fields
|
||||||
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
||||||
|
|
||||||
|
customFieldsMap.put(field.getFieldName(), field.getFieldCurrentValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for(CustomFieldEntry customEntry : customFieldEntriesList){
|
for(CustomFieldEntry customEntry : customFieldEntriesList){
|
||||||
|
|
||||||
String key = customEntry.getKey();
|
String key = customEntry.getKey();
|
||||||
|
@ -445,7 +521,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
// invoke the create method
|
// invoke the create method
|
||||||
createButton.setEnabled(false);
|
createButton.setEnabled(false);
|
||||||
resetButton.setEnabled(false);
|
goBackButton.setEnabled(false);
|
||||||
|
|
||||||
alertOnCreate("Trying to create dataset, please wait", AlertType.INFO);
|
alertOnCreate("Trying to create dataset, please wait", AlertType.INFO);
|
||||||
|
|
||||||
|
@ -465,7 +541,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
if(!resourcesControlGroup.isVisible()){
|
if(!resourcesControlGroup.isVisible()){
|
||||||
|
|
||||||
createButton.setVisible(false);
|
createButton.setVisible(false);
|
||||||
resetButton.setVisible(false);
|
goBackButton.setVisible(false);
|
||||||
|
|
||||||
// show the add resources button
|
// show the add resources button
|
||||||
addResourcesButton.setVisible(true);
|
addResourcesButton.setVisible(true);
|
||||||
|
@ -519,11 +595,57 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
|
||||||
|
alertOnCreate("Please check the inserted values", AlertType.ERROR);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create show alert box and enable buttons
|
* Test if profile data are valid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean areProfileDataValid() {
|
||||||
|
|
||||||
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
||||||
|
|
||||||
|
if(!field.isFieldValueValid())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On continue show alert box and enable buttons
|
||||||
|
* @param text
|
||||||
|
* @param 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
|
* @param text
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
|
@ -533,7 +655,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
onCreateAlertBlock.setType(type);
|
onCreateAlertBlock.setType(type);
|
||||||
onCreateAlertBlock.setVisible(true);
|
onCreateAlertBlock.setVisible(true);
|
||||||
createButton.setEnabled(true);
|
createButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
goBackButton.setEnabled(true);
|
||||||
|
|
||||||
// hide after some seconds
|
// hide after some seconds
|
||||||
Timer t = new Timer() {
|
Timer t = new Timer() {
|
||||||
|
@ -546,41 +668,61 @@ public class CreateDatasetForm extends Composite{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
t.schedule(2000);
|
t.schedule(4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate data
|
* Validate data
|
||||||
* @return true on success, false otherwise
|
* @return true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean validateData() {
|
private String validateDataOnContinue() {
|
||||||
|
|
||||||
boolean correct = true;
|
String errorMessage = null;
|
||||||
|
|
||||||
if(titleTextBox.getText().isEmpty())
|
if(titleTextBox.getText().isEmpty()){
|
||||||
correct = false;
|
errorMessage = "Missing title";
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
// email reg expression
|
// email reg expression
|
||||||
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
||||||
|
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
|
||||||
correct &= 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)){
|
||||||
correct &= validateByRegExpression(maintainerTextbox.getText(), regexName);
|
errorMessage = "Not valid maintainer name"; // TODO
|
||||||
|
return errorMessage;
|
||||||
return correct;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
||||||
|
if(checkSelectedMetaDataProfile()){
|
||||||
|
errorMessage = "You must select a metadata profile different frome none";
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a metadata profile has been chosen and its fields have been fulfilled
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean checkSelectedMetaDataProfile() {
|
||||||
|
return metadataProfilesFormatListbox.getSelectedItemText().equals("none");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate a text against a regular expression.
|
||||||
|
* @param textToValidate
|
||||||
|
* @param regex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private boolean validateByRegExpression(String textToValidate, String regex){
|
private boolean validateByRegExpression(String textToValidate, String regex){
|
||||||
|
|
||||||
RegExp pattern = RegExp.compile(regex);
|
RegExp pattern = RegExp.compile(regex);
|
||||||
MatchResult matcher = pattern.exec(textToValidate);
|
return pattern.test(textToValidate);
|
||||||
|
|
||||||
GWT.log("Matcher is " + matcher);
|
|
||||||
|
|
||||||
return (matcher != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("resetButton")
|
@UiHandler("resetButton")
|
||||||
|
@ -629,6 +771,14 @@ public class CreateDatasetForm extends Composite{
|
||||||
tagWidget.getWidget(1).removeFromParent();
|
tagWidget.getWidget(1).removeFromParent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable profile fields
|
||||||
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
||||||
|
|
||||||
|
field.freeze();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,10 +33,14 @@
|
||||||
.tagsPanelStyle {
|
.tagsPanelStyle {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.selected-profile {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
||||||
ui:field="form">
|
ui:field="formFirstStep" visible="true">
|
||||||
<b:Fieldset styleName="{style.fieldset-border-style}">
|
<b:Fieldset styleName="{style.fieldset-border-style}">
|
||||||
|
|
||||||
<b:Legend styleName="{style.legend-style}">
|
<b:Legend styleName="{style.legend-style}">
|
||||||
|
@ -62,18 +66,6 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
|
|
||||||
<!-- <b:ControlGroup> -->
|
|
||||||
<!-- <b:ControlLabel for="url" title="Dataset url"> -->
|
|
||||||
<!-- <font color="red">*</font> -->
|
|
||||||
<!-- URL: -->
|
|
||||||
<!-- </b:ControlLabel> -->
|
|
||||||
<!-- <b:Controls> -->
|
|
||||||
<!-- <b:TextBox alternateSize="LARGE" placeholder="Dataset URL" -->
|
|
||||||
<!-- b:id="url" title="Dataset URL" ui:field="urlTextbox" /> -->
|
|
||||||
<!-- </b:Controls> -->
|
|
||||||
<!-- </b:ControlGroup> -->
|
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup>
|
||||||
<b:ControlLabel for="description" title="Dataset description">
|
<b:ControlLabel for="description" title="Dataset description">
|
||||||
Description:
|
Description:
|
||||||
|
@ -196,18 +188,45 @@
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup>
|
||||||
<b:ControlLabel for="metadataFormat" title="Metadata format">Metadata
|
<b:ControlLabel for="metadataProfilesFormat" title="Metadata profile formats">Metadata
|
||||||
Format:</b:ControlLabel>
|
Profile:</b:ControlLabel>
|
||||||
<b:Controls>
|
<b:Controls>
|
||||||
<b:ListBox b:id="metadataFormat" alternateSize="LARGE"
|
<b:ListBox b:id="metadataProfilesFormat" alternateSize="LARGE"
|
||||||
title="The metadata format to be used" ui:field="metadataFormatListbox">
|
title="The metadata profile format to be used" ui:field="metadataProfilesFormatListbox">
|
||||||
|
<g:item enabled="true" title="None">none</g:item>
|
||||||
</b:ListBox>
|
</b:ListBox>
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<!-- Here will be placed the metadata formats -->
|
<!-- Alert block on continue -->
|
||||||
<g:VerticalPanel ui:field="metadataPanel" visible="false"
|
<b:AlertBlock type="INFO" close="false" animation="true"
|
||||||
width="100%"></g:VerticalPanel>
|
visible="false" ui:field="onContinueAlertBlock" styleName="{style.block-alert-style}">
|
||||||
|
</b:AlertBlock>
|
||||||
|
|
||||||
|
<b:Button title="Continue" ui:field="continueButton" type="PRIMARY"
|
||||||
|
block="true">Continue</b:Button>
|
||||||
|
<b:Button title="Reset" ui:field="resetButton" block="true">Reset</b:Button>
|
||||||
|
|
||||||
|
</b:Fieldset>
|
||||||
|
</b:Form>
|
||||||
|
|
||||||
|
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
|
||||||
|
ui:field="formSecondStep" visible="false">
|
||||||
|
<b:Fieldset styleName="{style.fieldset-border-style}">
|
||||||
|
|
||||||
|
<b:Legend styleName="{style.legend-style}">
|
||||||
|
Insert Metadata Profile Information
|
||||||
|
<small>
|
||||||
|
<span style="color:red;">*</span>
|
||||||
|
is required
|
||||||
|
</small>
|
||||||
|
</b:Legend>
|
||||||
|
|
||||||
|
<b:Paragraph ui:field="selectedProfile" styleName="{style.selected-profile}"></b:Paragraph>
|
||||||
|
|
||||||
|
<!-- Here will be placed the metadata fields formats -->
|
||||||
|
<g:VerticalPanel ui:field="metadataFieldsPanel"
|
||||||
|
visible="false" width="100%"></g:VerticalPanel>
|
||||||
|
|
||||||
<!-- Custom fields can be dinamically added -->
|
<!-- Custom fields can be dinamically added -->
|
||||||
<b:ControlGroup ui:field="customFields">
|
<b:ControlGroup ui:field="customFields">
|
||||||
|
@ -230,7 +249,7 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup ui:field="resourcesControlGroup">
|
<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 +277,8 @@
|
||||||
|
|
||||||
<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="Reset" ui:field="resetButton" block="true">Reset</b:Button>
|
<b:Button title="Go Back" ui:field="goBackButton" block="true">Go
|
||||||
|
Back</b:Button>
|
||||||
|
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
|
|
|
@ -0,0 +1,198 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
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.Display;
|
||||||
|
import com.google.gwt.regexp.shared.RegExp;
|
||||||
|
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.SimplePanel;
|
||||||
|
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<Widget, MetaDataFieldSkeleton> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField Element mandatorySymbol;
|
||||||
|
@UiField SpanElement name;
|
||||||
|
@UiField SimplePanel elementPanel;
|
||||||
|
@UiField SpanElement noteFieldContainer;
|
||||||
|
@UiField SpanElement noteField;
|
||||||
|
|
||||||
|
// the element that holds the value (it could be a checkbox, textbox or listbox)
|
||||||
|
private Widget holder;
|
||||||
|
|
||||||
|
// the field this object rapresents
|
||||||
|
private MetadataFieldWrapper field;
|
||||||
|
|
||||||
|
public MetaDataFieldSkeleton(MetadataFieldWrapper field) {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
|
// prepare information
|
||||||
|
this.field = field;
|
||||||
|
|
||||||
|
// save the name
|
||||||
|
name.setInnerText(field.getFieldName() + ":");
|
||||||
|
|
||||||
|
// check if it is mandatory
|
||||||
|
if(!field.getMandatory())
|
||||||
|
mandatorySymbol.getStyle().setDisplay(Display.NONE);
|
||||||
|
|
||||||
|
if(field.getIsBoolean()){
|
||||||
|
|
||||||
|
// its a checkbox
|
||||||
|
holder = new CheckBox();
|
||||||
|
|
||||||
|
if(field.getDefaulValue() != null)
|
||||||
|
((CheckBox)holder).setValue(Boolean.valueOf(field.getDefaulValue()));
|
||||||
|
|
||||||
|
// add to the elementPanel
|
||||||
|
elementPanel.add(holder);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// it could be a listbox or a textbox according to the vocabulary fields
|
||||||
|
if(field.getVocabulary() == null || field.getVocabulary().isEmpty()){
|
||||||
|
|
||||||
|
// textbox
|
||||||
|
holder = new TextBox();
|
||||||
|
|
||||||
|
if(field.getDefaulValue() != null)
|
||||||
|
((TextBox)holder).setText(field.getDefaulValue());
|
||||||
|
|
||||||
|
// add to the elementPanel
|
||||||
|
elementPanel.add(holder);
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// listbox
|
||||||
|
holder = new ListBox();
|
||||||
|
|
||||||
|
// get vocabulary fields
|
||||||
|
List<String> vocabulary = field.getVocabulary();
|
||||||
|
|
||||||
|
for (String term : vocabulary) {
|
||||||
|
|
||||||
|
((ListBox)holder).addItem(term);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// set default value
|
||||||
|
((ListBox)holder).setSelectedValue(field.getDefaulValue());
|
||||||
|
|
||||||
|
// add to the elementPanel
|
||||||
|
elementPanel.add(holder);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the notes, if any
|
||||||
|
if(field.getNote() != null && !field.getNote().isEmpty()){
|
||||||
|
noteField.setInnerText(field.getNote());
|
||||||
|
noteFieldContainer.getStyle().setDisplay(Display.INITIAL);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
noteFieldContainer.getStyle().setDisplay(Display.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this field has a valid values
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isFieldValueValid() {
|
||||||
|
|
||||||
|
String validator = field.getValidator();
|
||||||
|
|
||||||
|
// if validator is not present and it is not a textbox
|
||||||
|
if((validator == null || validator.isEmpty()) && !holder.getClass().equals(TextBox.class))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// current value
|
||||||
|
String value;
|
||||||
|
|
||||||
|
// we validate only listbox and textbox
|
||||||
|
if(holder.getClass().equals(ListBox.class))
|
||||||
|
value = ((ListBox)holder).getSelectedItemText();
|
||||||
|
else if(holder.getClass().equals(TextBox.class)){
|
||||||
|
value = ((TextBox)holder).getText();
|
||||||
|
|
||||||
|
// if thereis not a validator...
|
||||||
|
if(validator == null){
|
||||||
|
if(value.isEmpty() && field.getMandatory())
|
||||||
|
return false;
|
||||||
|
else if(value.isEmpty() && !field.getMandatory())
|
||||||
|
return true;
|
||||||
|
else if(!value.isEmpty())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true; // it's a checkbox
|
||||||
|
|
||||||
|
RegExp pattern = RegExp.compile(validator);
|
||||||
|
return pattern.test(value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current value of the field
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getFieldCurrentValue(){
|
||||||
|
|
||||||
|
String value;
|
||||||
|
|
||||||
|
// we validate only listbox and textbox
|
||||||
|
if(holder.getClass().equals(ListBox.class))
|
||||||
|
value = ((ListBox)holder).getSelectedItemText();
|
||||||
|
else if(holder.getClass().equals(TextBox.class))
|
||||||
|
value = ((TextBox)holder).getText();
|
||||||
|
else
|
||||||
|
value = ((CheckBox)holder).getValue().toString();
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current value of the field
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getFieldName(){
|
||||||
|
|
||||||
|
return field.getFieldName();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Freeze this widget (after on create)
|
||||||
|
*/
|
||||||
|
public void freeze() {
|
||||||
|
|
||||||
|
if(holder.getClass().equals(ListBox.class))
|
||||||
|
((ListBox)holder).setEnabled(false);
|
||||||
|
else if(holder.getClass().equals(TextBox.class))
|
||||||
|
((TextBox)holder).setEnabled(false);
|
||||||
|
else
|
||||||
|
((CheckBox)holder).setEnabled(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!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:ControlGroup>
|
||||||
|
<b:ControlLabel>
|
||||||
|
<font color="red" ui:field="mandatorySymbol">*</font>
|
||||||
|
<!-- Name goes here -->
|
||||||
|
<span ui:field="name"></span>
|
||||||
|
</b:ControlLabel>
|
||||||
|
<b:Controls>
|
||||||
|
<!-- Listbox or Checkbox or Textbox according to isBoolean field -->
|
||||||
|
<g:SimplePanel ui:field="elementPanel" ></g:SimplePanel>
|
||||||
|
<span style="float:right; width:256px; color: #aaaaaa;" ui:field="noteFieldContainer" display="none">
|
||||||
|
<b:Icon type="INFO_SIGN" size="TWO_TIMES"/>
|
||||||
|
<span ui:field="noteField" visible="false"></span>
|
||||||
|
</span>
|
||||||
|
</b:Controls>
|
||||||
|
</b:ControlGroup>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -22,10 +22,18 @@ import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsFactory;
|
import org.gcube.datacatalogue.ckanutillibrary.CKanUtilsFactory;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.models.MetaDataBean;
|
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.MetadataType;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataValidator;
|
||||||
|
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataVocabulary;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataTypeWrapper;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceBean;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
|
@ -159,21 +167,60 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
* Retrieve the list of metadata beans
|
* Retrieve the list of metadata beans
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<MetaDataBean> getMetaDataBeanList(){
|
public List<MetaDataProfileBean> getMetadataProfilesList() {
|
||||||
|
|
||||||
logger.debug("Request for metadata beans list");
|
List<MetaDataProfileBean> beans = new ArrayList<MetaDataProfileBean>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String currentScope = getCurrentScope();
|
ScopeProvider.instance.set("/gcube/devsec/devVRE"); // TODO remove
|
||||||
return CKanUtilsFactory.getInstance().getCkanUtilsForScope(currentScope).getMetadataList();
|
DataCalogueMetadataFormatReader reader = new DataCalogueMetadataFormatReader();
|
||||||
|
|
||||||
|
for (MetadataType mt : reader.getListOfMetadataTypes()) {
|
||||||
|
MetadataFormat metadata = reader.getMetadataFormatForMetadataType(mt);
|
||||||
|
|
||||||
|
// we need to wrap the list of metadata
|
||||||
|
List<MetadataFieldWrapper> wrapperList = new ArrayList<MetadataFieldWrapper>();
|
||||||
|
List<MetadataField> toWrap = metadata.getMetadataFields();
|
||||||
|
for(MetadataField metadataField: toWrap){
|
||||||
|
|
||||||
|
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
|
||||||
|
wrapperObj.setDefaulValue(metadataField.getDefaulValue());
|
||||||
|
wrapperObj.setFieldName(metadataField.getFieldName());
|
||||||
|
wrapperObj.setIsBoolean(metadataField.getIsBoolean());
|
||||||
|
wrapperObj.setMandatory(metadataField.getMandatory());
|
||||||
|
wrapperObj.setNote(metadataField.getNote());
|
||||||
|
|
||||||
|
MetadataValidator validator = metadataField.getValidator();
|
||||||
|
if(validator != null)
|
||||||
|
wrapperObj.setValidator(validator.getRegularExpression());
|
||||||
|
|
||||||
|
MetadataVocabulary vocabulary = metadataField.getVocabulary();
|
||||||
|
if(vocabulary != null)
|
||||||
|
wrapperObj.setVocabulary(vocabulary.getVocabularyFields());
|
||||||
|
|
||||||
|
// add to the list
|
||||||
|
wrapperList.add(wrapperObj);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap the mt as well
|
||||||
|
MetaDataTypeWrapper typeWrapper = new MetaDataTypeWrapper();
|
||||||
|
typeWrapper.setDescription(mt.getDescription());
|
||||||
|
typeWrapper.setId(mt.getId());
|
||||||
|
typeWrapper.setName(mt.getName());
|
||||||
|
MetaDataProfileBean bean = new MetaDataProfileBean(typeWrapper, wrapperList);
|
||||||
|
beans.add(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("List of beans is " + beans);
|
||||||
|
return beans;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to retrieve metadata", e);
|
logger.error("Error while retrieving metadata beans ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -251,7 +298,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
bean.setResourcesIds(childrenIds);
|
bean.setResourcesIds(childrenIds);
|
||||||
|
|
||||||
// retrieve the metadata
|
// retrieve the metadata
|
||||||
List<MetaDataBean> metadataBeans = getMetaDataBeanList();
|
List<MetaDataProfileBean> metadataBeans = getMetadataProfilesList();
|
||||||
bean.setMetadataList(metadataBeans);
|
bean.setMetadataList(metadataBeans);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -301,7 +348,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
}
|
}
|
||||||
|
|
||||||
// retrieve the metadata
|
// retrieve the metadata
|
||||||
List<MetaDataBean> metadataBeans = getMetaDataBeanList();
|
List<MetaDataProfileBean> metadataBeans = getMetadataProfilesList();
|
||||||
bean.setMetadataList(metadataBeans);
|
bean.setMetadataList(metadataBeans);
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|
|
@ -4,8 +4,6 @@ import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.models.MetaDataBean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This bean will contain during ckan metadata creation the following information
|
* This bean will contain during ckan metadata creation the following information
|
||||||
* (related to the workspace folder that represents a dataset)
|
* (related to the workspace folder that represents a dataset)
|
||||||
|
@ -47,7 +45,7 @@ public class DatasetMetadataBean implements Serializable {
|
||||||
private String selectedOrganization;
|
private String selectedOrganization;
|
||||||
private List<String> resourcesIds; // in case of workspace, this is the list of children's ids
|
private List<String> resourcesIds; // in case of workspace, this is the list of children's ids
|
||||||
private boolean addResources; // if true, add these files as resources to the dataset
|
private boolean addResources; // if true, add these files as resources to the dataset
|
||||||
private List<MetaDataBean> metadataList;
|
private List<MetaDataProfileBean> metadataList;
|
||||||
|
|
||||||
public DatasetMetadataBean(){
|
public DatasetMetadataBean(){
|
||||||
super();
|
super();
|
||||||
|
@ -81,7 +79,7 @@ public class DatasetMetadataBean implements Serializable {
|
||||||
String maintainerEmail, String ownerIdentifier,
|
String maintainerEmail, String ownerIdentifier,
|
||||||
List<String> organizationList, String selectedOrganization,
|
List<String> organizationList, String selectedOrganization,
|
||||||
List<String> resourcesIds, boolean addResources,
|
List<String> resourcesIds, boolean addResources,
|
||||||
List<MetaDataBean> metadataList) {
|
List<MetaDataProfileBean> metadataList) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -104,11 +102,11 @@ public class DatasetMetadataBean implements Serializable {
|
||||||
this.metadataList = metadataList;
|
this.metadataList = metadataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaDataBean> getMetadataList() {
|
public List<MetaDataProfileBean> getMetadataList() {
|
||||||
return metadataList;
|
return metadataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetadataList(List<MetaDataBean> metadataList) {
|
public void setMetadataList(List<MetaDataProfileBean> metadataList) {
|
||||||
this.metadataList = metadataList;
|
this.metadataList = metadataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MetaDataProfileBean with its children (MetaDataFormat)
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class MetaDataProfileBean implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -7377022025375553568L;
|
||||||
|
|
||||||
|
private MetaDataTypeWrapper type; // the type
|
||||||
|
private List<MetadataFieldWrapper> metadataFields; // the fields of this type
|
||||||
|
|
||||||
|
public MetaDataProfileBean(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type
|
||||||
|
* @param metadataFields
|
||||||
|
*/
|
||||||
|
public MetaDataProfileBean(MetaDataTypeWrapper type, List<MetadataFieldWrapper> metadataFields) {
|
||||||
|
super();
|
||||||
|
this.type = type;
|
||||||
|
this.metadataFields = metadataFields;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the type
|
||||||
|
*/
|
||||||
|
public MetaDataTypeWrapper getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param type the type to set
|
||||||
|
*/
|
||||||
|
public void setType(MetaDataTypeWrapper type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return the metadataFields
|
||||||
|
*/
|
||||||
|
public List<MetadataFieldWrapper> getMetadataFields() {
|
||||||
|
return metadataFields;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param metadataFields the metadataFields to set
|
||||||
|
*/
|
||||||
|
public void setMetadataFields(List<MetadataFieldWrapper> metadataFields) {
|
||||||
|
this.metadataFields = metadataFields;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MetaDataBean [type=" + type + ", metadataFields="
|
||||||
|
+ metadataFields + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class MetadataTypeWrapper
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class MetaDataTypeWrapper implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2609935614105035447L;
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new metadata type.
|
||||||
|
*/
|
||||||
|
public MetaDataTypeWrapper() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new metadata type.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @param name the name
|
||||||
|
* @param description the description
|
||||||
|
*/
|
||||||
|
public MetaDataTypeWrapper(String id, String name, String description) {
|
||||||
|
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id.
|
||||||
|
*
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the description.
|
||||||
|
*
|
||||||
|
* @return the description
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the id.
|
||||||
|
*
|
||||||
|
* @param id the id to set
|
||||||
|
*/
|
||||||
|
public void setId(String id) {
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name.
|
||||||
|
*
|
||||||
|
* @param name the name to set
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the description.
|
||||||
|
*
|
||||||
|
* @param description the description to set
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MetaDataTypeWrapper [id=" + id + ", name=" + name
|
||||||
|
+ ", description=" + description + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,205 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.shared;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class MetadataFieldWrapper.
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class MetadataFieldWrapper implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -8476731365884466698L;
|
||||||
|
private String fieldName;
|
||||||
|
private Boolean mandatory = false;
|
||||||
|
private Boolean isBoolean = false;
|
||||||
|
private String defaulValue;
|
||||||
|
private String note;
|
||||||
|
private List<String> vocabulary;
|
||||||
|
private String validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new metadata field.
|
||||||
|
*/
|
||||||
|
public MetadataFieldWrapper() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new metadata field.
|
||||||
|
*
|
||||||
|
* @param fieldName the field name
|
||||||
|
* @param mandatory the mandatory
|
||||||
|
* @param isBoolean the is boolean
|
||||||
|
* @param defaulValue the defaul value
|
||||||
|
* @param note the note
|
||||||
|
* @param vocabulary the vocabulary
|
||||||
|
* @param validator the validator
|
||||||
|
*/
|
||||||
|
public MetadataFieldWrapper(
|
||||||
|
String fieldName, Boolean mandatory, Boolean isBoolean,
|
||||||
|
String defaulValue, String note, List<String> vocabulary,
|
||||||
|
String validator) {
|
||||||
|
super();
|
||||||
|
this.fieldName = fieldName;
|
||||||
|
this.mandatory = mandatory;
|
||||||
|
this.isBoolean = isBoolean;
|
||||||
|
this.defaulValue = defaulValue;
|
||||||
|
this.note = note;
|
||||||
|
this.vocabulary = vocabulary;
|
||||||
|
this.validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 checks if is boolean.
|
||||||
|
*
|
||||||
|
* @return the isBoolean
|
||||||
|
*/
|
||||||
|
public Boolean getIsBoolean() {
|
||||||
|
|
||||||
|
return isBoolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the defaul value.
|
||||||
|
*
|
||||||
|
* @return the defaulValue
|
||||||
|
*/
|
||||||
|
public String getDefaulValue() {
|
||||||
|
|
||||||
|
return defaulValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the note.
|
||||||
|
*
|
||||||
|
* @return the note
|
||||||
|
*/
|
||||||
|
public String getNote() {
|
||||||
|
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the vocabulary.
|
||||||
|
*
|
||||||
|
* @return the vocabulary
|
||||||
|
*/
|
||||||
|
public List<String> 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 checks if is boolean.
|
||||||
|
*
|
||||||
|
* @param isBoolean the isBoolean to set
|
||||||
|
*/
|
||||||
|
public void setIsBoolean(Boolean isBoolean) {
|
||||||
|
|
||||||
|
this.isBoolean = isBoolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the defaul value.
|
||||||
|
*
|
||||||
|
* @param defaulValue the defaulValue to set
|
||||||
|
*/
|
||||||
|
public void setDefaulValue(String defaulValue) {
|
||||||
|
|
||||||
|
this.defaulValue = defaulValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<String> vocabulary) {
|
||||||
|
|
||||||
|
this.vocabulary = vocabulary;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the validator.
|
||||||
|
*
|
||||||
|
* @param validator the validator to set
|
||||||
|
*/
|
||||||
|
public void setValidator(String validator) {
|
||||||
|
|
||||||
|
this.validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "MetadataFieldWrapper [fieldName=" + fieldName + ", mandatory="
|
||||||
|
+ mandatory + ", isBoolean=" + isBoolean + ", defaulValue="
|
||||||
|
+ defaulValue + ", note=" + note + ", vocabulary=" + vocabulary
|
||||||
|
+ ", validator=" + validator + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue