Package org.openrefine.wikibase.updates
Class LabeledStatementEntityEdit
- java.lang.Object
-
- org.openrefine.wikibase.updates.LabeledStatementEntityEdit
-
- All Implemented Interfaces:
EntityEdit,StatementEntityEdit
- Direct Known Subclasses:
MediaInfoEdit,TermedStatementEntityEdit
public abstract class LabeledStatementEntityEdit extends Object implements StatementEntityEdit
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Long>contributingRowIdsprotected org.wikidata.wdtk.datamodel.interfaces.EntityIdValueidprotected Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue>labelsprotected Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue>labelsIfNewprotected List<StatementEdit>statements
-
Constructor Summary
Constructors Modifier Constructor Description protectedLabeledStatementEntityEdit(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue id, List<StatementEdit> statements, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labels, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labelsIfNew, Set<Long> contributingRowIds)Protected constructor to avoid re-constructing term maps when merging two entity updates.LabeledStatementEntityEdit(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue id, List<StatementEdit> statements, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labels, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labelsIfNew, Set<Long> contributingRowIds)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete 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 editedSet<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue>getLabels()Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue>getLabelsIfNew()List<StatementEdit>getStatementEdits()Edits made to statementsList<StatementGroupEdit>getStatementGroupEdits()Groups added statements inStatementGroupEditobjects.protected List<org.wikidata.wdtk.datamodel.interfaces.StatementGroup>getStatementGroupsForNewEntity()Generates the statement groups which should appear on this entity if it is created as new.protected static voidmergeSingleTermMaps(Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> currentTerms, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> currentTermsIfNew, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> newTerms, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> newTermsIfNew)Helper function to merge dictionaries of terms to override or provide.protected org.wikidata.wdtk.datamodel.interfaces.StatementUpdatetoStatementUpdate(org.wikidata.wdtk.datamodel.interfaces.StatementDocument currentDocument)Generates the statement update given the current statement groups on the entity.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrefine.wikibase.updates.EntityEdit
isEmpty, isNew, isNull, merge, requiresFetchingExistingState, toEntityUpdate, toNewEntity
-
Methods inherited from interface org.openrefine.wikibase.updates.StatementEntityEdit
getAddedStatements, getDeletedStatements
-
-
-
-
Field Detail
-
id
protected final org.wikidata.wdtk.datamodel.interfaces.EntityIdValue id
-
statements
protected final List<StatementEdit> statements
-
labels
protected final Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labels
-
-
Constructor Detail
-
LabeledStatementEntityEdit
public LabeledStatementEntityEdit(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue id, List<StatementEdit> statements, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labels, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labelsIfNew, Set<Long> contributingRowIds)Constructor.- Parameters:
id- the subject of the document. It can be a reconciled entity value for new entities.statements- the statements to change on the entity.labels- the labels to add on the entity, overriding any existing one in that languagelabelsIfNew- the labels to add on the entity, only if no label for that language exists
-
LabeledStatementEntityEdit
protected LabeledStatementEntityEdit(org.wikidata.wdtk.datamodel.interfaces.EntityIdValue id, List<StatementEdit> statements, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labels, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> labelsIfNew, Set<Long> contributingRowIds)Protected constructor to avoid re-constructing term maps when merging two entity updates. No validation is done on the arguments, they all have to be non-null.- Parameters:
id- the subject of the updatestatements- the statements to editlabels- the labels to add on the entity, overriding any existing one in that languagelabelsIfNew- the labels to add on the entity, only if no label for that language exists
-
-
Method Detail
-
getEntityId
public org.wikidata.wdtk.datamodel.interfaces.EntityIdValue getEntityId()
Description copied from interface:EntityEditThe id of the entity being edited- Specified by:
getEntityIdin interfaceEntityEdit- Returns:
- the subject of the entity
-
getContributingRowIds
public Set<Long> getContributingRowIds()
Description copied from interface:EntityEditThe set of row ids which contributed to generate this entity edit.- Specified by:
getContributingRowIdsin interfaceEntityEdit
-
getLabels
public Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> getLabels()
- Returns:
- the list of updated labels, overriding existing ones
-
getLabelsIfNew
public Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> getLabelsIfNew()
- Returns:
- the list of updated labels, only added if new
-
getStatementEdits
public List<StatementEdit> getStatementEdits()
Description copied from interface:StatementEntityEditEdits made to statements- Specified by:
getStatementEditsin interfaceStatementEntityEdit- Returns:
- the list of statement updates
-
getStatementGroupEdits
public List<StatementGroupEdit> getStatementGroupEdits()
Description copied from interface:StatementEntityEditGroups added statements inStatementGroupEditobjects.- Specified by:
getStatementGroupEditsin interfaceStatementEntityEdit
-
getStatementGroupsForNewEntity
protected List<org.wikidata.wdtk.datamodel.interfaces.StatementGroup> getStatementGroupsForNewEntity()
Generates the statement groups which should appear on this entity if it is created as new. TODO those statements are not currently deduplicated among themselves
-
mergeSingleTermMaps
protected static void mergeSingleTermMaps(Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> currentTerms, Map<String,org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> currentTermsIfNew, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> newTerms, Set<org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue> newTermsIfNew)
Helper function to merge dictionaries of terms to override or provide.- Parameters:
currentTerms- current map of terms to overridecurrentTermsIfNew- current map of terms to provide if not already therenewTerms- new terms to overridenewTermsIfNew- new terms to provide if not already there
-
toStatementUpdate
protected org.wikidata.wdtk.datamodel.interfaces.StatementUpdate toStatementUpdate(org.wikidata.wdtk.datamodel.interfaces.StatementDocument currentDocument)
Generates the statement update given the current statement groups on the entity.- Parameters:
currentDocument-- Returns:
-
-