@JsonProperty("entity") String getEntityJson() { return entityId.getId(); }
/** * Writes OWL declarations for classes that have been added recently. * Declared classes are stored so that duplicate declarations are avoided. * * @param rdfWriter * the writer to write the declarations to * @throws RDFHandlerException * if there was a problem writing the declarations */ public void writeClassDeclarations(RdfWriter rdfWriter) throws RDFHandlerException { for (EntityIdValue entityIdValue : this.classEntityQueue) { if (!this.declaredClassEntities.add(entityIdValue)) { continue; } rdfWriter.writeTripleValueObject(entityIdValue.getIri(), RdfWriter.RDF_TYPE, RdfWriter.OWL_CLASS); } this.classEntityQueue.clear(); }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(EntityIdValue o) { int result; result = o.getId().hashCode(); result = prime * result + o.getSiteIri().hashCode(); result = prime * result + o.getEntityType().hashCode(); return result; }
/** * Constructor. * * @param id * the identifier of the subject of this document * @param revisionId * the id of the last revision of this document */ EntityDocumentImpl(EntityIdValue id, long revisionId) { Validate.notNull(id); this.entityId = id.getId(); this.siteIri = id.getSiteIri(); this.revisionId = revisionId; }
@Override public WikidataValue visit(EntityIdValue value) { if (value.getEntityType().equals(EntityIdValue.ET_ITEM)) { return WikidataValue.forItem(Integer.valueOf(value.getId().substring(1))); } else if (value.getEntityType().equals(EntityIdValue.ET_PROPERTY)) { return WikidataValue.forProperty(Integer.valueOf(value.getId().substring(1))); } else { throw new IllegalArgumentException("Unknown entity type: " + value.getEntityType()); } }
/** * Constructor. * * @param id * the identifier of the subject of this document * @param targetId * the identifier of the entity this document redirect to * @param revisionId * the id of the last revision of this document */ EntityRedirectDocumentImpl(EntityIdValue id, EntityIdValue targetId, long revisionId) { Validate.notNull(id); this.entityId = id; Validate.notNull(targetId); Validate.isTrue(id.getEntityType().equals(targetId.getEntityType()), "You could only do redirects between entities of the same type"); this.targetId = targetId; this.revisionId = revisionId; }
/** * 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()); }
@Override public WikidataValue visit(EntityIdValue value) { if (value.getEntityType().equals(EntityIdValue.ET_ITEM)) { return WikidataValue.forItem(Integer.valueOf(value.getId().substring(1))); } else if (value.getEntityType().equals(EntityIdValue.ET_PROPERTY)) { return WikidataValue.forProperty(Integer.valueOf(value.getId().substring(1))); } else { throw new IllegalArgumentException("Unknown entity type: " + value.getEntityType()); } }
/** * Constructor. * * @param id * the identifier of the subject of this document * @param revisionId * the id of the last revision of this document */ EntityDocumentImpl(EntityIdValue id, long revisionId) { Validate.notNull(id); this.entityId = id.getId(); this.siteIri = id.getSiteIri(); this.revisionId = revisionId; }
/** * Constructor. * * @param id * the identifier of the subject of this document * @param targetId * the identifier of the entity this document redirect to * @param revisionId * the id of the last revision of this document */ EntityRedirectDocumentImpl(EntityIdValue id, EntityIdValue targetId, long revisionId) { Validate.notNull(id); this.entityId = id; Validate.notNull(targetId); Validate.isTrue(id.getEntityType().equals(targetId.getEntityType()), "You could only do redirects between entities of the same type"); this.targetId = targetId; this.revisionId = revisionId; }
/** * 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()); }
@JsonProperty("redirect") String getTargetJson() { return targetId.getId(); }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(EntityIdValue o) { int result; result = o.getId().hashCode(); result = prime * result + o.getSiteIri().hashCode(); result = prime * result + o.getEntityType().hashCode(); return result; }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(EntityRedirectDocument o) { return "==EntityRedirect " + o.getEntityId().getIri() + " (r" + o.getRevisionId() + ") " + "==\n" + "Target: " + o.getTargetId().getIri(); } }
/** * Constructor used for JSON deserialization with Jackson. */ @JsonCreator EntityRedirectDocumentImpl( @JsonProperty("entity") String jsonId, @JsonProperty("redirect") String jsonTargetId, @JsonProperty("lastrevid") long revisionId, @JacksonInject("siteIri") String siteIri) { this.entityId = EntityIdValueImpl.fromId(jsonId, siteIri); Validate.notNull(jsonTargetId); this.targetId = EntityIdValueImpl.fromId(jsonTargetId, siteIri); Validate.isTrue(getEntityId().getEntityType().equals(targetId.getEntityType()), "You could only do redirects between entities of the same type"); this.revisionId = revisionId; }
@JsonProperty("entity") String getEntityJson() { return entityId.getId(); }
/** * Returns true if the parameters are two {@link EntityIdValue} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsEntityIdValue(EntityIdValue o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof EntityIdValue)) { return false; } EntityIdValue other = (EntityIdValue) o2; return o1.getId().equals(other.getId()) && o1.getSiteIri().equals(other.getSiteIri()) && o1.getEntityType().equals(other.getEntityType()); }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(EntityRedirectDocument o) { return "==EntityRedirect " + o.getEntityId().getIri() + " (r" + o.getRevisionId() + ") " + "==\n" + "Target: " + o.getTargetId().getIri(); } }