This commit is contained in:
Francesco Mangiacrapa 2023-07-27 15:09:39 +02:00
parent 2d4488703a
commit cb29e33652
5 changed files with 27 additions and 39 deletions

View File

@ -329,9 +329,9 @@ public class BasicInformationView extends Composite implements FormValidator {
// License // License
if (zMeta.getLicenses() != null) { if (zMeta.getLicenses() != null) {
List<String> listLicensesIds = null; List<String> listLicensesIds = null;
List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenses()); List<String> selectedLicensesId = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectedValues());
if(zMeta.getLicenses()!=null) { if(zMeta.getLicenses().getSelectableValues()!=null) {
listLicensesIds = FieldUtil.toZenodoIds(zMeta.getLicenses()); listLicensesIds = FieldUtil.toZenodoIds(zMeta.getLicenses().getSelectableValues());
FieldUtil.addValuesToListBox(field_license, listLicensesIds); FieldUtil.addValuesToListBox(field_license, listLicensesIds);
field_license.setEnabled(true); field_license.setEnabled(true);
}else { }else {

View File

@ -163,8 +163,8 @@ public class Ckan2ZenodoViewManager {
String licenseId = basicForm.getField_license().getSelectedValue(); String licenseId = basicForm.getField_license().getSelectedValue();
if(licenseId!=null) { if(licenseId!=null) {
LicenseBean licenseBean = new LicenseBean(licenseId, null, 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)); //meta.setLicenses(Arrays.asList(licenseBean));
} }
//embargo date //embargo date

View File

@ -180,17 +180,25 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
ItemTranslateError itemTrError = null; ItemTranslateError itemTrError = null;
try { try {
zdDeposition = client.translate(itemDescr); zdDeposition = client.translate(itemDescr);
} catch (ConfigurationException e) { } catch (ConfigurationException | TransformationException e) {
LOG.info(ConfigurationException.class.getSimpleName() + " thrown, trying to use forceTranslation for: " LOG.info(ConfigurationException.class.getSimpleName() + " thrown, trying to use forceTranslation for: "
+ itemDescr.getName()); + itemDescr.getName());
itemTrError = new ItemTranslateError(e.getMessage(), ERROR_TYPE.INFO); itemTrError = new ItemTranslateError(e.getMessage(), ERROR_TYPE.INFO);
zdDeposition = client.forceTranslation(itemDescr); zdDeposition = client.forceTranslation(itemDescr);
} }
// Loading Filtered resources according to VRE policies //fixing issue #25275
List<CkanResource> filteredResources = loadFilterResources(item.getItemId()); List<CkanResource> filteredResources = null;
try {
LOG.debug("Loaded filtered resources: " + filteredResources); // Loading Filtered resources according to VRE policies
filteredResources = loadFilterResources(item.getItemId());
LOG.debug("Loaded filtered resources: " + filteredResources);
} catch (ConfigurationException | TransformationException e) {
LOG.info(ConfigurationException.class.getSimpleName() + " thrown, registering loadFilterResources error: "
+ itemDescr.getName());
itemTrError = new ItemTranslateError(e.getMessage(), ERROR_TYPE.INFO);
//zdDeposition = client.forceTranslation(itemDescr);
}
// Converting ZenodoDeposition to ZenodoItem // Converting ZenodoDeposition to ZenodoItem
ZenodoItem zenodoItem = ItemToZenodoConverter.toZenodoItem(zdDeposition); ZenodoItem zenodoItem = ItemToZenodoConverter.toZenodoItem(zdDeposition);

View File

@ -240,8 +240,8 @@ public class ItemToZenodoConverter {
selectedLicenses = Arrays.asList(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null)); selectedLicenses = Arrays.asList(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null));
} }
if(selectedLicenses!=null) { if(selectedLicenses!=null) {
zm.setLicenses(selectedLicenses); //NEED TO ADD ALL LICENSES zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
//zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES //zm.setLicenses(selectedLicenses); //NEED TO ADD ALL LICENSES
} }
if(depositionMetadata.getEmbargo_date()!=null) { if(depositionMetadata.getEmbargo_date()!=null) {
@ -528,11 +528,11 @@ public class ItemToZenodoConverter {
} }
//license //license
List<LicenseBean> licenses = metadata.getLicenses(); SerializableEnum<LicenseBean> licenses = metadata.getLicenses();
LOG.debug("Read licenses: "+licenses); LOG.debug("Read licenses: "+licenses);
if(licenses!=null) { if(licenses!=null) {
try { try {
LicenseBean lB = licenses.get(0); LicenseBean lB = licenses.getSelectedValues().get(0);
LOG.debug("Set license: "+lB); LOG.debug("Set license: "+lB);
depositionMetadata.setLicense(lB.getId()); depositionMetadata.setLicense(lB.getId());
}catch (Exception e) { }catch (Exception e) {

View File

@ -77,9 +77,7 @@ public class ZenodoMetadata implements Serializable {
private List<ZenodoDateInterval> dates; private List<ZenodoDateInterval> dates;
private String method; // TODO html private String method; // TODO html
private List<LicenseBean> licenses; private SerializableEnum<LicenseBean> licenses;
private List<LicenseBean> allLicenses;
/** /**
* Instantiates a new zenodo metadata. * Instantiates a new zenodo metadata.
@ -884,37 +882,19 @@ public class ZenodoMetadata implements Serializable {
* *
* @param licenses the new licenses * @param licenses the new licenses
*/ */
public void setLicenses(List<LicenseBean> licenses) { public void setLicenses(SerializableEnum<LicenseBean> licenses) {
this.licenses = licenses; this.licenses = licenses;
} }
/** /**
* Gets the licenses. The selectable values * Gets the licenses.
* *
* @return the licenses * @return the licenses
*/ */
public List<LicenseBean> getLicenses() { public SerializableEnum<LicenseBean> getLicenses() {
return licenses; 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. * To string.
* *