Skip to content

Commit 18ef8aa

Browse files
committed
Added support for am domain (in _ccm.py), now doesn't load all components and all configs unless needed
If you specify a GC then all components and configs not loaded - saves a lot of time on very large projects with many components and configs If you specify a GC _and_ and local component and a local config then the config URL is found using the GC contribution and the query is made to that local config - avoids having to load all the configs in the component! If you specify a component and a local config then only the configs for that component are loaded AM support added but NOTE it doesn't currently (7.0.2) have any useful OSLC query capability even though there is a QueryCapability there aren't any shapes - not clear if this will change
1 parent f959af0 commit 18ef8aa

Some content is hidden

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

61 files changed

+14252
-14971
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.9.4
2+
current_version = 0.10.0
33
commit = True
44
tag = True
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
SPDX-License-Identifier: MIT
1010

11-
version="0.9.4"
11+
version="0.10.0"
1212

1313

1414
Introduction

elmclient/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
app = 'elmoslcquery'
1111
description = 'Commandline OSLC query for ELM'
12-
version = '0.9.4'
12+
version = '0.10.0'
1313
license = 'MIT'
1414
author_name = 'Ian Barnard'
1515
author_mail = 'ian.barnard@uk.ibm.com'

elmclient/_ccm.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,35 @@ def process_represt_arguments( self, args, allapps ):
395395
queryparams['fields'] = args.fields
396396

397397
return (queryurl,queryparams,queryheaders)
398+
399+
#################################################################################################
400+
401+
class _AMProject(_CCMProject):
402+
def __init__(self, name, project_uri, app, is_optin,singlemode):
403+
super().__init__(name, project_uri, app, is_optin,singlemode)
404+
self.default_query_resource = 'oslc_am:Resource'
405+
406+
#################################################################################################
407+
408+
@utils.mixinomatic
409+
class _AMApp(_app._App, _typesystem.No_Type_System_Mixin):
410+
domain = 'am'
411+
project_class = _AMProject
412+
supports_configs = False
413+
supports_components = False
414+
supports_reportable_rest = False
415+
reportable_rest_status = "Application does not support Reportable REST"
416+
identifier_uri = 'dcterms:identifier'
417+
418+
def __init__(self, server, contextroot, jts=None):
419+
super().__init__(server, contextroot, jts=jts)
420+
self.rootservices_xml = self.execute_get_xml(self.reluri('rootservices'), intent="Retrieve AM rootservices" )
421+
self.serviceproviders = 'oslc_am:amServiceProviders'
422+
423+
def _get_headers(self, headers=None):
424+
result = super()._get_headers()
425+
result['net.jazz.jfs.owning-context'] = self.baseurl
426+
result['OSLC-Core-Version'] = '2.0'
427+
if headers:
428+
result.update(headers)
429+
return result

elmclient/_project.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,27 @@ def find_config(self, name, nowarning=False):
195195

196196
def _do_find_config_by_name(self, name_or_uri, nowarning=False, allow_workspace=True, allow_snapshot=True, allow_changeset=False):
197197
raise Exception( 'Subclass must implement this method.' )
198-
198+
199+
def get_gc_contributions(self,gcuri):
200+
result = self.execute_get_json(self.reluri("gcsdk-api/flatListOfContributionsForGcHierarchy"), params={'configurationUri':gcuri,'include':'*'} )
201+
# print( f"{result=}" )
202+
return result
203+
199204
def set_local_config(self, name_or_uri, global_config_uri=None):
200205
if name_or_uri:
201-
config_uri = self._do_find_config_by_name(name_or_uri)
206+
if global_config_uri is None:
207+
config_uri = self._do_find_config_by_name(name_or_uri)
208+
else:
209+
# gc and local config both specified - try to avoid loading all the local configs by using the gc tree to locate the local config
210+
gc_contribs = self.get_gc_contributions(global_config_uri)
211+
# find the contribution for this component
212+
config_uri = None
213+
for config in gc_contribs['configurations']:
214+
print( f"Checking {config=} for {self.project_uri=}" )
215+
if config['componentUri'] == self.project_uri:
216+
config_uri = config['configurationUri']
217+
if config_uri is None:
218+
burp
202219
if not config_uri:
203220
raise Exception('Cannot find configuration [%s] in project [%s]' % (name_or_uri, self.uri))
204221
else:

elmclient/_rm.py

Lines changed: 125 additions & 66 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)