Class StatementUpdate

java.lang.Object
org.wikidata.wdtk.wikibaseapi.StatementUpdate
Direct Known Subclasses:
TermStatementUpdate

@Deprecated public class StatementUpdate extends Object
Deprecated.
Use WikibaseDataEditor.editEntityDocument(EntityUpdate, boolean, String, List) instead. Class to plan a statement update operation.
Author:
Markus Kroetzsch
  • Constructor Details

    • StatementUpdate

      public StatementUpdate(StatementDocument currentDocument, List<Statement> addStatements, List<Statement> deleteStatements)
      Deprecated.
      Constructor. Marks the given lists of statements for being added to or deleted from the given document, respectively. The current content of the document is compared with the requested changes to avoid duplicates (merging references of duplicate statements), and to avoid deletions of statements that have changed or ceased to exist.
      Parameters:
      currentDocument - the document with the current statements
      addStatements - the list of new statements to be added
      deleteStatements - the list of statements to be deleted
  • Method Details

    • getJsonUpdateString

      public String getJsonUpdateString()
      Deprecated.
      Returns a JSON serialization of the marked insertions and deletions of statements, in the format required by the Wikibase "wbeditentity" action.
      Returns:
      JSON serialization of updates
    • performEdit

      public StatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary, List<String> tags) throws IOException, MediaWikiApiErrorException
      Deprecated.
      Performs the update, selecting the appropriate API action depending on the nature of the change.
      Parameters:
      action - the endpoint to which the change should be pushed
      editAsBot - if true, the edit will be flagged as a "bot edit" provided that the logged in user is in the bot group; for regular users, the flag will just be ignored
      summary - 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 off
      tags - string identifiers of the tags to apply to the edit. Ignored if null or empty.
      Returns:
      the new document after update with the API
      Throws:
      MediaWikiApiErrorException
      IOException
    • getUpdatedStatements

      public List<Statement> getUpdatedStatements()
      Deprecated.
    • isEmptyEdit

      public boolean isEmptyEdit()
      Deprecated.
      Returns true when the edit is not going to change anything on the item. In this case, the change can be safely skipped, except if the side effects of a null edit are desired.
    • markStatementsForUpdate

      protected void markStatementsForUpdate(StatementDocument currentDocument, List<Statement> addStatements, List<Statement> deleteStatements)
      Deprecated.
      Marks the given lists of statements for being added to or deleted from the given document, respectively. The current content of the document is compared with the requested changes to avoid duplicates (merging references of duplicate statements), and to avoid deletions of statements that have changed or ceased to exist.
      Parameters:
      currentDocument - the document with the current statements
      addStatements - the list of new statements to be added
      deleteStatements - the list of statements to be deleted
    • markStatementsForDeletion

      protected void markStatementsForDeletion(StatementDocument currentDocument, List<Statement> deleteStatements)
      Deprecated.
      Marks the given list of statements for deletion. It is verified that the current document actually contains the statements before doing so. This check is based on exact statement equality, including qualifier order and statement id.
      Parameters:
      currentDocument - the document with the current statements
      deleteStatements - the list of statements to be deleted
    • markStatementsForInsertion

      protected void markStatementsForInsertion(StatementDocument currentDocument, List<Statement> addStatements)
      Deprecated.
      Marks a given list of statements for insertion into the current document. Inserted statements can have an id if they should update an existing statement, or use an empty string as id if they should be added. The method removes duplicates and avoids unnecessary modifications by checking the current content of the given document before marking statements for being written.
      Parameters:
      currentDocument - the document with the current statements
      addStatements - the list of new statements to be added
    • addStatement

      protected void addStatement(Statement statement, boolean isNew)
      Deprecated.
      Adds one statement to the list of statements to be kept, possibly merging it with other statements to be kept if possible. When two existing statements are merged, one of them will be updated and the other will be marked for deletion.
      Parameters:
      statement - statement to add
      isNew - if true, the statement should be marked for writing; if false, the statement already exists in the current data and is only added to remove duplicates and avoid unnecessary writes
    • mergeReferences

      protected List<Reference> mergeReferences(List<? extends Reference> references1, List<? extends Reference> references2)
      Deprecated.
      Merges two lists of references, eliminating duplicates in the process.
      Parameters:
      references1 -
      references2 -
      Returns:
      merged list
    • addBestReferenceToList

      protected void addBestReferenceToList(Reference reference, List<Reference> referenceList)
      Deprecated.
    • equivalentClaims

      protected boolean equivalentClaims(Claim claim1, Claim claim2)
      Deprecated.
      Checks if two claims are equivalent in the sense that they have the same main snak and the same qualifiers, but possibly in a different order.
      Parameters:
      claim1 -
      claim2 -
      Returns:
      true if claims are equivalent
    • isSameSnakSet

      protected boolean isSameSnakSet(Iterator<Snak> snaks1, Iterator<Snak> snaks2)
      Deprecated.
      Compares two sets of snaks, given by iterators. The method is optimised for short lists of snaks, as they are typically found in claims and references.
      Parameters:
      snaks1 -
      snaks2 -
      Returns:
      true if the lists are equal
    • setGuidGenerator

      public void setGuidGenerator(GuidGenerator generator)
      Deprecated.
      Sets the GUID generator for this statement update.
    • getRevisionIdFromResponse

      protected long getRevisionIdFromResponse(com.fasterxml.jackson.databind.JsonNode response) throws com.fasterxml.jackson.core.JsonProcessingException
      Deprecated.
      Extracts the last revision id from the JSON response returned by the API after an edit
      Parameters:
      response - the response as returned by Mediawiki
      Returns:
      the new revision id of the edited entity
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • getDatamodelObjectFromResponse

      protected <T> T getDatamodelObjectFromResponse(com.fasterxml.jackson.databind.JsonNode response, List<String> path, Class<T> targetClass) throws com.fasterxml.jackson.core.JsonProcessingException
      Deprecated.
      Extracts a particular data model instance from a JSON response returned by MediaWiki. The location is described by a list of successive fields to use, from the root to the target object.
      Parameters:
      response - the API response as returned by MediaWiki
      path - a list of fields from the root to the target object
      Returns:
      the parsed POJO object
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException