Class TermStatementUpdate

java.lang.Object
org.wikidata.wdtk.wikibaseapi.StatementUpdate
org.wikidata.wdtk.wikibaseapi.TermStatementUpdate

@Deprecated public class TermStatementUpdate extends StatementUpdate
Deprecated.
Use WikibaseDataEditor.editEntityDocument(EntityUpdate, boolean, String, List) instead. This class extends StatementUpdate to support update to terms (labels, descriptions and aliases). Various safeguards are implemented in this interface: - aliases are added and deleted independently - duplicate aliases cannot be added - adding an alias in a language that does not have a label sets the label instead
Author:
antonin
  • Field Details

  • Constructor Details

    • TermStatementUpdate

      public TermStatementUpdate(TermedStatementDocument currentDocument, List<Statement> addStatements, List<Statement> deleteStatements, List<MonolingualTextValue> addLabels, List<MonolingualTextValue> addDescriptions, List<MonolingualTextValue> addAliases, List<MonolingualTextValue> deleteAliases)
      Deprecated.
      Constructor. Plans an update on the statements and terms of a document. Statements are merged according to StatementUpdate's logic. Labels and descriptions will overwrite any existing values. The first aliases added on a language where no label is available yet will be treated as a label instead. Duplicate aliases are ignored.
      Parameters:
      currentDocument - the current state of the entity
      addStatements - the statements to be added to the entity.
      deleteStatements - the statements to be removed from the entity
      addLabels - the labels to be added to the entity
      addDescriptions - the descriptions to be added to the entity
      addAliases - the aliases to be added to the entity
      deleteAliases - the aliases to be removed from the entity
  • Method Details

    • initUpdatesFromCurrentValues

      protected Map<String,org.wikidata.wdtk.wikibaseapi.TermStatementUpdate.NameWithUpdate> initUpdatesFromCurrentValues(Collection<MonolingualTextValue> currentValues)
      Deprecated.
      Initializes the list of current values for a type of terms (label or description).
      Parameters:
      currentValues - current values for the type of terms
      Returns:
      a map of updates (where all terms are marked as not for write)
    • processAliases

      protected void processAliases(List<MonolingualTextValue> addAliases, List<MonolingualTextValue> deleteAliases)
      Deprecated.
      Processes changes on aliases, updating the planned state of the item.
      Parameters:
      addAliases - aliases that should be added to the document
      deleteAliases - aliases that should be removed from the document
    • deleteAlias

      protected void deleteAlias(MonolingualTextValue alias)
      Deprecated.
      Deletes an individual alias
      Parameters:
      alias - the alias to delete
    • addAlias

      protected void addAlias(MonolingualTextValue alias)
      Deprecated.
      Adds an individual alias. It will be merged with the current list of aliases, or added as a label if there is no label for this item in this language yet.
      Parameters:
      alias - the alias to add
    • processDescriptions

      protected void processDescriptions(List<MonolingualTextValue> descriptions)
      Deprecated.
      Adds descriptions to the item.
      Parameters:
      descriptions - the descriptions to add
    • processLabels

      protected void processLabels(List<MonolingualTextValue> labels)
      Deprecated.
      Adds labels to the item
      Parameters:
      labels - the labels to add
    • getLabelUpdates

      public Map<String,TermImpl> getLabelUpdates()
      Deprecated.
      Label accessor provided for JSON serialization only.
    • getDescriptionUpdates

      public Map<String,TermImpl> getDescriptionUpdates()
      Deprecated.
      Description accessor provided for JSON serialization only.
    • getAliasUpdates

      public Map<String,List<TermImpl>> getAliasUpdates()
      Deprecated.
      Alias accessor provided for JSON serialization only
    • isEmptyEdit

      public boolean isEmptyEdit()
      Deprecated.
      Is this change null? (Which means that nothing at all will be changed on the item.)
      Overrides:
      isEmptyEdit in class StatementUpdate
    • getAddedAliases

      public List<MonolingualTextValue> getAddedAliases(String language)
      Deprecated.
      Retrieves the list of aliases that will be added in a given language, after all the optimizations have been done (replacing empty labels by new aliases in the same language, for instance).
      Parameters:
      language - the language code of the added aliases
      Returns:
      the list of added aliases
    • getRemovedAliases

      public List<MonolingualTextValue> getRemovedAliases(String language)
      Deprecated.
      Retrieves the list of aliases that will be removed in a given language, after all the optimizations have been done (replacing empty labels by new aliases in the same language, for instance).
      Parameters:
      language - : the language code of the removed aliases
      Returns:
      the list of removed aliases
    • performEdit

      public TermedStatementDocument 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.
      Overrides:
      performEdit in class StatementUpdate
      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
    • getMonolingualUpdatedValues

      protected Map<String,TermImpl> getMonolingualUpdatedValues(Map<String,org.wikidata.wdtk.wikibaseapi.TermStatementUpdate.NameWithUpdate> updates)
      Deprecated.
      Helper to format term updates as expected by the Wikibase API
      Parameters:
      updates - planned updates for the type of term
      Returns:
      map ready to be serialized as JSON by Jackson
    • monolingualToJackson

      protected TermImpl monolingualToJackson(MonolingualTextValue monolingualTextValue)
      Deprecated.
      Creates a monolingual value that is suitable for JSON serialization.
      Parameters:
      monolingualTextValue - target monolingual value for serialization
      Returns:
      Jackson implementation that is serialized appropriately