diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06b50eb..7c435c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v1.0.2-SNAPSHOT] - 2021-04-23
+
+**Bug fixes**
+[#21263] manage empty mapping for creators/contributors
+
+**Enhancements**
+[#21153] ported to maven-portal-bom 3.6.1
+
+
## [v1.0.1] - 2021-03-09
[#20935] just to include new range 1.x, 2.0 of ckan2zenodo-library
diff --git a/pom.xml b/pom.xml
index d0c3d01..0458ec9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
org.gcube.portlets.widgets
ckan2zenodo-publisher-widget
jar
- 1.0.1
+ 1.0.2-SNAPSHOT
gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo
@@ -44,7 +44,7 @@
org.gcube.distribution
maven-portal-bom
- 3.6.0
+ 3.6.1-SNAPSHOT
pom
import
diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorView.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorView.java
index fc93061..e42f943 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorView.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorView.java
@@ -24,6 +24,7 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
+// TODO: Auto-generated Javadoc
/**
* The Class CreatorView.
*
@@ -75,23 +76,29 @@ public class CreatorView extends Composite {
private String userRole; //Can be: Creator, Contributor etc..
private ZenodoAuthor author;
+
+ private boolean isMandatoryField;
/**
* Instantiates a new creator view.
*
* @param author the author
* @param userRole the user role
+ * @param isMandatoryField the is mandatory field
*/
- public CreatorView(ZenodoAuthor author, String userRole) {
+ public CreatorView(ZenodoAuthor author, String userRole, Boolean isMandatoryField) {
initWidget(uiBinder.createAndBindUi(this));
+ GWT.log("Creating CreatorView for author: "+author+", userRole: "+userRole);
this.userRole = userRole;
this.author = author;
+ this.isMandatoryField = isMandatoryField == null? false:isMandatoryField;
+ String fieldLabel = isMandatoryField?"*":"";
if(this.userRole!=null) {
- field_cl_author.add(new HTML("* "+userRole));
+ field_cl_author.add(new HTML(fieldLabel+" "+userRole));
remove_author.setText("Remove "+userRole);
}else { //default role is Author
- field_cl_author.add(new HTML("* Author"));
+ field_cl_author.add(new HTML(fieldLabel+" Author"));
remove_author.setText("Remove Author");
}
@@ -107,12 +114,16 @@ public class CreatorView extends Composite {
}
}
- if(userRole.toLowerCase().startsWith("creator")) {
- InfoTextAndLabels.addTooltipForFieldKey("creators", field_cl_author);
- }else if(userRole.toLowerCase().startsWith("contributor")) {
- InfoTextAndLabels.addTooltipForFieldKey("contributors", field_cl_author);
- }else {
- InfoTextAndLabels.addTooltipForFieldKey("authors", field_cl_author);
+ if(this.userRole!=null) {
+ String userRoleToLowerCase = userRole.toLowerCase();
+
+ if(userRoleToLowerCase.startsWith("creator")) {
+ InfoTextAndLabels.addTooltipForFieldKey("creators", field_cl_author);
+ }else if(userRoleToLowerCase.startsWith("contributor")) {
+ InfoTextAndLabels.addTooltipForFieldKey("contributors", field_cl_author);
+ }else {
+ InfoTextAndLabels.addTooltipForFieldKey("authors", field_cl_author);
+ }
}
GWT.log("Created creator view with author: "+this.author);
@@ -125,9 +136,10 @@ public class CreatorView extends Composite {
* @param author the author
* @param userRole the user role
* @param eventBus the event bus
+ * @param isFieldMandatory the is field mandatory
*/
- public CreatorView(ZenodoAuthor author, String userRole, HandlerManager eventBus) {
- this(author, userRole);
+ public CreatorView(ZenodoAuthor author, String userRole, HandlerManager eventBus, Boolean isFieldMandatory) {
+ this(author, userRole, isFieldMandatory);
this.eventBus = eventBus;
remove_author.addClickHandler(new ClickHandler() {
@@ -148,6 +160,16 @@ public class CreatorView extends Composite {
public void setVisibleRemoveCreator(boolean visible) {
remove_author.setVisible(visible);
}
+
+
+ /**
+ * Checks if is mandatory field.
+ *
+ * @return true, if is mandatory field
+ */
+ public boolean isMandatoryField() {
+ return isMandatoryField;
+ }
/**
* Gets the field name.
@@ -230,6 +252,11 @@ public class CreatorView extends Composite {
return author;
}
+ /**
+ * Gets the field author type.
+ *
+ * @return the field author type
+ */
public ListBox getField_author_type() {
return field_author_type;
}
diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorsFormView.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorsFormView.java
index 792f3d7..6563599 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorsFormView.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/authors/CreatorsFormView.java
@@ -64,15 +64,19 @@ public class CreatorsFormView extends Composite implements FormValidator{
private SerializableEnum contributorTypeValues;
+ //Used as defaultRole in case of empty listAuthors
+ private Class theAuthorType;
+
/**
* Instantiates a new creators form view.
*
* @param listAuthors the list authors
*/
- public CreatorsFormView(List extends ZenodoAuthor> listAuthors) {
+ public CreatorsFormView(List extends ZenodoAuthor> listAuthors, Class theAuthorType) {
initWidget(uiBinder.createAndBindUi(this));
this.listAuthors = listAuthors;
+ this.theAuthorType = theAuthorType;
button_add_author.addClickHandler(new ClickHandler() {
@@ -105,6 +109,8 @@ public class CreatorsFormView extends Composite implements FormValidator{
*/
private void addAuthorsToView() {
+ GWT.log("Adding listAuthors: "+listAuthors);
+
if(listCreatorView==null)
listCreatorView = new ArrayList();
@@ -119,7 +125,7 @@ public class CreatorsFormView extends Composite implements FormValidator{
}else if(creator instanceof ZenodoCreator) {
userRole = "Creator";
}
- CreatorView view = new CreatorView(creator, userRole, eventBus);
+ CreatorView view = new CreatorView(creator, userRole, eventBus, true);
listCreatorView.add(view);
fieldset_authors.add(view);
}
@@ -146,18 +152,33 @@ public class CreatorsFormView extends Composite implements FormValidator{
* Adds the empty creator.
*/
private void addEmptyCreator() {
+ GWT.log("adding empty creator");
if(listCreatorView==null)
listCreatorView = new ArrayList();
ZenodoAuthor author = null;
- if(userRole.compareToIgnoreCase("Contributor")==0) {
- author = new ZenodoContributor();
- ((ZenodoContributor) author).setType(contributorTypeValues);
+
+
+ if(userRole == null) {
+ if (theAuthorType.equals(ZenodoCreator.class)) {
+ userRole = "Creator";
+ }else if(theAuthorType.equals(ZenodoContributor.class)) {
+ userRole = "Contributor";
+ }else
+ userRole = "Creator";
+
+ GWT.log("Empty list assigned the userRole: "+userRole);
+ }else {
+ //dead code???
+ if(userRole.compareToIgnoreCase("Contributor")==0) {
+ author = new ZenodoContributor();
+ ((ZenodoContributor) author).setType(contributorTypeValues);
+ }
}
- CreatorView view = new CreatorView(author, userRole, eventBus);
+ CreatorView view = new CreatorView(author, userRole, eventBus,false);
listCreatorView.add(view);
fieldset_authors.add(view);
@@ -190,15 +211,20 @@ public class CreatorsFormView extends Composite implements FormValidator{
for (CreatorView creatorView : listCreatorView) {
ZenodoAuthor author = creatorView.getAuthor();
GWT.log("Read ZenodoAuthor: "+author);
- author.setName(creatorView.getField_name().getValue());
- author.setAffiliation(creatorView.getField_affiliation().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);
+ boolean isValid = FieldUtil.isValidValue(creatorView.getField_name().getValue());
+ if(isValid) {
+ GWT.log("The fielName is valid going to add it to list of Authors");
+ author.setName(creatorView.getField_name().getValue());
+ author.setAffiliation(creatorView.getField_affiliation().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);
+ }else
+ GWT.log("The fielName is null or empty skpping he/she from list of Authors");
}
return listAuthors;
@@ -223,11 +249,14 @@ public class CreatorsFormView extends Composite implements FormValidator{
for (CreatorView creatorView : listCreatorView) {
ControlGroup cgAuthor = creatorView.getControlGroup_Author();
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.NONE);
- String value = FieldUtil.getTextValue(creatorView.getField_name());
- boolean isValid = FieldUtil.isValidValue(value);
- if(!isValid) {
- FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
- return "The field "+userRole+" Name is required";
+
+ if(creatorView.isMandatoryField()) {
+ String value = FieldUtil.getTextValue(creatorView.getField_name());
+ boolean isValid = FieldUtil.isValidValue(value);
+ if(!isValid) {
+ FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
+ return "The field "+userRole+" Name is required";
+ }
}
/*
diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java
index d7c28bd..5db3c28 100644
--- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java
+++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java
@@ -360,12 +360,14 @@ public class BasicInformationView extends Composite implements FormValidator {
listOfContributorsView = new ArrayList();
// ADDING AUTHORS
- GWT.log("Adding creators: " + zenodoItem.getMetadata().getCreators());
- CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
+ List extends ZenodoAuthor> authors = zenodoItem.getMetadata().getCreators();
+ GWT.log("Adding creators: " + authors);
+ CreatorsFormView authorView = new CreatorsFormView(authors, ZenodoCreator.class);
listOfCreatorsView.add(authorView);
- GWT.log("Adding contributors: " + zenodoItem.getMetadata().getContributors());
- CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors());
+ List extends ZenodoAuthor> contributors = zenodoItem.getMetadata().getContributors();
+ GWT.log("Adding contributors: " + contributors);
+ CreatorsFormView contributorView = new CreatorsFormView(contributors, ZenodoContributor.class);
listOfContributorsView.add(contributorView);
for (CreatorsFormView cfv : listOfCreatorsView) {