In progress on Task #18236

This commit is contained in:
Francesco Mangiacrapa 2019-12-12 18:32:30 +01:00
parent c65b87511b
commit 427cf8bd13
16 changed files with 346 additions and 82 deletions

View File

@ -62,6 +62,7 @@
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -73,6 +74,12 @@
<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>junit</groupId>
<artifactId>junit</artifactId>
@ -109,7 +116,7 @@
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>run</goal> -->
<!-- <goal>run</goal> -->
</goals>
</execution>
</executions>

View File

@ -6,7 +6,9 @@
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
@ -16,6 +18,7 @@
<!--<entry-point class='org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisher' />-->
<!-- Specify the paths for translatable code -->
<stylesheet src='CkanToZenodoPublisher.css' />
<source path='client' />
<source path='shared' />

View File

@ -1,6 +1,8 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.FormToPublishOnZenodoView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.AccordionBasicPanel;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.BasicInformationView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.Ckan2ZenodoViewManager;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
@ -42,24 +44,27 @@ public class CkanToZendoPublisherWidget {
@Override
public void onSuccess(ZenodoItem result) {
Modal modal = new Modal(true);
FormToPublishOnZenodoView form = new FormToPublishOnZenodoView(result) {
@Override
public void submitHandler() {
}
@Override
public void setError(boolean visible, String error) {
}
@Override
public void setConfirm(boolean visible, String msg) {
}
};
Ckan2ZenodoViewManager manager = new Ckan2ZenodoViewManager();
AccordionBasicPanel theForm = manager.viewForPublishing(result);
// BasicInformationView form = new BasicInformationView(result) {
//
//
// @Override
// public void submitHandler() {
// }
//
// @Override
// public void setError(boolean visible, String error) {
// }
//
// @Override
// public void setConfirm(boolean visible, String msg) {
// }
// };
modal.setTitle("Publishing on Zenodo...");
modal.addStyleName("ckan2zenodo-modal-style");
modal.setCloseVisible(true);
modal.add(form);
modal.add(theForm);
modal.show();
}
});

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
import com.github.gwtbootstrap.client.ui.AccordionGroup;
import com.google.gwt.core.client.GWT;
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.Widget;
public class AccordionBasicPanel extends Composite {
private static AccordionBasicPanelUiBinder uiBinder = GWT.create(AccordionBasicPanelUiBinder.class);
interface AccordionBasicPanelUiBinder extends UiBinder<Widget, AccordionBasicPanel> {
}
@UiField
AccordionGroup acc_basic_info;
@UiField
AccordionGroup acc_files;
@UiField
AccordionGroup acc_license;
public AccordionBasicPanel() {
initWidget(uiBinder.createAndBindUi(this));
}
public AccordionBasicPanel(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
public AccordionGroup getAcc_basic_info() {
return acc_basic_info;
}
public AccordionGroup getAcc_files() {
return acc_files;
}
public AccordionGroup getAcc_license() {
return acc_license;
}
}

View File

@ -0,0 +1,29 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<b:Accordion>
<b:AccordionGroup heading="The Item Information"
icon="BOOK" defaultOpen="true" ui:field="acc_basic_info">
</b:AccordionGroup>
<!-- <b:AccordionGroup heading="Upload as type" -->
<!-- defaultOpen="true" ui:field="acc_upload_type" icon="UPLOAD"> -->
<!-- </b:AccordionGroup> -->
<b:AccordionGroup defaultOpen="true" heading="Files"
icon="UPLOAD" ui:field="acc_files">
</b:AccordionGroup>
<b:AccordionGroup defaultOpen="true"
heading="License" icon="STAR" ui:field="acc_license">
</b:AccordionGroup>
<!-- <b:AccordionGroup defaultOpen="true" -->
<!-- heading="License" icon="STAR" ui:field="acc_license"> -->
<!-- </b:AccordionGroup> -->
</b:Accordion>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,8 +1,12 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.Pager;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
@ -10,7 +14,6 @@ import com.google.gwt.event.dom.client.ClickHandler;
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.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
@ -19,17 +22,17 @@ import com.google.gwt.user.client.ui.Widget;
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
*/
public abstract class FormToPublishOnZenodoView extends Composite {
public abstract class BasicInformationView extends Composite {
/** The ui binder. */
private static FormToPublishOnZenodoViewUiBinder uiBinder = GWT.create(FormToPublishOnZenodoViewUiBinder.class);
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
/**
* The Interface CreateTaskConfigurationViewUiBinder.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
*/
interface FormToPublishOnZenodoViewUiBinder extends UiBinder<Widget, FormToPublishOnZenodoView> {
interface BasicInformationViewUiBinder extends UiBinder<Widget, BasicInformationView> {
}
/** The pager. */
@ -41,7 +44,21 @@ public abstract class FormToPublishOnZenodoView extends Composite {
@UiField
TextBox field_record_url;
// @UiField
// ControlGroup cg_list_of_files;
//
// @UiField
// VerticalPanel vp_list_of_files;
@UiField
Fieldset to_zenodo_form_unit_fields;
@UiField
Label label_files;
@UiField
TextArea field_description;
public final static HandlerManager eventBus = new HandlerManager(null);
@ -82,7 +99,7 @@ public abstract class FormToPublishOnZenodoView extends Composite {
*
* @param zenodoItem the zenodo item
*/
public FormToPublishOnZenodoView(final ZenodoItem zenodoItem) {
public BasicInformationView(final ZenodoItem zenodoItem) {
initWidget(uiBinder.createAndBindUi(this));
this.zenodoItem = zenodoItem;
// if(conf!=null)
@ -109,11 +126,22 @@ public abstract class FormToPublishOnZenodoView extends Composite {
private void fillForm() {
field_title.setValue(zenodoItem.getTitle());
field_description.setValue(zenodoItem.getMetadata().getDescription());
field_record_url.setValue(zenodoItem.getRecord_url().toString());
Window.alert(zenodoItem.getMetadata().getRelated_identifiers().toString());
if(zenodoItem.getFiles()!=null) {
label_files.setVisible(true);
for (ZenodoFile file : zenodoItem.getFiles()) {
addFileForPublishing(file);
}
}
}
private void addFileForPublishing(ZenodoFile file) {
PublishFileView pv = new PublishFileView();
pv.getField_file_name().setValue(file.getFilename());
pv.getSwitchButton().setValue(true);
to_zenodo_form_unit_fields.add(pv);
}
/**

View File

@ -6,13 +6,19 @@
.noBorder {
border: 0px;
}
.margin-left-100 {
margin-left: 80px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="html_panel_field">
<b:Form type="HORIZONTAL">
<b:Fieldset styleName="{style.noBorder}"
ui:field="form_unit_fields">
ui:field="to_zenodo_form_unit_fields">
<b:Label type="INFO"
addStyleNames="{style.margin-left-100}">The Item</b:Label>
<b:ControlGroup ui:field="cg_title">
<b:ControlLabel for="cl_title">Title</b:ControlLabel>
<b:Controls>
@ -21,21 +27,25 @@
</b:TextBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_description">
<b:ControlLabel for="cl_description">Description</b:ControlLabel>
<b:Controls>
<b:TextArea name="Description"
ui:field="field_description"
addStyleNames="my-external-select-width"></b:TextArea>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_record_url">
<b:ControlLabel for="cl_record_url">Record URL</b:ControlLabel>
<b:ControlLabel for="cl_record_url">URL</b:ControlLabel>
<b:Controls>
<b:TextBox name="Record URL" b:id="field_record_url"
ui:field="field_record_url" addStyleNames="my-external-select-width">
ui:field="field_record_url"
addStyleNames="my-external-select-width" readOnly="true">
</b:TextBox>
</b:Controls>
</b:ControlGroup>
<!-- <b:ControlLabel for="cl_parameters_control">Add Parameter</b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b:Button icon="PLUS_SIGN" title="Add Parameter" -->
<!-- ui:field="addCustomFieldButton"></b:Button> -->
<!-- </b:Controls> -->
<b:Label type="INFO" ui:field="label_files"
addStyleNames="{style.margin-left-100}" visible="false">File/s</b:Label>
</b:Fieldset>
</b:Form>
</g:HTMLPanel>

View File

@ -0,0 +1,39 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
public class Ckan2ZenodoViewManager {
AccordionBasicPanel basePanel;
public Ckan2ZenodoViewManager() {
}
public AccordionBasicPanel viewForPublishing(final ZenodoItem zenodoItem){
basePanel = new AccordionBasicPanel();
BasicInformationView form = new BasicInformationView(zenodoItem) {
@Override
public void submitHandler() {
}
@Override
public void setError(boolean visible, String error) {
}
@Override
public void setConfirm(boolean visible, String msg) {
}
};
basePanel.getAcc_basic_info().add(form);
return basePanel;
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
import org.gcube.portlets.widgets.switchbutton.client.SwitchButton;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
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.Widget;
public class PublishFileView extends Composite {
private static PublishFileViewUiBinder uiBinder = GWT.create(PublishFileViewUiBinder.class);
@UiField
SwitchButton switchButton;
@UiField
TextBox field_file_name;
interface PublishFileViewUiBinder extends UiBinder<Widget, PublishFileView> {
}
public PublishFileView() {
initWidget(uiBinder.createAndBindUi(this));
switchButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
field_file_name.setEnabled(event.getValue());
if(event.getValue()) {
field_file_name.getElement().getStyle().setOpacity(1.0);
}else {
field_file_name.getElement().getStyle().setOpacity(0.5);
}
}
});
}
public SwitchButton getSwitchButton() {
return switchButton;
}
public TextBox getField_file_name() {
return field_file_name;
}
public void setSwitchButton(SwitchButton switchButton) {
this.switchButton = switchButton;
}
public void setField_file_name(TextBox field_file_name) {
this.field_file_name = field_file_name;
}
}

View File

@ -0,0 +1,34 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:citem="urn:import:org.gcube.portlets.widgets.switchbutton.client">
<ui:style>
.padding-left-10 {
padding-left: 10px;
}
.internal-width {
width: 295px !important;
}
</ui:style>
<b:ControlGroup>
<!-- <b:Well> -->
<b:ControlLabel
addStyleNames="{style.padding-left-10}">Publish</b:ControlLabel>
<b:Controls>
<g:HorizontalPanel>
<b:TextBox name="File Name" ui:field="field_file_name"
addStyleNames="{style.internal-width}">
</b:TextBox>
<citem:SwitchButton ui:field="switchButton"
addStyleNames="{style.padding-left-10}"></citem:SwitchButton>
</g:HorizontalPanel>
</b:Controls>
<!-- </b:Well> -->
</b:ControlGroup>
</ui:UiBinder>

View File

@ -0,0 +1,15 @@
/** Add css rules here for your application. */
.ckan2zenodo-modal-style {
width: 800px !important;
margin-left: -400px !important;
}
.ckan2zenodo-modal-style input, textarea {
width: 400px;
max-width: 400px;
}
.ckan2zenodo-modal-style .modal-body{
max-height: 550px;
}

View File

@ -9,6 +9,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.AccessRights;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.UploadType;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.FileDeposition;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.RelatedIdentifier;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.RelatedIdentifier.Relation;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
@ -55,7 +56,17 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
//TO TEST
ZenodoDeposition zd = new ZenodoDeposition();
zd.setTitle("My beautiful title");
ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
for (int i = 0; i < 5; i++) {
FileDeposition fd = new FileDeposition();
int index = i+1;
fd.setFilename("My file "+index);
files.add(fd);
}
zd.setFiles(files);
DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
metadata.setDescription("My beautiful description");
List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
metadata.setRelated_identifiers(related_identifiers);

View File

@ -59,6 +59,7 @@ public class ItemToZenodoConverter {
for (FileDeposition fileDeposition : zenodoDeposition.getFiles()) {
listOfFiles.add(toZenodoFile(fileDeposition));
}
zi.setFiles(listOfFiles);
}
zi.setModified(zenodoDeposition.getModified());
@ -106,6 +107,7 @@ public class ItemToZenodoConverter {
ZenodoMetadata zm = new ZenodoMetadata();
zm.setAccess_conditions(depositionMetadata.getAccess_conditions());
zm.setDescription(depositionMetadata.getDescription());
if(depositionMetadata.getAccess_right()!=null) {
AccessRights[] ar = { depositionMetadata.getAccess_right() };
@ -193,10 +195,8 @@ public class ItemToZenodoConverter {
DateInterval.Type[] rel = { dateInterval.getType() };
types = CkanToZenodoUtil.toSerializableEnum(rel, DateInterval.Type.values());
}
ZenodoDateInterval zdi = new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types, dateInterval.getDescription());
//TODO MUST BE COMPLETED
//list.add(new ZenodoCommunity(community.getIdentifier()));
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types, dateInterval.getDescription()));
}
return list;

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -110,15 +109,6 @@ public class ZenodoItem implements Serializable {
return files;
}
/**
* Sets the files.
*
* @param files the new files
*/
public void setFiles(ArrayList<ZenodoFile> files) {
this.files = files;
}
/**
* Gets the id.
*

View File

@ -6,7 +6,9 @@
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
@ -16,6 +18,7 @@
<!--<entry-point class='org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisher' />-->
<!-- Specify the paths for translatable code -->
<stylesheet src='CkanToZenodoPublisher.css' />
<source path='client' />
<source path='shared' />

View File

@ -1,34 +1,10 @@
/** Add css rules here for your application. */
/** Example rules used by the template application (remove for your app) */
h1 {
font-size: 2em;
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
text-align: center;
.ckan2zenodo-modal-style {
width: 800px !important;
left: -400px !important;
}
.sendButton {
display: block;
font-size: 16pt;
}
/** Most GWT widgets already have a style name defined */
.gwt-DialogBox {
width: 400px;
}
.dialogVPanel {
margin: 5px;
}
.serverResponseLabelError {
color: red;
}
/** Set ids using widget.getElement().setId("idOfElement") */
#closeButton {
margin: 15px 6px 6px;
}
.ckan2zenodo-modal-style input {
width: 400px
}