It's all about the answers!

Ask a question

Can I find out the number of Modules in a DNG Repository using a SPARQL query? if it is so, do you know what is the artifact type for a module?


Hugo Hernandez (52) | asked May 05, 4:50 p.m.
edited May 05, 5:02 p.m.

 I am trying to find out the number of DNG Modules in our production environment using SPARQL.


Comments
Ian Barnard commented May 10, 5:35 a.m.
JAZZ DEVELOPER

What version of DOORS Next are you using? SPARQL won't get much in 7.x as Jena not used for artifacts. OSLC Query is probably the best way to get the information you want (and will work for 6.x or 7.x) 


1
Hugo Hernandez commented May 10, 10:02 a.m.

Thanks Ian. We are using 6.x version. Hopefully, we will be using 7.x soon. 

Accepted answer


permanent link
Ian Barnard (1.2k613) | answered May 11, 5:27 a.m.
JAZZ DEVELOPER
edited May 11, 5:31 a.m.
Hi Hugo

I'd suggest moving away from SPARQL because it won't produce any results for 7.x - more detail on two alternatives below.

NOTE all these queries can place a large load on your server so be careful about the impact on other users.

1. Using SPARQL yes modules can be identified by their type, but then you'd have to list all the types you want to count. Probably simpler to check for the artifact format being Module - only consideration being that module templates have the same artifact format as normal modules, so will be included in totals. This SPARQL seems to count modules and templates, lists them by project area, but you MUST confirm for yourself that the count of modules is accurate for your needs! Not sure if this is the most efficient way to identify modules, but it works for my small test environment.

PREFIX jazz_rm: <http://jazz.net/ns/rm#>

SELECT DISTINCT ?context ( count(?artifact) as ?artifactCount ) ( count(?binding) as ?bindingCount ) ( count (?link) as ?linkCount ) ( count (?mod) as ?modCount )
WHERE {
{
?artifact rdf:type rm:Artifact .
OPTIONAL{?artifact rm:boundArtifact ?boundArt .}
FILTER (!BOUND(?boundArt)) .
?artifact jfs:resourceContext ?context
}
UNION
{
?binding rdf:type rm:Artifact .
?binding rm:boundArtifact ?boundArt .
?binding jfs:resourceContext ?context
}
UNION
{
?mod rmTypes:ArtifactFormat ?af .
?af owl:sameAs jazz_rm:Module .
?mod jfs:resourceContext ?context
}
UNION {
?link rdf:type rm:Link .
?link jfs:resourceContext ?context
}
}
GROUP BY ?context
ORDER BY ASC (?context )


2. You can also count modules by using the Reportable REST API which will work for 6.x or 7.x, for example

https://SERVER:PORT/rm/publish/modules/*

NOTE the results may be more than one page, you'll have to collect them all, then you'll have to count the modules in the XML - there's one <ds:artifact...> tag per module

For more info on the DNG Reportable REST API see https://jazz.net/wiki/bin/view/Main/DNGReportableRestAPI


3. Or use OSLC Query also works for 6.x and 7.x, but AFAIK you will have to query each project individually because DOORS Next doesn't have an application-wide query capability.

The query would also look for the artifact format being Module, i.e.:

* oslc.where=rdm_types:ArtifactFormat=jazz_rm:Module

A fully encoded OSLC Query URL against (in this case) an opt-out project looks like:


Again results may be several pages - then you'll have to count the modules in the result XML and sum it across all projects.

For more detail on how to do OSLC Query, search this forum, or there's an old but useful article here https://jazz.net/library/article/1197

Hugo Hernandez selected this answer as the correct answer

Comments
Hugo Hernandez commented May 11, 1:34 p.m.

Ian,


Thank you so much for your help. Hopefully, we will move to 7.x soon, so we don't have to deal with the SPARQL anymore...

Hugo.

One other answer



permanent link
Erica Tran (1.4k6) | answered May 05, 5:12 p.m.
JAZZ DEVELOPER

 Hi Hugo,


There are some example sparql queries in this article:

There is a sparql that counts for an artifact type. So you could use the artifact type of the modules.

I hope this helps.

Regards,
Erica


Comments
Hugo Hernandez commented May 09, 11:42 a.m.

Thanks Erica for replying back. Unfortunately those queries don't show the Artifact type for Modules. I also tried to run this query, but it did not work. It does not do anything.


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX jfs: <http://jazz.net/xmlns/foundation/1.0/>
PREFIX rm: <http://www.ibm.com/xmlns/rdm/rdf/>
PREFIX dc: <http://purl.org/dc/terms/>

SELECT ?url ?uniqueId ?title ?module WHERE { ?url rdf:type rm:BaselineMetadata . ?url rm:module ?module . ?url rm:uniqueId ?uniqueId . ?url dc:title ?title }

Your answer


Register or to post your answer.