simphony/simphony-osp

Attributes with range xsd:dateTime do not work

Closed this issue · 2 comments

An example ontology where this bug happens is https://github.com/stream-project/ontology/blob/master/MatVoc-Core.ttl.


Warning: the data type properties in the ontology are not correctly defined. In order to use the ontology with OSP-core, it is necessary to change the capitalization at the end of the file (DataTypeProperty -> DatatypeProperty).

:hasRawValue rdf:type owl:DataTypeProperty; 
    owl:equivalentProperty oboe:hasCode ;
    rdfs:domain oboe:MeasuredValue .

:startedAt rdf:type owl:DataTypeProperty; 
    rdfs:domain :Run ;
    rdfs:range xsd:dateTime .    

:fisnishedAt rdf:type owl:DataTypeProperty; 
    rdfs:domain :Run ;
    rdfs:range xsd:dateTime .    

OSP-core returns None when the attribute is accessed instead of an OntologyAttribute.

In [1]: from osp.core.namespaces import mvc

In [2]: run = mvc.Run()

In [3]: run.startedAt

In [4]: type(run.startedAt)
Out[4]: NoneType

In [6]: type(run.fisnishedAt)
Out[6]: NoneType

Edit: the above is not a problem.

@yzuuang I implemented the following in PR #722.

from osp.core.namespaces import mvc
from datetime import datetime
from osp.core.utils import export_cuds
run = mvc.Run()
run.startedAt = datetime(2020, 8, 10)
print(type(run.startedAt), run.startedAt)
export_cuds(run.session, './session.ttl')
<class 'datetime.datetime'> 2020-08-10 00:00:00

session.ttl

@prefix ns1: <http://stream-ontology.com/matvoc-core/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://www.osp-core.com/cuds#727a4ddd-997f-402b-a85c-be4d287aa5a3> a ns1:Run ;
    ns1:startedAt "2020-08-10T00:00:00"^^xsd:dateTime .

Is this solution acceptable for you?

@yzuuang I will assume the answer to be "yes". Feel free to reopen the issue if it is not the case.