1 |
41602
|
stefania.m
|
package eu.dnetlib.repo.manager.client.validator.test;
|
2 |
|
|
|
3 |
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
4 |
|
|
import com.google.gwt.user.client.ui.HTML;
|
5 |
|
|
import com.google.gwt.user.client.ui.IsWidget;
|
6 |
|
|
import com.google.gwt.user.client.ui.Widget;
|
7 |
|
|
import eu.dnetlib.repo.manager.shared.Tuple;
|
8 |
|
|
import eu.dnetlib.repo.manager.shared.Vocabulary;
|
9 |
|
|
import org.gwtbootstrap3.client.ui.Alert;
|
10 |
|
|
import org.gwtbootstrap3.client.ui.Form;
|
11 |
|
|
import org.gwtbootstrap3.client.ui.RadioButton;
|
12 |
|
|
import org.gwtbootstrap3.client.ui.constants.AlertType;
|
13 |
|
|
import org.gwtbootstrap3.client.ui.constants.ButtonType;
|
14 |
|
|
import org.gwtbootstrap3.client.ui.constants.FormType;
|
15 |
|
|
|
16 |
|
|
import java.util.ArrayList;
|
17 |
|
|
import java.util.HashSet;
|
18 |
|
|
import java.util.List;
|
19 |
|
|
import java.util.Set;
|
20 |
|
|
|
21 |
|
|
/**
|
22 |
|
|
* Created by stefania on 3/8/16.
|
23 |
|
|
*/
|
24 |
|
|
public class SelectCrisParametersWidget implements IsWidget {
|
25 |
|
|
|
26 |
|
|
private FlowPanel selectCrisParametersWidgetPanel = new FlowPanel();
|
27 |
|
|
|
28 |
|
|
private Alert errorLabel = new Alert();
|
29 |
|
|
|
30 |
|
|
private FlowPanel crisEntitiesPanel = new FlowPanel();
|
31 |
|
|
private HTML crisEntitiesLabel = new HTML();
|
32 |
|
|
private MultiSelectWidget multiSelectWidget;
|
33 |
|
|
|
34 |
|
|
private FlowPanel referentialIntegrityPanel = new FlowPanel();
|
35 |
|
|
private HTML referentialIntegrityLabel = new HTML();
|
36 |
|
|
private Form referentialIntegrityForm = new Form();
|
37 |
48932
|
antonis.le
|
private FlowPanel referentialIntegrityInlinePanel = new FlowPanel();
|
38 |
41602
|
stefania.m
|
private RadioButton yesReferentialIntegrityRadio = new RadioButton("referentialIntegrity", "Yes", false);
|
39 |
|
|
private RadioButton noReferentialIntegrityRadio = new RadioButton("referentialIntegrity", "No", false);
|
40 |
|
|
|
41 |
|
|
public SelectCrisParametersWidget(List<String> crisEntities) {
|
42 |
|
|
|
43 |
|
|
errorLabel.setType(AlertType.DANGER);
|
44 |
|
|
errorLabel.setDismissable(false);
|
45 |
|
|
errorLabel.setVisible(false);
|
46 |
|
|
|
47 |
|
|
selectCrisParametersWidgetPanel.add(errorLabel);
|
48 |
|
|
selectCrisParametersWidgetPanel.add(crisEntitiesPanel);
|
49 |
|
|
selectCrisParametersWidgetPanel.add(referentialIntegrityPanel);
|
50 |
|
|
|
51 |
|
|
// CRIS ENTITIES
|
52 |
|
|
crisEntitiesLabel.setHTML("<label>Cris Entities</label>");
|
53 |
|
|
|
54 |
|
|
List<Vocabulary> crisEntitiesVocabulary = new ArrayList<Vocabulary>();
|
55 |
|
|
for(String crisEntity : crisEntities)
|
56 |
|
|
crisEntitiesVocabulary.add(new Vocabulary(crisEntity, crisEntity));
|
57 |
|
|
multiSelectWidget = new MultiSelectWidget(crisEntitiesVocabulary, "Entities");
|
58 |
|
|
|
59 |
48932
|
antonis.le
|
crisEntitiesPanel.addStyleName("marginBottom20 uk-margin-top");
|
60 |
41602
|
stefania.m
|
crisEntitiesPanel.add(crisEntitiesLabel);
|
61 |
|
|
crisEntitiesPanel.add(multiSelectWidget);
|
62 |
|
|
|
63 |
|
|
// REFERENTIAL INTEGRITY
|
64 |
|
|
referentialIntegrityLabel.setHTML("<label>Check Referential Integrity</label>");
|
65 |
|
|
|
66 |
|
|
referentialIntegrityPanel.addStyleName("marginBottom20");
|
67 |
|
|
referentialIntegrityPanel.add(referentialIntegrityLabel);
|
68 |
|
|
referentialIntegrityPanel.add(referentialIntegrityForm);
|
69 |
|
|
|
70 |
48932
|
antonis.le
|
referentialIntegrityForm.addStyleName("uk-grid");
|
71 |
41602
|
stefania.m
|
referentialIntegrityForm.setType(FormType.INLINE);
|
72 |
|
|
|
73 |
48932
|
antonis.le
|
referentialIntegrityInlinePanel.addStyleName("uk-width-1-1");
|
74 |
|
|
referentialIntegrityForm.add(referentialIntegrityInlinePanel);
|
75 |
|
|
|
76 |
41602
|
stefania.m
|
yesReferentialIntegrityRadio.setType(ButtonType.LINK);
|
77 |
|
|
yesReferentialIntegrityRadio.setValue(true);
|
78 |
48932
|
antonis.le
|
referentialIntegrityInlinePanel.add(yesReferentialIntegrityRadio);
|
79 |
41602
|
stefania.m
|
|
80 |
|
|
noReferentialIntegrityRadio.setType(ButtonType.LINK);
|
81 |
48932
|
antonis.le
|
referentialIntegrityInlinePanel.add(noReferentialIntegrityRadio);
|
82 |
41602
|
stefania.m
|
}
|
83 |
|
|
|
84 |
|
|
@Override
|
85 |
|
|
public Widget asWidget() {
|
86 |
|
|
return selectCrisParametersWidgetPanel;
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
public Tuple<Set<String>, Boolean> getParameters() {
|
90 |
|
|
|
91 |
|
|
errorLabel.setVisible(false);
|
92 |
|
|
|
93 |
|
|
Tuple<Set<String>, Boolean> parameters = new Tuple<Set<String>, Boolean>();
|
94 |
|
|
|
95 |
|
|
if(multiSelectWidget.getSelections().isEmpty()) {
|
96 |
|
|
errorLabel.setText("You need to select at least one entity");
|
97 |
|
|
errorLabel.setVisible(true);
|
98 |
|
|
parameters.setFirst(null);
|
99 |
|
|
} else {
|
100 |
|
|
Set<String> selectedEntities = new HashSet<String>();
|
101 |
|
|
for(String selection : multiSelectWidget.getSelections())
|
102 |
|
|
selectedEntities.add(selection);
|
103 |
|
|
parameters.setFirst(selectedEntities);
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
parameters.setSecond(yesReferentialIntegrityRadio.getValue());
|
107 |
|
|
|
108 |
|
|
return parameters;
|
109 |
|
|
}
|
110 |
|
|
}
|