Revision 51030
Added by Panagiotis Kanakakis about 6 years ago
SelectTopicWidget.java | ||
---|---|---|
10 | 10 |
import eu.dnetlib.gwt.client.help.HelpServiceAsync; |
11 | 11 |
import eu.dnetlib.repo.manager.client.AbstractRepositoryManagerWidget; |
12 | 12 |
import eu.dnetlib.repo.manager.client.HelpCallback; |
13 |
import eu.dnetlib.repo.manager.client.RepositoryManager; |
|
13 | 14 |
import eu.dnetlib.repo.manager.client.RepositoryManagerWidget; |
14 | 15 |
import eu.dnetlib.repo.manager.client.services.BrokerService; |
15 | 16 |
import eu.dnetlib.repo.manager.client.services.BrokerServiceAsync; |
17 |
import eu.dnetlib.repo.manager.shared.Term; |
|
16 | 18 |
import eu.dnetlib.repo.manager.shared.Tuple; |
17 | 19 |
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; |
18 | 20 |
import org.gwtbootstrap3.client.ui.Alert; |
19 | 21 |
import org.gwtbootstrap3.client.ui.constants.AlertType; |
20 | 22 |
|
23 |
import java.util.ArrayList; |
|
24 |
import java.util.HashMap; |
|
21 | 25 |
import java.util.List; |
26 |
import java.util.Map; |
|
22 | 27 |
|
23 | 28 |
/** |
24 | 29 |
* Created by stefania on 10/31/16. |
... | ... | |
28 | 33 |
private String parentToken = ""; |
29 | 34 |
private String restToken = ""; |
30 | 35 |
|
36 |
private HTML title = new HTML(); |
|
31 | 37 |
private FlowPanel selectTopicBoxContent = new FlowPanel(); |
32 | 38 |
|
33 | 39 |
private Alert errorAlert = new Alert(); |
34 | 40 |
|
41 |
public static Map<String, Term> topicsVocabulary = new HashMap<>(); |
|
42 |
|
|
35 | 43 |
private static HelpServiceAsync helpService = GWT.create(HelpService.class); |
36 | 44 |
private static BrokerServiceAsync brokerService = GWT.create(BrokerService.class); |
37 | 45 |
|
... | ... | |
39 | 47 |
|
40 | 48 |
super(); |
41 | 49 |
|
42 |
//TODO find datasource name? |
|
43 |
HTML title = new HTML("<h1 class=\"uk-article-title\">Topics for datasource</h1>"); |
|
44 | 50 |
title.addStyleName("uk-margin-medium-bottom"); |
45 | 51 |
contentPanel.add(title); |
46 | 52 |
|
... | ... | |
66 | 72 |
Document.get().getElementById("headerNoTransparent").removeClassName("tm-header-transparent"); |
67 | 73 |
selectTopicBoxContent.add(errorAlert); |
68 | 74 |
|
75 |
title.setHTML("<h1 class=\"uk-article-title\">Enrichments for " + restToken + "</h1>"); |
|
76 |
|
|
69 | 77 |
helpService.getHelpById(parentToken + "_selectTopic", new HelpCallback(helpPanel, gridPanel)); |
70 | 78 |
|
71 | 79 |
final HTML loadingWheel = new HTML("<div class=\"loader-big\" style=\"text-align: center; padding-top: 170px; " + |
... | ... | |
87 | 95 |
} |
88 | 96 |
|
89 | 97 |
@Override |
90 |
public void onSuccess(List<BrowseEntry> browseEntries) { |
|
98 |
public void onSuccess(final List<BrowseEntry> browseEntries) {
|
|
91 | 99 |
|
92 |
selectTopicBoxContent.removeStyleName("loading-big"); |
|
93 |
selectTopicBoxContent.remove(loadingWheel); |
|
100 |
brokerService.getDnetTopics(new AsyncCallback<Map<String, Term>>() { |
|
94 | 101 |
|
95 |
final FlowPanel topicsList = new FlowPanel(); |
|
96 |
createTopicsList(browseEntries, topicsList); |
|
97 |
selectTopicBoxContent.add(topicsList); |
|
102 |
@Override |
|
103 |
public void onFailure(Throwable throwable) { |
|
104 |
|
|
105 |
selectTopicBoxContent.removeStyleName("loading-big"); |
|
106 |
selectTopicBoxContent.remove(loadingWheel); |
|
107 |
|
|
108 |
errorAlert.setText("System error retrieving topics vocabulary."); |
|
109 |
errorAlert.setVisible(true); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public void onSuccess(Map<String, Term> stringTermMap) { |
|
114 |
|
|
115 |
topicsVocabulary.putAll(stringTermMap); |
|
116 |
|
|
117 |
selectTopicBoxContent.removeStyleName("loading-big"); |
|
118 |
selectTopicBoxContent.remove(loadingWheel); |
|
119 |
|
|
120 |
final FlowPanel topicsList = new FlowPanel(); |
|
121 |
createTopicsList(browseEntries, topicsList); |
|
122 |
selectTopicBoxContent.add(topicsList); |
|
123 |
} |
|
124 |
}); |
|
125 |
|
|
98 | 126 |
} |
99 | 127 |
}); |
100 | 128 |
} |
... | ... | |
120 | 148 |
|
121 | 149 |
} else { |
122 | 150 |
|
123 |
long total = 0; |
|
151 |
List<BrowseEntry> enrichMoreEntries = new ArrayList<>(); |
|
152 |
List<BrowseEntry> enrichMissingEntries = new ArrayList<>(); |
|
124 | 153 |
|
125 |
FlowPanel colPanel = new FlowPanel(); |
|
126 |
colPanel.addStyleName("uk-width-1-1@m uk-first-column"); |
|
127 |
topicsList.add(colPanel); |
|
154 |
for(BrowseEntry browseEntry : browseEntries) { |
|
155 |
if(browseEntry.getValue().startsWith("ENRICH/MORE")) |
|
156 |
enrichMoreEntries.add(browseEntry); |
|
157 |
else if(browseEntry.getValue().startsWith("ENRICH/MISSING")) |
|
158 |
enrichMissingEntries.add(browseEntry); |
|
159 |
} |
|
128 | 160 |
|
129 |
FlowPanel divPanel = new FlowPanel(); |
|
130 |
divPanel.addStyleName("uk-overflow-auto uk-scrollspy-inview uk-animation-slide-top-medium"); |
|
131 |
colPanel.add(divPanel); |
|
161 |
//COLUMN FOR ENRICH/MORE |
|
162 |
FlowPanel colPanel1 = new FlowPanel(); |
|
163 |
colPanel1.addStyleName("uk-width-1-2@m uk-first-column"); |
|
164 |
topicsList.add(colPanel1); |
|
132 | 165 |
|
133 |
String content = "<table class=\"uk-table uk-table-striped uk-table-middle\">" + |
|
134 |
"<thead><tr><th>Topic</th><th class=\"uk-text-nowrap\"># of events</th>" + |
|
135 |
"</tr></thead>"; |
|
166 |
colPanel1.add(createTopicGroupPanel(enrichMoreEntries, "More")); |
|
136 | 167 |
|
137 |
content += "<tbody>"; |
|
168 |
//COLUMN FOR ENRICH/MISSING |
|
169 |
FlowPanel colPanel2 = new FlowPanel(); |
|
170 |
colPanel2.addStyleName("uk-width-1-2@m uk-first-column"); |
|
171 |
topicsList.add(colPanel2); |
|
138 | 172 |
|
139 |
for(BrowseEntry browseEntry : browseEntries) {
|
|
173 |
colPanel2.add(createTopicGroupPanel(enrichMissingEntries, "Missing"));
|
|
140 | 174 |
|
141 |
content += "<tr class=\"el-item\">" + |
|
142 |
"<td class=\"uk-text-nowrap uk-table-shrink\">\n" + |
|
143 |
"<a href=\"#" + parentToken + "/" + restToken + "/" +browseEntry.getValue() + "\" class=\"el-link\">" + |
|
144 |
browseEntry.getValue() + "</a>" + |
|
145 |
"</td>" + |
|
146 |
"<td class=\"uk-text-nowrap uk-table-shrink\">\n" + |
|
147 |
"<div class=\"el-title\">" + browseEntry.getSize() + "</div>" + |
|
148 |
"</td>" + |
|
149 |
"</tr>"; |
|
150 | 175 |
|
151 |
total += browseEntry.getSize();
|
|
152 |
}
|
|
176 |
}
|
|
177 |
} |
|
153 | 178 |
|
154 |
content += "<tr class=\"el-item footers\">" + |
|
155 |
"<td class=\"uk-text-nowrap uk-table-shrink\">\n" + |
|
156 |
"<div class=\"el-title\">Total</div>" + |
|
179 |
private FlowPanel createTopicGroupPanel(List<BrowseEntry> browseEntries, String group) { |
|
180 |
|
|
181 |
long total = 0; |
|
182 |
|
|
183 |
FlowPanel divPanel = new FlowPanel(); |
|
184 |
divPanel.addStyleName("uk-overflow-auto uk-scrollspy-inview uk-animation-slide-top-medium"); |
|
185 |
|
|
186 |
String content = "<h4 class=\"uk-h4 uk-text-primary uk-scrollspy-inview uk-animation-slide-top-medium\" " + |
|
187 |
"uk-scrollspy-class=\"\"><span>" + group + "</span></h4>"; |
|
188 |
|
|
189 |
content += "<table class=\"uk-table uk-table-striped uk-table-middle\">" + |
|
190 |
// "<thead><tr><th>Related events that may potentially enrich " + restToken + " content</th>" + |
|
191 |
"<thead><tr><th>Events that may enrich " + restToken + " content</th>" + |
|
192 |
"<th class=\"uk-text-nowrap\"># of events</th>" + |
|
193 |
"</tr></thead>"; |
|
194 |
|
|
195 |
content += "<tbody>"; |
|
196 |
|
|
197 |
for(BrowseEntry browseEntry : browseEntries) { |
|
198 |
|
|
199 |
content += "<tr class=\"el-item\">" + |
|
200 |
"<td class=\"uk-table-shrink uk-width-4-5\">\n" + |
|
201 |
"<a href=\"#" + parentToken + "/" + restToken + "/" + browseEntry.getValue() + "\" class=\"el-link\">" + |
|
202 |
browseEntry.getValue() + "</a>"; |
|
203 |
|
|
204 |
if(this.topicsVocabulary.get(browseEntry.getValue())!=null) |
|
205 |
content += "<div class=\"uk-text uk-text-meta\">" + this.topicsVocabulary.get(browseEntry.getValue()).getEnglishName() + "</div>"; |
|
206 |
|
|
207 |
content += "</td>" + |
|
208 |
"<td class=\"uk-text-nowrap uk-table-shrink uk-width-1-5\">\n" + |
|
209 |
"<div class=\"el-title\">" + browseEntry.getSize() + "</div>" + |
|
157 | 210 |
"</td>" + |
158 |
"<td class=\"uk-text-nowrap uk-table-shrink\">\n" + |
|
159 |
"<div class=\"el-title\">" + total + "</div>" + |
|
160 |
"</td>" + |
|
161 | 211 |
"</tr>"; |
162 | 212 |
|
163 |
content += "</tbody></table>"; |
|
213 |
total += browseEntry.getSize(); |
|
214 |
} |
|
164 | 215 |
|
165 |
HTML reposListHTML = new HTML(); |
|
166 |
reposListHTML.setHTML(content); |
|
216 |
content += "<tr class=\"el-item footers\">" + |
|
217 |
"<td class=\"uk-text-nowrap uk-table-shrink uk-width-4-5\">\n" + |
|
218 |
"<div class=\"el-title\">Total</div>" + |
|
219 |
"</td>" + |
|
220 |
"<td class=\"uk-text-nowrap uk-table-shrink uk-width-1-5\">\n" + |
|
221 |
"<div class=\"el-title\">" + total + "</div>" + |
|
222 |
"</td>" + |
|
223 |
"</tr>"; |
|
167 | 224 |
|
168 |
divPanel.add(reposListHTML); |
|
169 |
} |
|
225 |
content += "</tbody></table>"; |
|
226 |
|
|
227 |
HTML reposListHTML = new HTML(); |
|
228 |
reposListHTML.setHTML(content); |
|
229 |
|
|
230 |
divPanel.add(reposListHTML); |
|
231 |
|
|
232 |
return divPanel; |
|
170 | 233 |
} |
171 | 234 |
} |
Also available in: Unified diff
1. Properties file changes.
2. Aggregation details / aggregation object add.
3. Other changes from stef