renamed license bean

This commit is contained in:
Francesco Mangiacrapa 2023-07-27 15:27:26 +02:00
parent cb29e33652
commit b668e7c5b2
8 changed files with 43 additions and 81 deletions

View File

@ -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<LicenseBean>(Arrays.asList(licenseBean),null));
LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null);
meta.setLicenses(new SerializableEnum<LicenseDTO>(Arrays.asList(licenseBean),null));
//meta.setLicenses(Arrays.asList(licenseBean));
}

View File

@ -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<String> toZenodoIds(List<LicenseBean> listLicenses){
public static List<String> toZenodoIds(List<LicenseDTO> listLicenses){
if(listLicenses==null)
return null;
List<String> licenses = new ArrayList<String>(listLicenses.size());
for (ZenodoLicense zenodoLicense : listLicenses) {
for (LicenseDTO zenodoLicense : listLicenses) {
licenses.add(zenodoLicense.getId());
}

View File

@ -187,18 +187,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
zdDeposition = client.forceTranslation(itemDescr);
}
//fixing issue #25275
List<CkanResource> 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<CkanResource> filteredResources = loadFilterResources(item.getItemId());
LOG.debug("Loaded filtered resources: " + filteredResources);
// Converting ZenodoDeposition to ZenodoItem
ZenodoItem zenodoItem = ItemToZenodoConverter.toZenodoItem(zdDeposition);

View File

@ -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<LicenseBean> licenseToSerializableEnum(List<LicenseBean> selectedLicense, List<LicenseBean> allLicenses) {
// if(allLicenses==null)
// allLicenses = new ArrayList<LicenseBean>();
public static SerializableEnum<LicenseDTO> licenseToSerializableEnum(List<LicenseDTO> selectedLicense, List<LicenseDTO> allLicenses) {
return new SerializableEnum<LicenseBean>(selectedLicense, allLicenses);
return new SerializableEnum<LicenseDTO>(selectedLicense, allLicenses);
}
/**

View File

@ -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<LicenseBean> selectedLicenses = null;
List<LicenseDTO> 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<LicenseBean> licenses = metadata.getLicenses();
SerializableEnum<LicenseDTO> 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) {

View File

@ -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);
// }
}

View File

@ -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.

View File

@ -77,7 +77,7 @@ public class ZenodoMetadata implements Serializable {
private List<ZenodoDateInterval> dates;
private String method; // TODO html
private SerializableEnum<LicenseBean> licenses;
private SerializableEnum<LicenseDTO> licenses;
/**
* Instantiates a new zenodo metadata.
@ -882,7 +882,7 @@ public class ZenodoMetadata implements Serializable {
*
* @param licenses the new licenses
*/
public void setLicenses(SerializableEnum<LicenseBean> licenses) {
public void setLicenses(SerializableEnum<LicenseDTO> licenses) {
this.licenses = licenses;
}
@ -891,7 +891,7 @@ public class ZenodoMetadata implements Serializable {
*
* @return the licenses
*/
public SerializableEnum<LicenseBean> getLicenses() {
public SerializableEnum<LicenseDTO> getLicenses() {
return licenses;
}