public class WikibaseDataFetcher extends Object
Constructor and Description |
---|
WikibaseDataFetcher(ApiConnection connection,
String siteUri)
Creates an object to fetch data from API with the given
ApiConnection object. |
Modifier and Type | Method and Description |
---|---|
EntityDocument |
getEntityDocument(String entityId)
Fetches the documents for the entity of the given string IDs.
|
EntityDocument |
getEntityDocumentByTitle(String siteKey,
String title)
Fetches the document for the entity that has a page of the given title on
the given site.
|
Map<String,EntityDocument> |
getEntityDocuments(List<String> entityIds)
Fetches the documents for the entities of the given string IDs.
|
Map<String,EntityDocument> |
getEntityDocuments(String... entityIds)
Fetches the documents for the entities of the given string IDs.
|
Map<String,EntityDocument> |
getEntityDocumentsByTitle(String siteKey,
List<String> titles)
Fetches the documents for the entities that have pages of the given
titles on the given site.
|
Map<String,EntityDocument> |
getEntityDocumentsByTitle(String siteKey,
String... titles)
Fetches the documents for the entities that have pages of the given
titles on the given site.
|
DocumentDataFilter |
getFilter()
Returns the
DocumentDataFilter object that is used to filter API
requests. |
MediaInfoIdValue |
getMediaInfoIdByFileName(String fileName)
Fetches the MediaInfoId of a file with the given name.
|
Map<String,MediaInfoIdValue> |
getMediaInfoIdsByFileName(List<String> fileNames)
Fetches the MediaInfoIds of files with the given names.
|
Map<String,MediaInfoIdValue> |
getMediaInfoIdsByFileName(String... fileNames)
Fetches the MediaInfoIds of files with the given names.
|
static WikibaseDataFetcher |
getWikidataDataFetcher()
Creates an object to fetch data from wikidata.org.
|
static WikibaseDataFetcher |
getWikimediaCommonsDataFetcher()
Creates an object to fetch data from commons.wikimedia.org.
|
List<WbSearchEntitiesResult> |
searchEntities(String search) |
List<WbSearchEntitiesResult> |
searchEntities(String search,
Long limit) |
List<WbSearchEntitiesResult> |
searchEntities(String search,
String language) |
List<WbSearchEntitiesResult> |
searchEntities(String search,
String language,
Long limit) |
List<WbSearchEntitiesResult> |
searchEntities(WbGetEntitiesSearchData properties) |
public WikibaseDataFetcher(ApiConnection connection, String siteUri)
ApiConnection
object. The site URI is necessary since it is not
contained in the data retrieved from the URI.connection
- ApiConnectionsiteUri
- the URI identifying the site that is accessed (usually the
prefix of entity URIs), e.g.,
"http://www.wikidata.org/entity/"public static WikibaseDataFetcher getWikidataDataFetcher()
ApiConnection
that is not logged in. To
use an existing connection, the constructor
WikibaseDataFetcher(ApiConnection, String)
should be called,
using Datamodel.SITE_WIKIDATA
as a site URI.public static WikibaseDataFetcher getWikimediaCommonsDataFetcher()
ApiConnection
that is not logged in. To
use an existing connection, the constructor
WikibaseDataFetcher(ApiConnection, String)
should be called,
using Datamodel.SITE_WIKIMEDIA_COMMONS
as a site URI.public DocumentDataFilter getFilter()
DocumentDataFilter
object that is used to filter API
requests. Settings made in this object will affect the API request, and
often lead to reduced network traffic and better performance.
Note: Filtering individual properties is currently not supported (such filters will be ignored). However, filtering all properties is possible; in this case all statements are excluded.
public EntityDocument getEntityDocument(String entityId) throws MediaWikiApiErrorException, IOException
EntityDocument
or null if the data could not be fetched.entityId
- string IDs (e.g., "P31" or "Q42") of requested entityMediaWikiApiErrorException
IOException
public Map<String,EntityDocument> getEntityDocuments(String... entityIds) throws MediaWikiApiErrorException, IOException
EntityDocument
objects. It is
possible that a requested ID could not be found: then this key is not set
in the map.entityIds
- string IDs (e.g., "P31", "Q42") of requested entitiesMediaWikiApiErrorException
IOException
public Map<String,EntityDocument> getEntityDocuments(List<String> entityIds) throws MediaWikiApiErrorException, IOException
EntityDocument
objects. It is
possible that a requested ID could not be found: then this key is not set
in the map.entityIds
- list of string IDs (e.g., "P31", "Q42") of requested entitiesMediaWikiApiErrorException
IOException
public EntityDocument getEntityDocumentByTitle(String siteKey, String title) throws MediaWikiApiErrorException, IOException
Note: This method will not work properly if a filter is set for sites that excludes the requested site.
siteKey
- wiki site id, e.g., "enwiki"title
- string titles (e.g. "Douglas Adams") of requested entitiesMediaWikiApiErrorException
IOException
public Map<String,EntityDocument> getEntityDocumentsByTitle(String siteKey, String... titles) throws MediaWikiApiErrorException, IOException
Note: This method will not work properly if a filter is set for sites that excludes the requested site.
siteKey
- wiki site id, e.g. "enwiki"titles
- list of string titles (e.g. "Douglas Adams") of requested
entitiesMediaWikiApiErrorException
IOException
public Map<String,EntityDocument> getEntityDocumentsByTitle(String siteKey, List<String> titles) throws MediaWikiApiErrorException, IOException
Note: This method will not work properly if a filter is set for sites that excludes the requested site.
siteKey
- wiki site id, e.g. "enwiki"titles
- list of string titles (e.g. "Douglas Adams") of requested
entitiesMediaWikiApiErrorException
IOException
public MediaInfoIdValue getMediaInfoIdByFileName(String fileName) throws IOException, MediaWikiApiErrorException
getEntityDocumentByTitle(String siteKey, String title)
fileName
- file name (e.g. "File:Albert Einstein Head.jpg" or "Albert Einstein Head.jpg")
of the requested MediaInfoId, the "File:" prefix can be omittedIOException
MediaWikiApiErrorException
public Map<String,MediaInfoIdValue> getMediaInfoIdsByFileName(String... fileNames) throws IOException, MediaWikiApiErrorException
getEntityDocumentsByTitle(String siteKey, String... titles)
fileNames
- list of file names of the requested MediaInfoIdsIOException
MediaWikiApiErrorException
public Map<String,MediaInfoIdValue> getMediaInfoIdsByFileName(List<String> fileNames) throws IOException, MediaWikiApiErrorException
getEntityDocumentsByTitle(String siteKey, List titles)
fileNames
- list of file names of the requested MediaInfoIdsIOException
MediaWikiApiErrorException
public List<WbSearchEntitiesResult> searchEntities(String search) throws MediaWikiApiErrorException, IOException
public List<WbSearchEntitiesResult> searchEntities(String search, String language) throws MediaWikiApiErrorException, IOException
public List<WbSearchEntitiesResult> searchEntities(String search, Long limit) throws MediaWikiApiErrorException, IOException
public List<WbSearchEntitiesResult> searchEntities(String search, String language, Long limit) throws MediaWikiApiErrorException, IOException
public List<WbSearchEntitiesResult> searchEntities(WbGetEntitiesSearchData properties) throws MediaWikiApiErrorException, IOException
Copyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage