From b668e7c5b2910c2d9991064ab13f7b10727fac19 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 27 Jul 2023 15:27:26 +0200 Subject: [PATCH] renamed license bean --- .../client/view/Ckan2ZenodoViewManager.java | 6 +- .../client/view/FieldUtil.java | 6 +- .../CkanToZenodoPublisherServiceImpl.java | 14 +--- .../server/CkanToZenodoUtil.java | 9 +-- .../converter/ItemToZenodoConverter.java | 10 +-- .../{LicenseBean.java => LicenseDTO.java} | 71 ++++++------------- .../shared/wrapped/ZenodoItem.java | 2 + .../shared/wrapped/ZenodoMetadata.java | 6 +- 8 files changed, 43 insertions(+), 81 deletions(-) rename src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/{LicenseBean.java => LicenseDTO.java} (60%) diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java index 5beeb51..be9b835 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/Ckan2ZenodoViewManager.java @@ -8,7 +8,7 @@ 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.LicenseDTO; 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; @@ -162,8 +162,8 @@ public class Ckan2ZenodoViewManager { //license String licenseId = basicForm.getField_license().getSelectedValue(); if(licenseId!=null) { - LicenseBean licenseBean = new LicenseBean(licenseId, null, null); - meta.setLicenses(new SerializableEnum(Arrays.asList(licenseBean),null)); + LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null); + meta.setLicenses(new SerializableEnum(Arrays.asList(licenseBean),null)); //meta.setLicenses(Arrays.asList(licenseBean)); } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/FieldUtil.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/FieldUtil.java index 618cb21..245990b 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/FieldUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/view/FieldUtil.java @@ -3,7 +3,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view; import java.util.ArrayList; import java.util.List; -import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean; +import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseDTO; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoLicense; import com.github.gwtbootstrap.client.ui.ControlGroup; @@ -102,12 +102,12 @@ public class FieldUtil { * @param listLicenses the list licenses * @return the list */ - public static List toZenodoIds(List listLicenses){ + public static List toZenodoIds(List listLicenses){ if(listLicenses==null) return null; List licenses = new ArrayList(listLicenses.size()); - for (ZenodoLicense zenodoLicense : listLicenses) { + for (LicenseDTO zenodoLicense : listLicenses) { licenses.add(zenodoLicense.getId()); } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java index 0140f2b..7a3f958 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java @@ -187,18 +187,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple zdDeposition = client.forceTranslation(itemDescr); } - //fixing issue #25275 - List filteredResources = null; - try { - // 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); - } + List filteredResources = loadFilterResources(item.getItemId()); + LOG.debug("Loaded filtered resources: " + filteredResources); // Converting ZenodoDeposition to ZenodoItem ZenodoItem zenodoItem = ItemToZenodoConverter.toZenodoItem(zdDeposition); diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoUtil.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoUtil.java index 604e170..28e535a 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoUtil.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; 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.LicenseDTO; /** @@ -56,12 +56,9 @@ public class CkanToZenodoUtil { * @param allLicenses the all licenses * @return the serializable enum */ - public static SerializableEnum licenseToSerializableEnum(List selectedLicense, List allLicenses) { - -// if(allLicenses==null) -// allLicenses = new ArrayList(); + public static SerializableEnum licenseToSerializableEnum(List selectedLicense, List allLicenses) { - return new SerializableEnum(selectedLicense, allLicenses); + return new SerializableEnum(selectedLicense, allLicenses); } /** diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/converter/ItemToZenodoConverter.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/converter/ItemToZenodoConverter.java index 76e2470..2720a8e 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/converter/ItemToZenodoConverter.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/converter/ItemToZenodoConverter.java @@ -23,7 +23,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Subject; import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition; import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil; 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.LicenseDTO; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor; @@ -235,9 +235,9 @@ public class ItemToZenodoConverter { zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values())); //Licenses - List selectedLicenses = null; + List selectedLicenses = null; if(depositionMetadata.getLicense()!=null) { - selectedLicenses = Arrays.asList(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null)); + selectedLicenses = Arrays.asList(new LicenseDTO(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null)); } if(selectedLicenses!=null) { zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES @@ -528,11 +528,11 @@ public class ItemToZenodoConverter { } //license - SerializableEnum licenses = metadata.getLicenses(); + SerializableEnum licenses = metadata.getLicenses(); LOG.debug("Read licenses: "+licenses); if(licenses!=null) { try { - LicenseBean lB = licenses.getSelectedValues().get(0); + LicenseDTO lB = licenses.getSelectedValues().get(0); LOG.debug("Set license: "+lB); depositionMetadata.setLicense(lB.getId()); }catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseBean.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseDTO.java similarity index 60% rename from src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseBean.java rename to src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseDTO.java index dddeb59..28f4fe1 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseBean.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/LicenseDTO.java @@ -7,74 +7,58 @@ import java.io.Serializable; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Jan 13, 2020 + * Jan 13, 2020 */ -public class LicenseBean implements ZenodoLicense, Serializable { +public class LicenseDTO implements Serializable { - /** * */ - private static final long serialVersionUID = -7484830974654963132L; + private static final long serialVersionUID = 8796338619448833841L; private String id; private String title; private String url; - + /** * Instantiates a new license bean. */ - public LicenseBean() { + public LicenseDTO() { } - - /** - * Instantiates a new license bean. - * - * @param id the id - * @param title the title - * @param url the url - */ - public LicenseBean(String id, String title, String url) { - super(); + public LicenseDTO(String id, String title, String url) { this.id = id; this.title = title; this.url = url; } - - - public String getTitle() { - return title; - } - - - public void setTitle(String title) { - this.title = title; - } - - - public String getUrl() { - return url; - } - - - public void setUrl(String url) { - this.url = url; - } - public String getId() { return id; } + public String getTitle() { + return title; + } + + public String getUrl() { + return url; + } + public void setId(String id) { this.id = id; } + public void setTitle(String title) { + this.title = title; + } + + public void setUrl(String url) { + this.url = url; + } @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("LicenseBean [id="); + builder.append("LicenseDTO [id="); builder.append(id); builder.append(", title="); builder.append(title); @@ -84,15 +68,4 @@ public class LicenseBean implements ZenodoLicense, Serializable { return builder.toString(); } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ -// @Override -// public boolean equals(Object obj) { -// return obj.getClass().equals(this.getClass()) && ((LicenseBean)obj).getTitle().equals(this.title); -// } - - - } diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java index 712efea..effdff9 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java @@ -35,6 +35,8 @@ public class ZenodoItem implements Serializable { private String name; // this is the dataset name private ItemTranslateError translateError; + + private LicenseDTO licenseDTO; //not used, here only for GWT serialization /** * Instantiates a new zenodo item. diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoMetadata.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoMetadata.java index e637142..d820067 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoMetadata.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoMetadata.java @@ -77,7 +77,7 @@ public class ZenodoMetadata implements Serializable { private List dates; private String method; // TODO html - private SerializableEnum licenses; + private SerializableEnum licenses; /** * Instantiates a new zenodo metadata. @@ -882,7 +882,7 @@ public class ZenodoMetadata implements Serializable { * * @param licenses the new licenses */ - public void setLicenses(SerializableEnum licenses) { + public void setLicenses(SerializableEnum licenses) { this.licenses = licenses; } @@ -891,7 +891,7 @@ public class ZenodoMetadata implements Serializable { * * @return the licenses */ - public SerializableEnum getLicenses() { + public SerializableEnum getLicenses() { return licenses; }