Class MediaInfoEdit

    • Field Detail

      • filePath

        protected final String filePath
      • fileName

        protected final String fileName
      • wikitext

        protected final String wikitext
      • overrideWikitext

        protected final boolean overrideWikitext
    • 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 language
        labelsIfNew - the labels to add on the entity, only if no label for that language exists
        filePath - the path of the file to upload
        fileName - 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 update
        statements - the statements to edit
        labels - the labels to add on the entity, overriding any existing one in that language
        labelsIfNew - the labels to add on the entity, only if no label for that language exists
        filePath - the path of the file to upload
        fileName - 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. If EntityEdit.requiresFetchingExistingState() returns false, then this parameter may be null, as it should not be required to compute the EntityUpdate.
      • 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 - the WikibaseDataEditor to use
        mediaFileUtils - the MediaFileUtils to use
        summary - the edit summary
        tags - 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object