diff --git a/extensions/kDBRobotics/Agents.cpp b/extensions/kDBRobotics/Agents.cpp index 98c8f438333bde21d9ee627618808f52baf62e9b..bd017583fac6da7f0e397c5c5814f13d88bd2af9 100644 --- a/extensions/kDBRobotics/Agents.cpp +++ b/extensions/kDBRobotics/Agents.cpp @@ -584,7 +584,7 @@ knowCore::ReturnValue<Agent> Agents::createAgent(const knowCore::Uri& _typeUri, } } -knowCore::ReturnValue<Stream> Agents::createStream(const knowCore::Uri& _typeUri, const QString& _identifier, const knowCore::Uri& _streamUri) +knowCore::ReturnValue<Stream> Agents::createStream(const knowCore::Uri& _contenttypeUri, const QString& _identifier, const knowCore::Uri& _datatypeUri, const knowCore::Uri& _streamUri) { if(isReadOnly()) { @@ -595,7 +595,7 @@ knowCore::ReturnValue<Stream> Agents::createStream(const knowCore::Uri& _typeUri { return kCrvLogError("Failed to create stream {}, it is already added to a graph.", _streamUri); } - Queries::Agents::StreamInsert::Results r = Queries::Agents::StreamInsert::execute(d->connection, d->definition->uri, _streamUri, _identifier, _typeUri); + Queries::Agents::StreamInsert::Results r = Queries::Agents::StreamInsert::execute(d->connection, d->definition->uri, _streamUri, _identifier, _contenttypeUri, _datatypeUri); if(r.success) { return stream(_streamUri); diff --git a/extensions/kDBRobotics/Agents.h b/extensions/kDBRobotics/Agents.h index 1ef879cb4a491423f88a7ef9ad774c122b99d596..421366241b75233b82e17a0679234910409cc92b 100644 --- a/extensions/kDBRobotics/Agents.h +++ b/extensions/kDBRobotics/Agents.h @@ -112,7 +112,7 @@ namespace kDBRobotics /** * Create a new \ref Stream of uri type \p _typeUri with name \p _name and add it to this agent graph. */ - knowCore::ReturnValue<Stream> createStream(const knowCore::Uri& _typeUri, const QString& _identifier, const knowCore::Uri& _streamUri = knowCore::Uri::createUnique({"stream"})); + knowCore::ReturnValue<Stream> createStream(const knowCore::Uri& _contentTypeUri, const QString& _identifier, const knowCore::Uri& _dataTypeUri, const knowCore::Uri& _streamUri = knowCore::Uri::createUnique({"stream"})); private: struct Private; QExplicitlySharedDataPointer<Private> d; diff --git a/extensions/kDBRobotics/Stream.cpp b/extensions/kDBRobotics/Stream.cpp index 5ee1978420f54b61a7da0dedf511603519da83a6..d7b3fd5aa8ef22ed870c433034e2cb0589aed803 100644 --- a/extensions/kDBRobotics/Stream.cpp +++ b/extensions/kDBRobotics/Stream.cpp @@ -34,6 +34,11 @@ knowCore::Uri Stream::datatype() const return d->definition->datatype; } +knowCore::Uri Stream::contentType() const +{ + return d->definition->contentType; +} + knowCore::ReturnValue<bool> Stream::hasProperty(const knowCore::Uri& _property) const { return d->object.hasProperty(_property); diff --git a/extensions/kDBRobotics/Stream.h b/extensions/kDBRobotics/Stream.h index 38c3269daa99ba9f4a3aa58a1a5ff591a278c438..e33460afdc73ee0c486b67d886723b29f03d0ad9 100644 --- a/extensions/kDBRobotics/Stream.h +++ b/extensions/kDBRobotics/Stream.h @@ -17,6 +17,7 @@ namespace kDBRobotics knowCore::Uri uri() const; QString identifier() const; knowCore::Uri datatype() const; + knowCore::Uri contentType() const; /** * @return if the given property is set */ diff --git a/extensions/kDBRobotics/Stream_p.h b/extensions/kDBRobotics/Stream_p.h index cdc0e9b7ae8e7bf6f63bd063d2f6fcad202f1b54..89c63d554defb92e659c52dad67a6daa9a4b2f49 100644 --- a/extensions/kDBRobotics/Stream_p.h +++ b/extensions/kDBRobotics/Stream_p.h @@ -15,7 +15,7 @@ namespace kDBRobotics struct Definition { QMutex mutex; - knowCore::Uri uri, datatype; + knowCore::Uri uri, datatype, contentType; QString identifier; knowCore::Uri triplestores; QList<knowCore::Uri> resources_with_stream; diff --git a/extensions/kDBRobotics/data/agents_queries.ttl b/extensions/kDBRobotics/data/agents_queries.ttl index a04c8910ff8baf8aceaa25591d80371d58b05a2d..37db64dcbb792023745fb739aee0df00a376be6d 100644 --- a/extensions/kDBRobotics/data/agents_queries.ttl +++ b/extensions/kDBRobotics/data/agents_queries.ttl @@ -111,6 +111,7 @@ INSERT DATA { GRAPH %graph { %stream_uri a askcore_stream:stream ; askcore_stream:identifier %identifier ; + askcore_stream:contenttype %contenttype ; askcore_stream:datatype %datatype . } } @@ -118,7 +119,8 @@ INSERT DATA { askcore_queries:binding [ foaf:name "graph" ; xsi:type xsd:anyURI ; dc:description "URI for the graph where to insert this agent" ] ; askcore_queries:binding [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; askcore_queries:binding [ foaf:name "identifier" ; xsi:type xsd:string ; dc:description "Identifier of the stream (e.g. could be a topic name)" ] ; - askcore_queries:binding [ foaf:name "datatype" ; xsi:type xsd:anyURI ; dc:description "Uri of the datatype" ] ; + askcore_queries:binding [ foaf:name "contenttype" ; xsi:type xsd:anyURI ; dc:description "Uri of the content type" ] ; + askcore_queries:binding [ foaf:name "datatype" ; xsi:type xsd:anyURI ; dc:description "Uri of the data type" ] ; askcore_queries:graph "%graph" . @@ -137,13 +139,15 @@ ASK { GRAPH %graph { %stream_uri a askcore_stream:stream } }""" ; foaf:name "stream_select" ; askcore_queries:query """PREFIX askcore_stream: <http://askco.re/stream#> -SELECT ?datatype ?identifier FROM %graph WHERE { +SELECT ?datatype ?identifier ?contenttype FROM %graph WHERE { %stream_uri a askcore_stream:stream ; askcore_stream:datatype ?datatype ; + askcore_stream:contenttype ?contenttype ; askcore_stream:identifier ?identifier . }""" ; askcore_queries:binding [ foaf:name "graph" ; xsi:type xsd:anyURI ; dc:description "URI for the graph where to get all the agents." ] ; askcore_queries:binding [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; + askcore_queries:result [ foaf:name "contenttype" ; xsi:type xsd:anyURI ; dc:description "contenttype of stream" ] ; askcore_queries:result [ foaf:name "datatype" ; xsi:type xsd:anyURI ; dc:description "Datatype of stream" ] ; askcore_queries:result [ foaf:name "identifier" ; xsi:type xsd:string ; dc:description "Identifier of agent" ] ; askcore_queries:graph "%graph" . @@ -152,13 +156,15 @@ SELECT ?datatype ?identifier FROM %graph WHERE { foaf:name "stream_select_all" ; askcore_queries:query """PREFIX askcore_stream: <http://askco.re/stream#> -SELECT ?stream_uri ?datatype ?identifier FROM %graph WHERE { +SELECT ?stream_uri ?datatype ?identifier ?contenttype FROM %graph WHERE { ?stream_uri a askcore_stream:stream ; askcore_stream:datatype ?datatype ; + askcore_stream:contenttype ?contenttype ; askcore_stream:identifier ?identifier . }""" ; askcore_queries:binding [ foaf:name "graph" ; xsi:type xsd:anyURI ; dc:description "URI for the graph where to get all the agents." ] ; - askcore_queries:result [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; + askcore_queries:result [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; + askcore_queries:result [ foaf:name "contenttype" ; xsi:type xsd:anyURI ; dc:description "contenttype of stream" ] ; askcore_queries:result [ foaf:name "datatype" ; xsi:type xsd:anyURI ; dc:description "Datatype of stream" ] ; askcore_queries:result [ foaf:name "identifier" ; xsi:type xsd:string ; dc:description "Identifier of agent" ] ; askcore_queries:graph "%graph" . @@ -167,15 +173,17 @@ SELECT ?stream_uri ?datatype ?identifier FROM %graph WHERE { foaf:name "stream_select_all_for" ; askcore_queries:query """PREFIX askcore_stream: <http://askco.re/stream#> -SELECT ?stream_uri ?datatype ?identifier FROM %graph WHERE { +SELECT ?stream_uri ?datatype ?identifier ?contenttype FROM %graph WHERE { %resource_uri askcore_stream:has_stream ?stream_uri . ?stream_uri a askcore_stream:stream ; askcore_stream:datatype ?datatype ; + askcore_stream:contenttype ?contenttype ; askcore_stream:identifier ?identifier . }""" ; askcore_queries:binding [ foaf:name "graph" ; xsi:type xsd:anyURI ; dc:description "URI for the graph where to get all the agents." ] ; - askcore_queries:binding [ foaf:name "resource_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the resource" ] ; - askcore_queries:result [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; + askcore_queries:binding [ foaf:name "resource_uri"; xsi:type xsd:anyURI ; dc:description "Uri of the resource" ] ; + askcore_queries:result [ foaf:name "stream_uri" ; xsi:type xsd:anyURI ; dc:description "Uri of the stream" ] ; + askcore_queries:result [ foaf:name "contenttype" ; xsi:type xsd:anyURI ; dc:description "contenttype of stream" ] ; askcore_queries:result [ foaf:name "datatype" ; xsi:type xsd:anyURI ; dc:description "Datatype of stream" ] ; askcore_queries:result [ foaf:name "identifier" ; xsi:type xsd:string ; dc:description "Identifier of agent" ] ; askcore_queries:graph "%graph" .