Skip to content

Commit

Permalink
Add plain EDTF value to RDF
Browse files Browse the repository at this point in the history
This is for #3

Note: I am unsure if this output makes sense RDF/SPARQL wise.
  • Loading branch information
JeroenDeDauw committed Mar 28, 2021
1 parent 17140d0 commit bb9e9b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Services/RdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ public function __construct( TimeRdfBuilder $timeRdfBuilder, TimeValueBuilder $t
* @param string $propertyValueNamespace Property value relation namespace
* @param string $propertyValueLName Property value relation name
* @param string $dataType Property data type
* @param PropertyValueSnak $snak
* @param PropertyValueSnak $edtfSnak
*/
public function addValue( RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, $snakNamespace, PropertyValueSnak $snak ) {
foreach ( $this->edtfSnakToTimeSnaks( $snak ) as $timeValueSnak ) {
public function addValue( RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, $snakNamespace, PropertyValueSnak $edtfSnak ) {
$writer->say( $propertyValueNamespace, $propertyValueLName )
->value( $edtfSnak->getDataValue()->getValue(), 'xsd', 'edtf' );

foreach ( $this->edtfSnakToTimeSnaks( $edtfSnak ) as $timeValueSnak ) {
$this->timeRdfBuilder->addValue(
$writer,
$propertyValueNamespace,
Expand Down
4 changes: 4 additions & 0 deletions tests/php/Unit/RdfBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function testAddValue(): void {

$this->helper->assertNTriplesEquals(
[
'<http://www/Q1> '
. '<http://acme/statement/P7> '
. '"[2021-03-28]"^^<http://www.w3.org/2001/XMLSchema#edtf> .',

'<http://www/Q1> '
. '<http://acme/statement/P7> '
. '"2021-03-28T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .',
Expand Down

0 comments on commit bb9e9b8

Please sign in to comment.