Fixed creators/contributors view and submit
This commit is contained in:
parent
3e938addad
commit
6fd20c127d
|
@ -91,14 +91,16 @@ public class CreatorView extends Composite {
|
||||||
|
|
||||||
if(this.userRole!=null) {
|
if(this.userRole!=null) {
|
||||||
field_cl_author.add(new HTML("<font color='red'>*</font> "+userRole));
|
field_cl_author.add(new HTML("<font color='red'>*</font> "+userRole));
|
||||||
|
remove_author.setText("Remove "+userRole);
|
||||||
}else { //default role is Author
|
}else { //default role is Author
|
||||||
field_cl_author.add(new HTML("<font color='red'>*</font> Author"));
|
field_cl_author.add(new HTML("<font color='red'>*</font> Author"));
|
||||||
|
remove_author.setText("Remove Author");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.author!=null) {
|
if(this.author!=null) {
|
||||||
setField_name(InfoTextAndLabels.validValue(author.getName()));
|
setField_name(InfoTextAndLabels.validValue(this.author.getName()));
|
||||||
setField_affiliation(InfoTextAndLabels.validValue(author.getAffiliation()));
|
setField_affiliation(InfoTextAndLabels.validValue(this.author.getAffiliation()));
|
||||||
setField_orcid(InfoTextAndLabels.validValue(author.getOrcid()));
|
setField_orcid(InfoTextAndLabels.validValue(this.author.getOrcid()));
|
||||||
|
|
||||||
if(this.author.getType()!=null) {
|
if(this.author.getType()!=null) {
|
||||||
controls_author_type.setVisible(true);
|
controls_author_type.setVisible(true);
|
||||||
|
@ -106,6 +108,8 @@ public class CreatorView extends Composite {
|
||||||
FieldUtil.selectValueToListBox(field_author_type, Arrays.asList(this.author.getType().getSelectedValues().get(0)));
|
FieldUtil.selectValueToListBox(field_author_type, Arrays.asList(this.author.getType().getSelectedValues().get(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GWT.log("Created creator view with author: "+this.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +124,6 @@ public class CreatorView extends Composite {
|
||||||
this(author, userRole);
|
this(author, userRole);
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
|
|
||||||
remove_author.addClickHandler(new ClickHandler() {
|
remove_author.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -220,5 +223,25 @@ public class CreatorView extends Composite {
|
||||||
public ZenodoAuthor getAuthor() {
|
public ZenodoAuthor getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ListBox getField_author_type() {
|
||||||
|
return field_author_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the author type value.
|
||||||
|
*
|
||||||
|
* @return the author type value
|
||||||
|
*/
|
||||||
|
public String getAuthorTypeValue(){
|
||||||
|
|
||||||
|
String authorTypeSelected = null;
|
||||||
|
if(controls_author_type.isVisible()) {
|
||||||
|
authorTypeSelected = field_author_type.getValue();
|
||||||
|
}
|
||||||
|
return authorTypeSelected;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEvent;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEvent;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEventHandler;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoTextAndLabels;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||||
|
@ -112,11 +112,10 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
||||||
userRole = "Author";
|
userRole = "Author";
|
||||||
|
|
||||||
for (ZenodoAuthor creator : listAuthors) {
|
for (ZenodoAuthor creator : listAuthors) {
|
||||||
GWT.log("author is "+creator.getClass());
|
GWT.log("Author class is "+creator.getClass());
|
||||||
if (creator instanceof ZenodoContributor) {
|
if (creator instanceof ZenodoContributor) {
|
||||||
GWT.log("author is a ZenodoContributor");
|
|
||||||
userRole = "Contributor";
|
userRole = "Contributor";
|
||||||
contributorTypeValues = creator.getType();
|
contributorTypeValues = new SerializableEnum<String>(Arrays.asList(creator.getType().getSelectableValues().get(0)), creator.getType().getSelectableValues());
|
||||||
}else if(creator instanceof ZenodoCreator) {
|
}else if(creator instanceof ZenodoCreator) {
|
||||||
userRole = "Creator";
|
userRole = "Creator";
|
||||||
}
|
}
|
||||||
|
@ -190,9 +189,15 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
||||||
|
|
||||||
for (CreatorView creatorView : listCreatorView) {
|
for (CreatorView creatorView : listCreatorView) {
|
||||||
ZenodoAuthor author = creatorView.getAuthor();
|
ZenodoAuthor author = creatorView.getAuthor();
|
||||||
|
GWT.log("Read ZenodoAuthor: "+author);
|
||||||
author.setName(creatorView.getField_name().getValue());
|
author.setName(creatorView.getField_name().getValue());
|
||||||
author.setAffiliation(creatorView.getField_affiliation().getValue());
|
author.setAffiliation(creatorView.getField_affiliation().getValue());
|
||||||
author.setOrcid(creatorView.getField_orcid().getValue());
|
author.setOrcid(creatorView.getField_orcid().getValue());
|
||||||
|
String typeSelected = creatorView.getAuthorTypeValue();
|
||||||
|
if(typeSelected!=null && !typeSelected.isEmpty()) {
|
||||||
|
author.setType(new SerializableEnum<>(Arrays.asList(typeSelected), null));
|
||||||
|
}
|
||||||
|
|
||||||
listAuthors.add(author);
|
listAuthors.add(author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,9 +210,11 @@ public class BasicInformationView extends Composite implements FormValidator {
|
||||||
listOfContributorsView = new ArrayList<CreatorsFormView>();
|
listOfContributorsView = new ArrayList<CreatorsFormView>();
|
||||||
|
|
||||||
// ADDING AUTHORS
|
// ADDING AUTHORS
|
||||||
|
GWT.log("Adding creators: "+zenodoItem.getMetadata().getCreators());
|
||||||
CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||||
listOfCreatorsView.add(authorView);
|
listOfCreatorsView.add(authorView);
|
||||||
|
|
||||||
|
GWT.log("Adding contributors: "+zenodoItem.getMetadata().getContributors());
|
||||||
CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors());
|
CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors());
|
||||||
listOfContributorsView.add(contributorView);
|
listOfContributorsView.add(contributorView);
|
||||||
|
|
||||||
|
|
|
@ -124,9 +124,11 @@ public class Ckan2ZenodoViewManager {
|
||||||
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
||||||
|
|
||||||
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
||||||
|
GWT.log("Read creators from FORM: "+creators);
|
||||||
meta.setCreators(creators);
|
meta.setCreators(creators);
|
||||||
|
|
||||||
List<ZenodoContributor> contributors = basicForm.getListOfContributors();
|
List<ZenodoContributor> contributors = basicForm.getListOfContributors();
|
||||||
|
GWT.log("Read contributors from FORM: "+contributors);
|
||||||
meta.setContributors(contributors);
|
meta.setContributors(contributors);
|
||||||
|
|
||||||
// upload type
|
// upload type
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
//Actually publish to zenodo :
|
//Actually publish to zenodo :
|
||||||
// Step 1 : metadata
|
// Step 1 : metadata
|
||||||
Ckan2Zenodo client= new Ckan2ZenodoImpl();
|
/*Ckan2Zenodo client= new Ckan2ZenodoImpl();
|
||||||
zenodoDepositionPreview = client.updatedMetadata(zenodoDepositionPreview);
|
zenodoDepositionPreview = client.updatedMetadata(zenodoDepositionPreview);
|
||||||
|
|
||||||
//Step 2 : publish Resources
|
//Step 2 : publish Resources
|
||||||
|
@ -98,19 +98,19 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
}
|
}
|
||||||
zenodoDepositionPreview = future_Dep.get(180,TimeUnit.SECONDS);
|
zenodoDepositionPreview = future_Dep.get(180,TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the item representation
|
// Get the item representation
|
||||||
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
||||||
|
|
||||||
//Finalize
|
//Finalize
|
||||||
client.publish(zenodoDepositionPreview, item);
|
client.publish(zenodoDepositionPreview, item);*/
|
||||||
return zenodoDepositionPreview.toString();
|
return zenodoDepositionPreview.toString();
|
||||||
|
|
||||||
}catch (TimeoutException e) {
|
/* }catch (TimeoutException e) {
|
||||||
String error = "I'm waiting too time for publishing on Zenodo the catalogue item: "+zenodoItem.getName()+". Check by yourself the result later";
|
String error = "I'm waiting too time for publishing on Zenodo the catalogue item: "+zenodoItem.getName()+". Check by yourself the result later";
|
||||||
LOG.error(error, e);
|
LOG.error(error, e);
|
||||||
String clientError = String.format("%s", error);
|
String clientError = String.format("%s", error);
|
||||||
throw new Exception(clientError);
|
throw new Exception(clientError);
|
||||||
|
*/
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String error = "Error when publishing on Zenodo the catalogue item: "+zenodoItem.getName();
|
String error = "Error when publishing on Zenodo the catalogue item: "+zenodoItem.getName();
|
||||||
LOG.error(error, e);
|
LOG.error(error, e);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.CkanResource;
|
import org.gcube.data.publishing.ckan2zenodo.model.CkanResource;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Community;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Community;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Contributor;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Contributor;
|
||||||
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Contributor.Type;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DateInterval;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DateInterval;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
||||||
|
@ -20,6 +21,7 @@ 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.LicenseBean;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
||||||
|
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;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
||||||
|
@ -438,14 +440,99 @@ public class ItemToZenodoConverter {
|
||||||
LOG.debug("Read publication type: "+publicationType);
|
LOG.debug("Read publication type: "+publicationType);
|
||||||
if(publicationType!=null) {
|
if(publicationType!=null) {
|
||||||
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
||||||
|
LOG.debug("Set publication type: "+thePublicationTypeValue);
|
||||||
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//creators
|
||||||
|
List<Creator> creators = null;
|
||||||
|
List<? extends ZenodoAuthor> zenodoCreators = metadata.getCreators();
|
||||||
|
LOG.debug("Read Creators: "+zenodoCreators);
|
||||||
|
if(zenodoCreators!=null) {
|
||||||
|
creators = toCreators(zenodoCreators);
|
||||||
|
}
|
||||||
|
LOG.debug("Set Creators: "+creators);
|
||||||
|
depositionMetadata.setCreators(creators);
|
||||||
|
|
||||||
|
//contributors
|
||||||
|
List<Contributor> contributors = null;
|
||||||
|
List<? extends ZenodoAuthor> zenodoContributors = metadata.getContributors();
|
||||||
|
LOG.debug("Read Contributors: "+zenodoContributors);
|
||||||
|
if(zenodoContributors!=null) {
|
||||||
|
contributors = toContributors(zenodoContributors);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(LOG.isDebugEnabled()) {
|
||||||
|
for (Contributor contributor : contributors) {
|
||||||
|
LOG.debug("Set contributor: name "+contributor.getName() + " type "+contributor.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
depositionMetadata.setContributors(contributors);
|
||||||
|
|
||||||
//keywords
|
//keywords
|
||||||
depositionMetadata.setKeywords(metadata.getKeywords());
|
depositionMetadata.setKeywords(metadata.getKeywords());
|
||||||
|
|
||||||
return depositionMetadata;
|
return depositionMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To creators.
|
||||||
|
*
|
||||||
|
* @param zenodoCreators the zenodo creators
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public static List<Creator> toCreators(List<? extends ZenodoAuthor> zenodoCreators){
|
||||||
|
|
||||||
|
if(zenodoCreators==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Creator> listOfCreators = new ArrayList<>(zenodoCreators.size());
|
||||||
|
for (ZenodoAuthor zenodoAuthor : zenodoCreators) {
|
||||||
|
Creator creator = new Creator();
|
||||||
|
creator.setName(zenodoAuthor.getName());
|
||||||
|
creator.setAffiliation(zenodoAuthor.getAffiliation());
|
||||||
|
creator.setGnd(zenodoAuthor.getGnd());
|
||||||
|
creator.setOrcid(zenodoAuthor.getOrcid());
|
||||||
|
listOfCreators.add(creator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listOfCreators;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To contributors.
|
||||||
|
*
|
||||||
|
* @param zenodoContributors the zenodo contributors
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public static List<Contributor> toContributors(List<? extends ZenodoAuthor> zenodoContributors){
|
||||||
|
|
||||||
|
if(zenodoContributors==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List<Contributor> listOfContributors = new ArrayList<Contributor>(zenodoContributors.size());
|
||||||
|
for (ZenodoAuthor zenodoAuthor : zenodoContributors) {
|
||||||
|
Contributor contributor = new Contributor();
|
||||||
|
contributor.setName(zenodoAuthor.getName());
|
||||||
|
contributor.setAffiliation(zenodoAuthor.getAffiliation());
|
||||||
|
contributor.setGnd(zenodoAuthor.getGnd());
|
||||||
|
contributor.setOrcid(zenodoAuthor.getOrcid());
|
||||||
|
Type type = null;
|
||||||
|
String theType = null;
|
||||||
|
try {
|
||||||
|
theType = zenodoAuthor.getType().getSelectedValues().get(0);
|
||||||
|
type = Type.valueOf(theType);
|
||||||
|
}catch (Exception e) {
|
||||||
|
LOG.error("No able to convert "+theType + " as value of "+Type.class.getName());
|
||||||
|
}
|
||||||
|
contributor.setType(type);
|
||||||
|
listOfContributors.add(contributor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listOfContributors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,14 @@ public interface ZenodoAuthor {
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public SerializableEnum<String> getType();
|
public SerializableEnum<String> getType();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type.
|
||||||
|
*
|
||||||
|
* @param type the new type
|
||||||
|
*/
|
||||||
|
public void setType(SerializableEnum<String> type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name.
|
* Sets the name.
|
||||||
|
|
|
@ -57,14 +57,13 @@ public class ZenodoContributor extends ZenodoCreator{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("ZenodoContributor [type=");
|
builder.append("ZenodoContributor [type=");
|
||||||
builder.append(type);
|
builder.append(type);
|
||||||
|
builder.append(", toString()=");
|
||||||
|
builder.append(super.toString());
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,11 @@ public class ZenodoCreator implements ZenodoAuthor, Serializable{
|
||||||
public SerializableEnum<String> getType() {
|
public SerializableEnum<String> getType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(SerializableEnum<String> type) {
|
||||||
|
//empty
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
|
|
Loading…
Reference in New Issue