/** * Produces RDF dump of the entity * * @param EntityId $entityId * * @throws EntityLookupException * @throws StorageException * @return string|null RDF */ protected function generateDumpForEntityId(EntityId $entityId) { try { $entityRevision = $this->entityRevisionLookup->getEntityRevision($entityId); if (!$entityRevision) { throw new EntityLookupException($entityId, 'Entity not found: ' . $entityId->getSerialization()); } $this->rdfBuilder->addEntityRevisionInfo($entityRevision->getEntity()->getId(), $entityRevision->getRevisionId(), $entityRevision->getTimestamp()); $this->rdfBuilder->addEntity($entityRevision->getEntity()); } catch (MWContentSerializationException $ex) { throw new StorageException('Deserialization error for ' . $entityId->getSerialization()); } catch (RevisionedUnresolvedRedirectException $e) { if ($e->getRevisionId() > 0) { $this->rdfBuilder->addEntityRevisionInfo($entityId, $e->getRevisionId(), $e->getRevisionTimestamp()); } $this->rdfBuilder->addEntityRedirect($entityId, $e->getRedirectTargetId()); } $rdf = $this->rdfBuilder->getRDF(); return $rdf; }
/** * Extract text test data from RDF builder * @param RdfBuilder $builder * @return string[] ntriples lines */ private function getDataFromBuilder(RdfBuilder $builder) { $data = $builder->getRDF(); $dataSplit = explode("\n", trim($data)); sort($dataSplit); $dataSplit = array_map('trim', $dataSplit); return $dataSplit; }