Hi Holger, 

Unfortunately, it doesn't work. 
I get the comment but nothing gets added. The record is empty.  
When i look at the console I see correct "orphans" and I changed so the  
usedURIs  should be a match when filtering but the result is the same. 

let graphURI = 'urn:x-evn-master:test';
graph.withDataGraph(graphURI, () => {
    let usedURIs = graph.withDataGraph(graphURI + '.tch', () => {
        return graph.select(`
            SELECT DISTINCT ?uri
            WHERE {
                ?t ?o ?uri .
                FILTER isIRI(?uri) .
            }`).bindings.map(b => b.uri.uri);
    });
    console.log('Found ' + usedURIs.length);
    // console.log(usedURIs);

Am I missing sth ?

Br,

Kasia

On Friday, January 5, 2024 at 3:56:26 PM UTC+1 Holger Knublauch wrote:

>
> On 5 Jan 2024, at 3:51 pm, Kasia Kryczka <[email protected]> wrote:
>
> Hi Holger, 
>
>
> I used a different thing  as I need to add a change history to all these 
> objects: I used the following :
>
>
> let graphURI = 'urn:x-evn-master:test';
> graph.withDataGraph(graphURI, () => {
>     let usedURIs = graph.withDataGraph(graphURI + '.tch', () => {
>         return graph.select(`
>             SELECT DISTINCT ?uri
>             WHERE {
>                 ?t teamwork:subject|teamwork:predicate|teamwork:object 
> ?uri .
>                 FILTER isIRI(?uri) .
>             }`).bindings.map(b => b.uri.uri);
>     });
>
>     console.log('Found ' + usedURIs.length);
>     let orphans = graph.withDataGraph(dataset.withImports(graphURI), () 
> => 
>         graph.select(`SELECT ?subject  WHERE { ?subject a owl:Class. 
>  FILTER isIRI(?subject) }`))
>         .bindings
>         .map(b => b.subject)
>           .filter(subject => !usedURIs.includes(subject.uri));
>     
>     orphans.forEach((orphan) => {
>         console.log('Orphan is ' + orphan.uri);
>         let triples = graph.triples(orphan, null, null);
>         graph.transaction(graphURI + '.tch', 'Create dummy change for ' + 
> orphan.uri, () => {
>             let uuid = graph.eval('STRUUID()');
>             let change = graph.namedNode('urn:x-change:' + uuid);
>             console.log('Change: ' + change.uri);
>             graph.update(`
>                 PREFIX dcterms: <http://purl.org/dc/terms/>
>                 PREFIX sioc: <http://rdfs.org/sioc/ns#>
>                 INSERT {
>                     $change rdf:type teamwork:Change ;
>                         rdfs:comment "Dummy change entry for ${orphan.uri}
> ";
>                         dcterms:created ?now ;
>                         sioc:has_creator  <urn:x-tb-users:Anonymous4>;
>                         teamwork:status   teamwork:Committed .
>                 }
>                 WHERE {
>                     BIND (NOW() AS ?now) .
>                 }`, {
>                     change: change
>                 });
>             triples.forEach(triple => {
>                 triple.change = change;
>                 graph.update(`
>                     INSERT {
>                         $change teamwork:added [
>                             teamwork:object     $object ;
>                             teamwork:predicate  $predicate ;
>                             teamwork:subject    $subject ;
>                         ]
>                     } WHERE {}`, triple);
>
>
> Here, $change would be unbound. So you either need to insert that into the 
> query string or pre-bind it:
>
>                 graph.update(`
>                     INSERT {
>                         <${change.uri}> teamwork:added [
>
>                             teamwork:object     $object ;
>                             teamwork:predicate  $predicate ;
>                             teamwork:subject    $subject ;
>                         ]
>                     } WHERE {}`, triple);
>
>
> HTH
> Holger
>
>
>             });
>         });
>     });
>     
>    return orphans; // Return the list of orphans after processing
> });
>
>
>
> it shows result in the change history but nothing gets added, the change 
> is empty. 
>
> Could you have a look and let me know what should be changed ?
>
>
> Thank you, 
>
> Kasia
> On Friday, January 5, 2024 at 10:53:11 AM UTC+1 Holger Knublauch wrote:
>
>> To get instances of a class and its subclasses, use this trick from 
>> further below,
>>
>> SELECT ?instance
>>>> WHERE {
>>>>     ?instance rdf:type/rdfs:subClassOf* ex:SomeClass .
>>>> }
>>>>
>>>
>> This can also be rewritten as
>>
>> SELECT ?instance
>> WHERE {
>> ?type rdfs:subClassOf* ex:SomeClass .
>> ?instance a ?type .
>> }
>>
>> Holger
>>
>>
>> On 5 Jan 2024, at 9:32 am, Kasia Kryczka <[email protected]> wrote:
>>
>> Hi Holger, 
>>
>> ok, but this still doesn't give me everything I need. I get like a part 
>> of all the results from imports.  Unfortynately I cannot post pictures. 
>> My ontology has   owl:imports <http://datashapes.org/graphql> ;
>>   owl:imports <http://topbraid.org/teamworkconstraints> ;
>>   owl:imports <urn:x-evn-master:ontology_1> ;
>>   owl:imports <urn:x-evn-master:ontology_2> ;
>>   owl:imports <urn:x-evn-master: ontology_3  > ;
>>   owl:imports <urn:x-evn-master: taxonomy_1> ;
>>   owl:imports <urn:x-evn-master: ontology_4  > ;
>>  
>> in the class hierarchy I can see more objects sth like that :
>>
>> Data Object 
>>  - Abstract Object 
>>       - Level 2 Object 
>>           -Level 3 Object 
>>       -Level 2 Object 
>> - Conceptual Object 
>>    - Level 2 Object 
>>           -Level 3 Object 
>>       -Level 2 Object etc.
>>    
>>
>> and all of them are from imports there are only 3 which are locally 
>> defined. 
>> I would like to get all with a sparql query if that's possible. 
>> Hope this clarifies a bit. 
>>
>> Br,
>>
>> Kasia
>> On Friday, January 5, 2024 at 9:05:47 AM UTC+1 Holger Knublauch wrote:
>>
>>> In ADS you can write
>>>
>>> let instances = graph.withDataGraph(dataset.withImports(
>>> 'urn:x-evn-master:geo'), () => 
>>> graph.select(`
>>> SELECT ?instance
>>> WHERE {
>>> ?instance a skos:Concept .
>>> }
>>> `))
>>> instances.bindings
>>>
>>> Holger
>>>
>>> On 5 Jan 2024, at 8:46 am, Kasia Kryczka <[email protected]> wrote:
>>>
>>> Hi Holger, 
>>>
>>> thank you for quick reply. 
>>> The thing is I don't want to use the include imports checkbox. I want to 
>>> have a query which I can later use in ADS.
>>> Br,
>>>
>>> Kasia
>>>
>>>
>>> On Thursday, January 4, 2024 at 4:02:09 PM UTC+1 Holger Knublauch wrote:
>>>
>>>> Are you using the SPARQL endpoint? Then activate the Include Imports 
>>>> checkbox.
>>>>
>>>> From the SPARQL query panel, it would be something like
>>>>
>>>> SELECT ?instance
>>>> WHERE {
>>>>     ?instance rdf:type/rdfs:subClassOf* ex:SomeClass .
>>>> }
>>>>
>>>> which would also get the instances of the subclasses of the given class.
>>>>
>>>> Holger
>>>>
>>>>
>>>>
>>>> On 4 Jan 2024, at 3:52 pm, Kasia Kryczka <[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> This might be a simple question but I got stuck. 
>>>>
>>>> I want to get all object from an ontology which are of a owl:Class but 
>>>> which are also defined in all the includes of that particular ontology. 
>>>>
>>>> Any help would be great.
>>>>
>>>> Thanks,
>>>>
>>>> Kasia
>>>>
>>>>
>>>>
>>>> -- 
>>>> The topics of this mailing list include TopBraid EDG and related 
>>>> technologies such as SHACL.
>>>> To post to this group, send email to [email protected]
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "TopBraid Suite Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/topbraid-users/9315cc2f-a166-47b0-ab9d-7b320f2f527dn%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/topbraid-users/9315cc2f-a166-47b0-ab9d-7b320f2f527dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>>
>>>>
>>> -- 
>>> The topics of this mailing list include TopBraid EDG and related 
>>> technologies such as SHACL.
>>> To post to this group, send email to [email protected]
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "TopBraid Suite Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>>
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/topbraid-users/cb28593f-90cc-4fac-8f65-6c9a85ad7a5fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/topbraid-users/cb28593f-90cc-4fac-8f65-6c9a85ad7a5fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>>
>>>
>> -- 
>> The topics of this mailing list include TopBraid EDG and related 
>> technologies such as SHACL.
>> To post to this group, send email to [email protected]
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/4048808a-006c-4133-8db3-377fbcf39e5en%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/4048808a-006c-4133-8db3-377fbcf39e5en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>>
> -- 
> The topics of this mailing list include TopBraid EDG and related 
> technologies such as SHACL.
> To post to this group, send email to [email protected]
> --- 
> You received this message because you are subscribed to the Google Groups 
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/topbraid-users/86850741-274c-4c18-bf66-49b5cc00e2fen%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/86850741-274c-4c18-bf66-49b5cc00e2fen%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
The topics of this mailing list include TopBraid EDG and related technologies 
such as SHACL.
To post to this group, send email to [email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/176296e7-e1f9-4fe1-b03e-7a178e48069en%40googlegroups.com.

Reply via email to