/** * Constructor. Marks the given lists of statements for being added to or * deleted from the given document, respectively. The current content of the * document is compared with the requested changes to avoid duplicates * (merging references of duplicate statements), and to avoid deletions of * statements that have changed or ceased to exist. * * @param currentDocument * the document with the current statements * @param addStatements * the list of new statements to be added * @param deleteStatements * the list of statements to be deleted */ public StatementUpdate(StatementDocument currentDocument, List<Statement> addStatements, List<Statement> deleteStatements) { this.currentDocument = currentDocument; this.toKeep = new HashMap<>(); this.toDelete = new ArrayList<>(); markStatementsForUpdate(currentDocument, addStatements, deleteStatements); this.mapper = new DatamodelMapper(currentDocument.getEntityId().getSiteIri()); }
/** * Constructor. Marks the given lists of statements for being added to or * deleted from the given document, respectively. The current content of the * document is compared with the requested changes to avoid duplicates * (merging references of duplicate statements), and to avoid deletions of * statements that have changed or ceased to exist. * * @param currentDocument * the document with the current statements * @param addStatements * the list of new statements to be added * @param deleteStatements * the list of statements to be deleted */ public StatementUpdate(StatementDocument currentDocument, List<Statement> addStatements, List<Statement> deleteStatements) { this.currentDocument = currentDocument; this.toKeep = new HashMap<>(); this.toDelete = new ArrayList<>(); markStatementsForUpdate(currentDocument, addStatements, deleteStatements); this.mapper = new DatamodelMapper(currentDocument.getEntityId().getSiteIri()); }
/** * Performs a null edit on an entity. This has some effects on Wikibase, * such as refreshing the labels of the referred items in the UI. * * @param currentDocument * the document to perform a null edit on * @throws MediaWikiApiErrorException * if the API returns errors * @throws IOException * if there are any IO errors, such as missing network connection */ @SuppressWarnings("unchecked") public <T extends StatementDocument> T nullEdit(T currentDocument) throws IOException, MediaWikiApiErrorException { StatementUpdate statementUpdate = new StatementUpdate(currentDocument, Collections.<Statement>emptyList(), Collections.<Statement>emptyList()); statementUpdate.setGuidGenerator(guidGenerator); return (T) this.wbEditingAction.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, statementUpdate .getJsonUpdateString(), false, this.editAsBot, currentDocument .getRevisionId(), null); } }
/** * Performs a null edit on an entity. This has some effects on Wikibase, * such as refreshing the labels of the referred items in the UI. * * @param currentDocument * the document to perform a null edit on * @throws MediaWikiApiErrorException * if the API returns errors * @throws IOException * if there are any IO errors, such as missing network connection */ @SuppressWarnings("unchecked") public <T extends StatementDocument> T nullEdit(T currentDocument) throws IOException, MediaWikiApiErrorException { StatementUpdate statementUpdate = new StatementUpdate(currentDocument, Collections.<Statement>emptyList(), Collections.<Statement>emptyList()); statementUpdate.setGuidGenerator(guidGenerator); return (T) this.wbEditingAction.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, statementUpdate .getJsonUpdateString(), false, this.editAsBot, currentDocument .getRevisionId(), null); } }
statement = statement.withStatementId(guidGenerator.freshStatementId(currentDocument.getEntityId().getId())); } else { return (StatementDocument) action.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, getJsonUpdateString(), false, editAsBot, currentDocument .getRevisionId(), summary);
statement = statement.withStatementId(guidGenerator.freshStatementId(currentDocument.getEntityId().getId())); } else { return (StatementDocument) action.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, getJsonUpdateString(), false, editAsBot, currentDocument .getRevisionId(), summary);
} else { return (T) this.wbEditingAction.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, statementUpdate .getJsonUpdateString(), false, this.editAsBot, currentDocument .getRevisionId(), summary);
} else { return (T) this.wbEditingAction.wbEditEntity(currentDocument .getEntityId().getId(), null, null, null, statementUpdate .getJsonUpdateString(), false, this.editAsBot, currentDocument .getRevisionId(), summary);