@Override public Map<String, List<LocalWikidataStatement>> getLocalStatements(LocalPage page) throws DaoException { int conceptId = getItemId(page); if (conceptId < 0) { return new HashMap<String, List<LocalWikidataStatement>>(); } return getLocalStatements(getRealLang(page.getLanguage()), WikidataEntity.Type.ITEM, conceptId); }
@Override public Map<String, List<LocalWikidataStatement>> getLocalStatements(LocalPage page) throws DaoException { int conceptId = getItemId(page); if (conceptId < 0) { return new HashMap<String, List<LocalWikidataStatement>>(); } return getLocalStatements(getRealLang(page.getLanguage()), WikidataEntity.Type.ITEM, conceptId); }
@Override public Map<String, List<LocalWikidataStatement>> getLocalStatements(Language lang, WikidataEntity.Type type, int id) throws DaoException { lang = getRealLang(lang); WikidataFilter filter = new WikidataFilter.Builder() .withEntityType(type) .withEntityId(id) .build(); Map<String, List<LocalWikidataStatement>> local = new HashMap<String, List<LocalWikidataStatement>>(); for (WikidataStatement st : get(filter)) { LocalWikidataStatement lws = getLocalStatement(lang, st); if (!local.containsKey(lws.getProperty())) { local.put(lws.getProperty(), new ArrayList<LocalWikidataStatement>()); } local.get(lws.getProperty()).add(lws); } return local; }
@Override public Map<String, List<LocalWikidataStatement>> getLocalStatements(Language lang, WikidataEntity.Type type, int id) throws DaoException { lang = getRealLang(lang); WikidataFilter filter = new WikidataFilter.Builder() .withEntityType(type) .withEntityId(id) .build(); Map<String, List<LocalWikidataStatement>> local = new HashMap<String, List<LocalWikidataStatement>>(); for (WikidataStatement st : get(filter)) { LocalWikidataStatement lws = getLocalStatement(lang, st); if (!local.containsKey(lws.getProperty())) { local.put(lws.getProperty(), new ArrayList<LocalWikidataStatement>()); } local.get(lws.getProperty()).add(lws); } return local; }
@Override public LocalWikidataStatement getLocalStatement(Language language, WikidataStatement statement) throws DaoException { language = getRealLang(language ); String item = getLabel(language, statement.getItem().getType(), statement.getItem().getId()); String prop = getLabel(language, statement.getProperty().getType(), statement.getProperty().getId()); String value = null; WikidataValue wdv = statement.getValue(); if (wdv.getType() == WikidataValue.Type.ITEM) { value = getLabel(language, WikidataEntity.Type.ITEM, wdv.getItemValue()); } else if (wdv.getValue() == null) { value = "unknown"; } else { value = wdv.getValue().toString(); } String full = item + " " + prop + " " + value; return new LocalWikidataStatement(language, statement, full, item, prop, value); }
@Override public LocalWikidataStatement getLocalStatement(Language language, WikidataStatement statement) throws DaoException { language = getRealLang(language ); String item = getLabel(language, statement.getItem().getType(), statement.getItem().getId()); String prop = getLabel(language, statement.getProperty().getType(), statement.getProperty().getId()); String value = null; WikidataValue wdv = statement.getValue(); if (wdv.getType() == WikidataValue.Type.ITEM) { value = getLabel(language, WikidataEntity.Type.ITEM, wdv.getItemValue()); } else if (wdv.getValue() == null) { value = "unknown"; } else { value = wdv.getValue().toString(); } String full = item + " " + prop + " " + value; return new LocalWikidataStatement(language, statement, full, item, prop, value); }