Class EditOnlineDataExample
IMPORTANT: Running this program will perform edits on test.wikidata.org. These edits are permanent and public. When running this program as is, the edits will be performed without logging in. This means that your current IP address will be recorded in the edit history of the page. If you prefer to use a login, please comment-in the respective line in the source code and modify it to use your credentials.
Note that all modification operations can throw an
MediaWikiApiErrorException
(if there was an API error) or
IOException
(if there was a network error, etc.). We do not handle
this here. In real applications, you may want to handle some subclasses of
MediaWikiApiErrorException
in special ways, e.g.,
EditConflictErrorException
(you tried to edit an entity that has been
modified by someone else since) and NoSuchEntityErrorException
(you
tried to modify an entity that meanwhile was deleted).
- Author:
- Markus Kroetzsch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
findSomeStringProperties
(ApiConnection connection) Finds properties of datatype string on test.wikidata.org.protected static StatementGroup
findStatementGroup
(PropertyIdValue pid, StatementDocument document) Finds theStatementGroup
for the given property in a document.static void
static void
Prints some basic documentation about this program.
-
Constructor Details
-
EditOnlineDataExample
public EditOnlineDataExample()
-
-
Method Details
-
main
-
findSomeStringProperties
public static void findSomeStringProperties(ApiConnection connection) throws MediaWikiApiErrorException, IOException Finds properties of datatype string on test.wikidata.org. Since the test site changes all the time, we cannot hardcode a specific property here. Instead, we just look through all properties starting from P1 to find the first few properties of type string that have an English label. These properties are used for testing in this code.- Parameters:
connection
-- Throws:
MediaWikiApiErrorException
IOException
-
printDocumentation
public static void printDocumentation()Prints some basic documentation about this program. -
findStatementGroup
Finds theStatementGroup
for the given property in a document.- Parameters:
pid
- the property to look fordocument
- the document to search- Returns:
- the
StatementGroup
with this property, or null if there is none
-