removed LicenseBean and passed to String #25275
This commit is contained in:
parent
b668e7c5b2
commit
a5892227ca
|
@ -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.BasicTabPanel;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
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.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.ZenodoContributor;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||||
|
@ -162,8 +161,8 @@ public class Ckan2ZenodoViewManager {
|
||||||
//license
|
//license
|
||||||
String licenseId = basicForm.getField_license().getSelectedValue();
|
String licenseId = basicForm.getField_license().getSelectedValue();
|
||||||
if(licenseId!=null) {
|
if(licenseId!=null) {
|
||||||
LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null);
|
//LicenseDTO licenseBean = new LicenseDTO(licenseId, null, null);
|
||||||
meta.setLicenses(new SerializableEnum<LicenseDTO>(Arrays.asList(licenseBean),null));
|
meta.setLicenses(new SerializableEnum<String>(Arrays.asList(licenseId),null));
|
||||||
//meta.setLicenses(Arrays.asList(licenseBean));
|
//meta.setLicenses(Arrays.asList(licenseBean));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,6 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
@ -98,17 +95,18 @@ public class FieldUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To zenodo ids.
|
* To zenodo ids.
|
||||||
|
* TODO Must passed an object License
|
||||||
*
|
*
|
||||||
* @param listLicenses the list licenses
|
* @param listLicenses the list licenses
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public static List<String> toZenodoIds(List<LicenseDTO> listLicenses){
|
public static List<String> toZenodoIds(List<String> listLicenses){
|
||||||
if(listLicenses==null)
|
if(listLicenses==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<String> licenses = new ArrayList<String>(listLicenses.size());
|
List<String> licenses = new ArrayList<String>(listLicenses.size());
|
||||||
for (LicenseDTO zenodoLicense : listLicenses) {
|
for (String zenodoLicense : listLicenses) {
|
||||||
licenses.add(zenodoLicense.getId());
|
licenses.add(zenodoLicense);
|
||||||
}
|
}
|
||||||
|
|
||||||
return licenses;
|
return licenses;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
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);
|
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.
|
* Checks if is not empty.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
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.ZenodoAuthor;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
||||||
|
@ -235,13 +234,12 @@ public class ItemToZenodoConverter {
|
||||||
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
||||||
|
|
||||||
//Licenses
|
//Licenses
|
||||||
List<LicenseDTO> selectedLicenses = null;
|
SerializableEnum<String> selectedLicenses = null;
|
||||||
if(depositionMetadata.getLicense()!=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) {
|
if(selectedLicenses!=null) {
|
||||||
zm.setLicenses(CkanToZenodoUtil.licenseToSerializableEnum(selectedLicenses, null)); //NEED TO ADD ALL LICENSES
|
zm.setLicenses(selectedLicenses);
|
||||||
//zm.setLicenses(selectedLicenses); //NEED TO ADD ALL LICENSES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(depositionMetadata.getEmbargo_date()!=null) {
|
if(depositionMetadata.getEmbargo_date()!=null) {
|
||||||
|
@ -528,13 +526,13 @@ public class ItemToZenodoConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
//license
|
//license
|
||||||
SerializableEnum<LicenseDTO> licenses = metadata.getLicenses();
|
SerializableEnum<String> licenses = metadata.getLicenses();
|
||||||
LOG.debug("Read licenses: "+licenses);
|
LOG.debug("Read licenses: "+licenses);
|
||||||
if(licenses!=null) {
|
if(licenses!=null) {
|
||||||
try {
|
try {
|
||||||
LicenseDTO lB = licenses.getSelectedValues().get(0);
|
String lB = licenses.getSelectedValues().get(0);
|
||||||
LOG.debug("Set license: "+lB);
|
LOG.debug("Set license: "+lB);
|
||||||
depositionMetadata.setLicense(lB.getId());
|
depositionMetadata.setLicense(lB);
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
LOG.warn("Set license error: ",e);
|
LOG.warn("Set license error: ",e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
//package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||||
|
//
|
||||||
import java.io.Serializable;
|
//import java.io.Serializable;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* A license bean like the ckan's one.
|
// * A license bean like the ckan's one.
|
||||||
*
|
// *
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
// *
|
||||||
* Jan 13, 2020
|
// * Jan 13, 2020
|
||||||
*/
|
// */
|
||||||
public class LicenseDTO implements Serializable {
|
//public class LicenseDTO implements Serializable {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
private static final long serialVersionUID = 8796338619448833841L;
|
// private static final long serialVersionUID = 8796338619448833841L;
|
||||||
private String id;
|
// private String id;
|
||||||
private String title;
|
// private String title;
|
||||||
private String url;
|
// private String url;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Instantiates a new license bean.
|
// * Instantiates a new license bean.
|
||||||
*/
|
// */
|
||||||
public LicenseDTO() {
|
// public LicenseDTO() {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public LicenseDTO(String id, String title, String url) {
|
// public LicenseDTO(String id, String title, String url) {
|
||||||
this.id = id;
|
// this.id = id;
|
||||||
this.title = title;
|
// this.title = title;
|
||||||
this.url = url;
|
// this.url = url;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getId() {
|
// public String getId() {
|
||||||
return id;
|
// return id;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getTitle() {
|
// public String getTitle() {
|
||||||
return title;
|
// return title;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public String getUrl() {
|
// public String getUrl() {
|
||||||
return url;
|
// return url;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setId(String id) {
|
// public void setId(String id) {
|
||||||
this.id = id;
|
// this.id = id;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setTitle(String title) {
|
// public void setTitle(String title) {
|
||||||
this.title = title;
|
// this.title = title;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setUrl(String url) {
|
// public void setUrl(String url) {
|
||||||
this.url = url;
|
// this.url = url;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String toString() {
|
// public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
// StringBuilder builder = new StringBuilder();
|
||||||
builder.append("LicenseDTO [id=");
|
// builder.append("LicenseDTO [id=");
|
||||||
builder.append(id);
|
// builder.append(id);
|
||||||
builder.append(", title=");
|
// builder.append(", title=");
|
||||||
builder.append(title);
|
// builder.append(title);
|
||||||
builder.append(", url=");
|
// builder.append(", url=");
|
||||||
builder.append(url);
|
// builder.append(url);
|
||||||
builder.append("]");
|
// builder.append("]");
|
||||||
return builder.toString();
|
// return builder.toString();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -35,8 +35,6 @@ public class ZenodoItem implements Serializable {
|
||||||
private String name; // this is the dataset name
|
private String name; // this is the dataset name
|
||||||
|
|
||||||
private ItemTranslateError translateError;
|
private ItemTranslateError translateError;
|
||||||
|
|
||||||
private LicenseDTO licenseDTO; //not used, here only for GWT serialization
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new zenodo item.
|
* Instantiates a new zenodo item.
|
||||||
|
|
|
@ -77,7 +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 SerializableEnum<LicenseDTO> licenses;
|
private SerializableEnum<String> licenses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new zenodo metadata.
|
* Instantiates a new zenodo metadata.
|
||||||
|
@ -882,7 +882,7 @@ public class ZenodoMetadata implements Serializable {
|
||||||
*
|
*
|
||||||
* @param licenses the new licenses
|
* @param licenses the new licenses
|
||||||
*/
|
*/
|
||||||
public void setLicenses(SerializableEnum<LicenseDTO> licenses) {
|
public void setLicenses(SerializableEnum<String> licenses) {
|
||||||
this.licenses = licenses;
|
this.licenses = licenses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ public class ZenodoMetadata implements Serializable {
|
||||||
*
|
*
|
||||||
* @return the licenses
|
* @return the licenses
|
||||||
*/
|
*/
|
||||||
public SerializableEnum<LicenseDTO> getLicenses() {
|
public SerializableEnum<String> getLicenses() {
|
||||||
return licenses;
|
return licenses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue