Package org.openrefine.wikibase.updates
Interface EntityEdit
-
- All Known Subinterfaces:
StatementEntityEdit
- All Known Implementing Classes:
ItemEdit,LabeledStatementEntityEdit,MediaInfoEdit,TermedStatementEntityEdit
public interface EntityEditA class to plan an update of an entity, after evaluating the schema but before fetching the current content of the entity (this is why it does not extendEntityUpdate).- Author:
- Antonin Delpeuch
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Set<Long>getContributingRowIds()The set of row ids which contributed to generate this entity edit.org.wikidata.wdtk.datamodel.interfaces.EntityIdValuegetEntityId()The id of the entity being editedstatic Map<org.wikidata.wdtk.datamodel.interfaces.EntityIdValue,EntityEdit>groupBySubject(List<EntityEdit> entityDocuments)Group a list ofEntityUpdates by subject: this is useful to make one single edit per entity.booleanisEmpty()default booleanisNew()Is this update about a new entity?default booleanisNull()EntityEditmerge(EntityEdit otherEdit)Merges all the changes in other with this instance.default booleanrequiresFetchingExistingState()org.wikidata.wdtk.datamodel.interfaces.EntityUpdatetoEntityUpdate(org.wikidata.wdtk.datamodel.interfaces.EntityDocument entityDocument)In case the subject id is not new, returns the corresponding update given the current state of the entity.org.wikidata.wdtk.datamodel.interfaces.EntityDocumenttoNewEntity()In case the subject id is new, returns the corresponding new item document to be created.
-
-
-
Method Detail
-
getEntityId
org.wikidata.wdtk.datamodel.interfaces.EntityIdValue getEntityId()
The id of the entity being edited
-
getContributingRowIds
Set<Long> getContributingRowIds()
The set of row ids which contributed to generate this entity edit.
-
toEntityUpdate
org.wikidata.wdtk.datamodel.interfaces.EntityUpdate toEntityUpdate(org.wikidata.wdtk.datamodel.interfaces.EntityDocument entityDocument)
In case the subject id is not new, returns the corresponding update given the current state of the entity. Throws a validation exception otherwise.- Parameters:
entityDocument- The current state of the entity. IfrequiresFetchingExistingState()returns false, then this parameter may be null, as it should not be required to compute theEntityUpdate.
-
merge
EntityEdit merge(EntityEdit otherEdit)
Merges all the changes in other with this instance. Both updates should have the same subject. Changes coming from `other` have priority over changes from this instance. This instance is not modified, the merged update is returned instead.- Parameters:
otherEdit- the other change that should be merged
-
toNewEntity
org.wikidata.wdtk.datamodel.interfaces.EntityDocument toNewEntity()
In case the subject id is new, returns the corresponding new item document to be created. Throws a validation exception otherwise.
-
groupBySubject
static Map<org.wikidata.wdtk.datamodel.interfaces.EntityIdValue,EntityEdit> groupBySubject(List<EntityEdit> entityDocuments)
Group a list ofEntityUpdates by subject: this is useful to make one single edit per entity.- Parameters:
entityDocuments-- Returns:
- a map from entity ids to merged
EntityUpdatefor that id
-
isNew
default boolean isNew()
Is this update about a new entity?
-
isEmpty
boolean isEmpty()
- Returns:
- true when this change leaves the content of the document untouched. In the case of a new entity, this could still mean making an edit to create the blank entity.
-
isNull
default boolean isNull()
- Returns:
- true when this change is empty and its subject is not new
-
requiresFetchingExistingState
default boolean requiresFetchingExistingState()
- Returns:
- true when performing this edit requires fetching the current contents of the entity before making the edit. By default, this is true when making non-empty edits on existing entities. But implementations may override this, to spare the request to fetch the current entity, if that information is not necessary to compute the update.
-
-