Changeset 32887 in osm for applications/editors/josm/plugins/wikipedia
- Timestamp:
- 2016-08-30T10:52:38+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia
- Files:
-
- 8 added
- 3 edited
- 12 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r32829 r32887 12 12 import java.util.Collection; 13 13 import java.util.Collections; 14 import java.util.Comparator;15 14 import java.util.HashMap; 16 15 import java.util.List; … … 19 18 import java.util.Objects; 20 19 import java.util.TreeMap; 21 import java.util.regex.Matcher;22 20 import java.util.regex.Pattern; 23 21 import java.util.stream.Collectors; … … 31 29 import org.openstreetmap.josm.data.coor.LatLon; 32 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 33 import org.openstreetmap.josm.data.osm.Tag;34 31 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 35 import org.openstreetmap.josm.tools.AlphanumComparator;36 import org.openstreetmap.josm.tools.CheckParameterUtil;37 32 import org.openstreetmap.josm.tools.HttpClient; 38 33 import org.openstreetmap.josm.tools.Utils; 39 34 import org.w3c.dom.Document; 40 35 import org.w3c.dom.Node; 36 import org.wikipedia.data.WikidataEntry; 37 import org.wikipedia.data.WikipediaEntry; 38 import org.wikipedia.data.WikipediaLangArticle; 39 import org.wikipedia.tools.XPath; 41 40 42 41 public final class WikipediaApp { … … 56 55 } 57 56 58 static String getSiteUrl(String wikipediaLang) {57 public static String getSiteUrl(String wikipediaLang) { 59 58 if ("wikidata".equals(wikipediaLang)) { 60 59 return "https://www.wikidata.org"; … … 64 63 } 65 64 66 static List<WikipediaEntry> getEntriesFromCoordinates(String wikipediaLang, LatLon min, LatLon max) {65 public static List<WikipediaEntry> getEntriesFromCoordinates(String wikipediaLang, LatLon min, LatLon max) { 67 66 try { 68 67 // construct url … … 99 98 } 100 99 101 static List<WikidataEntry> getWikidataEntriesForQuery(final String languageForQuery, final String query, final Locale localeForLabels) {100 public static List<WikidataEntry> getWikidataEntriesForQuery(final String languageForQuery, final String query, final Locale localeForLabels) { 102 101 try { 103 102 final String url = "https://www.wikidata.org/w/api.php" + … … 120 119 } 121 120 122 static List<WikipediaEntry> getEntriesFromCategory(String wikipediaLang, String category, int depth) {121 public static List<WikipediaEntry> getEntriesFromCategory(String wikipediaLang, String category, int depth) { 123 122 try { 124 123 final String url = "https://tools.wmflabs.org/cats-php/" … … 138 137 } 139 138 140 static List<WikipediaEntry> getEntriesFromClipboard(final String wikipediaLang) {139 public static List<WikipediaEntry> getEntriesFromClipboard(final String wikipediaLang) { 141 140 return Pattern.compile("[\\n\\r]+") 142 141 .splitAsStream(ClipboardUtils.getClipboardStringContent()) … … 145 144 } 146 145 147 static void updateWIWOSMStatus(String wikipediaLang, List<WikipediaEntry> entries) {146 public static void updateWIWOSMStatus(String wikipediaLang, List<WikipediaEntry> entries) { 148 147 if (entries.size() > 20) { 149 148 partitionList(entries, 20).forEach(chunk -> updateWIWOSMStatus(wikipediaLang, chunk)); … … 179 178 } 180 179 181 static Stream<String> getWikipediaArticles(final String wikipediaLang, OsmPrimitive p) {180 public static Stream<String> getWikipediaArticles(final String wikipediaLang, OsmPrimitive p) { 182 181 if ("wikidata".equals(wikipediaLang)) { 183 182 return Stream.of(p.get("wikidata")).filter(Objects::nonNull); … … 194 193 * Returns a map mapping wikipedia articles to wikidata ids. 195 194 */ 196 static Map<String, String> getWikidataForArticles(String wikipediaLang, List<String> articles) {195 public static Map<String, String> getWikidataForArticles(String wikipediaLang, List<String> articles) { 197 196 if (articles.size() > 50) { 198 197 return partitionList(articles, 50).stream() … … 225 224 } 226 225 227 static List<String> getCategoriesForPrefix(final String wikipediaLang, final String prefix) {226 public static List<String> getCategoriesForPrefix(final String wikipediaLang, final String prefix) { 228 227 try { 229 228 final String url = getSiteUrl(wikipediaLang) + "/w/api.php" … … 247 246 } 248 247 249 static String getLabelForWikidata(String wikidataId, Locale locale, String... preferredLanguage) {248 public static String getLabelForWikidata(String wikidataId, Locale locale, String... preferredLanguage) { 250 249 try { 251 250 final List<WikidataEntry> entry = Collections.singletonList(new WikidataEntry(wikidataId, null, null, null)); … … 310 309 } 311 310 312 static Collection<WikipediaLangArticle> getInterwikiArticles(String wikipediaLang, String article) {311 public static Collection<WikipediaLangArticle> getInterwikiArticles(String wikipediaLang, String article) { 313 312 try { 314 313 final String url = getSiteUrl(wikipediaLang) + "/w/api.php" + … … 332 331 } 333 332 334 static LatLon getCoordinateForArticle(String wikipediaLang, String article) {333 public static LatLon getCoordinateForArticle(String wikipediaLang, String article) { 335 334 try { 336 335 final String url = getSiteUrl(wikipediaLang) + "/w/api.php" + … … 351 350 throw new RuntimeException(ex); 352 351 } 353 }354 355 static class WikipediaLangArticle {356 357 final String lang, article;358 359 public WikipediaLangArticle(String lang, String article) {360 this.lang = lang;361 this.article = article;362 }363 364 public static WikipediaLangArticle parseFromUrl(String url) {365 if (url == null) {366 return null;367 }368 // decode URL for nicer value369 url = Utils.decodeUrl(url);370 // extract Wikipedia language and371 final Matcher m = Pattern.compile("(https?:)?//(\\w*)\\.wikipedia\\.org/wiki/(.*)").matcher(url);372 if (!m.matches()) {373 return null;374 }375 return new WikipediaLangArticle(m.group(2), m.group(3));376 }377 378 public static WikipediaLangArticle parseTag(String key, String value) {379 if (value == null) {380 return null;381 } else if (value.startsWith("http")) {382 //wikipedia=http...383 return parseFromUrl(value);384 } else if (value.contains(":")) {385 //wikipedia=[lang]:[article]386 //wikipedia:[lang]=[lang]:[article]387 final String[] item = Utils.decodeUrl(value).split(":", 2);388 final String article = item[1].replace("_", " ");389 return new WikipediaLangArticle(item[0], article);390 } else if (key.startsWith("wikipedia:")) {391 //wikipedia:[lang]=[lang]:[article]392 //wikipedia:[lang]=[article]393 final String lang = key.split(":", 2)[1];394 final String[] item = Utils.decodeUrl(value).split(":", 2);395 final String article = item[item.length == 2 ? 1 : 0].replace("_", " ");396 return new WikipediaLangArticle(lang, article);397 } else {398 return null;399 }400 }401 402 @Override403 public String toString() {404 return lang + ":" + article;405 }406 407 @Override408 public boolean equals(Object o) {409 if (this == o) return true;410 if (o == null || getClass() != o.getClass()) return false;411 final WikipediaLangArticle that = (WikipediaLangArticle) o;412 return Objects.equals(lang, that.lang) &&413 Objects.equals(article, that.article);414 }415 416 @Override417 public int hashCode() {418 return Objects.hash(lang, article);419 }420 }421 422 static class WikipediaEntry implements Comparable<WikipediaEntry> {423 424 final String label;425 final String wikipediaLang, wikipediaArticle;426 final LatLon coordinate;427 private Boolean wiwosmStatus;428 429 WikipediaEntry(String wikipediaLang, String wikipediaArticle) {430 this(wikipediaLang, wikipediaArticle, null, null);431 }432 433 WikipediaEntry(String wikipediaLang, String wikipediaArticle, String label, LatLon coordinate) {434 this.label = label;435 this.wikipediaLang = wikipediaLang;436 this.wikipediaArticle = wikipediaArticle;437 this.coordinate = coordinate;438 }439 440 protected Tag createWikipediaTag() {441 return new Tag("wikipedia", wikipediaLang + ":" + wikipediaArticle);442 }443 444 public void setWiwosmStatus(Boolean wiwosmStatus) {445 this.wiwosmStatus = wiwosmStatus;446 }447 448 public Boolean getWiwosmStatus() {449 return wiwosmStatus;450 }451 452 public String getBrowserUrl() {453 return getSiteUrl(wikipediaLang) + "/wiki/" + Utils.encodeUrl(wikipediaArticle.replace(" ", "_"));454 }455 456 public String getLabelText() {457 return wikipediaArticle;458 }459 460 @Override461 public String toString() {462 return wikipediaArticle;463 }464 465 @Override466 public int compareTo(WikipediaEntry o) {467 return Comparator468 .<WikipediaEntry, String>comparing(x -> x.label, AlphanumComparator.getInstance())469 .thenComparing(x -> x.wikipediaArticle, AlphanumComparator.getInstance())470 .compare(this, o);471 }472 }473 474 static class WikidataEntry extends WikipediaEntry {475 476 final String description;477 478 WikidataEntry(String id, String label, LatLon coordinate, String description) {479 super("wikidata", id, label, coordinate);480 this.description = description;481 ensureValidWikidataId(id);482 }483 484 @Override485 protected Tag createWikipediaTag() {486 return new Tag("wikidata", wikipediaArticle);487 }488 489 @Override490 public String getLabelText() {491 final String descriptionInParen = description == null ? "" : (" (" + description + ")");492 return getLabelText(label, wikipediaArticle + descriptionInParen);493 }494 495 static String getLabelText(String bold, String gray) {496 return Utils.escapeReservedCharactersHTML(bold) + " <span color='gray'>" + Utils.escapeReservedCharactersHTML(gray) + "</span>";497 }498 }499 500 static void ensureValidWikidataId(String id) {501 CheckParameterUtil.ensureThat(WIKIDATA_PATTERN.matcher(id).matches(), "Invalid Wikidata ID given: " + id);502 352 } 503 353 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaPlugin.java
r32625 r32887 7 7 import org.openstreetmap.josm.plugins.Plugin; 8 8 import org.openstreetmap.josm.plugins.PluginInformation; 9 import org.wikipedia.actions.FetchWikidataAction; 10 import org.wikipedia.actions.WikipediaAddNamesAction; 11 import org.wikipedia.actions.WikipediaCopyTemplate; 12 import org.wikipedia.gui.WikidataItemSearchDialog; 13 import org.wikipedia.gui.WikidataTagCellRenderer; 14 import org.wikipedia.gui.WikipediaToggleDialog; 9 15 10 16 public class WikipediaPlugin extends Plugin { -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/FetchWikidataAction.java
r32884 r32887 1 1 // License: GPL. See LICENSE file for details./* 2 package org.wikipedia ;2 package org.wikipedia.actions; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 28 28 import org.openstreetmap.josm.tools.MultiMap; 29 29 import org.openstreetmap.josm.tools.Utils; 30 import org.wikipedia.WikipediaApp; 31 import org.wikipedia.data.WikipediaLangArticle; 32 import org.wikipedia.gui.GuiUtils; 30 33 31 34 public class FetchWikidataAction extends JosmAction { … … 45 48 } 46 49 47 static class Fetcher extends PleaseWaitRunnable {50 public static class Fetcher extends PleaseWaitRunnable { 48 51 private final Collection<? extends OsmPrimitive> selection; 49 52 private boolean canceled = false; 50 53 private final List<Command> commands = new ArrayList<>(); 51 private final Collection<Wikipedia App.WikipediaLangArticle> notFound = new ArrayList<>();54 private final Collection<WikipediaLangArticle> notFound = new ArrayList<>(); 52 55 53 56 public Fetcher(Collection<? extends OsmPrimitive> selection) { … … 79 82 } 80 83 81 protectedstatic Map<String, PrimitivesWithWikipedia> getLanguageToArticlesMap(final Iterable<? extends OsmPrimitive> selection) {84 static Map<String, PrimitivesWithWikipedia> getLanguageToArticlesMap(final Iterable<? extends OsmPrimitive> selection) { 82 85 final Map<String, PrimitivesWithWikipedia> r = new HashMap<>(); 83 86 for (final OsmPrimitive i : selection) { 84 final Wikipedia App.WikipediaLangArticle tag = WikipediaApp.WikipediaLangArticle.parseTag("wikipedia", i.get("wikipedia"));87 final WikipediaLangArticle tag = WikipediaLangArticle.parseTag("wikipedia", i.get("wikipedia")); 85 88 if (tag != null) { 86 89 if (!r.containsKey(tag.lang)) { … … 107 110 } 108 111 109 static class PrimitivesWithWikipedia {112 private static class PrimitivesWithWikipedia { 110 113 final String lang; 111 114 final MultiMap<String, OsmPrimitive> byArticle = new MultiMap<>(); 112 115 final List<Command> commands = new ArrayList<>(); 113 final List<Wikipedia App.WikipediaLangArticle> notFound = new ArrayList<>();116 final List<WikipediaLangArticle> notFound = new ArrayList<>(); 114 117 115 publicPrimitivesWithWikipedia(String lang) {118 PrimitivesWithWikipedia(String lang) { 116 119 this.lang = lang; 117 120 } … … 121 124 } 122 125 123 protectedvoid updateWikidataIds(ProgressMonitor monitor) {126 void updateWikidataIds(ProgressMonitor monitor) { 124 127 final int size = byArticle.keySet().size(); 125 128 monitor.beginTask(trn( … … 136 139 } 137 140 } else { 138 final Wikipedia App.WikipediaLangArticle article = new WikipediaApp.WikipediaLangArticle(lang, wikipedia);141 final WikipediaLangArticle article = new WikipediaLangArticle(lang, wikipedia); 139 142 Main.warn(tr("No Wikidata ID found for: {0}", article)); 140 143 notFound.add(article); … … 151 154 } 152 155 153 public List<WikipediaApp.WikipediaLangArticle> getNotFound() {156 List<WikipediaLangArticle> getNotFound() { 154 157 return notFound; 155 158 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/WikipediaAddNamesAction.java
r32884 r32887 1 1 // License: GPL. See LICENSE file for details./* 2 package org.wikipedia ;2 package org.wikipedia.actions; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 17 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; 18 import org.wikipedia.WikipediaApp; 19 import org.wikipedia.data.WikipediaLangArticle; 18 20 19 21 public class WikipediaAddNamesAction extends JosmAction { … … 27 29 @Override 28 30 public void actionPerformed(ActionEvent e) { 29 final Wikipedia App.WikipediaLangArticle wp = WikipediaApp.WikipediaLangArticle.parseTag("wikipedia", getWikipediaValue());31 final WikipediaLangArticle wp = WikipediaLangArticle.parseTag("wikipedia", getWikipediaValue()); 30 32 List<String[]> tags = new ArrayList<>(); 31 33 WikipediaApp.getInterwikiArticles(wp.lang, wp.article).stream() … … 39 41 } 40 42 41 pr otected boolean useWikipediaLangArticle(WikipediaApp.WikipediaLangArticle i) {43 private boolean useWikipediaLangArticle(WikipediaLangArticle i) { 42 44 return (!Main.pref.getBoolean("wikipedia.filter-iso-languages", true) 43 45 || Arrays.asList(Locale.getISOLanguages()).contains(i.lang)) … … 46 48 } 47 49 48 pr otectedString getWikipediaValue() {50 private String getWikipediaValue() { 49 51 DataSet ds = getLayerManager().getEditDataSet(); 50 52 if (ds == null || ds.getSelected() == null || ds.getSelected().size() != 1) { -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/WikipediaCopyTemplate.java
r32884 r32887 1 package org.wikipedia ;1 package org.wikipedia.actions; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 46 46 * Public visibility is needed for reflection used in {@link Preferences#getListOfStructs}. 47 47 */ 48 @SuppressWarnings("WeakerAccess") 48 49 public static class CoordCopyTemplateEntry { 49 50 @pref … … 68 69 protected final String pattern; 69 70 70 publicCoordCopyTemplate(final CoordCopyTemplateEntry entry) {71 CoordCopyTemplate(final CoordCopyTemplateEntry entry) { 71 72 this(tr("Copy {0} template", entry.name), entry.id, entry.pattern); 72 73 } 73 74 74 publicCoordCopyTemplate(String name, String toolbarId, String pattern) {75 CoordCopyTemplate(String name, String toolbarId, String pattern) { 75 76 super(name, "dialogs/wikipedia", null, null, true, toolbarId, true); 76 77 this.pattern = pattern; … … 98 99 } 99 100 100 protectedNode getSelectedNode() {101 Node getSelectedNode() { 101 102 DataSet ds = getLayerManager().getEditDataSet(); 102 103 if (ds == null) { -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/GuiUtils.java
r32884 r32887 1 1 // License: GPL. See LICENSE file for details./* 2 package org.wikipedia ;2 package org.wikipedia.gui; 3 3 4 4 import org.openstreetmap.josm.Main; … … 19 19 import static org.openstreetmap.josm.tools.I18n.trn; 20 20 21 class GuiUtils {21 public class GuiUtils { 22 22 23 static final String PREF_OVERWRITE = "wikipedia.overwrite-tag";23 public static final String PREF_OVERWRITE = "wikipedia.overwrite-tag"; 24 24 25 static boolean confirmOverwrite(final String key, final String newValue, final Collection<OsmPrimitive> primitives) {25 public static boolean confirmOverwrite(final String key, final String newValue, final Collection<OsmPrimitive> primitives) { 26 26 final SortedSet<String> existingValues = primitives.stream() 27 27 .map(x -> x.get(key)) -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikiSearchTextResultListPanel.java
r32884 r32887 1 package org.wikipedia ;1 package org.wikipedia.gui; 2 2 3 3 import java.util.concurrent.Executors; … … 5 5 import org.openstreetmap.josm.gui.widgets.SearchTextResultListPanel; 6 6 import org.openstreetmap.josm.tools.Utils; 7 import org.wikipedia.tools.Debouncer; 7 8 8 9 abstract class WikiSearchTextResultListPanel<T> extends SearchTextResultListPanel<T> { -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikidataItemSearchDialog.java
r32884 r32887 1 1 // License: GPL. For details, see LICENSE file. 2 package org.wikipedia ;2 package org.wikipedia.gui; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 29 29 import org.openstreetmap.josm.gui.util.GuiHelper; 30 30 import org.openstreetmap.josm.tools.GBC; 31 import org.wikipedia.WikipediaApp; 32 import org.wikipedia.data.WikidataEntry; 31 33 32 34 public final class WikidataItemSearchDialog extends ExtendedDialog { … … 37 39 38 40 private WikidataItemSearchDialog() { 39 super(Main.parent, tr("Search Wikidata items"), new String[]{tr("Add Tag"), tr("Cancel")});41 super(Main.parent, tr("Search Wikidata items"), tr("Add Tag"), tr("Cancel")); 40 42 this.selector = new Selector(); 41 43 this.selector.setDblClickListener(e -> buttonAction(0, null)); … … 97 99 return; 98 100 } 99 final Wiki pediaApp.WikidataEntry selected = selector.getSelectedItem();101 final WikidataEntry selected = selector.getSelectedItem(); 100 102 if (selected == null) { 101 103 return; … … 106 108 } 107 109 108 private static class Selector extends WikiSearchTextResultListPanel<Wiki pediaApp.WikidataEntry> {110 private static class Selector extends WikiSearchTextResultListPanel<WikidataEntry> { 109 111 110 112 Selector() { … … 113 115 @Override 114 116 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 115 final Wiki pediaApp.WikidataEntry entry = (WikipediaApp.WikidataEntry) value;117 final WikidataEntry entry = (WikidataEntry) value; 116 118 final String labelText = "<html>" + entry.getLabelText(); 117 119 return super.getListCellRendererComponent(list, labelText, index, isSelected, cellHasFocus); … … 124 126 final String query = edSearchText.getText(); 125 127 debouncer.debounce(getClass(), () -> { 126 final List<Wiki pediaApp.WikidataEntry> entries = query == null || query.isEmpty()128 final List<WikidataEntry> entries = query == null || query.isEmpty() 127 129 ? Collections.emptyList() 128 130 : WikipediaApp.getWikidataEntriesForQuery(WikipediaToggleDialog.wikipediaLang.get(), query, Locale.getDefault()); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikidataTagCellRenderer.java
r32884 r32887 1 package org.wikipedia ;1 package org.wikipedia.gui; 2 2 3 3 import java.awt.Component; … … 21 21 import org.openstreetmap.josm.gui.util.GuiHelper; 22 22 import org.openstreetmap.josm.tools.Utils; 23 import org.wikipedia.WikipediaApp; 24 import org.wikipedia.data.WikidataEntry; 23 25 24 26 public class WikidataTagCellRenderer extends DefaultTableCellRenderer { … … 74 76 return null; 75 77 } 76 texts.add(Wiki pediaApp.WikidataEntry.getLabelText(id, label));78 texts.add(WikidataEntry.getLabelText(id, label)); 77 79 } 78 80 component.setText("<html>" + texts.stream().collect(Collectors.joining("; "))); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikipediaCategorySearchDialog.java
r32884 r32887 1 1 // License: GPL. For details, see LICENSE file. 2 package org.wikipedia ;2 package org.wikipedia.gui; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 12 12 import org.openstreetmap.josm.gui.ExtendedDialog; 13 13 import org.openstreetmap.josm.gui.util.GuiHelper; 14 import org.wikipedia.WikipediaApp; 14 15 15 publicfinal class WikipediaCategorySearchDialog extends ExtendedDialog {16 final class WikipediaCategorySearchDialog extends ExtendedDialog { 16 17 17 18 private final Selector selector; … … 45 46 } 46 47 47 publicString getCategory() {48 String getCategory() { 48 49 return selector.getSelectedItem(); 49 50 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikipediaToggleDialog.java
r32884 r32887 1 1 // License: GPL. See LICENSE file for details. 2 package org.wikipedia ;2 package org.wikipedia.gui; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 42 42 import org.openstreetmap.josm.tools.LanguageInfo; 43 43 import org.openstreetmap.josm.tools.OpenBrowser; 44 import org.wikipedia.WikipediaApp.WikipediaEntry; 44 import org.wikipedia.WikipediaApp; 45 import org.wikipedia.actions.FetchWikidataAction; 46 import org.wikipedia.data.WikipediaEntry; 45 47 46 48 public class WikipediaToggleDialog extends ToggleDialog implements ActiveLayerChangeListener, DataSetListenerAdapter.Listener { -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/tools/Debouncer.java
r32884 r32887 1 package org.wikipedia ;1 package org.wikipedia.tools; 2 2 3 3 import java.util.concurrent.ConcurrentHashMap; -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/tools/XPath.java
r32884 r32887 1 1 // License: GPL. See LICENSE file for details./* 2 package org.wikipedia ;2 package org.wikipedia.tools; 3 3 4 4 import org.w3c.dom.Node; -
applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/WikipediaAppTest.java
r32884 r32887 1 1 package org.wikipedia; 2 2 3 import org.junit.Before;4 3 import org.junit.Rule; 5 4 import org.junit.Test; 6 import org.openstreetmap.josm.Main;7 5 import org.openstreetmap.josm.data.coor.LatLon; 8 6 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 import org.wikipedia.WikipediaApp.WikipediaEntry; 10 import org.wikipedia.WikipediaApp.WikipediaLangArticle; 7 import org.wikipedia.data.WikidataEntry; 8 import org.wikipedia.data.WikipediaEntry; 9 import org.wikipedia.data.WikipediaLangArticle; 11 10 12 11 import java.util.Arrays; … … 152 151 @Test 153 152 public void testForQuery() throws Exception { 154 final List<Wiki pediaApp.WikidataEntry> de = WikipediaApp.getWikidataEntriesForQuery("de", "Österreich", Locale.GERMAN);155 final List<Wiki pediaApp.WikidataEntry> en = WikipediaApp.getWikidataEntriesForQuery("de", "Österreich", Locale.ENGLISH);153 final List<WikidataEntry> de = WikipediaApp.getWikidataEntriesForQuery("de", "Österreich", Locale.GERMAN); 154 final List<WikidataEntry> en = WikipediaApp.getWikidataEntriesForQuery("de", "Österreich", Locale.ENGLISH); 156 155 assertThat(de.get(0).wikipediaArticle, is("Q40")); 157 156 assertThat(de.get(0).wikipediaLang, is("wikidata")); … … 191 190 // not found -> null 192 191 assertThat(WikipediaApp.getLabelForWikidata("Q" + Long.MAX_VALUE, Locale.ENGLISH), nullValue()); 193 final Wiki pediaApp.WikidataEntry q84 = new WikipediaApp.WikidataEntry("Q84", null, null, null);194 final Wiki pediaApp.WikidataEntry q1741 = new WikipediaApp.WikidataEntry("Q1741", null, null, null);195 final List<Wiki pediaApp.WikidataEntry> twoLabels = WikipediaApp.getLabelForWikidata(Arrays.asList(q84, q1741), Locale.GERMAN);192 final WikidataEntry q84 = new WikidataEntry("Q84", null, null, null); 193 final WikidataEntry q1741 = new WikidataEntry("Q1741", null, null, null); 194 final List<WikidataEntry> twoLabels = WikipediaApp.getLabelForWikidata(Arrays.asList(q84, q1741), Locale.GERMAN); 196 195 assertThat(twoLabels.get(0).label, is("London")); 197 196 assertThat(twoLabels.get(1).label, is("Wien")); -
applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/gui/WikidataTagCellRendererTest.java
r32884 r32887 1 package org.wikipedia ;1 package org.wikipedia.gui; 2 2 3 3 import static org.hamcrest.CoreMatchers.is; … … 14 14 import org.junit.Test; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 import org.wikipedia.gui.WikidataTagCellRenderer; 16 17 17 18 public class WikidataTagCellRendererTest {
Note:
See TracChangeset
for help on using the changeset viewer.