public class FixIntegerQuantityPrecisionsBot extends Object implements EntityDocumentProcessor
The activity of the bot is logged in the file bot-log-fixintprec-TIMESTAMP.txt. Note that this log contains all edits that would have been made, even if editing was disabled. Errors are logged to the console only.
By default, this program has the actual editing disabled (see source code), so as to avoid accidental modifications. The output will still mention changes that would be done. If you want to do real edits, please respect the bot etiquette and community guidelines.
The function of the bot is very basic, but it illustrates some important techniques:
Constructor and Description |
---|
FixIntegerQuantityPrecisionsBot()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
finish()
Finishes processing and makes sure that the log file is written.
|
protected void |
fixIntegerPrecisions(ItemIdValue itemIdValue,
String propertyId)
Fetches the current online data for the given item, and fixes the
precision of integer quantities if necessary.
|
protected boolean |
hasPlusMinusOneValues(StatementGroup statementGroup)
Checks if the given statement group contains at least one value of
precision +/-1.
|
protected boolean |
isPlusMinusOneValue(QuantityValue quantityValue)
Checks if the given value is a number with precision +/-1.
|
protected void |
logEntityModification(EntityIdValue entityId,
List<Statement> updateStatements,
String propertyId)
Logs information about entities changed so far.
|
static void |
main(String[] args)
Main method to run the bot.
|
static void |
printDocumentation()
Prints some basic documentation about this program.
|
void |
processItemDocument(ItemDocument itemDocument)
Processes the given ItemDocument.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processEntityRedirectDocument, processLexemeDocument, processMediaInfoDocument, processPropertyDocument
public FixIntegerQuantityPrecisionsBot() throws LoginFailedException, IOException
LoginFailedException
IOException
public static void main(String[] args) throws LoginFailedException, IOException
args
- LoginFailedException
IOException
public static void printDocumentation()
public void processItemDocument(ItemDocument itemDocument)
EntityDocumentProcessor
processItemDocument
in interface EntityDocumentProcessor
itemDocument
- the ItemDocumentpublic void finish()
protected void fixIntegerPrecisions(ItemIdValue itemIdValue, String propertyId)
itemIdValue
- the id of the document to inspectpropertyId
- id of the property to considerprotected void logEntityModification(EntityIdValue entityId, List<Statement> updateStatements, String propertyId)
entityId
- the id of the modified itemupdateStatements
- propertyId
- protected boolean isPlusMinusOneValue(QuantityValue quantityValue)
quantityValue
- protected boolean hasPlusMinusOneValues(StatementGroup statementGroup)
statementGroup
- 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