implementing publisher on zenodo
This commit is contained in:
parent
427cf8bd13
commit
ed39d4eb1a
|
@ -1,8 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
|
||||
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;
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.PublishFileView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
public class Ckan2ZenodoViewManager {
|
||||
|
||||
|
||||
AccordionBasicPanel basePanel;
|
||||
|
||||
|
||||
public Ckan2ZenodoViewManager() {
|
||||
}
|
||||
|
||||
|
||||
public AccordionBasicPanel viewForPublishing(final ZenodoItem zenodoItem){
|
||||
basePanel = new AccordionBasicPanel();
|
||||
|
||||
BasicInformationView basicForm = 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(basicForm);
|
||||
|
||||
|
||||
if(zenodoItem.getFiles()!=null) {
|
||||
List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
|
||||
VerticalPanel fileVP = new VerticalPanel();
|
||||
for (ZenodoFile file : zenodoItem.getFiles()) {
|
||||
PublishFileView pfv = addFileForPublishing(file);
|
||||
lstPFV.add(pfv);
|
||||
fileVP.add(pfv);
|
||||
}
|
||||
basePanel.getAcc_files().add(fileVP);
|
||||
}
|
||||
return basePanel;
|
||||
|
||||
}
|
||||
|
||||
private PublishFileView addFileForPublishing(ZenodoFile file) {
|
||||
PublishFileView pv = new PublishFileView(file);
|
||||
pv.getField_file_name().setValue(file.getFilename());
|
||||
pv.getSwitchButton().setValue(true);
|
||||
return pv;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
|
@ -27,12 +29,6 @@ public class AccordionBasicPanel extends Composite {
|
|||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
|
||||
public AccordionBasicPanel(String firstName) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
|
||||
public AccordionGroup getAcc_basic_info() {
|
||||
return acc_basic_info;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ public abstract class BasicInformationView extends Composite {
|
|||
interface BasicInformationViewUiBinder extends UiBinder<Widget, BasicInformationView> {
|
||||
}
|
||||
|
||||
/** The pager. */
|
||||
@UiField
|
||||
Pager pager;
|
||||
// /** The pager. */
|
||||
// @UiField
|
||||
// Pager pager;
|
||||
|
||||
@UiField
|
||||
TextBox field_title;
|
||||
|
@ -54,8 +54,8 @@ public abstract class BasicInformationView extends Composite {
|
|||
@UiField
|
||||
Fieldset to_zenodo_form_unit_fields;
|
||||
|
||||
@UiField
|
||||
Label label_files;
|
||||
//@UiField
|
||||
//Label label_files;
|
||||
|
||||
@UiField
|
||||
TextArea field_description;
|
||||
|
@ -106,15 +106,15 @@ public abstract class BasicInformationView extends Composite {
|
|||
// this.isEditConfiguration = true;
|
||||
// this.editConfiguration = conf;
|
||||
|
||||
bindEvents();
|
||||
pager.getLeft().setVisible(false);
|
||||
//bindEvents();
|
||||
//pager.getLeft().setVisible(false);
|
||||
fillForm();
|
||||
|
||||
if (isEditConfiguration) {
|
||||
pager.getRight().setText("Update Configuration");
|
||||
} else {
|
||||
|
||||
}
|
||||
// if (isEditConfiguration) {
|
||||
// pager.getRight().setText("Update Configuration");
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,46 +129,46 @@ public abstract class BasicInformationView extends Composite {
|
|||
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
||||
field_record_url.setValue(zenodoItem.getRecord_url().toString());
|
||||
|
||||
if(zenodoItem.getFiles()!=null) {
|
||||
label_files.setVisible(true);
|
||||
for (ZenodoFile file : zenodoItem.getFiles()) {
|
||||
addFileForPublishing(file);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
pager.getLeft().addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
pager.getRight().addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
setError(false, "");
|
||||
boolean isValid = validateSubmit();
|
||||
if (isValid)
|
||||
submitHandler();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
// /**
|
||||
// * Bind events.
|
||||
// */
|
||||
// private void bindEvents() {
|
||||
//
|
||||
// pager.getLeft().addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// pager.getRight().addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// setError(false, "");
|
||||
// boolean isValid = validateSubmit();
|
||||
// if (isValid)
|
||||
// submitHandler();
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Validate submit.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<!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:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
xmlns:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder">
|
||||
<ui:style>
|
||||
.noBorder {
|
||||
border: 0px;
|
||||
|
@ -16,40 +17,55 @@
|
|||
<b:Form type="HORIZONTAL">
|
||||
<b:Fieldset styleName="{style.noBorder}"
|
||||
ui:field="to_zenodo_form_unit_fields">
|
||||
<!-- <b:Label type="INFO" -->
|
||||
<!-- addStyleNames="{style.margin-left-100}">Basic Information</b:Label> -->
|
||||
<b:ControlGroup ui:field="cg_record_url">
|
||||
<b:ControlLabel for="cl_record_url">Digital Object Identifier
|
||||
(DOI)</b:ControlLabel>
|
||||
<b:Controls>
|
||||
|
||||
<b:Label type="INFO"
|
||||
addStyleNames="{style.margin-left-100}">The Item</b:Label>
|
||||
<b:TextBox name="DOI" b:id="field_doi"
|
||||
ui:field="field_record_url"
|
||||
addStyleNames="my-external-select-width" readOnly="true">
|
||||
</b:TextBox>
|
||||
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_title">
|
||||
<b:ControlLabel for="cl_title">Title</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:TextBox name="Title" b:id="field_title"
|
||||
ui:field="field_title" addStyleNames="my-external-select-width">
|
||||
</b:TextBox>
|
||||
<b:InputAddOn prependIcon="BOOK">
|
||||
<b:TextBox name="Title" b:id="field_title"
|
||||
ui:field="field_title" addStyleNames="my-external-select-width">
|
||||
</b:TextBox>
|
||||
</b:InputAddOn>
|
||||
</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:InputAddOn prependIcon="PENCIL">
|
||||
<b:TextArea name="Description"
|
||||
ui:field="field_description"
|
||||
addStyleNames="my-external-select-width"></b:TextArea>
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_record_url">
|
||||
<b:ControlLabel for="cl_record_url">URL</b:ControlLabel>
|
||||
<b:ControlGroup ui:field="cg_authors">
|
||||
<b:ControlLabel for="cl_authors">Authors</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:TextBox name="Record URL" b:id="field_record_url"
|
||||
ui:field="field_record_url"
|
||||
addStyleNames="my-external-select-width" readOnly="true">
|
||||
</b:TextBox>
|
||||
<b:InputAddOn prependIcon="USER">
|
||||
<citem:CreatorView ui:field="field_authors"></citem:CreatorView>
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
|
||||
</b:ControlGroup>
|
||||
<b:Label type="INFO" ui:field="label_files"
|
||||
addStyleNames="{style.margin-left-100}" visible="false">File/s</b:Label>
|
||||
<!-- <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>
|
||||
<b:Pager left="Go back" right="Publish on Zenodo"
|
||||
aligned="true" ui:field="pager" />
|
||||
<!-- <b:Pager left="Go back" right="Publish on Zenodo" -->
|
||||
<!-- aligned="true" ui:field="pager" /> -->
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -1,39 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
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 CreatorView extends Composite {
|
||||
|
||||
private static CreatorViewUiBinder uiBinder = GWT.create(CreatorViewUiBinder.class);
|
||||
|
||||
interface CreatorViewUiBinder extends UiBinder<Widget, CreatorView> {
|
||||
}
|
||||
|
||||
public CreatorView() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
@UiField
|
||||
TextBox field_name;
|
||||
|
||||
@UiField
|
||||
TextBox field_affiliation;
|
||||
|
||||
@UiField
|
||||
TextBox field_orcid;
|
||||
|
||||
public TextBox getField_name() {
|
||||
return field_name;
|
||||
}
|
||||
|
||||
public void setField_name(TextBox field_name) {
|
||||
this.field_name = field_name;
|
||||
}
|
||||
|
||||
public TextBox getField_affiliation() {
|
||||
return field_affiliation;
|
||||
}
|
||||
|
||||
public void setField_affiliation(TextBox field_affiliation) {
|
||||
this.field_affiliation = field_affiliation;
|
||||
}
|
||||
|
||||
public TextBox getField_orcid() {
|
||||
return field_orcid;
|
||||
}
|
||||
|
||||
public void setField_orcid(TextBox field_orcid) {
|
||||
this.field_orcid = field_orcid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<!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:VerticalPanel>
|
||||
<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" />
|
||||
</g:VerticalPanel>
|
||||
</ui:UiBinder>
|
|
@ -1,5 +1,9 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
import org.gcube.portlets.widgets.switchbutton.client.SwitchButton;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
|
@ -20,12 +24,15 @@ public class PublishFileView extends Composite {
|
|||
|
||||
@UiField
|
||||
TextBox field_file_name;
|
||||
|
||||
private ZenodoFile file;
|
||||
|
||||
interface PublishFileViewUiBinder extends UiBinder<Widget, PublishFileView> {
|
||||
}
|
||||
|
||||
public PublishFileView() {
|
||||
public PublishFileView(ZenodoFile file) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.file = file;
|
||||
|
||||
switchButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
||||
|
||||
|
@ -40,6 +47,8 @@ public class PublishFileView extends Composite {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
setFieldName(file.getFilename());
|
||||
}
|
||||
|
||||
public SwitchButton getSwitchButton() {
|
||||
|
@ -53,9 +62,11 @@ public class PublishFileView extends Composite {
|
|||
this.switchButton = switchButton;
|
||||
}
|
||||
|
||||
public void setField_file_name(TextBox field_file_name) {
|
||||
this.field_file_name = field_file_name;
|
||||
public void setFieldName(String value) {
|
||||
this.field_file_name.setValue(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Tester {
|
||||
|
||||
public static String expression = "^\\/dataset(\\?([a-zA-Z0-9_.-]*.+))*";
|
||||
public static String toMatch = "/dataset?systemtype=E39_Actor&groups=huma_num___nakala";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Pattern p = Pattern.compile(expression);
|
||||
Matcher m = p.matcher(toMatch);
|
||||
boolean b = m.matches();
|
||||
|
||||
System.out.println(b);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue