Package org.openrefine.wikibase.editing
Class ReconEntityRewriter
- java.lang.Object
-
- org.wikidata.wdtk.datamodel.helpers.DatamodelConverter
-
- org.openrefine.wikibase.editing.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 anTermedStatementEntityEdit
, 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, anIllegalArgumentException
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ReconEntityRewriter.MissingEntityIdFound
Unchecked version ofNewEntityNotCreatedYetException
, for internal use only.
-
Field Summary
Fields Modifier and Type Field Description protected static String
notCreatedYetMessage
-
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
-
-
-
-
Field Detail
-
notCreatedYetMessage
protected static final String notCreatedYetMessage
- See Also:
- Constant Field Values
-
-
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 createdsubject
- 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 classorg.wikidata.wdtk.datamodel.helpers.DatamodelConverter
-
copy
public org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue copy(org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue value)
- Overrides:
copy
in classorg.wikidata.wdtk.datamodel.helpers.DatamodelConverter
-
copy
public org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue copy(org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue value)
- Overrides:
copy
in classorg.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 interfaceorg.wikidata.wdtk.datamodel.interfaces.ValueVisitor<org.wikidata.wdtk.datamodel.interfaces.Value>
- Overrides:
visit
in classorg.wikidata.wdtk.datamodel.helpers.DatamodelConverter
-
copy
public StatementEdit copy(StatementEdit value)
-
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
-
-