on going #18226
This commit is contained in:
parent
1341b7b853
commit
3e938addad
|
@ -1,9 +1,9 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
24
pom.xml
24
pom.xml
|
@ -31,10 +31,10 @@
|
|||
|
||||
<properties>
|
||||
<!-- Convenience property to set the GWT version -->
|
||||
<gwtVersion>2.8.2</gwtVersion>
|
||||
<gwtVersion>2.7.0</gwtVersion>
|
||||
|
||||
<!-- GWT needs at least java 1.6 -->
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
@ -48,13 +48,6 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -69,17 +62,17 @@
|
|||
<groupId>com.github.gwtbootstrap</groupId>
|
||||
<artifactId>gwt-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>switch-button-widget</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>ckan2zenodo-library</artifactId>
|
||||
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>switch-button-widget</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
|
@ -162,6 +155,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
<!-- any one of the following lines. -->
|
||||
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
|
||||
|
||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
|
||||
<inherits name='com.github.gwtbootstrap.datepicker.Datepicker' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
|
|
|
@ -29,23 +29,17 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
*/
|
||||
public class CkanToZendoPublisherWidget {
|
||||
|
||||
private final CkanToZenodoPublisherServiceAsync ckanToZenodoService = CkanToZenodoPublisherServiceAsync.Util
|
||||
.getInstance();
|
||||
private CkanToZenodoPublisherServiceAsync ckanToZenodoService;
|
||||
|
||||
private Button buttonPublish = new Button("Publish on Zenodo");
|
||||
private Ckan2ZenodoViewManager manager = null;
|
||||
/**
|
||||
* Instantiates a new ckan to zendo publisher widget.
|
||||
*/
|
||||
public CkanToZendoPublisherWidget() {
|
||||
|
||||
|
||||
public CkanToZendoPublisherWidget() {
|
||||
ckanToZenodoService = CkanToZenodoPublisherServiceAsync.Util.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish on zenodo.
|
||||
*
|
||||
* @param item the item
|
||||
*/
|
||||
|
||||
public void publishOnZenodo(final CatalogueItem item) {
|
||||
|
||||
final Modal modal = new Modal(true);
|
||||
|
@ -145,27 +139,4 @@ public class CkanToZendoPublisherWidget {
|
|||
modal.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit publish on zenodo.
|
||||
*/
|
||||
private void submitPublishOnZenodo() {
|
||||
|
||||
ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm();
|
||||
|
||||
GWT.log("Publishing file: "+zenodoItem.getFiles());
|
||||
|
||||
ckanToZenodoService.publishOnZenodo(zenodoItem, new AsyncCallback<String>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
Window.alert(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
*/
|
||||
public class CkanToZenodoPublisher implements EntryPoint {
|
||||
/**
|
||||
* The message displayed to the user when the server cannot be reached or
|
||||
* returns an error.
|
||||
*/
|
||||
private static final String SERVER_ERROR = "An error occurred while "
|
||||
+ "attempting to contact the server. Please check your network "
|
||||
+ "connection and try again.";
|
||||
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final CkanToZenodoPublisherServiceAsync greetingService = GWT.create(CkanToZenodoPublisherService.class);
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
public void onModuleLoad() {
|
||||
|
||||
}
|
||||
}
|
||||
//package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
//
|
||||
//import com.google.gwt.core.client.EntryPoint;
|
||||
//import com.google.gwt.core.client.GWT;
|
||||
//
|
||||
///**
|
||||
// * Entry point classes define <code>onModuleLoad()</code>.
|
||||
// */
|
||||
//public class CkanToZenodoPublisher implements EntryPoint {
|
||||
// /**
|
||||
// * The message displayed to the user when the server cannot be reached or
|
||||
// * returns an error.
|
||||
// */
|
||||
// private static final String SERVER_ERROR = "An error occurred while "
|
||||
// + "attempting to contact the server. Please check your network "
|
||||
// + "connection and try again.";
|
||||
//
|
||||
// /**
|
||||
// * Create a remote service proxy to talk to the server-side Greeting service.
|
||||
// */
|
||||
// private final CkanToZenodoPublisherServiceAsync greetingService = GWT.create(CkanToZenodoPublisherService.class);
|
||||
//
|
||||
// /**
|
||||
// * This is the entry point method.
|
||||
// */
|
||||
// public void onModuleLoad() {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEvent;
|
||||
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.shared.wrapped.ZenodoAuthor;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
||||
import com.github.gwtbootstrap.client.ui.Controls;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
|
@ -12,13 +20,30 @@ import com.google.gwt.event.shared.HandlerManager;
|
|||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CreatorView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
public class CreatorView extends Composite {
|
||||
|
||||
private static CreatorViewUiBinder uiBinder = GWT.create(CreatorViewUiBinder.class);
|
||||
|
||||
/**
|
||||
* The Interface CreatorViewUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
interface CreatorViewUiBinder extends UiBinder<Widget, CreatorView> {
|
||||
}
|
||||
|
||||
|
@ -36,17 +61,66 @@ public class CreatorView extends Composite {
|
|||
|
||||
@UiField
|
||||
ControlGroup cg_authors;
|
||||
|
||||
@UiField
|
||||
ListBox field_author_type;
|
||||
|
||||
@UiField
|
||||
HorizontalPanel controls_author_type;
|
||||
|
||||
@UiField
|
||||
ControlLabel field_cl_author;
|
||||
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
public CreatorView() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
public CreatorView(final HandlerManager eventBus) {
|
||||
this();
|
||||
private String userRole; //Can be: Creator, Contributor etc..
|
||||
|
||||
private ZenodoAuthor author;
|
||||
|
||||
/**
|
||||
* Instantiates a new creator view.
|
||||
*
|
||||
* @param author the author
|
||||
* @param userRole the user role
|
||||
*/
|
||||
public CreatorView(ZenodoAuthor author, String userRole) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.userRole = userRole;
|
||||
this.author = author;
|
||||
|
||||
if(this.userRole!=null) {
|
||||
field_cl_author.add(new HTML("<font color='red'>*</font> "+userRole));
|
||||
}else { //default role is Author
|
||||
field_cl_author.add(new HTML("<font color='red'>*</font> Author"));
|
||||
}
|
||||
|
||||
if(this.author!=null) {
|
||||
setField_name(InfoTextAndLabels.validValue(author.getName()));
|
||||
setField_affiliation(InfoTextAndLabels.validValue(author.getAffiliation()));
|
||||
setField_orcid(InfoTextAndLabels.validValue(author.getOrcid()));
|
||||
|
||||
if(this.author.getType()!=null) {
|
||||
controls_author_type.setVisible(true);
|
||||
FieldUtil.addValuesToListBox(field_author_type, this.author.getType().getSelectableValues());
|
||||
FieldUtil.selectValueToListBox(field_author_type, Arrays.asList(this.author.getType().getSelectedValues().get(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new creator view.
|
||||
*
|
||||
* @param author the author
|
||||
* @param userRole the user role
|
||||
* @param eventBus the event bus
|
||||
*/
|
||||
public CreatorView(ZenodoAuthor author, String userRole, HandlerManager eventBus) {
|
||||
this(author, userRole);
|
||||
this.eventBus = eventBus;
|
||||
|
||||
|
||||
remove_author.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -66,32 +140,85 @@ public class CreatorView extends Composite {
|
|||
remove_author.setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field name.
|
||||
*
|
||||
* @return the field name
|
||||
*/
|
||||
public TextBox getField_name() {
|
||||
return field_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field name.
|
||||
*
|
||||
* @param field_name the new field name
|
||||
*/
|
||||
public void setField_name(String field_name) {
|
||||
this.field_name.setValue(field_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field affiliation.
|
||||
*
|
||||
* @return the field affiliation
|
||||
*/
|
||||
public TextBox getField_affiliation() {
|
||||
return field_affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field affiliation.
|
||||
*
|
||||
* @param field_affiliation the new field affiliation
|
||||
*/
|
||||
public void setField_affiliation(String field_affiliation) {
|
||||
this.field_affiliation.setValue(field_affiliation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field orcid.
|
||||
*
|
||||
* @return the field orcid
|
||||
*/
|
||||
public TextBox getField_orcid() {
|
||||
return field_orcid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field orcid.
|
||||
*
|
||||
* @param field_orcid the new field orcid
|
||||
*/
|
||||
public void setField_orcid(String field_orcid) {
|
||||
this.field_orcid.setValue(field_orcid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the control group author.
|
||||
*
|
||||
* @return the control group author
|
||||
*/
|
||||
public ControlGroup getControlGroup_Author() {
|
||||
return cg_authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user role.
|
||||
*
|
||||
* @return the user role
|
||||
*/
|
||||
public String getUserRole() {
|
||||
return userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author.
|
||||
*
|
||||
* @return the author
|
||||
*/
|
||||
public ZenodoAuthor getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,22 +6,32 @@
|
|||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
.custom-width{
|
||||
width: 625px !important;
|
||||
}
|
||||
</ui:style>
|
||||
<b:ControlGroup ui:field="cg_authors">
|
||||
<b:ControlLabel for="cl_authors">
|
||||
<font color="red">*</font>
|
||||
Author
|
||||
<b:ControlLabel ui:field="field_cl_author">
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<!-- -->
|
||||
<g:VerticalPanel addStyleNames="authors-table-spacing">
|
||||
<g:VerticalPanel
|
||||
addStyleNames="authors-table-spacing">
|
||||
<b:TextBox alternateSize="SMALL" placeholder="Name"
|
||||
ui:field="field_name" />
|
||||
<b:TextBox alternateSize="SMALL" placeholder="Affiliation"
|
||||
ui:field="field_affiliation" />
|
||||
<b:TextBox alternateSize="SMALL" placeholder="ORCID"
|
||||
ui:field="field_orcid" />
|
||||
<b:Button icon="REMOVE" text="Remove Author" visible="false" ui:field="remove_author" type="LINK"></b:Button>
|
||||
<g:HorizontalPanel ui:field="controls_author_type" visible="false">
|
||||
<b:InputAddOn prependText="Type">
|
||||
<b:ListBox name="Author type"
|
||||
ui:field="field_author_type" addStyleNames="{style.custom-width}">
|
||||
</b:ListBox>
|
||||
</b:InputAddOn>
|
||||
</g:HorizontalPanel>
|
||||
<b:Button icon="REMOVE" text="Remove Author"
|
||||
visible="false" ui:field="remove_author" type="LINK"></b:Button>
|
||||
</g:VerticalPanel>
|
||||
<!-- -->
|
||||
</b:Controls>
|
||||
|
|
|
@ -8,6 +8,9 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreat
|
|||
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.FormValidator;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
|
@ -55,13 +58,21 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
|
||||
private List<CreatorView> listCreatorView;
|
||||
|
||||
private String userRole;
|
||||
|
||||
private List<? extends ZenodoAuthor> listAuthors;
|
||||
|
||||
private SerializableEnum<String> contributorTypeValues;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new creators form view.
|
||||
*
|
||||
* @param listCreators the list creators
|
||||
* @param listAuthors the list authors
|
||||
*/
|
||||
public CreatorsFormView(List<ZenodoCreator> listCreators) {
|
||||
public CreatorsFormView(List<? extends ZenodoAuthor> listAuthors) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.listAuthors = listAuthors;
|
||||
|
||||
button_add_author.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
@ -85,27 +96,37 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
}
|
||||
});
|
||||
|
||||
addCreatorsToView(listCreators);
|
||||
addAuthorsToView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the creators to view.
|
||||
* @param listCreators
|
||||
* Adds the authors to view.
|
||||
*/
|
||||
private void addCreatorsToView(List<ZenodoCreator> listCreators) {
|
||||
private void addAuthorsToView() {
|
||||
|
||||
if(listCreatorView==null)
|
||||
listCreatorView = new ArrayList<CreatorView>();
|
||||
|
||||
if(listCreators!=null && listCreators.size()>0) {
|
||||
for (ZenodoCreator creator : listCreators) {
|
||||
CreatorView view = new CreatorView(eventBus);
|
||||
view.setField_name(InfoTextAndLabels.validValue(creator.getName()));
|
||||
view.setField_affiliation(InfoTextAndLabels.validValue(creator.getAffiliation()));
|
||||
view.setField_orcid(InfoTextAndLabels.validValue(creator.getOrcid()));
|
||||
if(listAuthors!=null && listAuthors.size()>0) {
|
||||
userRole = "Author";
|
||||
|
||||
for (ZenodoAuthor creator : listAuthors) {
|
||||
GWT.log("author is "+creator.getClass());
|
||||
if (creator instanceof ZenodoContributor) {
|
||||
GWT.log("author is a ZenodoContributor");
|
||||
userRole = "Contributor";
|
||||
contributorTypeValues = creator.getType();
|
||||
}else if(creator instanceof ZenodoCreator) {
|
||||
userRole = "Creator";
|
||||
}
|
||||
CreatorView view = new CreatorView(creator, userRole, eventBus);
|
||||
listCreatorView.add(view);
|
||||
fieldset_authors.add(view);
|
||||
}
|
||||
|
||||
button_add_author.setText("Add another "+userRole);
|
||||
|
||||
setRemovableCreators();
|
||||
}else {
|
||||
//ADDING EMPTY CREATOR
|
||||
|
@ -113,16 +134,31 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list creator view.
|
||||
*
|
||||
* @return the list creator view
|
||||
*/
|
||||
public List<CreatorView> getListCreatorView() {
|
||||
return listCreatorView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the empty creator.
|
||||
*/
|
||||
private void addEmptyCreator() {
|
||||
|
||||
if(listCreatorView==null)
|
||||
listCreatorView = new ArrayList<CreatorView>();
|
||||
|
||||
CreatorView view = new CreatorView(eventBus);
|
||||
ZenodoAuthor author = null;
|
||||
if(userRole.compareToIgnoreCase("Contributor")==0) {
|
||||
author = new ZenodoContributor();
|
||||
((ZenodoContributor) author).setType(contributorTypeValues);
|
||||
}
|
||||
|
||||
|
||||
CreatorView view = new CreatorView(author, userRole, eventBus);
|
||||
listCreatorView.add(view);
|
||||
fieldset_authors.add(view);
|
||||
|
||||
|
@ -130,6 +166,9 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the removable creators.
|
||||
*/
|
||||
private void setRemovableCreators() {
|
||||
|
||||
for (int i=0; i<listCreatorView.size(); i++) {
|
||||
|
@ -143,24 +182,36 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
/**
|
||||
* Read list of creators from view.
|
||||
*
|
||||
* @return the list
|
||||
* @return the list<? extends zenodo author>
|
||||
*/
|
||||
public List<ZenodoCreator> readListOfCreatorsFromView(){
|
||||
List<ZenodoCreator> listCreators = new ArrayList<ZenodoCreator>(listCreatorView.size());
|
||||
public List<? extends ZenodoAuthor> readListOfCreatorsFromView(){
|
||||
|
||||
List<ZenodoAuthor> listAuthors = new ArrayList<>(listCreatorView.size());
|
||||
|
||||
for (CreatorView creatorView : listCreatorView) {
|
||||
listCreators.add(new ZenodoCreator(creatorView.getField_name().getValue(), creatorView.getField_affiliation().getValue(), creatorView.getField_affiliation().getValue(), null));
|
||||
ZenodoAuthor author = creatorView.getAuthor();
|
||||
author.setName(creatorView.getField_name().getValue());
|
||||
author.setAffiliation(creatorView.getField_affiliation().getValue());
|
||||
author.setOrcid(creatorView.getField_orcid().getValue());
|
||||
listAuthors.add(author);
|
||||
}
|
||||
|
||||
return listCreators;
|
||||
return listAuthors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#isValidForm()
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidForm() {
|
||||
return validateFormFields()==null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#validateFormFields()
|
||||
*/
|
||||
@Override
|
||||
public String validateFormFields() {
|
||||
|
||||
|
@ -171,7 +222,7 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
|||
boolean isValid = FieldUtil.isValidValue(value);
|
||||
if(!isValid) {
|
||||
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
||||
return "The Author Name is required";
|
||||
return "The Name is required";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,12 +2,15 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformati
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.tags.TagsPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor;
|
||||
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.ZenodoItem;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMetadata;
|
||||
|
@ -36,7 +39,8 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
/** The ui binder. */
|
||||
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
|
||||
|
||||
private CreatorsFormView creatorsView;
|
||||
private List<CreatorsFormView> listOfCreatorsView;
|
||||
private List<CreatorsFormView> listOfContributorsView;
|
||||
|
||||
/**
|
||||
* The Interface CreateTaskConfigurationViewUiBinder.
|
||||
|
@ -88,6 +92,8 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
|
||||
private ZenodoItem zenodoItem;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Because this class has a default constructor, it can be used as a binder
|
||||
* template. In other words, it can be used in other *.ui.xml files as follows:
|
||||
|
@ -167,27 +173,27 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
|
||||
//Upload type
|
||||
if(zMeta.getUpload_type()!=null) {
|
||||
addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
||||
selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
|
||||
FieldUtil.addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
||||
FieldUtil.selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
|
||||
}else
|
||||
field_upload_type.setEnabled(false);
|
||||
|
||||
//Publication Type
|
||||
if(zMeta.getPublication_type()!=null) {
|
||||
addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||
selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues());
|
||||
FieldUtil.addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||
FieldUtil.selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues());
|
||||
}else
|
||||
field_publication_type.setEnabled(false);
|
||||
|
||||
if(zMeta.getAccess_right()!=null) {
|
||||
addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues());
|
||||
selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues());
|
||||
FieldUtil.addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues());
|
||||
FieldUtil.selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues());
|
||||
}else
|
||||
field_access_right.setEnabled(false);
|
||||
|
||||
if(zMeta.getLicense()!=null) {
|
||||
addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||
selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||
FieldUtil.addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||
FieldUtil.selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||
}
|
||||
field_license.setEnabled(false); //because is not changeable
|
||||
|
||||
|
@ -196,10 +202,28 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
the_tags_panel.addTagElement(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
if(listOfCreatorsView==null)
|
||||
listOfCreatorsView = new ArrayList<CreatorsFormView>();
|
||||
|
||||
if(listOfContributorsView==null)
|
||||
listOfContributorsView = new ArrayList<CreatorsFormView>();
|
||||
|
||||
// ADDING AUTHORS
|
||||
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||
fieldset_basic_informations.add(creatorsView);
|
||||
CreatorsFormView authorView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||
listOfCreatorsView.add(authorView);
|
||||
|
||||
CreatorsFormView contributorView = new CreatorsFormView(zenodoItem.getMetadata().getContributors());
|
||||
listOfContributorsView.add(contributorView);
|
||||
|
||||
for (CreatorsFormView cfv : listOfCreatorsView) {
|
||||
fieldset_basic_informations.add(cfv);
|
||||
}
|
||||
|
||||
for (CreatorsFormView cfv : listOfContributorsView) {
|
||||
fieldset_basic_informations.add(cfv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if(zenodoItem.getFiles()!=null) {
|
||||
|
@ -210,43 +234,43 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the values to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param listValues the list values
|
||||
*/
|
||||
private void addValuesToListBox(ListBox list, List<String> listValues) {
|
||||
if (listValues == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < listValues.size(); i++) {
|
||||
list.addItem(listValues.get(i), listValues.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select value to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param values the values
|
||||
*/
|
||||
private void selectValueToListBox(ListBox list, List<String> values) {
|
||||
GWT.log("Selecting value: "+values);
|
||||
String selectValue = null;
|
||||
if (values == null || values.isEmpty()) {
|
||||
selectValue = null;
|
||||
} else {
|
||||
selectValue = values.get(0);
|
||||
}
|
||||
|
||||
try {
|
||||
if (list.getItemCount() > 0)
|
||||
list.setSelectedValue(selectValue);
|
||||
} catch (Exception e) {
|
||||
GWT.log("error: " + e);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * Adds the values to list box.
|
||||
// *
|
||||
// * @param list the list
|
||||
// * @param listValues the list values
|
||||
// */
|
||||
// private void addValuesToListBox(ListBox list, List<String> listValues) {
|
||||
// if (listValues == null)
|
||||
// return;
|
||||
//
|
||||
// for (int i = 0; i < listValues.size(); i++) {
|
||||
// list.addItem(listValues.get(i), listValues.get(i));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Select value to list box.
|
||||
// *
|
||||
// * @param list the list
|
||||
// * @param values the values
|
||||
// */
|
||||
// private void selectValueToListBox(ListBox list, List<String> values) {
|
||||
// GWT.log("Selecting value: "+values);
|
||||
// String selectValue = null;
|
||||
// if (values == null || values.isEmpty()) {
|
||||
// selectValue = null;
|
||||
// } else {
|
||||
// selectValue = values.get(0);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// if (list.getItemCount() > 0)
|
||||
// list.setSelectedValue(selectValue);
|
||||
// } catch (Exception e) {
|
||||
// GWT.log("error: " + e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void addFileForPublishing(ZenodoFile file) {
|
||||
// PublishFileView pv = new PublishFileView();
|
||||
|
@ -367,16 +391,26 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
}
|
||||
}
|
||||
|
||||
//Validating Authors
|
||||
if(creatorsView!=null) {
|
||||
String error = creatorsView.validateFormFields();
|
||||
//Validating Creators
|
||||
for (CreatorsFormView cfv : listOfCreatorsView) {
|
||||
String error = cfv.validateFormFields();
|
||||
if(error!=null) {
|
||||
error_alert.setVisible(true);
|
||||
error_alert.setText(error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Validating Contributors
|
||||
for (CreatorsFormView cfv : listOfContributorsView) {
|
||||
String error = cfv.validateFormFields();
|
||||
if(error!=null) {
|
||||
error_alert.setVisible(true);
|
||||
error_alert.setText(error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -401,60 +435,152 @@ public class BasicInformationView extends Composite implements FormValidator {
|
|||
return box.getText();
|
||||
}
|
||||
|
||||
public CreatorsFormView getCreatorsView() {
|
||||
return creatorsView;
|
||||
/**
|
||||
* Gets the list of contributors view.
|
||||
*
|
||||
* @return the list of contributors view
|
||||
*/
|
||||
public List<CreatorsFormView> getListOfContributorsView() {
|
||||
return listOfContributorsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of creators view.
|
||||
*
|
||||
* @return the list of creators view
|
||||
*/
|
||||
public List<CreatorsFormView> getListOfCreatorsView() {
|
||||
return listOfCreatorsView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of authors.
|
||||
*
|
||||
* @return the list of authors
|
||||
*/
|
||||
public List<ZenodoCreator> getListOfCreators() {
|
||||
List<ZenodoCreator> listOfCreators = new ArrayList<>();
|
||||
for (CreatorsFormView cfv : listOfCreatorsView) {
|
||||
List<? extends ZenodoAuthor> listOfUsers = cfv.readListOfCreatorsFromView();
|
||||
for (ZenodoAuthor zenodoAuthor : listOfUsers) {
|
||||
listOfCreators.add((ZenodoCreator) zenodoAuthor);
|
||||
}
|
||||
}
|
||||
return listOfCreators;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of creators.
|
||||
* Gets the list of contributors.
|
||||
*
|
||||
* @return the list of creators
|
||||
* @return the list of contributors
|
||||
*/
|
||||
public List<ZenodoCreator> getListOfCreators() {
|
||||
return creatorsView.readListOfCreatorsFromView();
|
||||
public List<ZenodoContributor> getListOfContributors() {
|
||||
List<ZenodoContributor> listOfContributors = new ArrayList<>();
|
||||
for (CreatorsFormView cfv : listOfContributorsView) {
|
||||
List<? extends ZenodoAuthor> listOfUsers = cfv.readListOfCreatorsFromView();
|
||||
for (ZenodoAuthor zenodoAuthor : listOfUsers) {
|
||||
listOfContributors.add((ZenodoContributor) zenodoAuthor);
|
||||
}
|
||||
}
|
||||
return listOfContributors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field title.
|
||||
*
|
||||
* @return the field title
|
||||
*/
|
||||
public TextBox getField_title() {
|
||||
return field_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field doi.
|
||||
*
|
||||
* @return the field doi
|
||||
*/
|
||||
public TextBox getField_doi() {
|
||||
return field_doi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fieldset basic informations.
|
||||
*
|
||||
* @return the fieldset basic informations
|
||||
*/
|
||||
public Fieldset getFieldset_basic_informations() {
|
||||
return fieldset_basic_informations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field description.
|
||||
*
|
||||
* @return the field description
|
||||
*/
|
||||
public TextArea getField_description() {
|
||||
return field_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field upload type.
|
||||
*
|
||||
* @return the field upload type
|
||||
*/
|
||||
public ListBox getField_upload_type() {
|
||||
return field_upload_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field access right.
|
||||
*
|
||||
* @return the field access right
|
||||
*/
|
||||
public ListBox getField_access_right() {
|
||||
return field_access_right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field license.
|
||||
*
|
||||
* @return the field license
|
||||
*/
|
||||
public ListBox getField_license() {
|
||||
return field_license;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field publication type.
|
||||
*
|
||||
* @return the field publication type
|
||||
*/
|
||||
public ListBox getField_publication_type() {
|
||||
return field_publication_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field publication date.
|
||||
*
|
||||
* @return the field publication date
|
||||
*/
|
||||
public DateBox getField_publication_date() {
|
||||
return field_publication_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error alert.
|
||||
*
|
||||
* @return the error alert
|
||||
*/
|
||||
public Alert getError_alert() {
|
||||
return error_alert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags.
|
||||
*
|
||||
* @return the tags
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
return the_tags_panel.getTags();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile;
|
|||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.switchbutton.client.SwitchButton;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
|
@ -28,6 +29,9 @@ public class PublishFileView extends Composite {
|
|||
|
||||
@UiField
|
||||
TextBox field_file_name;
|
||||
|
||||
@UiField
|
||||
Label field_label_info;
|
||||
|
||||
private ZenodoFile file;
|
||||
|
||||
|
@ -77,6 +81,23 @@ public class PublishFileView extends Composite {
|
|||
return switchButton;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hide switch button.
|
||||
*
|
||||
* @param bool the bool
|
||||
* @param msg the msg
|
||||
*/
|
||||
public void hideSwitchButton(boolean bool, String msg) {
|
||||
if(bool) {
|
||||
switchButton.setVisible(false);
|
||||
}else {
|
||||
switchButton.setVisible(true);
|
||||
}
|
||||
|
||||
field_label_info.setText(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field file name.
|
||||
*
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</b:TextBox>
|
||||
<g:HorizontalPanel
|
||||
addStyleNames="{style.to-publish-hr}">
|
||||
<b:Label type="INFO" addStyleNames="{style.to-padding}">Publish</b:Label>
|
||||
<b:Label type="INFO" addStyleNames="{style.to-padding}" ui:field="field_label_info">Publish</b:Label>
|
||||
<citem:SwitchButton ui:field="switchButton"
|
||||
addStyleNames="{style.padding-left-10}"></citem:SwitchButton>
|
||||
</g:HorizontalPanel>
|
||||
|
|
|
@ -5,9 +5,10 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorView;
|
||||
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.ZenodoAuthor;
|
||||
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;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
@ -121,8 +122,12 @@ public class Ckan2ZenodoViewManager {
|
|||
ZenodoMetadata meta = zenodoItem.getMetadata();
|
||||
meta.setDescription(basicForm.getField_description().getValue());
|
||||
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
||||
|
||||
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
||||
meta.setCreators(creators);
|
||||
|
||||
List<ZenodoContributor> contributors = basicForm.getListOfContributors();
|
||||
meta.setContributors(contributors);
|
||||
|
||||
// upload type
|
||||
String uploadType = basicForm.getField_upload_type().getSelectedValue();
|
||||
|
@ -143,7 +148,7 @@ public class Ckan2ZenodoViewManager {
|
|||
|
||||
// Updating list of file for publishing
|
||||
List<ZenodoFile> publishingFile = getListFileToPublish();
|
||||
zenodoItem.setFiles(publishingFile);
|
||||
zenodoItem.addFiles(publishingFile);
|
||||
|
||||
return zenodoItem;
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -72,4 +75,45 @@ public class FieldUtil {
|
|||
return box.getText();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the values to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param listValues the list values
|
||||
*/
|
||||
public static void addValuesToListBox(ListBox list, List<String> listValues) {
|
||||
if (listValues == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < listValues.size(); i++) {
|
||||
list.addItem(listValues.get(i), listValues.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select value to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param values the values
|
||||
*/
|
||||
public static void selectValueToListBox(ListBox list, List<String> values) {
|
||||
GWT.log("Selecting value: "+values);
|
||||
String selectValue = null;
|
||||
if (values == null || values.isEmpty()) {
|
||||
selectValue = null;
|
||||
} else {
|
||||
selectValue = values.get(0);
|
||||
}
|
||||
|
||||
try {
|
||||
if (list.getItemCount() > 0)
|
||||
list.setSelectedValue(selectValue);
|
||||
} catch (Exception e) {
|
||||
GWT.log("error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ public class PublishFileViewManager {
|
|||
PublishFileView pv = new PublishFileView(file);
|
||||
pv.getField_file_name().setValue(file.getFilename());
|
||||
pv.getSwitchButton().setValue(true);
|
||||
|
||||
if(file.getIsAlreadyPublished()) {
|
||||
pv.hideSwitchButton(true, "File already published on Zenodo");
|
||||
}
|
||||
return pv;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo;
|
||||
import org.gcube.data.publishing.ckan2zenodo.Ckan2ZenodoImpl;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.CkanItemDescriptor;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.CkanResource;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ConfigurationException;
|
||||
|
@ -12,7 +16,6 @@ import org.gcube.data.publishing.ckan2zenodo.model.faults.InvalidItemException;
|
|||
import org.gcube.data.publishing.ckan2zenodo.model.faults.TransformationException;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.FileDeposition;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidgetConstant;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
||||
|
@ -29,6 +32,10 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet implements CkanToZenodoPublisherService {
|
||||
|
@ -36,6 +43,9 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
private static Logger LOG = LoggerFactory.getLogger(CkanToZenodoPublisherServiceImpl.class);
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#publishOnZenodo(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem)
|
||||
*/
|
||||
@Override
|
||||
public String publishOnZenodo(ZenodoItem zenodoItem) throws Exception {
|
||||
|
||||
|
@ -46,48 +56,61 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||
}
|
||||
|
||||
ZenodoDeposition zdPreview=loadItemPreviewFromService(zenodoItem.getName());
|
||||
|
||||
//(EVENTUALLY) UPDATING INFO CHANGED BY FORM ON CLIENT-SIDE
|
||||
ZenodoDeposition zenodoDepositionPreview=loadItemPreviewFromService(zenodoItem.getName());
|
||||
//(EVENTUALLY) UPDATING BASIC INFO CHANGED BY FORM ON CLIENT-SIDE
|
||||
//Basic info
|
||||
zdPreview.setTitle(zenodoItem.getTitle());
|
||||
//Files
|
||||
if(zenodoItem.getFiles()!=null) {
|
||||
ArrayList<FileDeposition> listOfFiles = new ArrayList<FileDeposition>(zenodoItem.getFiles().size());
|
||||
for (ZenodoFile zf : zenodoItem.getFiles()) {
|
||||
FileDeposition fileDepos = ItemToZenodoConverter.toServiceFileDeposition(zf);
|
||||
listOfFiles.add(fileDepos);
|
||||
}
|
||||
zdPreview.setFiles(listOfFiles);
|
||||
}
|
||||
zenodoDepositionPreview.setTitle(zenodoItem.getTitle());
|
||||
|
||||
//Updating Deposition Metadata potentially changed on client-side
|
||||
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
||||
DepositionMetadata depositionMetadata = zdPreview.getMetadata();
|
||||
DepositionMetadata depositionMetadata = zenodoDepositionPreview.getMetadata();
|
||||
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata, depositionMetadata);
|
||||
zdPreview.setMetadata(depositionMetadata);
|
||||
zenodoDepositionPreview.setMetadata(depositionMetadata);
|
||||
|
||||
//Ckan2ZenodoImpl.publish(item.getItemName());
|
||||
//Eventually update values
|
||||
//zdPreview.getMetadata().setAccess_conditions("Ask me");
|
||||
//Loading Filtered resources according to VRE policies
|
||||
List<CkanResource> filteredResources = loadFilterResources(zenodoItem.getName());
|
||||
|
||||
HashSet<CkanResource> toUpload = new HashSet<CkanResource>();
|
||||
|
||||
//Adding for publishing only the resources selected on clien-side
|
||||
if(zenodoItem.getFiles()!=null) {
|
||||
for (ZenodoFile zf : zenodoItem.getFiles()) {
|
||||
for (CkanResource ckanResource : filteredResources) {
|
||||
if(zf.getId().compareTo(ckanResource.getId())==0 && zf.getIsAlreadyPublished()==false) {
|
||||
toUpload.add(ckanResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Actually publish to zenodo :
|
||||
// Step 1 : metadata
|
||||
// Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||
// CkanItemDescriptor item=client.read(zenodoItem.getName());
|
||||
// zdPreview = client.updatedMetadata(zdPreview);
|
||||
Ckan2Zenodo client= new Ckan2ZenodoImpl();
|
||||
zenodoDepositionPreview = client.updatedMetadata(zenodoDepositionPreview);
|
||||
|
||||
//Step 2 : publish Resources
|
||||
// Future<ZenodoDeposition> future_Dep=client.uploadFiles(Collections.singleton(toFilter.get(0)), zdPreview);
|
||||
// ZenodoDeposition preview = future_Dep.get();
|
||||
|
||||
//Finalize
|
||||
if(toUpload.size()>0) {
|
||||
LOG.debug("Trying to publish the set of CKAN resources: "+toUpload.toString());
|
||||
Future<ZenodoDeposition> future_Dep=client.uploadFiles(toUpload, zenodoDepositionPreview);
|
||||
while(!future_Dep.isDone()) {
|
||||
LOG.debug("Waiting for completed future computation (publishing of resources on Zenodo)...");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
zenodoDepositionPreview = future_Dep.get(180,TimeUnit.SECONDS);
|
||||
}
|
||||
// Get the item representation
|
||||
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
||||
|
||||
//Finalize
|
||||
client.publish(zenodoDepositionPreview, item);
|
||||
return zenodoDepositionPreview.toString();
|
||||
|
||||
}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";
|
||||
LOG.error(error, e);
|
||||
String clientError = String.format("%s", error);
|
||||
throw new Exception(clientError);
|
||||
|
||||
//client.publish(zdPreview, item);
|
||||
|
||||
return zdPreview.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
String error = "Error when publishing on Zenodo the catalogue item: "+zenodoItem.getName();
|
||||
LOG.error(error, e);
|
||||
|
@ -97,6 +120,9 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService#convertToZenodoItem(org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem)
|
||||
*/
|
||||
@Override
|
||||
public ZenodoItem convertToZenodoItem(CatalogueItem item) throws Exception {
|
||||
|
||||
|
@ -109,12 +135,18 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
|
||||
//Get a preview of the deposition to be published
|
||||
ZenodoDeposition zdPreview=loadItemPreviewFromService(item.getItemName());
|
||||
|
||||
//Filter resources according to VRE policies
|
||||
//List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
||||
|
||||
//zdPreview.setFiles(toFilterFiles);
|
||||
//Loading Filtered resources according to VRE policies
|
||||
List<CkanResource> filteredResources = loadFilterResources(item.getItemName());
|
||||
LOG.debug("Loaded filtered resources: "+filteredResources);
|
||||
|
||||
//Converting ZenodoDeposition to ZenodoItem
|
||||
ZenodoItem zenodoItem = ItemToZenodoConverter.toZenodoItem(zdPreview);
|
||||
|
||||
//Adding the filtered resources
|
||||
List<ZenodoFile> resources = ItemToZenodoConverter.toZenodoFiles(filteredResources, false);
|
||||
zenodoItem.addFiles(resources);
|
||||
|
||||
zenodoItem.setName(item.getItemName());
|
||||
LOG.debug("Returning item: "+zenodoItem);
|
||||
return zenodoItem;
|
||||
|
@ -152,31 +184,45 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
* Load item preview from service.
|
||||
*
|
||||
* @param itemName the item name
|
||||
* @return
|
||||
* @throws GcatException
|
||||
* @throws TransformationException
|
||||
* @throws ConfigurationException
|
||||
* @throws ZenodoException
|
||||
* @throws InvalidItemException
|
||||
* @return the zenodo deposition
|
||||
* @throws GcatException the gcat exception
|
||||
* @throws InvalidItemException the invalid item exception
|
||||
* @throws ZenodoException the zenodo exception
|
||||
* @throws ConfigurationException the configuration exception
|
||||
* @throws TransformationException the transformation exception
|
||||
*/
|
||||
private ZenodoDeposition loadItemPreviewFromService(String itemName) throws GcatException, InvalidItemException, ZenodoException, ConfigurationException, TransformationException {
|
||||
|
||||
Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||
|
||||
Ckan2Zenodo client= new Ckan2ZenodoImpl();
|
||||
// Get the item representation
|
||||
CkanItemDescriptor itemDescr=client.read(itemName);
|
||||
|
||||
//Get a preview of the deposition to be published
|
||||
ZenodoDeposition zenodoDeposition = client.translate(itemDescr);
|
||||
return client.translate(itemDescr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load filter resources.
|
||||
*
|
||||
* @param itemName the item name
|
||||
* @return the list
|
||||
* @throws GcatException the gcat exception
|
||||
* @throws ConfigurationException the configuration exception
|
||||
* @throws TransformationException the transformation exception
|
||||
*/
|
||||
private List<CkanResource> loadFilterResources(String itemName) throws GcatException, ConfigurationException, TransformationException {
|
||||
|
||||
Ckan2Zenodo client= new Ckan2ZenodoImpl();
|
||||
// Get the item representation
|
||||
CkanItemDescriptor itemDescr=client.read(itemName);
|
||||
//Filter resources according to VRE policies
|
||||
List<CkanResource> toFilter=client.filterResources(itemDescr);
|
||||
|
||||
return zenodoDeposition;
|
||||
return client.filterResources(itemDescr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Online or in development mode?
|
||||
* Online or in development mode?.
|
||||
*
|
||||
* @return true if you're running into the portal, false if in development
|
||||
*/
|
||||
private boolean isOutFromPortal() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.Contributor;
|
||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
||||
|
@ -72,13 +73,9 @@ public class ItemToZenodoConverter {
|
|||
zi.setDoi(zenodoDeposition.getDoi());
|
||||
zi.setCreated(zenodoDeposition.getCreated());
|
||||
|
||||
if(zenodoDeposition.getFiles()!=null) {
|
||||
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(zenodoDeposition.getFiles().size());
|
||||
for (FileDeposition fileDeposition : zenodoDeposition.getFiles()) {
|
||||
listOfFiles.add(toZenodoFile(fileDeposition));
|
||||
}
|
||||
zi.setFiles(listOfFiles);
|
||||
}
|
||||
//Add files already published in the deposition
|
||||
List<ZenodoFile> files = toZenodoFiles(zenodoDeposition.getFiles(),true);
|
||||
zi.addFiles(files);
|
||||
|
||||
zi.setModified(zenodoDeposition.getModified());
|
||||
zi.setOwner(zenodoDeposition.getOwner());
|
||||
|
@ -95,13 +92,56 @@ public class ItemToZenodoConverter {
|
|||
return zi;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the files.
|
||||
*
|
||||
* @param files the files
|
||||
* @param filesAlreadyPublished the files already published
|
||||
* @return the list
|
||||
*/
|
||||
private static List<ZenodoFile> toZenodoFiles(ArrayList<FileDeposition> files, boolean filesAlreadyPublished) {
|
||||
|
||||
if(files==null)
|
||||
return null;
|
||||
|
||||
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(files.size());
|
||||
for (FileDeposition fileDeposition : files) {
|
||||
listOfFiles.add(toZenodoFile(fileDeposition, filesAlreadyPublished));
|
||||
}
|
||||
|
||||
return listOfFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* To zenodo files.
|
||||
*
|
||||
* @param filteredResources the filtered resources
|
||||
* @param filesAlreadyPublished the files already published
|
||||
* @return the list
|
||||
*/
|
||||
public static List<ZenodoFile> toZenodoFiles(List<CkanResource> filteredResources, boolean filesAlreadyPublished) {
|
||||
if(filteredResources==null)
|
||||
return null;
|
||||
|
||||
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(filteredResources.size());
|
||||
for (CkanResource ckanResource : filteredResources) {
|
||||
listOfFiles.add(toZenodoFile(ckanResource,filesAlreadyPublished));
|
||||
}
|
||||
|
||||
return listOfFiles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo file.
|
||||
*
|
||||
* @param fileDeposition the file deposition
|
||||
* @param fileAlreadyPublished the file already published
|
||||
* @return the zenodo file
|
||||
*/
|
||||
public static ZenodoFile toZenodoFile(FileDeposition fileDeposition) {
|
||||
public static ZenodoFile toZenodoFile(FileDeposition fileDeposition, boolean fileAlreadyPublished) {
|
||||
|
||||
if(fileDeposition==null)
|
||||
return null;
|
||||
|
@ -109,11 +149,38 @@ public class ItemToZenodoConverter {
|
|||
ZenodoFile zf = new ZenodoFile();
|
||||
zf.setId(fileDeposition.getId());
|
||||
zf.setFilename(fileDeposition.getFilename());
|
||||
zf.setFilesize(fileDeposition.getFilesize());
|
||||
zf.setFilesize(fileDeposition.getFilesize()+"");
|
||||
zf.setChecksum(fileDeposition.getChecksum());
|
||||
zf.setIsAlreadyPublished(fileAlreadyPublished);
|
||||
return zf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo file.
|
||||
*
|
||||
* @param ckanResource the ckan resource
|
||||
* @param fileAlreadyPublished the file already published
|
||||
* @return the zenodo file
|
||||
*/
|
||||
public static ZenodoFile toZenodoFile(CkanResource ckanResource, boolean fileAlreadyPublished) {
|
||||
|
||||
if(ckanResource==null)
|
||||
return null;
|
||||
|
||||
ZenodoFile zf = new ZenodoFile();
|
||||
zf.setId(ckanResource.getId());
|
||||
zf.setFilename(ckanResource.getName());
|
||||
zf.setFilesize(ckanResource.getSize());
|
||||
zf.setChecksum(null);
|
||||
zf.setMimeType(ckanResource.getMimetype());
|
||||
zf.setFormat(ckanResource.getFormat());
|
||||
zf.setDescription(ckanResource.getDescription());
|
||||
zf.setIsAlreadyPublished(fileAlreadyPublished);
|
||||
return zf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo metadata.
|
||||
*
|
||||
|
@ -303,7 +370,7 @@ public class ItemToZenodoConverter {
|
|||
|
||||
List<ZenodoCreator> list = new ArrayList<ZenodoCreator>(creators.size());
|
||||
for (Creator contr : creators) {
|
||||
ZenodoContributor zc = new ZenodoContributor();
|
||||
ZenodoCreator zc = new ZenodoCreator();
|
||||
zc.setAffiliation(contr.getAffiliation());
|
||||
zc.setGnd(contr.getGnd());
|
||||
zc.setName(contr.getName());
|
||||
|
@ -315,102 +382,6 @@ public class ItemToZenodoConverter {
|
|||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * **
|
||||
// *
|
||||
// *
|
||||
// * TO SERVICE.
|
||||
// *
|
||||
// * @param zenodoItem the zenodo item
|
||||
// * @param zenodoDeposition the zenodo deposition
|
||||
// * @return the zenodo deposition
|
||||
// */
|
||||
//
|
||||
// /**
|
||||
// * To service zenodo deposition.
|
||||
// *
|
||||
// * @param zenodoItem the zenodo item
|
||||
// */
|
||||
// public static ZenodoDeposition toServiceZenodoDeposition(ZenodoItem zenodoItem, ZenodoDeposition zenodoDeposition) {
|
||||
//
|
||||
// if(zenodoItem==null)
|
||||
// return zenodoDeposition;
|
||||
//
|
||||
// //zenodoDeposition.setId(zenodoItem.getId());
|
||||
// //zenodoDeposition.setDoi(zenodoItem.getDoi());
|
||||
// //zenodoDeposition.setCreated(zenodoItem.getCreated());
|
||||
//
|
||||
// zenodoDeposition.setTitle(zenodoItem.getTitle());
|
||||
//
|
||||
// if(zenodoItem.getFiles()!=null) {
|
||||
// ArrayList<FileDeposition> listOfFiles = new ArrayList<FileDeposition>(zenodoItem.getFiles().size());
|
||||
// for (ZenodoFile zf : zenodoItem.getFiles()) {
|
||||
// listOfFiles.add(toServiceZenodoDeposition(zf));
|
||||
// }
|
||||
// zenodoDeposition.setFiles(listOfFiles);
|
||||
// }
|
||||
//
|
||||
// //zenodoDeposition.setModified(zenodoItem.getModified());
|
||||
// //zenodoDeposition.setOwner(zenodoItem.getOwner());
|
||||
// //zenodoDeposition.setRecord_id(zenodoItem.getRecord_id());
|
||||
//// try {
|
||||
//// zenodoDeposition.setRecord_url(zenodoItem.getRecord_url()!=null?new URL(zenodoItem.getRecord_url()):null);
|
||||
//// } catch (MalformedURLException e) {
|
||||
//// LOG.warn(e.getMessage());
|
||||
//// }
|
||||
//
|
||||
//// zenodoDeposition.setState(zenodoItem.getState());
|
||||
//// zenodoDeposition.setSubmitted(zenodoItem.getSubmitted());
|
||||
// //zenodoDeposition.setMetadata(toServiceZenodoMetadata(zenodoItem.getMetadata(),zenodoDeposition.getMetadata()));
|
||||
//
|
||||
// return zenodoDeposition;
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
||||
// /**
|
||||
// * To service zenodo metadata.
|
||||
// *
|
||||
// * @param zenodoMetadata the zenodo metadata
|
||||
// * @param depositionMetadata the deposition metadata
|
||||
// * @return the deposition metadata
|
||||
// */
|
||||
// public static DepositionMetadata toServiceZenodoMetadata(ZenodoMetadata zenodoMetadata, DepositionMetadata depositionMetadata){
|
||||
//
|
||||
// if(zenodoMetadata==null)
|
||||
// return null;
|
||||
//
|
||||
// depositionMetadata.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
||||
// depositionMetadata.setDescription(depositionMetadata.getDescription());
|
||||
//
|
||||
// if(depositionMetadata.getAccess_right()!=null) {
|
||||
// AccessRights[] ar = { depositionMetadata.getAccess_right() };
|
||||
// SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(ar, AccessRights.values());
|
||||
// depositionMetadata.setAccess_right(sEnum);
|
||||
// }
|
||||
//
|
||||
// depositionMetadata.setCommunities(toZenodoCommunities(depositionMetadata.getCommunities()));
|
||||
// depositionMetadata.setConference_acronym(depositionMetadata.getConference_acronym());
|
||||
// depositionMetadata.setConference_dates(depositionMetadata.getConference_dates());
|
||||
// depositionMetadata.setConference_place(depositionMetadata.getConference_place());
|
||||
// depositionMetadata.setConference_session(depositionMetadata.getConference_session());
|
||||
// depositionMetadata.setConference_session_part(depositionMetadata.getConference_session_part());
|
||||
// depositionMetadata.setConference_title(depositionMetadata.getConference_title());
|
||||
// depositionMetadata.setConference_url(depositionMetadata.getConference_url());
|
||||
// depositionMetadata.setContributors(toZenodoContributors(depositionMetadata.getContributors()));
|
||||
// depositionMetadata.setCreators(toZenodoCreators(depositionMetadata.getCreators()));
|
||||
// depositionMetadata.setDates(toZenodDateIntervals(depositionMetadata.getDates()));
|
||||
// depositionMetadata.setRelated_identifiers(toRelatedIdentifiers(depositionMetadata.getRelated_identifiers()));
|
||||
// depositionMetadata.setSubjects(toZenodoSubjects(depositionMetadata.getSubjects()));
|
||||
// depositionMetadata.setThesis_supervisors(toZenodoCreators(depositionMetadata.getThesis_supervisors()));
|
||||
// depositionMetadata.setThesis_university(depositionMetadata.getThesis_university());
|
||||
// depositionMetadata.setTitle(depositionMetadata.getTitle());
|
||||
// depositionMetadata.setVersion(depositionMetadata.getVersion());
|
||||
// return zm;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To service file deposition.
|
||||
*
|
||||
|
@ -425,7 +396,11 @@ public class ItemToZenodoConverter {
|
|||
FileDeposition fileDep = new FileDeposition();
|
||||
fileDep.setId(zenodoFile.getId());
|
||||
fileDep.setFilename(zenodoFile.getFilename());
|
||||
fileDep.setFilesize(zenodoFile.getFilesize());
|
||||
try {
|
||||
fileDep.setFilesize(Integer.parseInt(zenodoFile.getFilesize()));
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
fileDep.setChecksum(zenodoFile.getChecksum());
|
||||
return fileDep;
|
||||
}
|
||||
|
@ -472,4 +447,6 @@ public class ItemToZenodoConverter {
|
|||
return depositionMetadata;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||
|
||||
/**
|
||||
* The Interface ZenodoAuthor.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
public interface ZenodoAuthor {
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets the affiliation.
|
||||
*
|
||||
* @return the affiliation
|
||||
*/
|
||||
public String getAffiliation();
|
||||
|
||||
/**
|
||||
* Gets the orcid.
|
||||
*
|
||||
* @return the orcid
|
||||
*/
|
||||
public String getOrcid();
|
||||
|
||||
/**
|
||||
* Gets the gnd.
|
||||
*
|
||||
* @return the gnd
|
||||
*/
|
||||
public String getGnd();
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public SerializableEnum<String> getType();
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* Sets the affiliation.
|
||||
*
|
||||
* @param affiliation the new affiliation
|
||||
*/
|
||||
public void setAffiliation(String affiliation);
|
||||
|
||||
/**
|
||||
* Sets the orcid.
|
||||
*
|
||||
* @param orcid the new orcid
|
||||
*/
|
||||
public void setOrcid(String orcid);
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
|||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 10, 2019
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
public class ZenodoContributor extends ZenodoCreator{
|
||||
|
||||
|
@ -39,11 +39,19 @@ public class ZenodoContributor extends ZenodoCreator{
|
|||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator#getType()
|
||||
*/
|
||||
public SerializableEnum<String> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the type.
|
||||
*
|
||||
* @param type the new type
|
||||
*/
|
||||
public void setType(SerializableEnum<String> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
|
|
@ -2,14 +2,17 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
||||
|
||||
|
||||
/**
|
||||
* The Class ZenodoCreator.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 10, 2019
|
||||
* Jan 15, 2020
|
||||
*/
|
||||
public class ZenodoCreator implements Serializable{
|
||||
public class ZenodoCreator implements ZenodoAuthor, Serializable{
|
||||
|
||||
|
||||
/**
|
||||
|
@ -21,9 +24,20 @@ public class ZenodoCreator implements Serializable{
|
|||
private String orcid;
|
||||
private String gnd;
|
||||
|
||||
/**
|
||||
* Instantiates a new zenodo creator.
|
||||
*/
|
||||
public ZenodoCreator(){}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new zenodo creator.
|
||||
*
|
||||
* @param name the name
|
||||
* @param affiliation the affiliation
|
||||
* @param orcid the orcid
|
||||
* @param gnd the gnd
|
||||
*/
|
||||
public ZenodoCreator(String name, String affiliation, String orcid, String gnd) {
|
||||
super();
|
||||
this.name = name;
|
||||
|
@ -34,38 +48,81 @@ public class ZenodoCreator implements Serializable{
|
|||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor#getAffiliation()
|
||||
*/
|
||||
public String getAffiliation() {
|
||||
return affiliation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the affiliation.
|
||||
*
|
||||
* @param affiliation the new affiliation
|
||||
*/
|
||||
public void setAffiliation(String affiliation) {
|
||||
this.affiliation = affiliation;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor#getOrcid()
|
||||
*/
|
||||
public String getOrcid() {
|
||||
return orcid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the orcid.
|
||||
*
|
||||
* @param orcid the new orcid
|
||||
*/
|
||||
public void setOrcid(String orcid) {
|
||||
this.orcid = orcid;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor#getGnd()
|
||||
*/
|
||||
public String getGnd() {
|
||||
return gnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the gnd.
|
||||
*
|
||||
* @param gnd the new gnd
|
||||
*/
|
||||
public void setGnd(String gnd) {
|
||||
this.gnd = gnd;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor#getType()
|
||||
*/
|
||||
@Override
|
||||
public SerializableEnum<String> getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -15,19 +15,31 @@ public class ZenodoFile implements Serializable{
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -844797695117716597L;
|
||||
private static final long serialVersionUID = 761497963654566281L;
|
||||
private String id;
|
||||
private String filename;
|
||||
private Integer filesize;
|
||||
private String description;
|
||||
private String filesize;
|
||||
private String checksum;
|
||||
private String mimeType;
|
||||
private String format;
|
||||
|
||||
|
||||
private Boolean isAlreadyPublished = false; //Used by Portlet to check if the file is already published on Zenodo
|
||||
|
||||
public ZenodoFile(){}
|
||||
|
||||
public ZenodoFile(String id, String filename, Integer filesize, String checksum) {
|
||||
public ZenodoFile(String id, String filename, String description, String filesize, String checksum, String mimeType,
|
||||
String format, Boolean isAlreadyPublished) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.filename = filename;
|
||||
this.description = description;
|
||||
this.filesize = filesize;
|
||||
this.checksum = checksum;
|
||||
this.mimeType = mimeType;
|
||||
this.format = format;
|
||||
this.isAlreadyPublished = isAlreadyPublished;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -46,11 +58,19 @@ public class ZenodoFile implements Serializable{
|
|||
this.filename = filename;
|
||||
}
|
||||
|
||||
public Integer getFilesize() {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFilesize() {
|
||||
return filesize;
|
||||
}
|
||||
|
||||
public void setFilesize(Integer filesize) {
|
||||
public void setFilesize(String filesize) {
|
||||
this.filesize = filesize;
|
||||
}
|
||||
|
||||
|
@ -62,6 +82,30 @@ public class ZenodoFile implements Serializable{
|
|||
this.checksum = checksum;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public Boolean getIsAlreadyPublished() {
|
||||
return isAlreadyPublished;
|
||||
}
|
||||
|
||||
public void setIsAlreadyPublished(Boolean isAlreadyPublished) {
|
||||
this.isAlreadyPublished = isAlreadyPublished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -69,10 +113,18 @@ public class ZenodoFile implements Serializable{
|
|||
builder.append(id);
|
||||
builder.append(", filename=");
|
||||
builder.append(filename);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", filesize=");
|
||||
builder.append(filesize);
|
||||
builder.append(", checksum=");
|
||||
builder.append(checksum);
|
||||
builder.append(", mimeType=");
|
||||
builder.append(mimeType);
|
||||
builder.append(", format=");
|
||||
builder.append(format);
|
||||
builder.append(", isAlreadyPublished=");
|
||||
builder.append(isAlreadyPublished);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -57,12 +57,17 @@ public class ZenodoItem implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the files.
|
||||
* Adds the files.
|
||||
*
|
||||
* @param files the new files
|
||||
* @param files the files
|
||||
*/
|
||||
public void setFiles(List<ZenodoFile> files) {
|
||||
this.files = files;
|
||||
public void addFiles(List<ZenodoFile> files) {
|
||||
|
||||
if(this.files==null) {
|
||||
this.files = files;
|
||||
}else {
|
||||
this.files.addAll(files);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -272,6 +277,9 @@ public class ZenodoItem implements Serializable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -21,7 +21,11 @@ public class ZenodoMetadata implements Serializable{
|
|||
|
||||
private Date publication_date;
|
||||
private String title;
|
||||
|
||||
private List<ZenodoCreator> creators;
|
||||
private List<ZenodoContributor> contributors;
|
||||
private List<ZenodoCreator> thesis_supervisors;
|
||||
|
||||
private String description; // TODO HTML
|
||||
|
||||
private SerializableEnum<String> access_right;
|
||||
|
@ -35,7 +39,6 @@ public class ZenodoMetadata implements Serializable{
|
|||
|
||||
private List<ZenodoRelatedIdentifier> related_identifiers;
|
||||
|
||||
private List<ZenodoContributor> contributors;
|
||||
private List<String> references;
|
||||
private List<ZenodoCommunity> communities;
|
||||
private List<ZenodoGrant> grants;
|
||||
|
@ -55,7 +58,7 @@ public class ZenodoMetadata implements Serializable{
|
|||
private String imprint_place;
|
||||
private String partof_title;
|
||||
private String partof_pages;
|
||||
private List<ZenodoCreator> thesis_supervisors;
|
||||
|
||||
private String thesis_university;
|
||||
private List<ZenodoSubject> subjects;
|
||||
private String version;
|
||||
|
@ -63,6 +66,7 @@ public class ZenodoMetadata implements Serializable{
|
|||
private List<ZenodoLocation> locations;
|
||||
private List<ZenodoDateInterval> dates;
|
||||
private String method; //TODO html
|
||||
|
||||
|
||||
private LicenseBean license; //TODO html
|
||||
|
||||
|
@ -71,8 +75,6 @@ public class ZenodoMetadata implements Serializable{
|
|||
|
||||
|
||||
public SerializableEnum<String> getUpload_type() {
|
||||
if(upload_type==null)
|
||||
return new SerializableEnum<>();
|
||||
return upload_type;
|
||||
}
|
||||
|
||||
|
@ -122,7 +124,7 @@ public class ZenodoMetadata implements Serializable{
|
|||
}
|
||||
|
||||
|
||||
public List<ZenodoCreator> getCreators() {
|
||||
public List<? extends ZenodoAuthor> getCreators() {
|
||||
return creators;
|
||||
}
|
||||
|
||||
|
@ -222,7 +224,7 @@ public class ZenodoMetadata implements Serializable{
|
|||
}
|
||||
|
||||
|
||||
public List<ZenodoContributor> getContributors() {
|
||||
public List<? extends ZenodoAuthor> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
<!-- any one of the following lines. -->
|
||||
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
|
||||
|
||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
|
||||
<inherits name='com.github.gwtbootstrap.datepicker.Datepicker' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
|
|
Loading…
Reference in New Issue