revisited the set/get licenses code
This commit is contained in:
parent
04795542f8
commit
2d4488703a
|
@ -329,9 +329,9 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
// License
|
||||
if (zMeta.getLicenses() != null) {
|
||||
List<String> listLicensesIds = null;
|
||||
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectedValues());
|
||||
if(zMeta.getLicenses().getSelectableValues()!=null) {
|
||||
listLicensesIds = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectableValues());
|
||||
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenses());
|
||||
if(zMeta.getLicenses()!=null) {
|
||||
listLicensesIds = FieldUtil.toZenodoIds(zMeta.getLicenses());
|
||||
FieldUtil.addValuesToListBox(field_license, listLicensesIds);
|
||||
field_license.setEnabled(true);
|
||||
}else {
|
||||
|
|
|
@ -163,7 +163,8 @@ public class Ckan2ZenodoViewManager {
|
|||
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));
|
||||
//meta.setLicenses(new SerializableEnum<LicenseBean>(Arrays.asList(licenseBean),null));
|
||||
meta.setLicenses(Arrays.asList(licenseBean));
|
||||
}
|
||||
|
||||
//embargo date
|
||||
|
|
|
@ -46,9 +46,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
private static Logger LOG = LoggerFactory.getLogger(CkanToZenodoPublisherServiceImpl.class);
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#publishOnZenodo(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
||||
* CkanToZenodoPublisherService#publishOnZenodo(org.gcube.portlets.widgets.
|
||||
* ckan2zenodopublisher.shared.wrapped.ZenodoItem)
|
||||
*/
|
||||
@Override
|
||||
public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception {
|
||||
|
@ -79,7 +82,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
// Updating Deposition Metadata potentially changed on client-side
|
||||
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
||||
DepositionMetadata depositionMetadata = zenodoDepositionPreview.getMetadata();
|
||||
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata, depositionMetadata);
|
||||
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata,
|
||||
depositionMetadata);
|
||||
zenodoDepositionPreview.setMetadata(depositionMetadata);
|
||||
|
||||
// Loading Filtered resources according to VRE policies
|
||||
|
@ -93,7 +97,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
for (CkanResource ckanResource : filteredResources) {
|
||||
if (zf.getId().compareTo(ckanResource.getId()) == 0 && zf.getIsAlreadyPublished() == false) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zf.getFilename())) {
|
||||
ckanResource.setName(zf.getFilename()); //only the filename can be changed on clien-side
|
||||
ckanResource.setName(zf.getFilename()); // only the filename can be changed on
|
||||
// clien-side
|
||||
toUpload.add(ckanResource);
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +138,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
String clientError = String.format("%s", error);
|
||||
throw new Exception(clientError);
|
||||
} catch (ZenodoException e) {
|
||||
String error = ZenodoException.class.getName()+" during upload to Zenodo the catalogue item: "+zenodoItem.getName();
|
||||
String error = ZenodoException.class.getName() + " during upload to Zenodo the catalogue item: "
|
||||
+ zenodoItem.getName();
|
||||
LOG.error(error, e);
|
||||
// String clientError = String.format("%s", e.getRemoteMessage());
|
||||
ZenodoError zenodoError = new ZenodoError(e);
|
||||
|
@ -149,8 +155,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
||||
* CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.
|
||||
* ckan2zenodopublisher.shared.CatalogueItem)
|
||||
*/
|
||||
@Override
|
||||
public ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception {
|
||||
|
@ -192,28 +202,20 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
List<ZenodoFile> resources = ItemToZenodoConverter.toZenodoFiles(filteredResources, false);
|
||||
zenodoItem.addFiles(resources);
|
||||
|
||||
//I'M SETTING THE ID BECAUSE THE NAME IS NULL INTO BEAN PASSED FROM PORTLET SIDE
|
||||
// I'M SETTING THE ID BECAUSE THE NAME IS NULL INTO BEAN PASSED FROM PORTLET
|
||||
// SIDE
|
||||
// TODO I'M WAITING FOR itemName retrieved from ckan2zenodo library
|
||||
zenodoItem.setName(item.getItemId());
|
||||
|
||||
LOG.info("zenodoItem setting contributors and image not null");
|
||||
// zenodoItem.getMetadata().setContributors(null);
|
||||
// zenodoItem.getMetadata().setContributorsTypes(null);
|
||||
// zenodoItem.getMetadata().setImage_type(null);
|
||||
|
||||
// zenodoItem.getMetadata().setUpload_type(null);
|
||||
// zenodoItem.getMetadata().setPublication_type(null);
|
||||
|
||||
LOG.info("zenodoItem setLicenses not null as LicenseBean Snew");
|
||||
LOG.info("zenodoItem getLicenses: "+zenodoItem.getMetadata().getLicenses());
|
||||
//zenodoItem.getMetadata().setLicenses(null);
|
||||
LOG.debug("zenodoItem getLicenses as list: " + zenodoItem.getMetadata().getLicenses());
|
||||
|
||||
LOG.debug("Returning item: " + zenodoItem);
|
||||
|
||||
return zenodoItem;
|
||||
|
||||
} catch (ZenodoException e) {
|
||||
String error = ZenodoException.class.getName()+" on converting the catalogue item with id: "+item.getItemId();
|
||||
String error = ZenodoException.class.getName() + " on converting the catalogue item with id: "
|
||||
+ item.getItemId();
|
||||
LOG.error(error, e);
|
||||
// String clientError = String.format("%s. %s", error, e.getRemoteMessage());
|
||||
ZenodoError zenodoError = new ZenodoError(e);
|
||||
|
@ -230,8 +232,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.
|
||||
* CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.
|
||||
* ckan2zenodopublisher.shared.CatalogueItem)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> readFieldsDescriptions() throws Exception {
|
||||
|
@ -288,7 +294,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
* @throws ConfigurationException the configuration exception
|
||||
* @throws TransformationException the transformation exception
|
||||
*/
|
||||
private List<CkanResource> loadFilterResources(String itemName) throws GcatException, ConfigurationException, TransformationException {
|
||||
private List<CkanResource> loadFilterResources(String itemName)
|
||||
throws GcatException, ConfigurationException, TransformationException {
|
||||
|
||||
Ckan2Zenodo client = new Ckan2ZenodoImpl();
|
||||
// Get the item representation
|
||||
|
@ -306,8 +313,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
try {
|
||||
UserLocalServiceUtil.getService();
|
||||
return false;
|
||||
}
|
||||
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||
} catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
||||
LOG.debug("Development Mode ON");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -239,8 +239,10 @@ public class ItemToZenodoConverter {
|
|||
if(depositionMetadata.getLicense()!=null) {
|
||||
selectedLicenses = Arrays.asList(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null));
|
||||
}
|
||||
if(selectedLicenses!=null)
|
||||
zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
|
||||
if(selectedLicenses!=null) {
|
||||
zm.setLicenses(selectedLicenses); //NEED TO ADD ALL LICENSES
|
||||
//zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
|
||||
}
|
||||
|
||||
if(depositionMetadata.getEmbargo_date()!=null) {
|
||||
|
||||
|
@ -526,11 +528,11 @@ public class ItemToZenodoConverter {
|
|||
}
|
||||
|
||||
//license
|
||||
SerializableEnum<LicenseBean> licenses = metadata.getLicenses();
|
||||
List<LicenseBean> licenses = metadata.getLicenses();
|
||||
LOG.debug("Read licenses: "+licenses);
|
||||
if(licenses!=null) {
|
||||
try {
|
||||
LicenseBean lB = licenses.getSelectedValues().get(0);
|
||||
LicenseBean lB = licenses.get(0);
|
||||
LOG.debug("Set license: "+lB);
|
||||
depositionMetadata.setLicense(lB.getId());
|
||||
}catch (Exception e) {
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.shared;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
||||
|
||||
/**
|
||||
* The Class SerializableEnum.
|
||||
*
|
||||
|
@ -13,7 +11,7 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBea
|
|||
* Dec 10, 2019
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class SerializableEnum<E extends Serializable> implements Serializable{
|
||||
public class SerializableEnum<E> implements Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -23,8 +21,6 @@ public class SerializableEnum<E extends Serializable> implements Serializable{
|
|||
|
||||
private List<E> selectableValues;
|
||||
|
||||
private LicenseBean licenseBean; //never used. Do not remove it, required for GWT serialization.
|
||||
|
||||
|
||||
public SerializableEnum() {
|
||||
}
|
||||
|
|
|
@ -77,7 +77,9 @@ public class ZenodoMetadata implements Serializable {
|
|||
private List<ZenodoDateInterval> dates;
|
||||
private String method; // TODO html
|
||||
|
||||
private SerializableEnum<LicenseBean> licenses;
|
||||
private List<LicenseBean> licenses;
|
||||
|
||||
private List<LicenseBean> allLicenses;
|
||||
|
||||
/**
|
||||
* Instantiates a new zenodo metadata.
|
||||
|
@ -103,10 +105,20 @@ public class ZenodoMetadata implements Serializable {
|
|||
this.upload_type = upload_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the contributors types.
|
||||
*
|
||||
* @return the contributors types
|
||||
*/
|
||||
public SerializableEnum<String> getContributorsTypes() {
|
||||
return contributorsTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contributors types.
|
||||
*
|
||||
* @param contributorsTypes the new contributors types
|
||||
*/
|
||||
public void setContributorsTypes(SerializableEnum<String> contributorsTypes) {
|
||||
this.contributorsTypes = contributorsTypes;
|
||||
}
|
||||
|
@ -872,21 +884,42 @@ public class ZenodoMetadata implements Serializable {
|
|||
*
|
||||
* @param licenses the new licenses
|
||||
*/
|
||||
public void setLicenses(SerializableEnum<LicenseBean> licenses) {
|
||||
public void setLicenses(List<LicenseBean> licenses) {
|
||||
this.licenses = licenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the licenses.
|
||||
* Gets the licenses. The selectable values
|
||||
*
|
||||
* @return the licenses
|
||||
*/
|
||||
public SerializableEnum<LicenseBean> getLicenses() {
|
||||
public List<LicenseBean> getLicenses() {
|
||||
return licenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all licenses.
|
||||
*
|
||||
* @return the all licenses
|
||||
*/
|
||||
public void getAllLicenses() {
|
||||
this.allLicenses = licenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the licenses.
|
||||
*
|
||||
* @param licenses the new licenses
|
||||
*/
|
||||
public void setAllLicenses(List<LicenseBean> licenses) {
|
||||
this.allLicenses = licenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue