Skip to content

Commit bc4b99c

Browse files
committed
Various updates, tested oslcquery against 7.1
fixed spelling error cas.eys() Started resources.py as a possible way of getting python objects for RM resources Fixed various problems (including represet.py) caused by outdated use of rdm_types:ArtifactFormat - all replaced with rdf:type Added customScenarios.py which comes with a built-in test for the API to start/stop custom scenarios Added discover sequence in rm_basic_discovery.py - generates a html log of the discovery sequence from rootservices to configurations and services.xml
1 parent 57bdfaf commit bc4b99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+17457
-16297
lines changed

elmclient/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from ._relm import *
1919
from .__meta__ import *
2020
from .httpops import *
21+
from ._customScenarios import *
22+
from .utils import *
2123

2224
__app__ = __meta__.app
2325
__version__ = __meta__.version

elmclient/_app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
from . import utils
1515
from . import httpops
1616
from . import _validate
17+
from . import _customScenarios
1718

1819
logger = logging.getLogger(__name__)
1920

2021
#################################################################################################
2122
# a generic jazz application
2223

23-
class _App( httpops.HttpOperations_Mixin, _validate.Validate_Mixin ):
24+
class _App( httpops.HttpOperations_Mixin, _validate.Validate_Mixin, _customScenarios.CustomScenarios_Mixin ):
2425
'A generic Jazz application'
2526
domain = 'UNSPECIFIED APP DOMAIN'
2627
project_class = None

elmclient/_customScenarios.py

Lines changed: 291 additions & 0 deletions
Large diffs are not rendered by default.

