public Collection<WikidataEntity> getPropertyByName(Language language, String name) throws DaoException { List<WikidataEntity> matches = new ArrayList<WikidataEntity>(); Map<Integer, WikidataEntity> props = getProperties(); for (WikidataEntity e : props.values()) { if (e.getAliases().containsKey(language) && e.getAliases().get(language).contains(name)) { matches.add(e); } else if (e.getLabels().containsKey(language) && e.getLabels().get(language).contains(name)) { matches.add(e); } } return matches; }
public Collection<WikidataEntity> getPropertyByName(Language language, String name) throws DaoException { List<WikidataEntity> matches = new ArrayList<WikidataEntity>(); Map<Integer, WikidataEntity> props = getProperties(); for (WikidataEntity e : props.values()) { if (e.getAliases().containsKey(language) && e.getAliases().get(language).contains(name)) { matches.add(e); } else if (e.getLabels().containsKey(language) && e.getLabels().get(language).contains(name)) { matches.add(e); } } return matches; }
public Collection<WikidataEntity> getPropertyByName(String name) throws DaoException { Set<WikidataEntity> matches = new HashSet<WikidataEntity>(); Map<Integer, WikidataEntity> props = getProperties(); for (WikidataEntity e : props.values()) { if (e.getLabels().values().contains(name)) { matches.add(e); continue; } if (e.getAliases().values().contains(name)) { matches.add(e); continue; } } return matches; }
public Collection<WikidataEntity> getPropertyByName(String name) throws DaoException { Set<WikidataEntity> matches = new HashSet<WikidataEntity>(); Map<Integer, WikidataEntity> props = getProperties(); for (WikidataEntity e : props.values()) { if (e.getLabels().values().contains(name)) { matches.add(e); continue; } if (e.getAliases().values().contains(name)) { matches.add(e); continue; } } return matches; }
@Override public void save(WikidataEntity entity) throws DaoException { for (Map.Entry<Language, String> entry : entity.getLabels().entrySet()) { labelLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), entry.getValue()); } for (Map.Entry<Language, String> entry : entity.getDescriptions().entrySet()) { descLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), entry.getValue()); } for (Map.Entry<Language, List<String>> entry : entity.getAliases().entrySet()) { for (String alias : entry.getValue()) { aliasLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), alias); } } for (WikidataStatement stmt : entity.getStatements()) { save(stmt); } if (entity.getType() == WikidataEntity.Type.PROPERTY) { synchronized (properties) { properties.put(entity.getId(), entity); } } }
@Override public void save(WikidataEntity entity) throws DaoException { for (Map.Entry<Language, String> entry : entity.getLabels().entrySet()) { labelLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), entry.getValue()); } for (Map.Entry<Language, String> entry : entity.getDescriptions().entrySet()) { descLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), entry.getValue()); } for (Map.Entry<Language, List<String>> entry : entity.getAliases().entrySet()) { for (String alias : entry.getValue()) { aliasLoader.load(entity.getType().code, entity.getId(), entry.getKey().getId(), alias); } } for (WikidataStatement stmt : entity.getStatements()) { save(stmt); } if (entity.getType() == WikidataEntity.Type.PROPERTY) { synchronized (properties) { properties.put(entity.getId(), entity); } } }
if (!validLanguage(vlist.get(0).getLanguageCode())) continue; Language lang = Language.getByLangCodeLenient(vlist.get(0).getLanguageCode()); record.getAliases().put(lang, new ArrayList<String>()); for (MonolingualTextValue v : vlist) { record.getAliases().get(lang).add(v.getText());
if (!validLanguage(vlist.get(0).getLanguageCode())) continue; Language lang = Language.getByLangCodeLenient(vlist.get(0).getLanguageCode()); record.getAliases().put(lang, new ArrayList<String>()); for (MonolingualTextValue v : vlist) { record.getAliases().get(lang).add(v.getText());
.and(Tables.WIKIDATA_ENTITY_ALIASES.ENTITY_ID.eq(id)) .fetch(); Map<Language, List<String>> aliases = entity.getAliases(); for (Record2<Short, String> record : result3) { Language lang = Language.getById(record.value1());
.and(Tables.WIKIDATA_ENTITY_ALIASES.ENTITY_ID.eq(id)) .fetch(); Map<Language, List<String>> aliases = entity.getAliases(); for (Record2<Short, String> record : result3) { Language lang = Language.getById(record.value1());