Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Rdf\RdfBuilder Class Reference

RDF mapping for wikibase data model. More...

+ Inheritance diagram for Wikibase\Repo\Rdf\RdfBuilder:
+ Collaboration diagram for Wikibase\Repo\Rdf\RdfBuilder:

Public Member Functions

 __construct (RdfVocabulary $vocabulary, ValueSnakRdfBuilderFactory $valueSnakRdfBuilderFactory, PropertyDataTypeLookup $propertyLookup, EntityRdfBuilderFactory $entityRdfBuilderFactory, $flavor, RdfWriter $writer, DedupeBag $dedupeBag, EntityContentFactory $entityContentFactory)
 
 startDocument ()
 Start writing RDF document Note that this builder does not have to finish it, it may be finished later. More...
 
 finishDocument ()
 Finish writing the document After that, nothing should ever be written into the document. More...
 
 getRDF ()
 Returns the RDF generated by the builder. More...
 
 getNamespaces ()
 Returns a map of namespace names to URIs. More...
 
 getPagePropertyDefs ()
 Get map of page properties used by this builder. More...
 
 entityReferenceMentioned (EntityId $id)
 
 propertyMentioned (PropertyId $id)
 
 subEntityMentioned (EntityDocument $entity)
 
 addEntityRevisionInfo (EntityId $entityId, $revision, $timestamp)
 Adds revision information about an entity's revision to the RDF graph. More...
 
 addEntityPageProps (EntityDocument $entity)
 Add page props information. More...
 
 addEntity (EntityDocument $entity)
 Add an entity to the RDF graph, including all supported structural components of the entity and its sub entities. More...
 
 resolveMentionedEntities (EntityLookup $entityLookup)
 Add stubs for any entities that were previously mentioned (e.g. More...
 
 addEntityStub (EntityDocument $entity)
 Adds stub information for the given Entity to the RDF graph. More...
 
 addEntityRedirect (EntityId $from, EntityId $to)
 Declares $from to be an alias for $to, using the owl:sameAs relationship. More...
 
 addDumpHeader ( $timestamp=0)
 Create header structure for the dump (this makes RdfProducer::PRODUCE_VERSION_INFO redundant) More...
 

Private Member Functions

 newSnakBuilder ( $flavorFlags)
 
 newTruthyStatementRdfBuilder ()
 
 newFullStatementRdfBuilder ()
 
 shouldProduce ( $what)
 Should we produce this aspect? More...
 
 entityToResolve (EntityId $entityId)
 Registers an entity as mentioned. More...
 
 entityResolved (EntityId $entityId)
 Registers an entity as resolved. More...
 
 addEntityMetaData (EntityDocument $entity)
 Adds meta-information about an entity (such as the ID and type) to the RDF graph. More...
 
 addSingleEntity (EntityDocument $entity)
 Add a single entity to the RDF graph, including all supported structural components of the entity. More...
 
 addQueuedEntities ()
 Add the RDF serialization of all entities in the entitiesToOutput queue. More...
 

Private Attributes

 $entitiesResolved = []
 
 $entitiesToOutput
 
 $produceWhat
 
 $writer
 
 $dedupeBag
 
 $builders = []
 
 $vocabulary
 
 $propertyLookup
 
 $valueSnakRdfBuilderFactory
 
 $entityContentFactory
 
 $entityRdfBuilders
 

Detailed Description

RDF mapping for wikibase data model.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Rdf\RdfBuilder::__construct ( RdfVocabulary  $vocabulary,
ValueSnakRdfBuilderFactory  $valueSnakRdfBuilderFactory,
PropertyDataTypeLookup  $propertyLookup,
EntityRdfBuilderFactory  $entityRdfBuilderFactory,
  $flavor,
RdfWriter  $writer,
DedupeBag  $dedupeBag,
EntityContentFactory  $entityContentFactory 
)
Parameters
RdfVocabulary$vocabulary
ValueSnakRdfBuilderFactory$valueSnakRdfBuilderFactory
PropertyDataTypeLookup$propertyLookup
EntityRdfBuilderFactory$entityRdfBuilderFactory
int$flavor
RdfWriter$writer
DedupeBag$dedupeBag
EntityContentFactory$entityContentFactory

Member Function Documentation

◆ addDumpHeader()

Wikibase\Repo\Rdf\RdfBuilder::addDumpHeader (   $timestamp = 0)

Create header structure for the dump (this makes RdfProducer::PRODUCE_VERSION_INFO redundant)

Parameters
int$timestampTimestamp (for testing)

◆ addEntity()

Wikibase\Repo\Rdf\RdfBuilder::addEntity ( EntityDocument  $entity)

Add an entity to the RDF graph, including all supported structural components of the entity and its sub entities.

Parameters
EntityDocument$entitythe entity to output.

Implements Wikibase\Repo\Rdf\EntityRdfBuilder.

◆ addEntityMetaData()

Wikibase\Repo\Rdf\RdfBuilder::addEntityMetaData ( EntityDocument  $entity)
private

Adds meta-information about an entity (such as the ID and type) to the RDF graph.

Todo:
extract into MetaDataRdfBuilder
Parameters
EntityDocument$entity

◆ addEntityPageProps()

Wikibase\Repo\Rdf\RdfBuilder::addEntityPageProps ( EntityDocument  $entity)

Add page props information.

To ensure consistent data, this recalculates the page props from the entity content; it does not actually query the page_props table.

◆ addEntityRedirect()

Wikibase\Repo\Rdf\RdfBuilder::addEntityRedirect ( EntityId  $from,
EntityId  $to 
)

Declares $from to be an alias for $to, using the owl:sameAs relationship.

Parameters
EntityId$from
EntityId$to

◆ addEntityRevisionInfo()

Wikibase\Repo\Rdf\RdfBuilder::addEntityRevisionInfo ( EntityId  $entityId,
  $revision,
  $timestamp 
)

Adds revision information about an entity's revision to the RDF graph.

Todo:
extract into MetaDataRdfBuilder
Parameters
EntityId$entityId
int$revision
string$timestampin TS_MW format

◆ addEntityStub()

Wikibase\Repo\Rdf\RdfBuilder::addEntityStub ( EntityDocument  $entity)

Adds stub information for the given Entity to the RDF graph.

Stub information means meta information and labels.

Parameters
EntityDocument$entity

Implements Wikibase\Repo\Rdf\EntityRdfBuilder.

◆ addQueuedEntities()

Wikibase\Repo\Rdf\RdfBuilder::addQueuedEntities ( )
private

Add the RDF serialization of all entities in the entitiesToOutput queue.

◆ addSingleEntity()

Wikibase\Repo\Rdf\RdfBuilder::addSingleEntity ( EntityDocument  $entity)
private

Add a single entity to the RDF graph, including all supported structural components of the entity.

Parameters
EntityDocument$entitythe entity to output.

◆ entityReferenceMentioned()

Wikibase\Repo\Rdf\RdfBuilder::entityReferenceMentioned ( EntityId  $id)

◆ entityResolved()

Wikibase\Repo\Rdf\RdfBuilder::entityResolved ( EntityId  $entityId)
private

Registers an entity as resolved.

Parameters
EntityId$entityId

◆ entityToResolve()

Wikibase\Repo\Rdf\RdfBuilder::entityToResolve ( EntityId  $entityId)
private

Registers an entity as mentioned.

Will be recorded as unresolved if it wasn't already marked as resolved.

Parameters
EntityId$entityId

◆ finishDocument()

Wikibase\Repo\Rdf\RdfBuilder::finishDocument ( )

Finish writing the document After that, nothing should ever be written into the document.

◆ getNamespaces()

Wikibase\Repo\Rdf\RdfBuilder::getNamespaces ( )

Returns a map of namespace names to URIs.

Returns
array

◆ getPagePropertyDefs()

Wikibase\Repo\Rdf\RdfBuilder::getPagePropertyDefs ( )

Get map of page properties used by this builder.

Returns
string[][]

◆ getRDF()

Wikibase\Repo\Rdf\RdfBuilder::getRDF ( )

Returns the RDF generated by the builder.

Returns
string RDF

◆ newFullStatementRdfBuilder()

Wikibase\Repo\Rdf\RdfBuilder::newFullStatementRdfBuilder ( )
private

◆ newSnakBuilder()

Wikibase\Repo\Rdf\RdfBuilder::newSnakBuilder (   $flavorFlags)
private
Parameters
int$flavorFlagsFlavor flags to use for this builder
Returns
SnakRdfBuilder

◆ newTruthyStatementRdfBuilder()

Wikibase\Repo\Rdf\RdfBuilder::newTruthyStatementRdfBuilder ( )
private

◆ propertyMentioned()

Wikibase\Repo\Rdf\RdfBuilder::propertyMentioned ( PropertyId  $id)

◆ resolveMentionedEntities()

Wikibase\Repo\Rdf\RdfBuilder::resolveMentionedEntities ( EntityLookup  $entityLookup)

Add stubs for any entities that were previously mentioned (e.g.

as properties or data values).

Parameters
EntityLookup$entityLookup

◆ shouldProduce()

Wikibase\Repo\Rdf\RdfBuilder::shouldProduce (   $what)
private

Should we produce this aspect?

Parameters
int$what
Returns
bool

◆ startDocument()

Wikibase\Repo\Rdf\RdfBuilder::startDocument ( )

Start writing RDF document Note that this builder does not have to finish it, it may be finished later.

◆ subEntityMentioned()

Wikibase\Repo\Rdf\RdfBuilder::subEntityMentioned ( EntityDocument  $entity)
See also
EntityMentionListener::subEntityMentioned
Parameters
EntityDocument$entity

Implements Wikibase\Repo\Rdf\EntityMentionListener.

Member Data Documentation

◆ $builders

Wikibase\Repo\Rdf\RdfBuilder::$builders = []
private

◆ $dedupeBag

Wikibase\Repo\Rdf\RdfBuilder::$dedupeBag
private

◆ $entitiesResolved

Wikibase\Repo\Rdf\RdfBuilder::$entitiesResolved = []
private

◆ $entitiesToOutput

Wikibase\Repo\Rdf\RdfBuilder::$entitiesToOutput
private

◆ $entityContentFactory

Wikibase\Repo\Rdf\RdfBuilder::$entityContentFactory
private

◆ $entityRdfBuilders

Wikibase\Repo\Rdf\RdfBuilder::$entityRdfBuilders
private

◆ $produceWhat

Wikibase\Repo\Rdf\RdfBuilder::$produceWhat
private

◆ $propertyLookup

Wikibase\Repo\Rdf\RdfBuilder::$propertyLookup
private

◆ $valueSnakRdfBuilderFactory

Wikibase\Repo\Rdf\RdfBuilder::$valueSnakRdfBuilderFactory
private

◆ $vocabulary

Wikibase\Repo\Rdf\RdfBuilder::$vocabulary
private

◆ $writer

Wikibase\Repo\Rdf\RdfBuilder::$writer
private

The documentation for this class was generated from the following file: