Skip to content

Commit e8576a9

Browse files
committed
updates to httpops
Started adding AM for OSLC Query - but not working yet! All HTTP operatoins now include two custom headers to make it easier to see where in the code the message was started from - elmclient-Intent and elmclient-Trace (with a stack trace) Started adding API demonstrator for the >=7.1 RM types API - not working yet!
1 parent 48610bf commit e8576a9

15 files changed

Lines changed: 669 additions & 50 deletions

elmclient/_ccm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ def __init__(self, name, project_uri, app, is_optin,singlemode):
465465
class AMApp(_app._App, _typesystem.No_Type_System_Mixin):
466466
domain = 'am'
467467
project_class = AMProject
468-
supports_configs = False
469-
supports_components = False
470-
supports_reportable_rest = False
471-
reportable_rest_status = "Application does not support Reportable REST"
468+
supports_configs = True
469+
supports_components = True
470+
supports_reportable_rest = True
471+
reportable_rest_status = "Application does support Reportable REST see https://jazz.net/wiki/bin/view/Main/RMMReportableRestAPI"
472472
identifier_uri = 'dcterms:identifier'
473473

474474
def __init__(self, server, contextroot, jts=None):

elmclient/_customScenarios.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def getRunningScenarios( self ):
128128
LOGLEVEL = os.environ.get("QUERY_LOGLEVEL" ,None )
129129

130130
# setup arghandler
131-
parser = argparse.ArgumentParser(description="Test harness for CusgtomScenarios")
131+
parser = argparse.ArgumentParser(description="Test harness for CustomScenarios")
132132

133133
parser.add_argument('action', choices=['start','stop','status'], help=f'start/stop/status')
134134
parser.add_argument('name', default=None, nargs='?', help=f'The anme of the scenario - only relevant for the start and stop actions')

elmclient/_project.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _get_typeuri_rdf(self,uri):
7575
logger.info( utils.callers() )
7676
try:
7777
# try to retrieve the rdf using no_error_log=True becase some urls don't exist and we don't really mind if it can't be retrieved, e.g. /jts/users/unassigned which never exits in JTS
78-
self._gettypecache[realuri] = self.execute_get_rdf_xml(uri, intent="Retrieve type definition", no_error_log=True) if uri.startswith( "https://") else None
78+
self._gettypecache[realuri] = self.execute_get_rdf_xml(uri, intent="Retrieve type definition", no_error_log=True, cacheable=True) if uri.startswith( "https://") else None
7979
logger.info( f"Retrieved:" )
8080
except ET.XMLSyntaxError:
8181
self._gettypecache[realuri] = None
@@ -256,6 +256,7 @@ def set_local_config(self, name_or_uri, global_config_uri=None):
256256
# print( f"Checking {config=} for {self.project_uri=}" )
257257
if config['componentUri'] == self.project_uri:
258258
config_uri = config['configurationUri']
259+
break # first match is correct according to GC SDK https://jazz.net/gc/doc/scenario?id=GetFlatListOfContributionsForGcHiearchy
259260
if not config_uri:
260261
raise Exception( 'Cannot find configuration [%s] in project [%s]' % (name_or_uri, self.uri))
261262
else:
@@ -293,9 +294,10 @@ def resolve_shape_name_to_uri(self, name, exception_if_not_found=True):
293294
# the context is the shape definition - can be None, needed to be specified ultimately by the user when property names aren't unique
294295
def resolve_property_name_to_uri(self, name, shapeuri=None, exception_if_not_found=True):
295296
logger.info( f"resolve_property_name_to_uri {name=} {shapeuri=}" )
297+
# print( f"resolve_property_name_to_uri {name=} {shapeuri=}" )
296298
# result = self.get_property_uri(name,shape_uri=shapeuri) or self.get_linktype_uri(name,shape_uri=shapeuri)
297299
result = self.get_property_uri(name, shape_uri=shapeuri) or self.get_linktype_uri(name)
298-
logger.info( f"resolve_property_name_to_uri {name=} {shapeuri=} {result=}" )
300+
# print( f"resolve_property_name_to_uri {name=} {shapeuri=} {result=}" )
299301
return result
300302

