removed LicenseBean and passed to String #25275

This commit is contained in:
Francesco Mangiacrapa 2023-07-27 15:52:22 +02:00
parent b668e7c5b2
commit a5892227ca
7 changed files with 86 additions and 107 deletions

View File

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

View File

@ -3,9 +3,6 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
import java.util.ArrayList;
import java.util.List;
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;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextBox;
@ -98,17 +95,18 @@ public class FieldUtil {
/**
* To zenodo ids.
* TODO Must passed an object License
*
* @param listLicenses the list licenses
* @return the list
*/
public static List<String> toZenodoIds(List<LicenseDTO> listLicenses){
public static List<String> toZenodoIds(List<String> listLicenses){
if(listLicenses==null)
return null;
List<String> licenses = new ArrayList<String>(listLicenses.size());
for (LicenseDTO zenodoLicense : listLicenses) {
licenses.add(zenodoLicense.getId());
for (String zenodoLicense : listLicenses) {
licenses.add(zenodoLicense);
}
return licenses;

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseDTO;
/**
@ -48,19 +47,6 @@ public class CkanToZenodoUtil {
return new SerializableEnum<String>(selectedValues, values);
}
/**
* License to serializable enum.
*
* @param selectedLicense the selected license
* @param allLicenses the all licenses
* @return the serializable enum
*/
public static SerializableEnum<LicenseDTO> licenseToSerializableEnum(List<LicenseDTO> selectedLicense, List<LicenseDTO> allLicenses) {
return new SerializableEnum<LicenseDTO>(selectedLicense, allLicenses);
}
/**
* Checks if is not empty.
*

View File

@ -23,7 +23,6 @@ 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.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,13 +234,12 @@ public class ItemToZenodoConverter {
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
//Licenses
List<LicenseDTO> selectedLicenses = null;
SerializableEnum<String> selectedLicenses = null;
if(depositionMetadata.getLicense()!=null) {
selectedLicenses = Arrays.asList(new LicenseDTO(depositionMetadata.getLicense(),depositionMetadata.getLicense(), null));
selectedLicenses = new SerializableEnum<String>(Arrays.asList(depositionMetadata.getLicense()), null); //NEED TO ADD ALL LICENSES
}
if(selectedLicenses!=null) {
zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
//zm.setLicenses(selectedLicenses); //NEED TO ADD ALL LICENSES
zm.setLicenses(selectedLicenses);
}
if(depositionMetadata.getEmbargo_date()!=null) {
@ -528,13 +526,13 @@ public class ItemToZenodoConverter {
}
//license
SerializableEnum<LicenseDTO> licenses = metadata.getLicenses();
SerializableEnum<String> licenses = metadata.getLicenses();
LOG.debug("Read licenses: "+licenses);
if(licenses!=null) {
try {
LicenseDTO lB = licenses.getSelectedValues().get(0);
String lB = licenses.getSelectedValues().get(0);
LOG.debug("Set license: "+lB);
depositionMetadata.setLicense(lB.getId());
depositionMetadata.setLicense(lB);
}catch (Exception e) {
LOG.warn("Set license error: ",e);
}

View File

@ -1,71 +1,71 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
import java.io.Serializable;
/**
* A license bean like the ckan's one.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Jan 13, 2020
*/
public class LicenseDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8796338619448833841L;
private String id;
private String title;
private String url;
/**
* Instantiates a new license bean.
*/
public LicenseDTO() {
}
public LicenseDTO(String id, String title, String url) {
this.id = id;
this.title = title;
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("LicenseDTO [id=");
builder.append(id);
builder.append(", title=");
builder.append(title);
builder.append(", url=");
builder.append(url);
builder.append("]");
return builder.toString();
}
}
//package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
//
//import java.io.Serializable;
//
///**
// * A license bean like the ckan's one.
// *
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
// *
// * Jan 13, 2020
// */
//public class LicenseDTO implements Serializable {
//
// /**
// *
// */
// private static final long serialVersionUID = 8796338619448833841L;
// private String id;
// private String title;
// private String url;
//
// /**
// * Instantiates a new license bean.
// */
// public LicenseDTO() {
// }
//
// public LicenseDTO(String id, String title, String url) {
// this.id = id;
// this.title = title;
// 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("LicenseDTO [id=");
// builder.append(id);
// builder.append(", title=");
// builder.append(title);
// builder.append(", url=");
// builder.append(url);
// builder.append("]");
// return builder.toString();
// }
//
//}

View File

@ -35,8 +35,6 @@ 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<LicenseDTO> licenses;
private SerializableEnum<String> licenses;
/**
* Instantiates a new zenodo metadata.
@ -882,7 +882,7 @@ public class ZenodoMetadata implements Serializable {
*
* @param licenses the new licenses
*/
public void setLicenses(SerializableEnum<LicenseDTO> licenses) {
public void setLicenses(SerializableEnum<String> licenses) {
this.licenses = licenses;
}
@ -891,7 +891,7 @@ public class ZenodoMetadata implements Serializable {
*
* @return the licenses
*/
public SerializableEnum<LicenseDTO> getLicenses() {
public SerializableEnum<String> getLicenses() {
return licenses;
}