Class ReconEntityRewriter

  • All Implemented Interfaces:
    org.wikidata.wdtk.datamodel.interfaces.SnakVisitor<org.wikidata.wdtk.datamodel.interfaces.Snak>, org.wikidata.wdtk.datamodel.interfaces.ValueVisitor<org.wikidata.wdtk.datamodel.interfaces.Value>

    public class ReconEntityRewriter
    extends org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
    A class that rewrites an TermedStatementEntityEdit, replacing reconciled entity id values by their concrete values after creation of all the new entities involved. If an entity has not been created yet, an IllegalArgumentException will be raised. The subject is treated as a special case: it is returned unchanged. This is because it is guaranteed not to appear in the update (but it does appear in the datamodel representation as the subject is passed around to the Claim objects its document contains).
    Author:
    Antonin Delpeuch
    • Constructor Summary

      Constructors 
      Constructor Description
      ReconEntityRewriter​(NewEntityLibrary library, org.wikidata.wdtk.datamodel.interfaces.EntityIdValue subject)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      StatementEdit copy​(StatementEdit value)  
      org.wikidata.wdtk.datamodel.interfaces.ItemIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue value)  
      org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue value)  
      org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue value)  
      EntityEdit rewrite​(EntityEdit edit)
      Rewrite an edit, replacing references to all entities already created by their fresh identifiers.
      org.wikidata.wdtk.datamodel.interfaces.EntityIdValue visit​(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue value)  
      • Methods inherited from class org.wikidata.wdtk.datamodel.helpers.DatamodelConverter

        copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copy, copySnak, copyValue, visit, visit, visit, visit, visit, visit, visit, visit, visit
    • Constructor Detail

      • ReconEntityRewriter

        public ReconEntityRewriter​(NewEntityLibrary library,
                                   org.wikidata.wdtk.datamodel.interfaces.EntityIdValue subject)
        Constructor. Sets up a rewriter which uses the provided library to look up ids of new entities.
        Parameters:
        library - the collection of entities already created
        subject - the subject id of the entity to rewrite
    • Method Detail

      • copy

        public org.wikidata.wdtk.datamodel.interfaces.ItemIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.ItemIdValue value)
        Overrides:
        copy in class org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
      • copy

        public org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue value)
        Overrides:
        copy in class org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
      • copy

        public org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue copy​(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue value)
        Overrides:
        copy in class org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
      • visit

        public org.wikidata.wdtk.datamodel.interfaces.EntityIdValue visit​(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue value)
        Specified by:
        visit in interface org.wikidata.wdtk.datamodel.interfaces.ValueVisitor<org.wikidata.wdtk.datamodel.interfaces.Value>
        Overrides:
        visit in class org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
      • rewrite

        public EntityEdit rewrite​(EntityEdit edit)
                           throws NewEntityNotCreatedYetException
        Rewrite an edit, replacing references to all entities already created by their fresh identifiers. The subject id might not have been created already, in which case it will be left untouched. All the other entities need to have been created already.
        Parameters:
        edit - the edit to rewrite
        Returns:
        the rewritten update
        Throws:
        NewEntityNotCreatedYetException - if any non-subject entity had not been created yet