301303
# for OSLC query, given an enumeration value name in and context (property uri), return its URI
@@ -487,33 +489,35 @@ def _generic_load_type_from_resource_shape(self, el, supershape=None):
487489
logger.info( "Starting a property")
488490
propnodeid = rdfxml.xmlrdf_get_resource_uri( propel, attrib="rdf:nodeID" )
489491
logger.info( f"{propnodeid=}" )
490-
logger.info( f"{propnodeid=}" )
492+
# print( f"{propnodeid=}" )
491493
real_propel_x = rdfxml.xml_find_element( shapedef_x, f'.//rdf:Description[@rdf:nodeID="{propnodeid}"]' )
492494
logger.info( f"{real_propel_x=}" )
493-
logger.info( f"{real_propel_x=}" )
495+
# print( f"{real_propel_x=}" )
494496
# print( "XML==",ET.tostring(real_propel_x) )
495497
# dcterms:title xml:lang="en"
496498
property_title_el = rdfxml.xml_find_element( real_propel_x, './dcterms:title[@xml:lang="en"]')
497499
logger.info( f"1 {property_title_el=}" )
500+
# print( f"1 {property_title_el=}" )
498501
if property_title_el is None:
499502
property_title_el = rdfxml.xml_find_element(real_propel_x, './dcterms:title[@rdf:datatype]' )
500503
logger.info( f"2 {property_title_el=}" )
504+
# print( f"2 {property_title_el=}" )
501505
if property_title_el is None:
502506
property_title_el = rdfxml.xml_find_element( real_propel_x, './oslc:name')
503507
logger.info( f"3 {property_title_el=}" )
508+
# print( f"3 {property_title_el=}" )
504509
logger.info( f"{property_title_el=}" )
505-
logger.info( f"{property_title_el=}" )
510+
# print( f"{property_title_el=}" )
506511
if property_title_el is None:
507512
logger.info( "Skipping shape with no title!" )
508-
logger.info( "Skipping shape with no title!" )
509-
burp
513+
# print( "Skipping shape with no title!" )
510514
continue
511515
property_title = property_title_el.text
512516
logger.info( f"{property_title=}" )
513-
logger.info( f"{property_title=}" )
517+
# print( f"{property_title=}" )
514518
if rdfxml.xmlrdf_get_resource_text(real_propel_x,"oslc:hidden") == "true":
515519
logger.info( f"Skipping hidden property {property_title}" )
516-
logger.info( f"Skipping hidden property {property_title}" )
520+
# print( f"Skipping hidden property {property_title}" )
517521
continue
518522
valueshape_uri = rdfxml.xmlrdf_get_resource_uri( real_propel_x,'./oslc:valueShape' )
519523
logger.info( f"{valueshape_uri=}" )

elmclient/_qm.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def load_components_and_configurations(self,force=False):
159159
logger.debug( f"full optin" )
160160
cmsp_xml = self.app.retrieve_cm_service_provider_xml()
161161
logger.info( f"cmsp=",ET.tostring(cmsp_xml) )
162+
# print( f"cmsp=",ET.tostring(cmsp_xml) )
162163
# <rdf:Description rdf:nodeID="A4">
163164
# <oslc:resourceType rdf:resource="http://open-services.net/ns/config#Component"/>
164165
# <oslc:queryBase rdf:resource="https://jazz.ibm.com:9443/qm/oslc_config/resources/com.ibm.team.vvc.Component"/>
@@ -167,11 +168,21 @@ def load_components_and_configurations(self,force=False):
167168
# <rdf:type rdf:resource="http://open-services.net/ns/core#QueryCapability"/>
168169
# </rdf:Description>
169170

170-
components_uri = rdfxml.xmlrdf_get_resource_uri(cmsp_xml, './/rdf:Description/rdf:type[@rdf:resource="http://open-services.net/ns/core#QueryCapability"]/../oslc:resourceType[@rdf:resource="http://open-services.net/ns/config#Component"]/../oslc:queryBase')
171-
logger.info( f"{components_uri=}" )
172-
# print( f"{components_uri=}" )
171+
components_x = rdfxml.xml_find_element(cmsp_xml, './/rdf:Description/rdf:type[@rdf:resource="http://open-services.net/ns/core#QueryCapability"]/../oslc:resourceType[@rdf:resource="http://open-services.net/ns/config#Component"]/../oslc:queryBase')
172+
component_uri = rdfxml.xmlrdf_get_resource_uri( components_x )
173+
logger.info( f"1 {component_uri=}" )
174+
if not component_uri:
175+
component_x = rdfxml.xml_find_element(cmsp_xml, './/rdf:Description/oslc:resourceType[@rdf:resource="http://open-services.net/ns/config#Component"]/../oslc:queryBase')
176+
# component_x = rdfxml.xml_find_element(cmsp_xml, './/rdf:Description/oslc:resourceType[@rdf:resource="http://open-services.net/ns/config#Component"]/../oslc:queryBase')
177+
# print( f"{component_x=}" )
178+
component_uri = rdfxml.xmlrdf_get_resource_uri(component_x)
179+
# print( f"3 {component_uri=}" )
180+
# burp
181+
182+
logger.info( f"{component_uri=}" )
183+
# print( f"2 {component_uri=}" )
173184
# get all components
174-
crx = self.execute_get_xml( components_uri, intent="Retrieve component definition" )
185+
crx = self.execute_get_xml( component_uri, intent="Retrieve component definitions" )
175186
logger.info( f"{crx=}" )
176187
# <oslc_config:Component rdf:about="https://jazz.ibm.com:9443/qm/oslc_config/resources/com.ibm.team.vvc.Component/_iw4s4EB3Eeus6Zk4qsm_Cw">
177188
# <dcterms:title rdf:parseType="Literal">SGC Agile</dcterms:title>
@@ -185,11 +196,13 @@ def load_components_and_configurations(self,force=False):
185196
# <dcterms:relation rdf:resource="https://jazz.ibm.com:9443/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/_rikP0EB1Eeus6Zk4qsm_Cw/component/_iw4s4EB3Eeus6Zk4qsm_Cw"/>
186197
# </oslc_config:Component>
187198

