using List<String> for licenses
This commit is contained in:
parent
baf76a4e9e
commit
bd9854a86e
|
@ -327,20 +327,19 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
InfoTextAndLabels.addTooltipForFieldKey("access_conditions", cl_access_conditions);
|
||||
|
||||
// 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());
|
||||
FieldUtil.addValuesToListBox(field_license, listLicensesIds);
|
||||
if (zMeta.getLicenseIDs() != null) {
|
||||
//List<String> listLicensesIds = null;
|
||||
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenseIDs());
|
||||
if(selectedLicensesId!=null) {
|
||||
FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
||||
field_license.setEnabled(true);
|
||||
}else {
|
||||
//Exception case on missing list of selectable license ids
|
||||
FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
||||
//FieldUtil.addValuesToListBox(field_license, selectedLicensesId);
|
||||
field_license.setEnabled(false); //only one license id is available
|
||||
|
||||
}
|
||||
FieldUtil.selectValueToListBox(field_license, selectedLicensesId);
|
||||
//FieldUtil.selectValueToListBox(field_license, selectedLicensesId);
|
||||
}else
|
||||
field_license.setEnabled(false);
|
||||
|
||||
|
|
|
@ -162,7 +162,9 @@ public class Ckan2ZenodoViewManager {
|
|||
String licenseId = basicForm.getField_license().getSelectedValue();
|
||||
if(licenseId!=null) {
|
||||
//LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null);
|
||||
meta.setLicenses(new SerializableEnum<String>(Arrays.asList(licenseId),null));
|
||||
List<String> licenses = new ArrayList<String>();
|
||||
licenses.add(licenseId);
|
||||
meta.setLicenseIDs(licenses);
|
||||
//meta.setLicenses(Arrays.asList(licenseBean));
|
||||
}
|
||||
|
||||
|
|
|
@ -205,9 +205,9 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
// TODO I'M WAITING FOR itemName retrieved from ckan2zenodo library
|
||||
zenodoItem.setName(item.getItemId());
|
||||
|
||||
LOG.debug("zenodoItem getLicenses as list: " + zenodoItem.getMetadata().getLicenses());
|
||||
LOG.debug("zenodoItem getLicenses as list: " + zenodoItem.getMetadata().getLicenseIDs());
|
||||
LOG.debug("setting licenses at null");
|
||||
zenodoItem.getMetadata().setLicenses(null);
|
||||
zenodoItem.getMetadata().setLicenseIDs(null);
|
||||
|
||||
LOG.debug("Returning item: " + zenodoItem);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -234,12 +233,13 @@ public class ItemToZenodoConverter {
|
|||
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
||||
|
||||
//Licenses
|
||||
SerializableEnum<String> selectedLicenses = null;
|
||||
List<String> selectedLicenses = null;
|
||||
if(depositionMetadata.getLicense()!=null) {
|
||||
selectedLicenses = new SerializableEnum<String>(Arrays.asList(depositionMetadata.getLicense()), new ArrayList<String>()); //NEED TO ADD ALL LICENSES
|
||||
selectedLicenses = new ArrayList<String>();
|
||||
selectedLicenses.add(depositionMetadata.getLicense()); //NEED TO ADD ALL LICENSES
|
||||
}
|
||||
if(selectedLicenses!=null) {
|
||||
zm.setLicenses(selectedLicenses);
|
||||
zm.setLicenseIDs(selectedLicenses);
|
||||
}
|
||||
|
||||
if(depositionMetadata.getEmbargo_date()!=null) {
|
||||
|
@ -526,11 +526,11 @@ public class ItemToZenodoConverter {
|
|||
}
|
||||
|
||||
//license
|
||||
SerializableEnum<String> licenses = metadata.getLicenses();
|
||||
List<String> licenses = metadata.getLicenseIDs();
|
||||
LOG.debug("Read licenses: "+licenses);
|
||||
if(licenses!=null) {
|
||||
if(licenses!=null && licenses.size()>0) {
|
||||
try {
|
||||
String lB = licenses.getSelectedValues().get(0);
|
||||
String lB = licenses.get(0);
|
||||
LOG.debug("Set license: "+lB);
|
||||
depositionMetadata.setLicense(lB);
|
||||
}catch (Exception e) {
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ZenodoLicense.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Jan 21, 2020
|
||||
*/
|
||||
public interface ZenodoLicense {
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Gets the title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
String getUrl();
|
||||
|
||||
}
|
||||
//package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * The Interface ZenodoLicense.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
// *
|
||||
// * Jan 21, 2020
|
||||
// */
|
||||
//public interface ZenodoLicense {
|
||||
//
|
||||
// /**
|
||||
// * Gets the id.
|
||||
// *
|
||||
// * @return the id
|
||||
// */
|
||||
// String getId();
|
||||
//
|
||||
// /**
|
||||
// * Gets the title.
|
||||
// *
|
||||
// * @return the title
|
||||
// */
|
||||
// String getTitle();
|
||||
//
|
||||
// /**
|
||||
// * Gets the url.
|
||||
// *
|
||||
// * @return the url
|
||||
// */
|
||||
// String getUrl();
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -77,7 +77,9 @@ public class ZenodoMetadata implements Serializable {
|
|||
private List<ZenodoDateInterval> dates;
|
||||
private String method; // TODO html
|
||||
|
||||
private SerializableEnum<String> licenses;
|
||||
// private SerializableEnum<String> licenseIDs;
|
||||
|
||||
private List<String> licenseIDs;
|
||||
|
||||
/**
|
||||
* Instantiates a new zenodo metadata.
|
||||
|
@ -878,21 +880,21 @@ public class ZenodoMetadata implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the licenses.
|
||||
* Sets the license IDs.
|
||||
*
|
||||
* @param licenses the new licenses
|
||||
* @param licensesIDs the new license IDs
|
||||
*/
|
||||
public void setLicenses(SerializableEnum<String> licenses) {
|
||||
this.licenses = licenses;
|
||||
public void setLicenseIDs(List<String> licensesIDs) {
|
||||
this.licenseIDs = licensesIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the licenses.
|
||||
* Gets the license IDs.
|
||||
*
|
||||
* @return the licenses
|
||||
* @return the license IDs
|
||||
*/
|
||||
public SerializableEnum<String> getLicenses() {
|
||||
return licenses;
|
||||
public List<String> getLicenseIDs() {
|
||||
return licenseIDs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -989,8 +991,8 @@ public class ZenodoMetadata implements Serializable {
|
|||
builder.append(dates);
|
||||
builder.append(", method=");
|
||||
builder.append(method);
|
||||
builder.append(", licenses=");
|
||||
builder.append(licenses);
|
||||
builder.append(", licenseIDs=");
|
||||
builder.append(licenseIDs);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue