Class ItemDocumentImpl
java.lang.Object
org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
org.wikidata.wdtk.datamodel.implementation.ItemDocumentImpl
- All Implemented Interfaces:
EntityDocument
,ItemDocument
,LabeledDocument
,LabeledStatementDocument
,StatementDocument
,TermedDocument
,TermedStatementDocument
Jackson implementation of
ItemDocument
.- Author:
- Fredo Erxleben, Antonin Delpeuch
-
Field Summary
Modifier and TypeFieldDescriptionThis is what is called claim in the JSON model.protected final Map<String,
MonolingualTextValue> Fields inherited from class org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
aliases, descriptions
Fields inherited from class org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
entityId, revisionId, siteIri
-
Constructor Summary
ModifierConstructorDescriptionItemDocumentImpl
(String jsonId, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<StatementImpl.PreStatement>> claims, Map<String, SiteLink> sitelinks, long revisionId, String siteIri) Constructor.ItemDocumentImpl
(ItemIdValue id, List<MonolingualTextValue> labels, List<MonolingualTextValue> descriptions, List<MonolingualTextValue> aliases, List<StatementGroup> statements, List<SiteLink> siteLinks, long revisionId) Constructor.protected
ItemDocumentImpl
(ItemIdValue subject, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<Statement>> claims, Map<String, SiteLink> siteLinks, long revisionId) Protected constructor, meant to be used to create modified copies of instances. -
Method Summary
Modifier and TypeMethodDescriptionAdds a Statement to a given collection of statement groups.protected static Map<String,
MonolingualTextValue> constructTermMap
(List<MonolingualTextValue> terms) boolean
findStatementGroup
(String propertyIdValue) Find a statement group by its property id, without checking for equality with the site IRI.Returns an iterator that provides access to all statements, without considering the statement groups.Return the ID of the item that the data refers to.Returns the "claims".Return a Map from Wikibase language codes to labels.Get a Map of site keys toSiteLink
objects.Return the list of all StatementGroups stored for this item.int
hashCode()
Removes statement ids from a collection of statement groups.toString()
withAliases
(String language, List<MonolingualTextValue> aliases) Returns a new version of this document with a new list of aliases for the given language code.withDescription
(MonolingualTextValue newDescription) Returns a new version of this document with a new description (which overrides any existing description).withEntityId
(ItemIdValue itemId) Returns a new version of this document with updated ID.withLabel
(MonolingualTextValue newLabel) Returns a new version of this document with a new label (which overrides any existing label for this language).withoutStatementIds
(Set<String> statementIds) Returns a new version of this document where all statements matching any of the statement ids provided have been removed.withRevisionId
(long newRevisionId) Returns a copy of this document with an updated revision id.withStatement
(Statement statement) Returns a new version of this document which includes the statement provided.protected static Map<String,
MonolingualTextValue> withTerm
(Map<String, MonolingualTextValue> values, MonolingualTextValue value) Methods inherited from class org.wikidata.wdtk.datamodel.implementation.TermedStatementDocumentImpl
getAliases, getDescriptions, getSiteIri, withAliases
Methods inherited from class org.wikidata.wdtk.datamodel.implementation.EntityDocumentImpl
getJsonId, getRevisionId
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.wikidata.wdtk.datamodel.interfaces.EntityDocument
getRevisionId
Methods inherited from interface org.wikidata.wdtk.datamodel.interfaces.LabeledDocument
findLabel, getLabels
Methods inherited from interface org.wikidata.wdtk.datamodel.interfaces.StatementDocument
findStatement, findStatement, findStatementEntityIdValue, findStatementEntityIdValue, findStatementGlobeCoordinatesValue, findStatementGlobeCoordinatesValue, findStatementGroup, findStatementGroup, findStatementItemIdValue, findStatementItemIdValue, findStatementMonolingualTextValue, findStatementMonolingualTextValue, findStatementPropertyIdValue, findStatementPropertyIdValue, findStatementQuantityValue, findStatementQuantityValue, findStatementStringValue, findStatementStringValue, findStatementTimeValue, findStatementTimeValue, findStatementValue, findStatementValue, getAllStatements, getStatementGroups, hasStatement, hasStatement, hasStatementValue, hasStatementValue, hasStatementValue, hasStatementValue
Methods inherited from interface org.wikidata.wdtk.datamodel.interfaces.TermedDocument
findDescription, getAliases, getDescriptions
-
Field Details
-
labels
-
claims
This is what is called claim in the JSON model. It corresponds to the statement group in the WDTK model.
-
-
Constructor Details
-
ItemDocumentImpl
public ItemDocumentImpl(ItemIdValue id, List<MonolingualTextValue> labels, List<MonolingualTextValue> descriptions, List<MonolingualTextValue> aliases, List<StatementGroup> statements, List<SiteLink> siteLinks, long revisionId) Constructor.- Parameters:
id
- the id of the item that data is aboutlabels
- the list of labels of this item, with at most one label for each language codedescriptions
- the list of descriptions of this item, with at most one description for each language codealiases
- the list of aliases of this itemstatements
- the list of statement groups of this item; all of them must have the given itemIdValue as their subjectsiteLinks
- the sitelinks of this itemrevisionId
- the revision ID or 0 if not known; seeEntityDocument.getRevisionId()
-
ItemDocumentImpl
public ItemDocumentImpl(String jsonId, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<StatementImpl.PreStatement>> claims, Map<String, SiteLink> sitelinks, long revisionId, String siteIri) Constructor. Creates an object that can be populated during JSON deserialization. Should only be used by Jackson for this very purpose. -
ItemDocumentImpl
protected ItemDocumentImpl(ItemIdValue subject, Map<String, MonolingualTextValue> labels, Map<String, MonolingualTextValue> descriptions, Map<String, List<MonolingualTextValue>> aliases, Map<String, List<Statement>> claims, Map<String, SiteLink> siteLinks, long revisionId) Protected constructor, meant to be used to create modified copies of instances.
-
-
Method Details
-
getEntityId
Description copied from interface:ItemDocument
Return the ID of the item that the data refers to.- Specified by:
getEntityId
in interfaceEntityDocument
- Specified by:
getEntityId
in interfaceItemDocument
- Returns:
- item id
-
getSiteLinks
Description copied from interface:ItemDocument
Get a Map of site keys toSiteLink
objects.- Specified by:
getSiteLinks
in interfaceItemDocument
- Returns:
- map of SiteLinks
-
hashCode
public int hashCode() -
equals
-
toString
-
withEntityId
Description copied from interface:ItemDocument
Returns a new version of this document with updated ID.- Specified by:
withEntityId
in interfaceItemDocument
- Parameters:
itemId
- new ID of the document- Returns:
- document with updated ID
-
withRevisionId
Description copied from interface:TermedDocument
Returns a copy of this document with an updated revision id.- Specified by:
withRevisionId
in interfaceEntityDocument
- Specified by:
withRevisionId
in interfaceItemDocument
- Specified by:
withRevisionId
in interfaceLabeledDocument
- Specified by:
withRevisionId
in interfaceLabeledStatementDocument
- Specified by:
withRevisionId
in interfaceStatementDocument
- Specified by:
withRevisionId
in interfaceTermedDocument
- Specified by:
withRevisionId
in interfaceTermedStatementDocument
-
withLabel
Description copied from interface:TermedDocument
Returns a new version of this document with a new label (which overrides any existing label for this language).- Specified by:
withLabel
in interfaceItemDocument
- Specified by:
withLabel
in interfaceLabeledDocument
- Specified by:
withLabel
in interfaceLabeledStatementDocument
- Specified by:
withLabel
in interfaceTermedDocument
- Specified by:
withLabel
in interfaceTermedStatementDocument
-
withDescription
Description copied from interface:TermedDocument
Returns a new version of this document with a new description (which overrides any existing description).- Specified by:
withDescription
in interfaceItemDocument
- Specified by:
withDescription
in interfaceTermedDocument
- Specified by:
withDescription
in interfaceTermedStatementDocument
-
withAliases
Description copied from interface:TermedDocument
Returns a new version of this document with a new list of aliases for the given language code. Any existing aliases for this language will be discarded.- Specified by:
withAliases
in interfaceItemDocument
- Specified by:
withAliases
in interfaceTermedDocument
- Specified by:
withAliases
in interfaceTermedStatementDocument
- Parameters:
language
- the language code for which the aliases should be setaliases
- the aliases to set for this language. The language codes they contain should all match the supplied language.
-
withStatement
Description copied from interface:StatementDocument
Returns a new version of this document which includes the statement provided. If the identifier of this statement matches that of any other statement for the same property, then the existing statement will be replaced by the new one. Otherwise, the new statement will be added at the end of the list of statements in this group.- Specified by:
withStatement
in interfaceItemDocument
- Specified by:
withStatement
in interfaceLabeledStatementDocument
- Specified by:
withStatement
in interfaceStatementDocument
- Specified by:
withStatement
in interfaceTermedStatementDocument
- Parameters:
statement
- the statement to add or update in the document
-
withoutStatementIds
Description copied from interface:StatementDocument
Returns a new version of this document where all statements matching any of the statement ids provided have been removed. These statements can use different properties.- Specified by:
withoutStatementIds
in interfaceItemDocument
- Specified by:
withoutStatementIds
in interfaceLabeledStatementDocument
- Specified by:
withoutStatementIds
in interfaceStatementDocument
- Specified by:
withoutStatementIds
in interfaceTermedStatementDocument
- Parameters:
statementIds
- the identifiers of the statements to remove
-
getLabels
Description copied from interface:LabeledDocument
Return a Map from Wikibase language codes to labels.- Specified by:
getLabels
in interfaceLabeledDocument
- Returns:
- the map of labels
-
constructTermMap
protected static Map<String,MonolingualTextValue> constructTermMap(List<MonolingualTextValue> terms) -
withTerm
protected static Map<String,MonolingualTextValue> withTerm(Map<String, MonolingualTextValue> values, MonolingualTextValue value) -
getStatementGroups
Description copied from interface:StatementDocument
Return the list of all StatementGroups stored for this item. The order of StatementGroups is significant.- Specified by:
getStatementGroups
in interfaceStatementDocument
- Returns:
- list of StatementGroups
-
findStatementGroup
Find a statement group by its property id, without checking for equality with the site IRI. More efficient implementation than the default one.- Specified by:
findStatementGroup
in interfaceStatementDocument
- Parameters:
propertyIdValue
- the property to search for- Returns:
StatementGroup
or null
-
getJsonClaims
Returns the "claims". Only used by Jackson.JSON "claims" correspond to statement groups in the WDTK model. You should use
StatementDocument.getStatementGroups()
to obtain this data.- Returns:
- map of statement groups
-
getAllStatements
Description copied from interface:StatementDocument
Returns an iterator that provides access to all statements, without considering the statement groups. The order of statements is preserved.- Specified by:
getAllStatements
in interfaceStatementDocument
- Returns:
- iterator over all statements
-
addStatementToGroups
protected static Map<String,List<Statement>> addStatementToGroups(Statement statement, Map<String, List<Statement>> claims) Adds a Statement to a given collection of statement groups. If the statement id is not null and matches that of an existing statement, this statement will be replaced.- Parameters:
statement
-claims
-- Returns:
-
removeStatements
protected static Map<String,List<Statement>> removeStatements(Set<String> statementIds, Map<String, List<Statement>> claims) Removes statement ids from a collection of statement groups.- Parameters:
statementIds
-claims
-- Returns:
-