public class WbEditingAction extends Object
Constructor and Description |
---|
WbEditingAction(ApiConnection connection,
String siteIri)
Creates an object to modify data on a Wikibase site.
|
Modifier and Type | Method and Description |
---|---|
int |
getAverageTimePerEdit()
Returns the average time in milliseconds that one edit will take.
|
double |
getCurrentLag()
Retrieves the current lag from the target site, by making an API call.
|
protected EntityDocument |
getEntityDocumentFromResponse(com.fasterxml.jackson.databind.JsonNode root)
TODO: TO BE REFACTORED
|
int |
getMaxLag()
Returns the current value of the maxlag parameter.
|
double |
getMaxLagBackOffFactor()
Factor by which the wait time between two maxlag retries should be
multiplied at each attempt.
|
int |
getMaxLagFirstWaitTime()
Initial wait time in milliseconds, when an edit fails for the first
time because of a high lag.
|
int |
getMaxLagMaxRetries()
Number of times we should retry if an editing action fails because
the lag is too high.
|
int |
getRemainingEdits()
Returns the number of edits that will be performed before entering
simulation mode, or -1 if there is no limit on the number of edits
(default).
|
void |
setAverageTimePerEdit(int milliseconds)
Sets the average time that a single edit should take, measured in
milliseconds.
|
void |
setMaxLag(int maxLag)
Set the value of the maxlag parameter.
|
void |
setMaxLagBackOffFactor(double value)
Factor by which the wait time between two maxlag retries should be
multiplied at each attempt.
|
void |
setMaxLagFirstWaitTime(int time)
Initial wait time in milliseconds, when an edit fails for the first
time because of a high lag.
|
void |
setMaxLagMaxRetries(int retries)
Number of times we should retry if an editing action fails because
the lag is too high.
|
void |
setRemainingEdits(int remainingEdits)
Sets the number of edits that this object can still perform.
|
EntityDocument |
wbEditEntity(String id,
String site,
String title,
String newEntity,
String data,
boolean clear,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbeditentity" for the given parameters.
|
com.fasterxml.jackson.databind.JsonNode |
wbRemoveClaims(List<String> statementIds,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbremoveclaims" for the given parameters.
|
com.fasterxml.jackson.databind.JsonNode |
wbSetAliases(String id,
String site,
String title,
String newEntity,
String language,
List<String> add,
List<String> remove,
List<String> set,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbsetaliases" for the given parameters.
|
com.fasterxml.jackson.databind.JsonNode |
wbSetClaim(String statement,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbsetclaim" for the given parameters.
|
com.fasterxml.jackson.databind.JsonNode |
wbSetDescription(String id,
String site,
String title,
String newEntity,
String language,
String value,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbsetlabel" for the given parameters.
|
com.fasterxml.jackson.databind.JsonNode |
wbSetLabel(String id,
String site,
String title,
String newEntity,
String language,
String value,
boolean bot,
long baserevid,
String summary,
List<String> tags)
Executes the API action "wbsetlabel" for the given parameters.
|
public WbEditingAction(ApiConnection connection, String siteIri)
connection
- ApiConnection
Object to send the requestssiteIri
- the URI identifying the site that is accessed (usually the
prefix of entity URIs), e.g.,
"http://www.wikidata.org/entity/"public int getMaxLag()
public void setMaxLag(int maxLag)
getMaxLag()
for details.maxLag
- the new value in secondspublic int getRemainingEdits()
public void setRemainingEdits(int remainingEdits)
remainingEdits
- number of edits that can still be performed, or -1 to disable
this limit (default setting)public int getAverageTimePerEdit()
public void setAverageTimePerEdit(int milliseconds)
getAverageTimePerEdit()
for details.milliseconds
- the new value in millisecondspublic EntityDocument wbEditEntity(String id, String site, String title, String newEntity, String data, boolean clear, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
Unless the parameter clear is true, data of existing entities will be modified or added, but not deleted. For labels, descriptions, and aliases, this happens by language. In particular, if an item has English and German aliases, and an edit action writes a new English alias, then this new alias will replace all previously existing English aliases, while the German aliases will remain untouched. In contrast, adding statements for a certain property will not delete existing statements of this property. In fact, it is even possible to create many copies of the exact same statement. A special JSON syntax exists for deleting specific statements.
See the online API documentation for further information.
TODO: There is currently no way to delete the label, description, or aliases for a particular language without clearing all data. Empty strings are not accepted. One might achieve this by adapting the JSON serialization to produce null values for such strings, and for alias lists that contain only such strings.
id
- the id of the entity to be edited; if used, the site and title
parameters must be nullsite
- when selecting an entity by title, the site key for the title,
e.g., "enwiki"; if used, title must also be given but id must
be nulltitle
- string used to select an entity by title; if used, site must
also be given but id must be nullnewEntity
- used for creating a new entity of a given type; the value
indicates the intended entity type; possible values include
"item" and "property"; if used, the parameters id, site, and
title must be nulldata
- JSON representation of the data that is to be written; this is
a mandatory parameterclear
- if true, existing data will be cleared (deleted) before
writing the new databot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorpublic com.fasterxml.jackson.databind.JsonNode wbSetLabel(String id, String site, String title, String newEntity, String language, String value, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
id
- the id of the entity to be edited; if used, the site and title
parameters must be nullsite
- when selecting an entity by title, the site key for the title,
e.g., "enwiki"; if used, title must also be given but id must
be nulltitle
- string used to select an entity by title; if used, site must
also be given but id must be nullnewEntity
- used for creating a new entity of a given type; the value
indicates the intended entity type; possible values include
"item" and "property"; if used, the parameters id, site, and
title must be nulllanguage
- the language code for the labelvalue
- the value of the label to set. Set it to null to remove the label.bot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorIOException
MediaWikiApiErrorException
public com.fasterxml.jackson.databind.JsonNode wbSetDescription(String id, String site, String title, String newEntity, String language, String value, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
id
- the id of the entity to be edited; if used, the site and title
parameters must be nullsite
- when selecting an entity by title, the site key for the title,
e.g., "enwiki"; if used, title must also be given but id must
be nulltitle
- string used to select an entity by title; if used, site must
also be given but id must be nullnewEntity
- used for creating a new entity of a given type; the value
indicates the intended entity type; possible values include
"item" and "property"; if used, the parameters id, site, and
title must be nulllanguage
- the language code for the labelvalue
- the value of the label to set. Set it to null to remove the label.bot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorIOException
MediaWikiApiErrorException
public com.fasterxml.jackson.databind.JsonNode wbSetAliases(String id, String site, String title, String newEntity, String language, List<String> add, List<String> remove, List<String> set, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
id
- the id of the entity to be edited; if used, the site and title
parameters must be nullsite
- when selecting an entity by title, the site key for the title,
e.g., "enwiki"; if used, title must also be given but id must
be nulltitle
- string used to select an entity by title; if used, site must
also be given but id must be nullnewEntity
- used for creating a new entity of a given type; the value
indicates the intended entity type; possible values include
"item" and "property"; if used, the parameters id, site, and
title must be nulllanguage
- the language code for the labeladd
- the values of the aliases to add. They will be merged with the
existing aliases. This parameter cannot be used in conjunction
with "set".remove
- the values of the aliases to remove. Other aliases will be retained.
This parameter cannot be used in conjunction with "set".set
- the values of the aliases to set. This will erase any existing
aliases in this language and replace them by the given list.bot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorIOException
MediaWikiApiErrorException
public com.fasterxml.jackson.databind.JsonNode wbSetClaim(String statement, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
statement
- the JSON serialization of claim to add or delete.bot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorIOException
MediaWikiApiErrorException
public com.fasterxml.jackson.databind.JsonNode wbRemoveClaims(List<String> statementIds, boolean bot, long baserevid, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
statementIds
- the statement ids to deletebot
- if true, edits will be flagged as "bot edits" provided that
the logged in user is in the bot group; for regular users, the
flag will just be ignoredbaserevid
- the revision of the data that the edit refers to or 0 if this
should not be submitted; when used, the site will ensure that
no edit has happened since this revision to detect edit
conflicts; it is recommended to use this whenever in all
operations where the outcome depends on the state of the
online datasummary
- summary for the edit; will be prepended by an automatically
generated comment; the length limit of the autocomment
together with the summary is 260 characters: everything above
that limit will be cut offtags
- string identifiers of the tags to apply to the edit. Ignored if null.IOException
- if there was an IO problem. such as missing network
connectionMediaWikiApiErrorException
- if the API returns an errorIOException
MediaWikiApiErrorException
protected EntityDocument getEntityDocumentFromResponse(com.fasterxml.jackson.databind.JsonNode root) throws IOException
root
- IOException
public int getMaxLagMaxRetries()
public void setMaxLagMaxRetries(int retries)
public int getMaxLagFirstWaitTime()
public void setMaxLagFirstWaitTime(int time)
public double getMaxLagBackOffFactor()
public void setMaxLagBackOffFactor(double value)
public double getCurrentLag() throws IOException, MediaWikiApiErrorException
MediaWikiApiErrorException
- when an unexpected MediaWiki API error happened (not the spurious
one normally returned by MediaWiki when retrieving lag).IOException
- when communication with the server failed.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