1
|
package eu.dnetlib.repo.manager.client.datasources.utils;
|
2
|
|
3
|
import com.google.gwt.core.client.GWT;
|
4
|
import com.google.gwt.editor.client.Editor;
|
5
|
import com.google.gwt.editor.client.EditorError;
|
6
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
7
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
8
|
import com.google.gwt.event.dom.client.ClickEvent;
|
9
|
import com.google.gwt.event.dom.client.ClickHandler;
|
10
|
import com.google.gwt.regexp.shared.RegExp;
|
11
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
12
|
import com.google.gwt.user.client.ui.HTML;
|
13
|
import com.google.gwt.user.client.ui.IsWidget;
|
14
|
import com.google.gwt.user.client.ui.Label;
|
15
|
import com.google.gwt.user.client.ui.Widget;
|
16
|
import eu.dnetlib.domain.data.Repository;
|
17
|
import eu.dnetlib.gwt.client.MyFormGroup;
|
18
|
import eu.dnetlib.repo.manager.client.services.RepositoryService;
|
19
|
import eu.dnetlib.repo.manager.client.services.RepositoryServiceAsync;
|
20
|
import eu.dnetlib.repo.manager.client.widgets.TextArea;
|
21
|
import eu.dnetlib.repo.manager.client.widgets.TextBox;
|
22
|
import eu.dnetlib.repo.manager.client.widgets.ValueChangeEvent;
|
23
|
import eu.dnetlib.repo.manager.client.widgets.ValueChangeHandler;
|
24
|
import eu.dnetlib.repo.manager.shared.Constants;
|
25
|
import eu.dnetlib.repo.manager.shared.DatasourceVocabularies;
|
26
|
import org.gwtbootstrap3.client.ui.Alert;
|
27
|
import org.gwtbootstrap3.client.ui.Button;
|
28
|
import org.gwtbootstrap3.client.ui.Form;
|
29
|
import org.gwtbootstrap3.client.ui.ListBox;
|
30
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
31
|
import org.gwtbootstrap3.client.ui.constants.ButtonType;
|
32
|
import org.gwtbootstrap3.client.ui.constants.ValidationState;
|
33
|
import org.gwtbootstrap3.client.ui.form.error.BasicEditorError;
|
34
|
import org.gwtbootstrap3.client.ui.form.validator.Validator;
|
35
|
import org.gwtbootstrap3.client.ui.gwt.FlowPanel;
|
36
|
|
37
|
import java.util.ArrayList;
|
38
|
import java.util.HashMap;
|
39
|
import java.util.List;
|
40
|
import java.util.Map;
|
41
|
|
42
|
/**
|
43
|
* Created by stefania on 12/21/15.
|
44
|
*/
|
45
|
public class RepositoryInformationFormWidget implements IsWidget {
|
46
|
|
47
|
private FlowPanel repositoryInformationPanel = new FlowPanel();
|
48
|
|
49
|
private Alert errorLabel = new Alert();
|
50
|
private Alert successLabel = new Alert();
|
51
|
|
52
|
private Form repositoryInformationForm = new Form();
|
53
|
|
54
|
private HTML basicInfoWarningLabel = new HTML();
|
55
|
|
56
|
private ListBox typologyListBox = new ListBox();
|
57
|
private MyFormGroup typologyListFormGroup = new MyFormGroup(false, "Software Platform (*)", typologyListBox);
|
58
|
private TextBox typologyTextBox = new TextBox();
|
59
|
private MyFormGroup typologyTextFormGroup = new MyFormGroup(false, null, typologyTextBox);
|
60
|
private TextBox officialName = new TextBox();
|
61
|
private MyFormGroup officialNameFormGroup = new MyFormGroup(false, "Official Name (*)", officialName);
|
62
|
private TextBox issn = new TextBox();
|
63
|
private MyFormGroup issnFormGroup = new MyFormGroup(true, "ISSN (*)", issn);
|
64
|
private TextBox eissn = new TextBox();
|
65
|
private MyFormGroup eissnFormGroup = new MyFormGroup(true, "EISSN", eissn);
|
66
|
private TextBox lissn = new TextBox();
|
67
|
private MyFormGroup lissnFormGroup = new MyFormGroup(true, "LISSN", lissn);
|
68
|
private TextArea description = new TextArea();
|
69
|
private MyFormGroup descriptionFormGroup = new MyFormGroup(false, "Description (*)", description);
|
70
|
private ListBox countryListBox = new ListBox();
|
71
|
private MyFormGroup countryFormGroup = new MyFormGroup(false, "Country (*)", countryListBox);
|
72
|
private TextBox longitude = new TextBox();
|
73
|
private MyFormGroup longitudeFormGroup = new MyFormGroup(true, "Longitude (*)", longitude);
|
74
|
private TextBox latitude = new TextBox();
|
75
|
private MyFormGroup latitudeFormGroup = new MyFormGroup(true, "Latitude (*)", latitude);
|
76
|
private TextBox entryURL = new TextBox();
|
77
|
private MyFormGroup entryURLFormGroup = new MyFormGroup(false, "Entry URL (*)", entryURL);
|
78
|
private TextBox institution = new TextBox();
|
79
|
private MyFormGroup institutionFormGroup = new MyFormGroup(false, "Institution (*)", institution);
|
80
|
|
81
|
private TextBox englishName = new TextBox();
|
82
|
private MyFormGroup englishNameFormGroup = new MyFormGroup(false, "English Name (*)", englishName);
|
83
|
private TextBox logoURL = new TextBox();
|
84
|
private ListBox timezoneListBox = new ListBox();
|
85
|
private MyFormGroup timezoneFormGroup = new MyFormGroup(false, "Timezone (*)", timezoneListBox);
|
86
|
private ListBox datasourceClassListBox = new ListBox();
|
87
|
private MyFormGroup datasourceClassFormGroup = new MyFormGroup(false, "Datasource Type (*)", datasourceClassListBox);
|
88
|
|
89
|
private TextBox admin = new TextBox();
|
90
|
private MyFormGroup adminFormGroup = new MyFormGroup(true, "Admin Email (*)", admin);
|
91
|
|
92
|
private Map<String, Integer> typologyValuesMap = new HashMap<String, Integer>();
|
93
|
private Map<String, Integer> countryValuesMap = new HashMap<String, Integer>();
|
94
|
private Map<String, Integer> timezoneValuesMap = new HashMap<String, Integer>();
|
95
|
private Map<String, Integer> datasourceClassValuesMap = new HashMap<String, Integer>();
|
96
|
|
97
|
private String mode;
|
98
|
|
99
|
private Repository repository;
|
100
|
|
101
|
private RepositoryServiceAsync repositoryService = GWT.create(RepositoryService.class);
|
102
|
|
103
|
public RepositoryInformationFormWidget(String mode, DatasourceVocabularies datasourceVocabularies, boolean isUpdate) {
|
104
|
|
105
|
this.mode = mode;
|
106
|
|
107
|
basicInfoWarningLabel.addStyleName("alert alert-warning");
|
108
|
basicInfoWarningLabel.setVisible(false);
|
109
|
|
110
|
errorLabel.setType(AlertType.DANGER);
|
111
|
errorLabel.setDismissable(false);
|
112
|
errorLabel.setVisible(false);
|
113
|
|
114
|
successLabel.setType(AlertType.SUCCESS);
|
115
|
successLabel.setDismissable(false);
|
116
|
successLabel.setVisible(false);
|
117
|
|
118
|
repositoryInformationPanel.add(successLabel);
|
119
|
repositoryInformationPanel.add(errorLabel);
|
120
|
repositoryInformationPanel.add(repositoryInformationForm);
|
121
|
|
122
|
typologyListBox.addItem("-- none selected --", "noneSelected");
|
123
|
for(int i=1; i<datasourceVocabularies.getTypologies().size(); i++) {
|
124
|
if(datasourceVocabularies.getTypologies().get(i-1).equals("[Other]")) {
|
125
|
typologyListBox.addItem("[Other] (enter name below)", "[Other]");
|
126
|
typologyValuesMap.put("[Other]", i);
|
127
|
} else {
|
128
|
typologyListBox.addItem(datasourceVocabularies.getTypologies().get(i - 1), datasourceVocabularies.getTypologies().get(i - 1));
|
129
|
typologyValuesMap.put(datasourceVocabularies.getTypologies().get(i - 1), i);
|
130
|
}
|
131
|
}
|
132
|
|
133
|
countryListBox.addItem("-- none selected --", "noneSelected");
|
134
|
int counter1 = 1;
|
135
|
for(String country : datasourceVocabularies.getCountries().keySet()) {
|
136
|
countryListBox.addItem(datasourceVocabularies.getCountries().get(country), country);
|
137
|
countryValuesMap.put(country, counter1);
|
138
|
counter1++;
|
139
|
}
|
140
|
|
141
|
timezoneListBox.addItem("-- none selected --", "noneSelected");
|
142
|
for(int i=1; i<datasourceVocabularies.getTimezones().size(); i++) {
|
143
|
timezoneListBox.addItem(datasourceVocabularies.getTimezones().get(i-1).name, datasourceVocabularies.getTimezones().get(i-1).offset+"");
|
144
|
timezoneValuesMap.put(datasourceVocabularies.getTimezones().get(i-1).offset+"", i);
|
145
|
}
|
146
|
|
147
|
datasourceClassListBox.addItem("-- none selected --", "noneSelected");
|
148
|
int counter2 = 1;
|
149
|
for(String datasourceClass : datasourceVocabularies.getDatasourceClasses().keySet()) {
|
150
|
datasourceClassListBox.addItem(datasourceVocabularies.getDatasourceClasses().get(datasourceClass), datasourceClass);
|
151
|
datasourceClassValuesMap.put(datasourceClass, counter2);
|
152
|
counter2++;
|
153
|
}
|
154
|
|
155
|
typologyTextBox.setVisible(false);
|
156
|
|
157
|
|
158
|
Label logoURLComment = new Label("Please make sure that the maximum size of the uploaded image is width=360px, height=240px");
|
159
|
logoURLComment.addStyleName("comment");
|
160
|
logoURLComment.addStyleName("fontItalic");
|
161
|
|
162
|
HTML basicInfoLabel = new HTML("<h4 class=\"uk-h4 uk-text-primary uk-scrollspy-inview uk-animation-slide-top-medium\" uk-scrollspy-class=\"\">Basic information</h4>");
|
163
|
repositoryInformationForm.add(basicInfoLabel);
|
164
|
repositoryInformationForm.add(basicInfoWarningLabel);
|
165
|
repositoryInformationForm.add(typologyListFormGroup);
|
166
|
repositoryInformationForm.add(typologyTextFormGroup);
|
167
|
repositoryInformationForm.add(officialNameFormGroup);
|
168
|
if(mode.equals(Constants.REPOSITORY_MODE_JOURNAL)) {
|
169
|
repositoryInformationForm.add(issnFormGroup);
|
170
|
repositoryInformationForm.add(eissnFormGroup);
|
171
|
repositoryInformationForm.add(lissnFormGroup);
|
172
|
}
|
173
|
repositoryInformationForm.add(descriptionFormGroup);
|
174
|
repositoryInformationForm.add(countryFormGroup);
|
175
|
repositoryInformationForm.add(longitudeFormGroup);
|
176
|
repositoryInformationForm.add(latitudeFormGroup);
|
177
|
repositoryInformationForm.add(entryURLFormGroup);
|
178
|
repositoryInformationForm.add(institutionFormGroup);
|
179
|
|
180
|
HTML extraInfoLabel = new HTML("<h4 class=\"uk-h4 uk-text-primary uk-scrollspy-inview uk-animation-slide-top-medium\" uk-scrollspy-class=\"\">Extra information</h4>");
|
181
|
repositoryInformationForm.add(extraInfoLabel);
|
182
|
repositoryInformationForm.add(englishNameFormGroup);
|
183
|
repositoryInformationForm.add(new MyFormGroup(false, "Logo URL", logoURL, logoURLComment));
|
184
|
repositoryInformationForm.add(timezoneFormGroup);
|
185
|
repositoryInformationForm.add(datasourceClassFormGroup);
|
186
|
|
187
|
if(mode.equals(Constants.REPOSITORY_MODE_JOURNAL))
|
188
|
datasourceClassFormGroup.setLabelText("Journal Type (*)");
|
189
|
else if(mode.equals(Constants.REPOSITORY_MODE_AGGREGATOR))
|
190
|
datasourceClassFormGroup.setLabelText("Aggregator Type (*)");
|
191
|
|
192
|
HTML adminInfoLabel = new HTML("<h4 class=\"uk-h4 uk-text-primary uk-scrollspy-inview uk-animation-slide-top-medium\" uk-scrollspy-class=\"\">Administrator & contact information</h4>");
|
193
|
repositoryInformationForm.add(adminInfoLabel);
|
194
|
repositoryInformationForm.add(adminFormGroup);
|
195
|
|
196
|
if(mode.equals(Constants.REPOSITORY_MODE_OPENDOAR) || mode.equals(Constants.REPOSITORY_MODE_RE3DATA)) {
|
197
|
typologyListBox.setEnabled(false);
|
198
|
typologyTextBox.setEnabled(false);
|
199
|
officialName.setEnabled(false);
|
200
|
description.setEnabled(false);
|
201
|
countryListBox.setEnabled(false);
|
202
|
longitude.setEnabled(false);
|
203
|
latitude.setEnabled(false);
|
204
|
entryURL.setEnabled(false);
|
205
|
institution.setEnabled(false);
|
206
|
}
|
207
|
|
208
|
if(isUpdate) {
|
209
|
|
210
|
Button updateInfoButton = new Button("Update Information");
|
211
|
updateInfoButton.setType(ButtonType.PRIMARY);
|
212
|
updateInfoButton.addStyleName("updateRepoInfoButton");
|
213
|
updateInfoButton.addClickHandler(new ClickHandler() {
|
214
|
@Override
|
215
|
public void onClick(ClickEvent event) {
|
216
|
|
217
|
errorLabel.setVisible(false);
|
218
|
successLabel.setVisible(false);
|
219
|
|
220
|
Repository repositoryToUpdate = getRepository();
|
221
|
if(repositoryToUpdate!=null) {
|
222
|
|
223
|
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 35%; " +
|
224
|
"color: rgb(47, 64, 80); font-weight: bold;\">Updating repository information</div>" +
|
225
|
"<div class=\"whiteFilm\"></div>");
|
226
|
repositoryInformationPanel.addStyleName("loading-big");
|
227
|
repositoryInformationPanel.add(loadingWheel);
|
228
|
|
229
|
repositoryService.updateRepositoryInformation(repositoryToUpdate, new AsyncCallback<Void>() {
|
230
|
|
231
|
@Override
|
232
|
public void onFailure(Throwable caught) {
|
233
|
|
234
|
repositoryInformationPanel.removeStyleName("loading-big");
|
235
|
repositoryInformationPanel.remove(loadingWheel);
|
236
|
|
237
|
errorLabel.setText("System error updating repository information");
|
238
|
errorLabel.setVisible(true);
|
239
|
}
|
240
|
|
241
|
@Override
|
242
|
public void onSuccess(Void result) {
|
243
|
|
244
|
repositoryInformationPanel.removeStyleName("loading-big");
|
245
|
repositoryInformationPanel.remove(loadingWheel);
|
246
|
|
247
|
successLabel.setText("Repository information updated successfully");
|
248
|
successLabel.setVisible(true);
|
249
|
}
|
250
|
});
|
251
|
}
|
252
|
}
|
253
|
});
|
254
|
repositoryInformationForm.add(new MyFormGroup(false, null, updateInfoButton));
|
255
|
}
|
256
|
|
257
|
addValueChangeHandlersToFormFields();
|
258
|
addFieldValidators();
|
259
|
}
|
260
|
|
261
|
@Override
|
262
|
public Widget asWidget() {
|
263
|
return repositoryInformationPanel;
|
264
|
}
|
265
|
|
266
|
public void loadRepository(Repository repository) {
|
267
|
|
268
|
errorLabel.setVisible(false);
|
269
|
successLabel.setVisible(false);
|
270
|
|
271
|
this.repository = repository;
|
272
|
|
273
|
if(mode.equals(Constants.REPOSITORY_MODE_OPENDOAR)) {
|
274
|
basicInfoWarningLabel.setHTML("The following fields are completed by OpenDOAR.<br>" +
|
275
|
"If you want to edit them, you can do it by using this <a target=\"_blank\" " +
|
276
|
"href=\"http://www.opendoar.org/suggest.php?rID=" + repository.getId().split("::")[1] + "\">OpenDOAR link</a>");
|
277
|
basicInfoWarningLabel.setVisible(true);
|
278
|
} else if(mode.equals(Constants.REPOSITORY_MODE_RE3DATA)) {
|
279
|
basicInfoWarningLabel.setHTML("The following fields are completed by Re3data.<br>" +
|
280
|
"If you want to edit them, you can do it by using this <a target=\"_blank\" " +
|
281
|
"href=\"http://service.re3data.org/repository/" + repository.getId().split("::")[1] + "\">Re3data link</a>");
|
282
|
basicInfoWarningLabel.setVisible(true);
|
283
|
}
|
284
|
|
285
|
if (repository.getTypology() != null) {
|
286
|
if(timezoneValuesMap.get(repository.getTypology())!=null)
|
287
|
typologyListBox.setSelectedIndex(typologyValuesMap.get(repository.getTypology()));
|
288
|
else if(typologyValuesMap.containsKey("[Other]")){
|
289
|
typologyListBox.setSelectedIndex(typologyValuesMap.get("[Other]"));
|
290
|
typologyTextBox.setVisible(true);
|
291
|
typologyTextBox.setValue(repository.getTypology());
|
292
|
}
|
293
|
}
|
294
|
|
295
|
if (repository.getOfficialName() != null)
|
296
|
officialName.setValue(repository.getOfficialName());
|
297
|
|
298
|
if (mode.equals(Constants.REPOSITORY_MODE_JOURNAL)) {
|
299
|
if (repository.getIssn() != null)
|
300
|
issn.setValue(repository.getIssn());
|
301
|
if (repository.getEissn() != null)
|
302
|
eissn.setValue(repository.getEissn());
|
303
|
if (repository.getLissn() != null)
|
304
|
lissn.setValue(repository.getLissn());
|
305
|
}
|
306
|
|
307
|
if (repository.getDescription() != null)
|
308
|
description.setValue(repository.getDescription());
|
309
|
if (repository.getCountryName() != null)
|
310
|
countryListBox.setSelectedIndex(countryValuesMap.get(repository.getCountryName()));
|
311
|
if (repository.getLongitude() != null)
|
312
|
longitude.setValue(repository.getLongitude() + "");
|
313
|
if (repository.getLatitude() != null)
|
314
|
latitude.setValue(repository.getLatitude() + "");
|
315
|
if (repository.getWebsiteUrl() != null)
|
316
|
entryURL.setValue(repository.getWebsiteUrl());
|
317
|
if (repository.getOrganization() != null)
|
318
|
institution.setValue(repository.getOrganization());
|
319
|
|
320
|
if (repository.getEnglishName() != null)
|
321
|
englishName.setValue(repository.getEnglishName());
|
322
|
if (repository.getLogoUrl() != null)
|
323
|
logoURL.setValue(repository.getLogoUrl());
|
324
|
if(repository.getTimezone()!=null)
|
325
|
timezoneListBox.setSelectedIndex(timezoneValuesMap.get(repository.getTimezone()+""));
|
326
|
if(repository.getDatasourceClass()!=null && datasourceClassValuesMap.containsKey(repository.getDatasourceClass()))
|
327
|
datasourceClassListBox.setSelectedIndex(datasourceClassValuesMap.get(repository.getDatasourceClass()));
|
328
|
|
329
|
if (repository.getContactEmail() != null)
|
330
|
admin.setValue(repository.getContactEmail());
|
331
|
}
|
332
|
|
333
|
public Repository getRepository() {
|
334
|
|
335
|
if(isComplete()) {
|
336
|
|
337
|
if(repositoryInformationForm.validate()) {
|
338
|
|
339
|
if (typologyListBox.getSelectedValue().equals("[Other]"))
|
340
|
repository.setTypology(typologyTextBox.getValue().trim());
|
341
|
else
|
342
|
repository.setTypology(typologyListBox.getSelectedValue());
|
343
|
|
344
|
repository.setOfficialName(officialName.getValue().trim());
|
345
|
|
346
|
if (mode.equals(Constants.REPOSITORY_MODE_JOURNAL)) {
|
347
|
repository.setIssn(issn.getValue().trim());
|
348
|
if (eissn.getValue() != null && !eissn.getValue().trim().isEmpty())
|
349
|
repository.setEissn(eissn.getValue().trim());
|
350
|
if (lissn.getValue() != null && !lissn.getValue().trim().isEmpty())
|
351
|
repository.setLissn(lissn.getValue().trim());
|
352
|
}
|
353
|
|
354
|
repository.setDescription(description.getValue().trim());
|
355
|
repository.setCountryName(countryListBox.getSelectedValue());
|
356
|
repository.setLongitude(Double.parseDouble(longitude.getValue().trim()));
|
357
|
repository.setLatitude(Double.parseDouble(latitude.getValue().trim()));
|
358
|
repository.setWebsiteUrl(entryURL.getValue().trim());
|
359
|
repository.setOrganization(institution.getValue().trim());
|
360
|
|
361
|
repository.setEnglishName(englishName.getValue().trim());
|
362
|
repository.setLogoUrl(logoURL.getValue().trim());
|
363
|
repository.setTimezone(Double.parseDouble(timezoneListBox.getSelectedValue()));
|
364
|
repository.setDatasourceClass(datasourceClassListBox.getSelectedValue());
|
365
|
|
366
|
repository.setContactEmail(admin.getValue());
|
367
|
|
368
|
return repository;
|
369
|
}
|
370
|
}
|
371
|
|
372
|
return null;
|
373
|
}
|
374
|
|
375
|
private boolean isComplete() {
|
376
|
|
377
|
boolean isComplete = true;
|
378
|
|
379
|
errorLabel.setVisible(false);
|
380
|
successLabel.setVisible(false);
|
381
|
|
382
|
if(typologyListBox.getSelectedValue().equals("noneSelected")) {
|
383
|
isComplete = false;
|
384
|
typologyListFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
385
|
} else if(typologyListBox.getSelectedValue().equals("[Other]")
|
386
|
&& (typologyTextBox.getValue()==null || typologyTextBox.getValue().trim().isEmpty())) {
|
387
|
isComplete = false;
|
388
|
typologyTextFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
389
|
}
|
390
|
|
391
|
if(officialName.getValue()==null || officialName.getValue().trim().isEmpty()) {
|
392
|
isComplete = false;
|
393
|
officialNameFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
394
|
}
|
395
|
|
396
|
if(mode.equals(Constants.REPOSITORY_MODE_JOURNAL)
|
397
|
&& (issn.getValue()==null || issn.getValue().trim().isEmpty())) {
|
398
|
isComplete = false;
|
399
|
issnFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
400
|
}
|
401
|
|
402
|
if(description.getValue()==null || description.getValue().trim().isEmpty()) {
|
403
|
isComplete = false;
|
404
|
descriptionFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
405
|
}
|
406
|
|
407
|
if(countryListBox.getSelectedValue().equals("noneSelected")) {
|
408
|
isComplete = false;
|
409
|
countryFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
410
|
}
|
411
|
|
412
|
if(longitude.getValue()==null || longitude.getValue().trim().isEmpty()) {
|
413
|
isComplete = false;
|
414
|
longitudeFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
415
|
}
|
416
|
|
417
|
if(latitude.getValue()==null || latitude.getValue().trim().isEmpty()) {
|
418
|
isComplete = false;
|
419
|
latitudeFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
420
|
}
|
421
|
|
422
|
if(entryURL.getValue()==null || entryURL.getValue().trim().isEmpty()) {
|
423
|
isComplete = false;
|
424
|
entryURLFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
425
|
}
|
426
|
|
427
|
if(institution.getValue()==null || institution.getValue().trim().isEmpty()) {
|
428
|
isComplete = false;
|
429
|
institutionFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
430
|
}
|
431
|
|
432
|
if(englishName.getValue()==null || englishName.getValue().trim().isEmpty()) {
|
433
|
isComplete = false;
|
434
|
englishNameFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
435
|
}
|
436
|
|
437
|
if(timezoneListBox.getSelectedValue().equals("noneSelected")) {
|
438
|
isComplete = false;
|
439
|
timezoneFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
440
|
}
|
441
|
|
442
|
if(datasourceClassListBox.getSelectedValue().equals("noneSelected")) {
|
443
|
isComplete = false;
|
444
|
datasourceClassFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
445
|
}
|
446
|
|
447
|
if(admin.getValue()==null || admin.getValue().trim().isEmpty()) {
|
448
|
isComplete = false;
|
449
|
adminFormGroup.setFormGroupValidationState(ValidationState.ERROR);
|
450
|
}
|
451
|
|
452
|
if(!isComplete) {
|
453
|
errorLabel.setText("All fields marked with * are mandatory.");
|
454
|
errorLabel.setVisible(true);
|
455
|
}
|
456
|
|
457
|
return isComplete;
|
458
|
}
|
459
|
|
460
|
private void addFieldValidators() {
|
461
|
|
462
|
longitude.addValidator(new Validator<String>() {
|
463
|
|
464
|
@Override
|
465
|
public int getPriority() {
|
466
|
return 0;
|
467
|
}
|
468
|
|
469
|
@Override
|
470
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
471
|
|
472
|
List<EditorError> result = new ArrayList<EditorError>();
|
473
|
String valueStr = value == null ? "" : value.toString();
|
474
|
|
475
|
RegExp regExp = RegExp.compile(Constants.LONGITUDE_PATTERN);
|
476
|
if (!regExp.test(valueStr.trim().toLowerCase())) {
|
477
|
|
478
|
longitudeFormGroup.displayInlineError("Invalid longitude");
|
479
|
result.add(new BasicEditorError(longitude, value, "Invalid longitude"));
|
480
|
errorLabel.setText("Invalid fields!");
|
481
|
errorLabel.setVisible(true);
|
482
|
}
|
483
|
|
484
|
return result;
|
485
|
}
|
486
|
});
|
487
|
|
488
|
latitude.addValidator(new Validator<String>() {
|
489
|
|
490
|
@Override
|
491
|
public int getPriority() {
|
492
|
return 0;
|
493
|
}
|
494
|
|
495
|
@Override
|
496
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
497
|
|
498
|
List<EditorError> result = new ArrayList<EditorError>();
|
499
|
String valueStr = value == null ? "" : value.toString();
|
500
|
|
501
|
RegExp regExp = RegExp.compile(Constants.LATITUDE_PATTERN);
|
502
|
if (!regExp.test(valueStr.trim().toLowerCase())) {
|
503
|
|
504
|
latitudeFormGroup.displayInlineError("Invalid latitude");
|
505
|
result.add(new BasicEditorError(latitude, value, "Invalid latitude"));
|
506
|
errorLabel.setText("Invalid fields!");
|
507
|
errorLabel.setVisible(true);
|
508
|
}
|
509
|
|
510
|
return result;
|
511
|
}
|
512
|
});
|
513
|
|
514
|
admin.addValidator(new Validator<String>() {
|
515
|
|
516
|
@Override
|
517
|
public int getPriority() {
|
518
|
return 0;
|
519
|
}
|
520
|
|
521
|
@Override
|
522
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
523
|
|
524
|
List<EditorError> result = new ArrayList<EditorError>();
|
525
|
String valueStr = value == null ? "" : value.toString();
|
526
|
|
527
|
RegExp regExp = RegExp.compile(Constants.EMAIL_PATTERN);
|
528
|
if (!regExp.test(valueStr.trim().toLowerCase())) {
|
529
|
|
530
|
adminFormGroup.displayInlineError("Invalid email address");
|
531
|
result.add(new BasicEditorError(admin, value, "Invalid email address"));
|
532
|
errorLabel.setText("Invalid fields!");
|
533
|
errorLabel.setVisible(true);
|
534
|
}
|
535
|
|
536
|
return result;
|
537
|
}
|
538
|
});
|
539
|
|
540
|
if(mode.equals(Constants.REPOSITORY_MODE_JOURNAL)) {
|
541
|
|
542
|
issn.addValidator(new Validator<String>() {
|
543
|
|
544
|
@Override
|
545
|
public int getPriority() {
|
546
|
return 0;
|
547
|
}
|
548
|
|
549
|
@Override
|
550
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
551
|
|
552
|
List<EditorError> result = new ArrayList<EditorError>();
|
553
|
String valueStr = value == null ? "" : value.toString();
|
554
|
|
555
|
if (valueStr.length()!=8) {
|
556
|
issnFormGroup.displayInlineError("Issn length has to be 8 characters");
|
557
|
result.add(new BasicEditorError(issn, value, "Issn length has to be 8 characters"));
|
558
|
errorLabel.setText("Invalid fields!");
|
559
|
errorLabel.setVisible(true);
|
560
|
}
|
561
|
|
562
|
return result;
|
563
|
}
|
564
|
});
|
565
|
|
566
|
eissn.addValidator(new Validator<String>() {
|
567
|
|
568
|
@Override
|
569
|
public int getPriority() {
|
570
|
return 0;
|
571
|
}
|
572
|
|
573
|
@Override
|
574
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
575
|
|
576
|
List<EditorError> result = new ArrayList<EditorError>();
|
577
|
String valueStr = value == null ? "" : value.toString();
|
578
|
|
579
|
if (valueStr.length()!=8) {
|
580
|
eissnFormGroup.displayInlineError("Eissn length has to be 8 characters");
|
581
|
result.add(new BasicEditorError(eissn, value, "Eissn length has to be 8 characters"));
|
582
|
errorLabel.setText("Invalid fields!");
|
583
|
errorLabel.setVisible(true);
|
584
|
}
|
585
|
|
586
|
return result;
|
587
|
}
|
588
|
});
|
589
|
|
590
|
lissn.addValidator(new Validator<String>() {
|
591
|
|
592
|
@Override
|
593
|
public int getPriority() {
|
594
|
return 0;
|
595
|
}
|
596
|
|
597
|
@Override
|
598
|
public List<EditorError> validate(Editor<String> editor, String value) {
|
599
|
|
600
|
List<EditorError> result = new ArrayList<EditorError>();
|
601
|
String valueStr = value == null ? "" : value.toString();
|
602
|
|
603
|
if (valueStr.length()!=8) {
|
604
|
lissnFormGroup.displayInlineError("Lissn length has to be 8 characters");
|
605
|
result.add(new BasicEditorError(lissn, value, "Lissn length has to be 8 characters"));
|
606
|
errorLabel.setText("Invalid fields!");
|
607
|
errorLabel.setVisible(true);
|
608
|
}
|
609
|
|
610
|
return result;
|
611
|
}
|
612
|
});
|
613
|
|
614
|
}
|
615
|
|
616
|
}
|
617
|
|
618
|
private void addValueChangeHandlersToFormFields() {
|
619
|
|
620
|
typologyListBox.addChangeHandler(new ChangeHandler() {
|
621
|
@Override
|
622
|
public void onChange(ChangeEvent event) {
|
623
|
typologyListFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
624
|
if(typologyListBox.getSelectedValue().equals("[Other]"))
|
625
|
typologyTextBox.setVisible(true);
|
626
|
else
|
627
|
typologyTextBox.setVisible(false);
|
628
|
}
|
629
|
});
|
630
|
|
631
|
typologyTextBox.setValueChangeHandler(new ValueChangeHandler() {
|
632
|
@Override
|
633
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
634
|
typologyTextFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
635
|
}
|
636
|
});
|
637
|
|
638
|
officialName.setValueChangeHandler(new ValueChangeHandler() {
|
639
|
@Override
|
640
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
641
|
officialNameFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
642
|
}
|
643
|
});
|
644
|
|
645
|
issn.setValueChangeHandler(new ValueChangeHandler() {
|
646
|
@Override
|
647
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
648
|
issnFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
649
|
}
|
650
|
});
|
651
|
|
652
|
eissn.setValueChangeHandler(new ValueChangeHandler() {
|
653
|
@Override
|
654
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
655
|
eissnFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
656
|
}
|
657
|
});
|
658
|
|
659
|
lissn.setValueChangeHandler(new ValueChangeHandler() {
|
660
|
@Override
|
661
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
662
|
lissnFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
663
|
}
|
664
|
});
|
665
|
|
666
|
description.setValueChangeHandler(new ValueChangeHandler() {
|
667
|
@Override
|
668
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
669
|
descriptionFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
670
|
}
|
671
|
});
|
672
|
|
673
|
countryListBox.addChangeHandler(new ChangeHandler() {
|
674
|
@Override
|
675
|
public void onChange(ChangeEvent event) {
|
676
|
countryFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
677
|
}
|
678
|
});
|
679
|
|
680
|
longitude.setValueChangeHandler(new ValueChangeHandler() {
|
681
|
@Override
|
682
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
683
|
longitudeFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
684
|
}
|
685
|
});
|
686
|
|
687
|
latitude.setValueChangeHandler(new ValueChangeHandler() {
|
688
|
@Override
|
689
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
690
|
latitudeFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
691
|
}
|
692
|
});
|
693
|
|
694
|
entryURL.setValueChangeHandler(new ValueChangeHandler() {
|
695
|
@Override
|
696
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
697
|
entryURLFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
698
|
}
|
699
|
});
|
700
|
|
701
|
institution.setValueChangeHandler(new ValueChangeHandler() {
|
702
|
@Override
|
703
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
704
|
institutionFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
705
|
}
|
706
|
});
|
707
|
|
708
|
englishName.setValueChangeHandler(new ValueChangeHandler() {
|
709
|
@Override
|
710
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
711
|
englishNameFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
712
|
}
|
713
|
});
|
714
|
|
715
|
timezoneListBox.addChangeHandler(new ChangeHandler() {
|
716
|
@Override
|
717
|
public void onChange(ChangeEvent event) {
|
718
|
timezoneFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
719
|
}
|
720
|
});
|
721
|
|
722
|
datasourceClassListBox.addChangeHandler(new ChangeHandler() {
|
723
|
@Override
|
724
|
public void onChange(ChangeEvent event) {
|
725
|
datasourceClassFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
726
|
}
|
727
|
});
|
728
|
|
729
|
admin.setValueChangeHandler(new ValueChangeHandler() {
|
730
|
@Override
|
731
|
public void handle(ValueChangeEvent valueChangeEvent) {
|
732
|
adminFormGroup.setFormGroupValidationState(ValidationState.NONE);
|
733
|
}
|
734
|
});
|
735
|
}
|
736
|
}
|