1
|
package eu.dnetlib.client.fundingrequest.newrequest.publicationstep;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Alert;
|
4
|
import com.github.gwtbootstrap.client.ui.Form;
|
5
|
import com.github.gwtbootstrap.client.ui.RadioButton;
|
6
|
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
|
7
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
8
|
import com.github.gwtbootstrap.client.ui.constants.AlternateSize;
|
9
|
import com.github.gwtbootstrap.client.ui.constants.FormType;
|
10
|
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
|
11
|
import com.github.gwtbootstrap.datepicker.client.ui.base.HasStartView;
|
12
|
import com.google.gwt.core.client.GWT;
|
13
|
import com.google.gwt.event.dom.client.ClickEvent;
|
14
|
import com.google.gwt.event.dom.client.ClickHandler;
|
15
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
16
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
17
|
import com.google.gwt.user.client.ui.FlowPanel;
|
18
|
import com.google.gwt.user.client.ui.IsWidget;
|
19
|
import com.google.gwt.user.client.ui.Label;
|
20
|
import com.google.gwt.user.client.ui.Widget;
|
21
|
import eu.dnetlib.client.GoldOAConstants;
|
22
|
import eu.dnetlib.client.widgets.FormFieldSet;
|
23
|
import eu.dnetlib.client.widgets.MultipleAuthorsWidget;
|
24
|
import eu.dnetlib.client.widgets.MultipleIdentifiersWidget;
|
25
|
import eu.dnetlib.client.widgets.TextBox;
|
26
|
import eu.dnetlib.goldoa.domain.Organization;
|
27
|
import eu.dnetlib.goldoa.domain.Publication;
|
28
|
import eu.dnetlib.goldoa.domain.PublicationType;
|
29
|
|
30
|
/**
|
31
|
* Created by stefania on 3/9/15.
|
32
|
*/
|
33
|
public class PublicationInfoStep implements IsWidget {
|
34
|
|
35
|
private FlowPanel publicationInfoStepPanel = new FlowPanel();
|
36
|
|
37
|
private Form publicationDOIForm = new Form();
|
38
|
private TextBox doi = new TextBox();
|
39
|
private IconAnchor resolveDOI = new IconAnchor();
|
40
|
private Label commentPublicationDOI = new Label();
|
41
|
private Label commentBookDOI = new Label();
|
42
|
private Label commentBookChapterDOI = new Label();
|
43
|
private Label commentItalic = new Label();
|
44
|
private FormFieldSet doiFieldSet = new FormFieldSet("DOI", doi, resolveDOI, commentPublicationDOI, commentItalic);
|
45
|
// private CheckBox noDOI = new CheckBox();
|
46
|
|
47
|
//publication info form
|
48
|
private FlowPanel publicationInfoPanel = new FlowPanel();
|
49
|
|
50
|
private Alert infoLabel = new Alert();
|
51
|
private Alert errorLabel = new Alert();
|
52
|
|
53
|
private Form publicationInfoForm = new Form();
|
54
|
private TextBox titleTextBox = new TextBox();
|
55
|
private FormFieldSet titleFieldSet = new FormFieldSet("Publication Title (*)", titleTextBox);
|
56
|
|
57
|
private TextBox alternativeTitleTextBox = new TextBox();
|
58
|
private FormFieldSet alternativeTitleFieldSet = new FormFieldSet("Book Title (*)", alternativeTitleTextBox);
|
59
|
private TextBox alternativeDOITextBox = new TextBox();
|
60
|
private FormFieldSet alternativeDOIFieldSet = new FormFieldSet("Book DOI", alternativeDOITextBox);
|
61
|
|
62
|
private TextBox eventDetailsTextBox = new TextBox();
|
63
|
private FormFieldSet eventDetailsFieldSet = new FormFieldSet("Event Details (*)", eventDetailsTextBox);
|
64
|
|
65
|
private DateBox publicationDateTextBox = new DateBox();
|
66
|
private DateBox acceptanceDateTextBox = new DateBox();
|
67
|
private FormFieldSet acceptanceDateFieldSet = new FormFieldSet("Acceptance Date (*)", acceptanceDateTextBox);
|
68
|
private TextBox languages = new TextBox();
|
69
|
|
70
|
private RadioButton articleRadio = new RadioButton("publicationType", "Article", false);
|
71
|
private RadioButton monographRadio = new RadioButton("publicationType", "Book", false);
|
72
|
private RadioButton bookChapterRadio = new RadioButton("publicationType", "Book Chapter", false);
|
73
|
private RadioButton conferenceProcsRadio = new RadioButton("publicationType", "Conference Procs", false);
|
74
|
|
75
|
private TextBox subjects = new TextBox();
|
76
|
|
77
|
private MultipleAuthorsWidget multipleAuthorsWidget = new MultipleAuthorsWidget();
|
78
|
|
79
|
private MultipleIdentifiersWidget multipleIdentifiersWidget = new MultipleIdentifiersWidget();
|
80
|
|
81
|
private PublicationTypeListener publicationTypeListener;
|
82
|
private ResolveDOIListener resolveDOIListener;
|
83
|
|
84
|
private GoldOAConstants goldOAConstants = GWT.create(GoldOAConstants.class);
|
85
|
|
86
|
public PublicationInfoStep() {
|
87
|
|
88
|
publicationDOIForm.setType(FormType.HORIZONTAL);
|
89
|
publicationDOIForm.addStyleName("publicationDOIForm");
|
90
|
publicationInfoStepPanel.add(publicationDOIForm);
|
91
|
publicationInfoStepPanel.add(publicationInfoPanel);
|
92
|
|
93
|
doi.setAlternateSize(AlternateSize.XLARGE);
|
94
|
doi.addStyleName("inlineBlock");
|
95
|
|
96
|
resolveDOI.setText("Resolve");
|
97
|
resolveDOI.addStyleName("resolveIcon");
|
98
|
resolveDOI.addStyleName("inlineBlock");
|
99
|
resolveDOI.addClickHandler(new ClickHandler() {
|
100
|
@Override
|
101
|
public void onClick(ClickEvent clickEvent) {
|
102
|
if(resolveDOIListener!=null)
|
103
|
resolveDOIListener.resolveDOIClicked(doi.getValue().trim());
|
104
|
}
|
105
|
});
|
106
|
|
107
|
commentPublicationDOI.setText("Enter the publication DOI and click resolve so that we can auto complete the publication information.");
|
108
|
commentPublicationDOI.addStyleName("comment");
|
109
|
|
110
|
commentBookDOI.setText("Enter the publication DOI");
|
111
|
commentBookDOI.addStyleName("comment");
|
112
|
|
113
|
commentBookChapterDOI.setText("Enter the book chapter DOI");
|
114
|
commentBookChapterDOI.addStyleName("comment");
|
115
|
|
116
|
commentItalic.setText("If you don't have it, check out our instructions on the right.");
|
117
|
commentItalic.addStyleName("comment");
|
118
|
commentItalic.addStyleName("fontItalic");
|
119
|
|
120
|
publicationDOIForm.add(doiFieldSet);
|
121
|
|
122
|
//publication info form
|
123
|
publicationInfoPanel.addStyleName("publicationInfoPanel");
|
124
|
|
125
|
errorLabel.addStyleName("alertLabel");
|
126
|
errorLabel.setType(AlertType.ERROR);
|
127
|
errorLabel.setVisible(false);
|
128
|
errorLabel.setClose(false);
|
129
|
|
130
|
infoLabel.setText("At least one author e-mail is required");
|
131
|
infoLabel.addStyleName("alertLabel");
|
132
|
infoLabel.setType(AlertType.INFO);
|
133
|
infoLabel.setClose(false);
|
134
|
|
135
|
publicationInfoForm.setType(FormType.HORIZONTAL);
|
136
|
publicationInfoForm.addStyleName("publicationInfoForm");
|
137
|
publicationInfoPanel.add(publicationInfoForm);
|
138
|
|
139
|
titleTextBox.setAlternateSize(AlternateSize.XXLARGE);
|
140
|
|
141
|
publicationDateTextBox.setAlternateSize(AlternateSize.LARGE);
|
142
|
publicationDateTextBox.setStartView(HasStartView.ViewMode.YEAR);
|
143
|
publicationDateTextBox.setAutoClose(true);
|
144
|
publicationDateTextBox.setFormat("yyyy/mm/dd");
|
145
|
publicationDateTextBox.setValue(null);
|
146
|
|
147
|
acceptanceDateTextBox.setAlternateSize(AlternateSize.LARGE);
|
148
|
acceptanceDateTextBox.setStartView(HasStartView.ViewMode.YEAR);
|
149
|
acceptanceDateTextBox.setAutoClose(true);
|
150
|
acceptanceDateTextBox.setFormat("yyyy/mm/dd");
|
151
|
acceptanceDateTextBox.setValue(null);
|
152
|
|
153
|
articleRadio.setValue(true);
|
154
|
articleRadio.addStyleName("inlineBlock");
|
155
|
articleRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
156
|
@Override
|
157
|
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
|
158
|
if(articleRadio.getValue()) {
|
159
|
acceptanceDateFieldSet.setLabelText("Acceptance Date (*)");
|
160
|
if(publicationTypeListener!=null)
|
161
|
publicationTypeListener.publicationTypeChanged("article");
|
162
|
publicationInfoForm.remove(alternativeTitleFieldSet.asWidget());
|
163
|
publicationInfoForm.remove(alternativeDOIFieldSet.asWidget());
|
164
|
publicationInfoForm.remove(eventDetailsFieldSet.asWidget());
|
165
|
titleFieldSet.setLabelText("Publication Title (*)");
|
166
|
publicationDOIForm.remove(doiFieldSet);
|
167
|
doiFieldSet = new FormFieldSet("DOI", doi, resolveDOI, commentPublicationDOI, commentItalic);
|
168
|
publicationDOIForm.add(doiFieldSet);
|
169
|
}
|
170
|
}
|
171
|
});
|
172
|
monographRadio.addStyleName("inlineBlock");
|
173
|
monographRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
174
|
@Override
|
175
|
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
|
176
|
if(monographRadio.getValue()) {
|
177
|
acceptanceDateFieldSet.setLabelText("Estimated Acceptance Date (*)");
|
178
|
if(publicationTypeListener!=null)
|
179
|
publicationTypeListener.publicationTypeChanged("monograph");
|
180
|
publicationInfoForm.remove(alternativeTitleFieldSet.asWidget());
|
181
|
publicationInfoForm.remove(alternativeDOIFieldSet.asWidget());
|
182
|
publicationInfoForm.remove(eventDetailsFieldSet.asWidget());
|
183
|
titleFieldSet.setLabelText("Publication Title (*)");
|
184
|
publicationDOIForm.remove(doiFieldSet);
|
185
|
doiFieldSet = new FormFieldSet("DOI", doi, commentBookDOI, commentItalic);
|
186
|
publicationDOIForm.add(doiFieldSet);
|
187
|
}
|
188
|
}
|
189
|
});
|
190
|
bookChapterRadio.addStyleName("inlineBlock");
|
191
|
bookChapterRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
192
|
@Override
|
193
|
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
|
194
|
if(bookChapterRadio.getValue()) {
|
195
|
acceptanceDateFieldSet.setLabelText("Estimated Acceptance Date (*)");
|
196
|
if(publicationTypeListener!=null)
|
197
|
publicationTypeListener.publicationTypeChanged("bookChapter");
|
198
|
publicationInfoForm.remove(eventDetailsFieldSet.asWidget());
|
199
|
publicationInfoForm.insert(alternativeTitleFieldSet.asWidget(), 4);
|
200
|
publicationInfoForm.insert(alternativeDOIFieldSet.asWidget(), 5);
|
201
|
titleFieldSet.setLabelText("Book Chapter Title (*)");
|
202
|
publicationDOIForm.remove(doiFieldSet);
|
203
|
doiFieldSet = new FormFieldSet("DOI", doi, commentBookChapterDOI, commentItalic);
|
204
|
publicationDOIForm.add(doiFieldSet);
|
205
|
}
|
206
|
}
|
207
|
});
|
208
|
conferenceProcsRadio.addStyleName("inlineBlock");
|
209
|
conferenceProcsRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
210
|
@Override
|
211
|
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
212
|
if(conferenceProcsRadio.getValue()) {
|
213
|
acceptanceDateFieldSet.setLabelText("Acceptance Date (*)");
|
214
|
if(publicationTypeListener!=null)
|
215
|
publicationTypeListener.publicationTypeChanged("proceedings");
|
216
|
publicationInfoForm.remove(alternativeTitleFieldSet.asWidget());
|
217
|
publicationInfoForm.remove(alternativeDOIFieldSet.asWidget());
|
218
|
publicationInfoForm.insert(eventDetailsFieldSet.asWidget(), 4);
|
219
|
titleFieldSet.setLabelText("Publication Title (*)");
|
220
|
publicationDOIForm.remove(doiFieldSet);
|
221
|
doiFieldSet = new FormFieldSet("DOI", doi, resolveDOI, commentPublicationDOI, commentItalic);
|
222
|
publicationDOIForm.add(doiFieldSet);
|
223
|
}
|
224
|
}
|
225
|
});
|
226
|
|
227
|
languages.setAlternateSize(AlternateSize.XXLARGE);
|
228
|
languages.setPlaceholder(" languages as a comma-separated list");
|
229
|
|
230
|
subjects.setAlternateSize(AlternateSize.XXLARGE);
|
231
|
subjects.setPlaceholder(" subjects as a comma-separated list");
|
232
|
|
233
|
alternativeTitleTextBox.setAlternateSize(AlternateSize.XXLARGE);
|
234
|
|
235
|
alternativeDOITextBox.setAlternateSize(AlternateSize.XXLARGE);
|
236
|
|
237
|
eventDetailsTextBox.setAlternateSize(AlternateSize.XXLARGE);
|
238
|
eventDetailsTextBox.setPlaceholder("Conference Name, Place, Dates");
|
239
|
|
240
|
publicationInfoForm.add(infoLabel);
|
241
|
publicationInfoForm.add(errorLabel);
|
242
|
publicationInfoForm.add(new FormFieldSet("Publication Type (*)", articleRadio, monographRadio, bookChapterRadio, conferenceProcsRadio));
|
243
|
publicationInfoForm.add(titleFieldSet);
|
244
|
publicationInfoForm.add(new FormFieldSet("Authors (*)", multipleAuthorsWidget.asWidget()));
|
245
|
publicationInfoForm.add(new FormFieldSet("Publication Date", publicationDateTextBox));
|
246
|
publicationInfoForm.add(acceptanceDateFieldSet);
|
247
|
publicationInfoForm.add(new FormFieldSet("Languages", languages));
|
248
|
publicationInfoForm.add(new FormFieldSet("Subjects", subjects));
|
249
|
publicationInfoForm.add(new FormFieldSet("Identifiers", multipleIdentifiersWidget.asWidget()));
|
250
|
}
|
251
|
|
252
|
@Override
|
253
|
public Widget asWidget() {
|
254
|
return publicationInfoStepPanel;
|
255
|
}
|
256
|
|
257
|
public interface PublicationTypeListener {
|
258
|
public void publicationTypeChanged(String publicationType);
|
259
|
}
|
260
|
|
261
|
public void setPublicationTypeListener(PublicationTypeListener publicationTypeListener) {
|
262
|
this.publicationTypeListener = publicationTypeListener;
|
263
|
}
|
264
|
|
265
|
public interface ResolveDOIListener {
|
266
|
public void resolveDOIClicked(String doi);
|
267
|
}
|
268
|
|
269
|
public void setResolveDOIListener(ResolveDOIListener resolveDOIListener) {
|
270
|
this.resolveDOIListener = resolveDOIListener;
|
271
|
}
|
272
|
|
273
|
public boolean isComplete() {
|
274
|
|
275
|
if(bookChapterRadio.getValue()) {
|
276
|
if (!titleTextBox.getValue().trim().equals("") && !multipleAuthorsWidget.getAuthors().isEmpty()
|
277
|
&& acceptanceDateTextBox.getValue() != null && !alternativeTitleTextBox.getValue().trim().isEmpty())
|
278
|
return true;
|
279
|
} else if(conferenceProcsRadio.getValue()) {
|
280
|
if (!titleTextBox.getValue().trim().equals("") && !multipleAuthorsWidget.getAuthors().isEmpty()
|
281
|
&& acceptanceDateTextBox.getValue() != null && !eventDetailsTextBox.getValue().trim().isEmpty())
|
282
|
return true;
|
283
|
} else {
|
284
|
if (!titleTextBox.getValue().trim().equals("") && !multipleAuthorsWidget.getAuthors().isEmpty()
|
285
|
&& acceptanceDateTextBox.getValue() != null)
|
286
|
return true;
|
287
|
}
|
288
|
|
289
|
return false;
|
290
|
}
|
291
|
|
292
|
public Publication getPublication() {
|
293
|
|
294
|
errorLabel.setVisible(false);
|
295
|
|
296
|
if(isComplete()) {
|
297
|
|
298
|
if(!multipleAuthorsWidget.hasAtLeastOneEmail()) {
|
299
|
|
300
|
if(publicationDateTextBox.getValue()!=null && acceptanceDateTextBox.getValue().after(publicationDateTextBox.getValue())) {
|
301
|
|
302
|
errorLabel.setText("At least one author e-mail is required and acceptance date must be before publication date");
|
303
|
errorLabel.setVisible(true);
|
304
|
|
305
|
} else {
|
306
|
|
307
|
errorLabel.setText(goldOAConstants.publicationFormErrorAtLeastOneAuthorEmail());
|
308
|
errorLabel.setVisible(true);
|
309
|
}
|
310
|
|
311
|
} else {
|
312
|
|
313
|
if(publicationDateTextBox.getValue()!=null && acceptanceDateTextBox.getValue().after(publicationDateTextBox.getValue())) {
|
314
|
|
315
|
errorLabel.setText("At least one author e-mail is required and acceptance date must be before publication date");
|
316
|
errorLabel.setVisible(true);
|
317
|
|
318
|
} else {
|
319
|
|
320
|
Publication publication = new Publication();
|
321
|
|
322
|
if (!doi.getValue().trim().equals(""))
|
323
|
publication.setDoi(doi.getValue().trim());
|
324
|
publication.setTitle(titleTextBox.getValue().trim());
|
325
|
publication.setAuthors(multipleAuthorsWidget.getAuthors());
|
326
|
publication.setDate(publicationDateTextBox.getValue());
|
327
|
publication.setAcceptancedate(acceptanceDateTextBox.getValue());
|
328
|
|
329
|
if (articleRadio.getValue())
|
330
|
publication.setType(PublicationType.ARTICLE);
|
331
|
else if(monographRadio.getValue())
|
332
|
publication.setType(PublicationType.MONOGRAPH);
|
333
|
else if(conferenceProcsRadio.getValue()) {
|
334
|
publication.setType(PublicationType.CONFERENCE_PROCS);
|
335
|
publication.setEventdetails(eventDetailsTextBox.getValue().trim());
|
336
|
} else {
|
337
|
publication.setType(PublicationType.BOOK_CHAPTER);
|
338
|
publication.setAlternativetitle(alternativeTitleTextBox.getValue());
|
339
|
if(!alternativeDOITextBox.getValue().trim().isEmpty())
|
340
|
publication.setAlternativedoi(alternativeDOITextBox.getValue());
|
341
|
}
|
342
|
|
343
|
publication.setLanguages(languages.getValue().trim());
|
344
|
publication.setSubjects(subjects.getValue().trim());
|
345
|
publication.setIdentifiers(multipleIdentifiersWidget.getPublicationIdentifiers());
|
346
|
|
347
|
return publication;
|
348
|
}
|
349
|
}
|
350
|
} else {
|
351
|
errorLabel.setText(goldOAConstants.publicationFormErrorAllFieldsRequired());
|
352
|
errorLabel.setVisible(true);
|
353
|
}
|
354
|
|
355
|
return null;
|
356
|
}
|
357
|
|
358
|
public void clear() {
|
359
|
|
360
|
doi.setValue("");
|
361
|
|
362
|
titleTextBox.setValue("");
|
363
|
|
364
|
articleRadio.setValue(true, true);
|
365
|
|
366
|
multipleAuthorsWidget.clear();
|
367
|
|
368
|
publicationDateTextBox.setValue(null);
|
369
|
acceptanceDateTextBox.setValue(null);
|
370
|
|
371
|
alternativeDOITextBox.setValue("");
|
372
|
alternativeTitleTextBox.setValue("");
|
373
|
|
374
|
eventDetailsTextBox.setValue("");
|
375
|
|
376
|
languages.setValue("");
|
377
|
subjects.setValue("");
|
378
|
|
379
|
multipleIdentifiersWidget.clear();
|
380
|
}
|
381
|
|
382
|
public void loadPublicationInfo(Publication publication) {
|
383
|
|
384
|
if(publication.getDoi()!=null)
|
385
|
doi.setValue(publication.getDoi());
|
386
|
|
387
|
titleTextBox.setValue(publication.getTitle());
|
388
|
|
389
|
if(publication.getType().equals(PublicationType.ARTICLE)) {
|
390
|
articleRadio.setValue(true, true);
|
391
|
} else if(publication.getType().equals(PublicationType.MONOGRAPH)) {
|
392
|
monographRadio.setValue(true, true);
|
393
|
} else if(publication.getType().equals(PublicationType.CONFERENCE_PROCS)) {
|
394
|
conferenceProcsRadio.setValue(true, true);
|
395
|
if(publication.getEventdetails()!=null)
|
396
|
eventDetailsTextBox.setValue(publication.getEventdetails());
|
397
|
} else {
|
398
|
bookChapterRadio.setValue(true, true);
|
399
|
if(publication.getAlternativetitle()!=null)
|
400
|
alternativeTitleTextBox.setValue(publication.getAlternativetitle());
|
401
|
if(publication.getAlternativedoi()!=null)
|
402
|
alternativeDOITextBox.setValue(publication.getAlternativedoi());
|
403
|
}
|
404
|
|
405
|
multipleAuthorsWidget.loadAuthors(publication.getAuthors());
|
406
|
|
407
|
if(publication.getDate()!=null)
|
408
|
publicationDateTextBox.setValue(publication.getDate());
|
409
|
if(publication.getAcceptancedate()!=null)
|
410
|
acceptanceDateTextBox.setValue(publication.getAcceptancedate());
|
411
|
|
412
|
languages.setValue(publication.getLanguages());
|
413
|
subjects.setValue(publication.getSubjects());
|
414
|
|
415
|
multipleIdentifiersWidget.loadPublicationIdentifiers(publication.getIdentifiers());
|
416
|
}
|
417
|
|
418
|
public void setDefaultOrganization(Organization organization) {
|
419
|
multipleAuthorsWidget.setDefaultOrganization(organization);
|
420
|
}
|
421
|
}
|