Managed embargo_date

This commit is contained in:
Francesco Mangiacrapa 2020-01-21 17:07:05 +01:00
parent 5e61b54214
commit a2add897fe
8 changed files with 100 additions and 105 deletions

View File

@ -18,18 +18,15 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMeta
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.github.gwtbootstrap.datepicker.client.Datepicker;
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
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.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
@ -81,10 +78,10 @@ public class BasicInformationView extends Composite implements FormValidator {
ListBox field_image_type;
@UiField
ControlGroup cg_access_condition;
ControlGroup cg_access_conditions;
@UiField
TextArea field_access_condition;
TextArea field_access_conditions;
@UiField
ControlGroup cg_publication_type;
@ -130,6 +127,12 @@ public class BasicInformationView extends Composite implements FormValidator {
@UiField
DateBox embargoDate;
@UiField
ControlLabel cl_embargo_date;
@UiField
ControlLabel cl_access_conditions;
// @UiField
// Pager pager;
@ -189,7 +192,7 @@ public class BasicInformationView extends Composite implements FormValidator {
@Override
public void onChange(ChangeEvent event) {
cg_embargo_date.setVisible(false);
cg_access_condition.setVisible(false);
cg_access_conditions.setVisible(false);
if(zenodoItem.getMetadata().getEmbargo_date()!=null) {
Date embDate = zenodoItem.getMetadata().getEmbargo_date();
@ -198,14 +201,14 @@ public class BasicInformationView extends Composite implements FormValidator {
}
if(zenodoItem.getMetadata().getAccess_conditions()!=null) {
cg_access_condition.setVisible(true);
cg_access_conditions.setVisible(true);
}
String selectedLower = field_access_right.getSelectedValue().toLowerCase();
if(selectedLower.compareTo("open")==0 || selectedLower.compareTo("embargoed")==0) {
cg_embargo_date.setVisible(true);
}else if(selectedLower.compareTo("restricted")==0) {
cg_access_condition.setVisible(true);
cg_access_conditions.setVisible(true);
}
}
@ -309,10 +312,14 @@ public class BasicInformationView extends Composite implements FormValidator {
}else
cg_embargo_date.setVisible(false);
InfoTextAndLabels.addFieldDescriptionInfo("embargo_date", cl_embargo_date);
if(zMeta.getAccess_conditions()!=null) {
field_access_condition.setValue(zMeta.getAccess_conditions());
field_access_conditions.setValue(zMeta.getAccess_conditions());
}else
cg_access_condition.setVisible(false);
cg_access_conditions.setVisible(false);
InfoTextAndLabels.addFieldDescriptionInfo("access_conditions", cl_access_conditions);
// License
if (zMeta.getLicenses() != null) {
@ -393,6 +400,8 @@ public class BasicInformationView extends Composite implements FormValidator {
FieldUtil.setControlGroup(cgDOI, ControlGroupType.NONE);
FieldUtil.setControlGroup(cgTitle, ControlGroupType.NONE);
FieldUtil.setControlGroup(cg_embargo_date, ControlGroupType.NONE);
FieldUtil.setControlGroup(cg_access_conditions, ControlGroupType.NONE);
// Validating DOI
if (cgDOI.isVisible()) {
@ -420,6 +429,26 @@ public class BasicInformationView extends Composite implements FormValidator {
return "This field is required";
}
}
if(cg_embargo_date.isVisible()) {
boolean isValid = embargoDate.getValue()!=null;
if(!isValid) {
FieldUtil.setControlGroup(cg_embargo_date, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("The field Embargo Date is required");
return "This field is required";
}
}
if(cg_access_conditions.isVisible()) {
boolean isValid = field_access_conditions.getValue()!= null && !field_access_conditions.getValue().isEmpty();
if(!isValid) {
FieldUtil.setControlGroup(cg_access_conditions, ControlGroupType.ERROR);
error_alert.setVisible(true);
error_alert.setText("The field Access Condition is required");
return "This field is required";
}
}
// Validating Creators
for (CreatorsFormView cfv : listOfCreatorsView) {
@ -571,6 +600,14 @@ public class BasicInformationView extends Composite implements FormValidator {
return field_access_right;
}
/**
* Gets the field access conditions.
*
* @return the field access conditions
*/
public TextArea getField_access_conditions() {
return field_access_conditions;
}
/**
* Gets the field image type.

View File

@ -154,15 +154,15 @@
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_access_condition">
<b:ControlLabel for="cl_access_condition"
ui:field="cl_access_condition">
<b:ControlGroup ui:field="cg_access_conditions">
<b:ControlLabel for="cl_access_conditions"
ui:field="cl_access_conditions">
<font color="red">*</font>
Access Condition
</b:ControlLabel>
<b:Controls>
<b:TextArea name="Access Condition"
ui:field="field_access_condition"></b:TextArea>
ui:field="field_access_conditions"></b:TextArea>
</b:Controls>
</b:ControlGroup>

View File

@ -1,38 +0,0 @@
//package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils;
//
//import com.github.gwtbootstrap.client.ui.Icon;
//import com.github.gwtbootstrap.client.ui.Popover;
//import com.google.gwt.core.client.GWT;
//import com.google.gwt.dom.client.Style.Cursor;
//import com.google.gwt.uibinder.client.UiBinder;
//import com.google.gwt.uibinder.client.UiField;
//import com.google.gwt.user.client.ui.Composite;
//import com.google.gwt.user.client.ui.HTML;
//import com.google.gwt.user.client.ui.Widget;
//
//public class FieldDescription extends Composite {
//
// private static FieldDescriptionUiBinder uiBinder = GWT.create(FieldDescriptionUiBinder.class);
//
// interface FieldDescriptionUiBinder extends UiBinder<Widget, FieldDescription> {
// }
//
// @UiField
// Popover popoverDescription;
//
// @UiField
// Icon infoIconDescription;
//
// public FieldDescription(String captionText, String text) {
// initWidget(uiBinder.createAndBindUi(this));
//
// // prepare the popover
// if(captionText!=null)
// popoverDescription.setHeading(new HTML("<b>" + captionText + "</b>").getHTML());
//
// popoverDescription.setText(new HTML("<p style='color:initial'>" + text + "</p>").getHTML());
//
// // set icon cursor
// infoIconDescription.getElement().getStyle().setCursor(Cursor.HELP);
// }
//}

View File

@ -1,29 +0,0 @@
<!-- <!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">
<ui:style>
.important {
font-weight: bold;
}
.div-inline {
position: relative;
}
.the-font-size {
font-size: 1.3em;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.div-inline}">
<div style="width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverDescription" html="true"
animation="true" placement="RIGHT">
<g:FocusPanel ui:field="focusPanelDescription">
<b:Icon type="INFO_SIGN" ui:field="infoIconDescription"
addStyleNames="{style.the-font-size}" />
</g:FocusPanel>
</b:Popover>
</div>
</g:HTMLPanel>
</ui:UiBinder> -->

View File

@ -2,11 +2,13 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
@ -156,9 +158,24 @@ public class Ckan2ZenodoViewManager {
String accessRight = basicForm.getField_access_right().getSelectedValue();
if(accessRight!=null)
meta.setAccess_right(new SerializableEnum<>(Arrays.asList(accessRight), meta.getAccess_right().getSelectableValues()));
//keywords
meta.setKeywords(basicForm.getTags());
//license
String licenseId = basicForm.getField_license().getSelectedValue();
if(licenseId!=null) {
LicenseBean licenseBean = new LicenseBean(licenseId, null, null);
meta.setLicenses(new SerializableEnum<LicenseBean>(Arrays.asList(licenseBean),null));
}
//embargo date
Date embargoDate = basicForm.getEmbargoDate();
if(embargoDate!=null)
meta.setEmbargo_date(embargoDate);
// access condition
String accessCondition = basicForm.getField_access_conditions().getValue();
if(accessCondition!=null)
meta.setAccess_conditions(accessCondition);
zenodoItem.setMetadata(meta);
// Updating list of file for publishing

View File

@ -155,25 +155,6 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
LOG.debug("Returning item: "+zenodoItem);
return zenodoItem;
// //TO TEST
// ZenodoDeposition zd = new ZenodoDeposition();
// zd.setTitle("My beautiful title");
// ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
// for (int i = 0; i < 5; i++) {
// FileDeposition fd = new FileDeposition();
// int index = i+1;
// fd.setFilename("My file "+index);
// files.add(fd);
// }
// zd.setFiles(files);
// DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
// metadata.setDescription("My beautiful description");
// List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
// related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
// metadata.setRelated_identifiers(related_identifiers);
// zd.setMetadata(metadata);
// return ItemToZenodoConverter.toZenodoItem(zd);
} catch (Exception e) {
String error = "Error on converting the catalogue item: "+item.getItemName();

View File

@ -8,4 +8,6 @@ contributors=The contributors of the deposition (e.g. editors, data curators, et
upload_type=Controlled vocabulary: <br>* publication: Publication<br>* poster: Poster<br>* presentation: Presentation<br>* dataset: Dataset, etc.
publication_type=Controlled vocabulary: <br>* annotationcollection: Annotation collection<br>* book: Book<br>* section: Book section<br>* conferencepaper: Conference paper<br>* datamanagementplan: Data management plan<br>* article: Journal article, etc.
publication_date=Date of publication in ISO8601 format (YYYY-MM-DD). Defaults to current date.
keywords=Free form keywords for this deposition.
keywords=Free form keywords for this deposition.
embargo_date=When the deposited files will be made automatically made publicly available by the system (Defaults to current date)
access_conditions=Specify the conditions under which you grant users access to the files in your upload. User requesting access will be asked to justify how they fulfil the conditions. Based on the justification, you decide who to grant/deny access. You are not allowed to charge users for granting access to data hosted on Zenodo.

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.gcube.data.publishing.ckan2zenodo.model.CkanResource;
@ -478,6 +479,31 @@ public class ItemToZenodoConverter {
depositionMetadata.setImage_type(ImageType.valueOf(imageTypeValue));
}
//embargo_date
Date embargoDate = metadata.getEmbargo_date();
LOG.debug("Read embargo date: "+imageType);
if(embargoDate!=null) {
LOG.debug("Set embargo date: "+embargoDate);
depositionMetadata.setEmbargo_date(embargoDate);
}
//access conditions
String accessConditions = metadata.getAccess_conditions();
LOG.debug("Read access conditions: "+accessConditions);
if(accessConditions!=null) {
LOG.debug("Set access conditions: "+accessConditions);
depositionMetadata.setAccess_conditions(accessConditions);
}
//license
SerializableEnum<LicenseBean> licenses = metadata.getLicenses();
LOG.debug("Read licenses: "+licenses);
if(licenses!=null) {
LicenseBean lB = licenses.getSelectedValues().get(0);
LOG.debug("Set license: "+lB);
depositionMetadata.setLicense(lB.getId());
}
//creators
List<Creator> creators = null;
List<? extends ZenodoAuthor> zenodoCreators = metadata.getCreators();
@ -501,7 +527,6 @@ public class ItemToZenodoConverter {
LOG.debug("Set contributor: name "+contributor.getName() + " type "+contributor.getType());
}
}
depositionMetadata.setContributors(contributors);
//keywords