188-
for component_el in rdfxml.xml_find_elements(crx, f'.//oslc_config:Component/process:projectArea[@rdf:resource="{self.project_uri}"]/..'):
199+
for component_el in rdfxml.xml_find_elements(crx, f'.//oslc_config:Component/process:projectArea[@rdf:resource="{self.project_uri}"]/..') or rdfxml.xml_find_elements(crx, f'.//rdf:Description/process:projectArea[@rdf:resource="{self.project_uri}"]/..'):
189200
logger.info( f"{component_el=}" )
201+
# print( f"{component_el=}" )
190202
compu = rdfxml.xmlrdf_get_resource_uri(component_el)
191203
comptitle = rdfxml.xmlrdf_get_resource_text(component_el, './/dcterms:title')
192204
logger.info( f"Found component {comptitle}" )
205+
# print( f"Found component {comptitle}" )
193206
ncomps += 1
194207
confu = rdfxml.xmlrdf_get_resource_uri(component_el, './/oslc_config:configurations')
195208
self._components[compu] = {'name': comptitle, 'configurations': {}, 'confs_to_load': [confu]}
@@ -498,7 +511,7 @@ def queryResourcesByIDs( self, identifiers, *, querytype=None, filterFunction=No
498511
identifiers = [str(i) for i in identifiers]
499512
# print( f"{identifiers=}" )
500513
for i in identifiers:
501-
print( f"{i=}" )
514+
# print( f"{i=}" )
502515
if not utils.isint( str(i) ):
503516
raise Exception( "value '{i}' is not an integer!" )
504517

elmclient/_queryparser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def simpleidentifier(self,s):
294294
raise Exception( "Bad simpleidentifier" )
295295
resultname = s[0].value
296296
# look it up and if necessary store to mapping
297+
# print( f"{self=} {self.resolverobject=} {self.resolverobject.resolve_property_name_to_uri=} {resultname=}" )
297298
result = self.resolverobject.resolve_property_name_to_uri(resultname)
298299
if result is None:
299300
raise Exception("Name resolution for %s failed!" % (resultname))

elmclient/_rm.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from . import utils
2828
from . import _newtypesystem
2929
from . import resource
30+
from . import _rmtypesapi
3031

3132
# used for OSLC Query on types
3233
typeresources = {
@@ -39,17 +40,50 @@
3940

4041
class CoreResource( resource.Resource ):
4142
name = "Core"
43+
def getBindings( self ):
44+
raise Exception( "Save not implemented yet" )
45+
pass
4246

4347
class BindingResource( resource.Resource):
4448
name = "Binding"
45-
49+
moduleResource=None
50+
coreResource=None
51+
def _getSection():
52+
pass
53+
def _getCoreResource(self):
54+
pass
55+
def _getParent(self):
56+
pass
57+
def _getChildren( self):
58+
pass
59+
def addBelow(self,coreid_or_coreresource_or_artifacttype):
60+
# add new binding below
61+
pass
62+
def addAfter( self,coreid_or_coreresource_or_artifacttype ):
63+
# add new binding after
64+
pass
65+
def moveAfter( self, binding ):
66+
# move self and all children
67+
pass
68+
def moveBelow( self, binding ):
69+
# move self and all children
70+
pass
71+
def delete( self ):
72+
# delete self and all children
73+
pass
74+
4675
class ModuleResource( resource.Resource ):
4776
name = "Module"
48-
77+
structureResource=None
78+
bindingHierarchyRoot=None # this will be an AnyTree, each entry pointing at a BindingResource
4979
def getModuleBindings( self ):
5080
raise Exception( "Save not implemented yet" )
5181
pass
52-
82+
def findBindingBySection( self, section ):
83+
pass
84+
def iterateHierarchy( self ):
85+
pass
86+
5387
class WrapperResource( resource.Resource ):
5488
name="Wrapper"
5589

@@ -210,7 +244,7 @@ class _RM_PA_changeset( _config._Changeset,_RMProject):
210244
pass
211245

212246
@utils.mixinomatic
213-
class RMProject(_project._Project, resource.Resources_Mixin ):
247+
class RMProject(_project._Project, resource.Resources_Mixin, _rmtypesapi.RMTypes_Mixin ):
214248
# A project
215249
# NOTE there is a derived class RMComponent used for RM components - it doesn't offer any
216250
# functionality, and is a separate class only so it's easier to see whether an instance is a component or the overall project

0 commit comments

Comments
 (0)