elmclient/_rm.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ def resolve_reqid_to_module_uris( self, reqid ):
10581058
def resolve_modulename_to_uri( self, modulename ):
10591059
# get the query capability base URL
10601060
qcbase = self.get_query_capability_uri("oslc_rm:Requirement")
1061-
results = self.execute_oslc_query( qcbase, whereterms=[['and', ['dcterms:title','=',f'"{modulename}"'],['rdm_types:ArtifactFormat','=','jazz_rm:Module']]], prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["rdm_types"]:'rdm_types',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
1061+
results = self.execute_oslc_query( qcbase, whereterms=[['and', ['dcterms:title','=',f'"{modulename}"'],['rdf:type','=','jazz_rm:Module']]], prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
10621062
logger.debug( f"resolve_modulename_to_uri {results=}" )
10631063
if len( results.keys() ) == 0:
10641064
result = None
@@ -1074,7 +1074,7 @@ def resolve_modulename_to_uri( self, modulename ):
10741074
# for example (remove the') 'rm:rm23/rm_optin_p1/rm_optin_p1 comp2/rm_optin_p1 comp2 Initial Stream'
10751075
# # get the query capability base URL
10761076
# qcbase = self.get_query_capability_uri("oslc_rm:Requirement")
1077-
# results = self.execute_oslc_query( qcbase, whereterms=[['and', ['dcterms:title','=',f'"{modulename}"'],['rdm_types:ArtifactFormat','=','jazz_rm:Module']]], prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["rdm_types"]:'rdm_types',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
1077+
# results = self.execute_oslc_query( qcbase, whereterms=[['and', ['dcterms:title','=',f'"{modulename}"'],['rdf:type','=','jazz_rm:Module']]], prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
10781078
# logger.debug( f"resolve_modulename_to_uri {results=}" )
10791079
# if len( results.keys() ) == 0:
10801080
# result = None
@@ -1126,7 +1126,7 @@ def get_default_stream_name( self ):
11261126

11271127
#################################################################################################
11281128

1129-
class RMComponent(RMProject):
1129+
class RMComponent( RMProject, resource.Resources_Mixin ):
11301130
def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defaultinit=True, project=None):
11311131
if not project:
11321132
raise Exception( "You must provide a project instance when creating a component" )
@@ -1613,9 +1613,9 @@ def process_represt_arguments( self, args, allapps ):
16131613
# query for a title and for format=module
16141614
modules = queryon.execute_oslc_query(
16151615
qcbase,
1616-
whereterms=[['dcterms:title','=',f'"{args.module}"'], ['rdm_types:ArtifactFormat','=','jazz_rm:Module']],
1616+
whereterms=[['dcterms:title','=',f'"{args.module}"'], ['rdf:type','=','jazz_rm:Module']],
16171617
select=['*'],
1618-
prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["rdm_types"]:'rdm_types',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
1618+
prefixes={rdfxml.RDF_DEFAULT_PREFIX["dcterms"]:'dcterms',rdfxml.RDF_DEFAULT_PREFIX["jazz_rm"]:'jazz_rm'})
16191619

16201620
if len(modules)==0:
16211621
raise Exception( f"No module '{args.module}' with that name in {args.project} {args.component}" )
@@ -1624,6 +1624,7 @@ def process_represt_arguments( self, args, allapps ):
16241624
print( f'{k} {v.get("dcterms:title","")}' )
16251625
raise Exception( "More than one module with that name in {args.project} {args.component}" )
16261626
moduleuuid = list(modules.keys())[0].rsplit("/",1)[1]
1627+
# print( f"Module is {list(modules.keys())[0]} {moduleuuid}" )
16271628
# queryparams['moduleUri'] = list(modules.keys())[0]
16281629
queryparams['moduleUri'] = moduleuuid
16291630

elmclient/_validate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: MIT
55
##
66

7-
# This mixin implements the validate API (will be used on each app that supports validate)
7+
# This mixin implements the validate API (can be used on each app that supports validate)
88
# ref https://jazz.net/rm/doc/scenarios
99

1010
import codecs
@@ -25,7 +25,6 @@
2525

2626
logger = logging.getLogger(__name__)
2727

28-
2928
class Validate_Mixin():
3029
def listFeeds( self ):
3130
valuri = self.reluri( 'trs_feed_validation/feeds' )

elmclient/examples/OSLCQUERY.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ The first four rows of results might look like this, with the first column $uri
367367

368368
This `oslcquery` application enforces that results always include dcterms:identifier and rm_nav:parent (which if the artifact is a core artifact shows the folder path) and by default are sorted by increasing identifier - to disable sorting use the `-S` option.
369369

370-
The first row of results doesn't have an identifier, because it's a Collection. If you want to see the format of a result row, add `rdm_types:ArtifactFormat` to the select open -s like this: `-s dcterms:title,rdm_types:ArtifactFormat` and you'll get results like this:
370+
The first row of results doesn't have an identifier, because it's a Collection. If you want to see the format of a result row, add `rdf:type` to the select open -s like this: `-s dcterms:title,rdf:type` and you'll get results like this:
371371

372-
|$uri|dcterms:identifier|dcterms:title|rdm_types:ArtifactFormat|rm_nav:parent|
372+
|$uri|dcterms:identifier|dcterms:title|rdf:type|rm_nav:parent|
373373
|----|:----------------:|-------------|------------------------|-------------|
374374
|https://jazz.ibm.com:9443/rm/materializedviews/VW_CMPEA0B5Eeuh3Iiax2L3Ow||Gold Plating|jazz_rm:Collection||
375375
|https://jazz.ibm.com:9443/rm/resources/MD_COUvCkB5Eeuh3Iiax2L3Ow|912|AMR System Requirements Specification|jazz_rm:Module|/01 Requirements|
@@ -416,19 +416,19 @@ To find artifacts created by a specifc user: `-q "dcterms:creator=@""tanuj"""`
416416

417417
To find artifacts with a specific title: `-q "dcterms:title=""Money that Matters"""` NOTE DN doesn't appear to support wildcards in string comparisons - you could try using -f/--searchterms for approximate match.
418418

419-
To find artifacts which are collections: `-q rdm_types:ArtifactFormat=jazz_rm:Collection`
419+
To find artifacts which are collections: `-q rdf:type=jazz_rm:Collection`
420420

421421
To get all artifacts in a project/component: don't specify -q (use with care, can place a large load on your DN server)
422422

423-
To find all modules: `-q rdm_types:ArtifactFormat=jazz_rm:Module`
423+
To find all modules: `-q rdf:type=jazz_rm:Module`
424424

425-
To find all resources which are modules and also retrieve their RDF XML to file too, into an existing subdirectory 'modules' with file names starting 'mod_': `-q rdm_types:ArtifactFormat=jazz_rm:Module -X modules\mod` - NOTE the files are named for the identifier of the artifact.
425+
To find all resources which are modules and also retrieve their RDF XML to file too, into an existing subdirectory 'modules' with file names starting 'mod_': `-q rdf:type=jazz_rm:Module -X modules\mod` - NOTE the files are named for the identifier of the artifact.
426426

427-
All Text format core artifacts: `-q rdm_types:ArtifactFormat=jazz_rm:Text -v rm_nav:parent`
427+
All Text format core artifacts: `-q rdf:type=jazz_rm:Text -v rm_nav:parent`
428428

429-
All Text format artifacts (in modules): `-q rdm_types:ArtifactFormat=jazz_rm:Text -n rm_nav:parent`
429+
All Text format artifacts (in modules): `-q rdf:type=jazz_rm:Text -n rm_nav:parent`
430430

431-
All wrapped resources: `-q rdm_types:ArtifactFormat=jazz_rm:WrapperResource`
431+
All wrapped resources: `-q rdf:type=jazz_rm:WrapperResource`
432432

433433
To find artifacts modified after a specific date-time: '-q "'Modified On'>""2020-08-01T21:51:40.979Z""^^xsd:datetime"' - note that DN requires specifying the `^^xsd:datetime`, unlike EWM
434434

@@ -460,7 +460,7 @@ To find all artifacts in project/component in a specific module id 3892 modified
460460

461461
To find all artifacts in project/component in a specific module id 3892 modified before a specific date `-q rm:module=~3892 and dcterms:modified<"2020-08-01T21:51:40.979Z"^^xsd:dateTime` - NOTE this is using the enhanced OSLC Query sytnax for finding an artifact by id using ~
462462

463-
To totalize a column which has multiple results replacing them with a count of the number of results, which might be useful for example to get a count of artifacts in each module, use a query for modules `rdm_types:ArtifactFormat=jazz_rm:Module` and select `oslc_rm:uses` then use the -I option. Because this doesn't need name resolution which can slow the query and post-processing down when processing many modules, also use -R and -Q - for results from components across a GC `/gc/configuration/26` in GCM project `gcproj` the query looks like: `-s oslc_rm:uses,dcterms:title -q rdm_types:ArtifactFormat=jazz_rm:Module -G 26 -E gcproj` - the result is a spreadsheet containing the module URI, the module name and identifier and a column with the count of artifacts in the module. You can improve performance (assuming you don't need friendly names, and counting artifacts/module doesn't really need friendly names) by suppressing the reading of the type system using `-Q` and `-R`, and because the results will be large you may consider carefully whether to suppress paging by using `--pagesize 0`.
463+
To totalize a column which has multiple results replacing them with a count of the number of results, which might be useful for example to get a count of artifacts in each module, use a query for modules `rdm_types:ArtifactFormat=jazz_rm:Module` and select `oslc_rm:uses` then use the -I option. Because this doesn't need name resolution which can slow the query and post-processing down when processing many modules, also use -R and -Q - for results from components across a GC `/gc/configuration/26` in GCM project `gcproj` the query looks like: `-s oslc_rm:uses,dcterms:title -q rdf:type=jazz_rm:Module -G 26 -E gcproj` - the result is a spreadsheet containing the module URI, the module name and identifier and a column with the count of artifacts in the module. You can improve performance (assuming you don't need friendly names, and counting artifacts/module doesn't really need friendly names) by suppressing the reading of the type system using `-Q` and `-R`, and because the results will be large you may consider carefully whether to suppress paging by using `--pagesize 0`.
464464

465465
If you have a project with many components and/or configurations, you may observe that startup is slow - this is because by default if you don't specify a component then oslcquery reads all the components in the project and all the configurations in each component so that it can find the configuration which might be in any component. As of version 0.10.0 you can reduce this cost in a few ways: - most basic is to specify a component using -C, when you do this oslcquery only reads the configurations for that component. The next is to specify a component using `-C` and GC as well - using `-E` and `-G` -and also as a local configuration using `-F` - `oslcquery` will find the contribution to the GC for that component. If you only specify a GC configuration (usinging `-E` and `-G`) then oslcquery won't read RM components or configurations and the query will work on the project returning results from all contributing componenets in the project.
466466

0 commit comments

Comments
 (0)