Package org.openrefine.wikibase.updates
Class MediaInfoEdit
- java.lang.Object
-
- org.openrefine.wikibase.updates.LabeledStatementEntityEdit
-
- org.openrefine.wikibase.updates.MediaInfoEdit
-
- All Implemented Interfaces:
EntityEdit
,StatementEntityEdit
public class MediaInfoEdit extends LabeledStatementEntityEdit
Represents a candidate edit on a MediaInfo entity.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description protected String
fileName
protected String
filePath
protected boolean
overrideWikitext
protected String
wikitext
-
Fields inherited from class org.openrefine.wikibase.updates.LabeledStatementEntityEdit
contributingRowIds, id, labels, labelsIfNew, statements
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MediaInfoEdit(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, String filePath, String fileName, String wikitext, boolean overrideWikitext, Set<Long> contributingRowIds)
Protected constructor to avoid re-constructing term maps when merging two entity updates.MediaInfoEdit(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, String filePath, String fileName, String wikitext, boolean overrideWikitext, Set<Long> contributingRowIds)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
String
getFileName()
String
getFilePath()
String
getWikitext()
int
hashCode()
boolean
isEmpty()
boolean
isOverridingWikitext()
MediaInfoEdit
merge(EntityEdit otherEdit)
Merges all the changes in other with this instance.boolean
requiresFetchingExistingState()
FullMediaInfoUpdate
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.org.wikidata.wdtk.datamodel.interfaces.EntityDocument
toNewEntity()
In case the subject id is new, returns the corresponding new item document to be created.String
toString()
org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue
uploadNewFile(org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor editor, MediaFileUtils mediaFileUtils, String summary, List<String> tags)
If the update corresponds to a new file, uploads the new file, its wikitext and its metadata.-
Methods inherited from class org.openrefine.wikibase.updates.LabeledStatementEntityEdit
getContributingRowIds, getEntityId, getLabels, getLabelsIfNew, getStatementEdits, getStatementGroupEdits, getStatementGroupsForNewEntity, mergeSingleTermMaps, toStatementUpdate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openrefine.wikibase.updates.EntityEdit
isNew, isNull
-
Methods inherited from interface org.openrefine.wikibase.updates.StatementEntityEdit
getAddedStatements, getDeletedStatements
-
-
-
-
Constructor Detail
-
MediaInfoEdit
public MediaInfoEdit(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, String filePath, String fileName, String wikitext, boolean overrideWikitext, 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 existsfilePath
- the path of the file to uploadfileName
- the desired file name on the wiki (File:…)wikitext
- the wikitext to associate to the file (depending on overriding settings)overrideWikitext
- whether the supplied wikitext should override any existing one
-
MediaInfoEdit
protected MediaInfoEdit(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, String filePath, String fileName, String wikitext, boolean overrideWikitext, 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 existsfilePath
- the path of the file to uploadfileName
- the desired file name on the wiki (File:…)wikitext
- the wikitext to associate to the file (depending on overriding settings)overrideWikitext
- whether the supplied wikitext should override any existing one
-
-
Method Detail
-
getFilePath
public String getFilePath()
-
getFileName
public String getFileName()
-
getWikitext
public String getWikitext()
-
isOverridingWikitext
public boolean isOverridingWikitext()
-
toEntityUpdate
public FullMediaInfoUpdate toEntityUpdate(org.wikidata.wdtk.datamodel.interfaces.EntityDocument entityDocument)
Description copied from interface:EntityEdit
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. IfEntityEdit.requiresFetchingExistingState()
returns false, then this parameter may be null, as it should not be required to compute theEntityUpdate
.
-
merge
public MediaInfoEdit merge(EntityEdit otherEdit)
Description copied from interface:EntityEdit
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
public org.wikidata.wdtk.datamodel.interfaces.EntityDocument toNewEntity()
Description copied from interface:EntityEdit
In case the subject id is new, returns the corresponding new item document to be created. Throws a validation exception otherwise.
-
uploadNewFile
public org.wikidata.wdtk.datamodel.interfaces.MediaInfoIdValue uploadNewFile(org.wikidata.wdtk.wikibaseapi.WikibaseDataEditor editor, MediaFileUtils mediaFileUtils, String summary, List<String> tags) throws org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException, IOException
If the update corresponds to a new file, uploads the new file, its wikitext and its metadata.- Parameters:
editor
- theWikibaseDataEditor
to usemediaFileUtils
- theMediaFileUtils
to usesummary
- the edit summarytags
- the tags to apply to both edits- Returns:
- the id of the created entity
- Throws:
org.wikidata.wdtk.wikibaseapi.apierrors.MediaWikiApiErrorException
IOException
-
isEmpty
public 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.
-
requiresFetchingExistingState
public 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.
-
-