Skip to content

Commit a7f0bb5

Browse files
committed
squashing bugs
1 parent 3db0668 commit a7f0bb5

File tree

14 files changed

+371
-76
lines changed

14 files changed

+371
-76
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,43 @@ ELM APIs
135135
This code provides examples of using various ELM APIs:
136136

137137
* DN
138+
138139
** Process - `elmclient`
140+
139141
** OSLC including OSLC Query - `oslcquery.py` for user use, internally `oslcqueryapi.py` implements OSLC Query parsing and querying
142+
140143
** Module Structure - `dn_simple_modulestructure.py` - currently external to `elmclient`
144+
141145
** ReqIF - `reqif_io.py` - currently reqif API is external to `elmclient`
146+
142147
** Reportable REST (incomplete for qm and ccm) - `represt.py` for user use, internally for each application in `_rm.py`, `_ccm.py`, `_qm.py`
143148

149+
144150
* ETM
151+
145152
** Process - `elmclient`
153+
146154
** OSLC including OSLC Query - `oslcquery.py` for user use, internally `oslcqueryapi.py` implements OSLC Query parsing and querying
155+
147156
** Reportable REST (incomplete for qm and ccm) - `represt.py` for user use, internally for each application in `_rm.py`, `_ccm.py`, `_qm.py`
148157

158+
149159
* EWM
160+
150161
** Process - `elmclient`
162+
151163
** OSLC including OSLC Query - `oslcquery.py` for user use, internally `oslcqueryapi.py` implements OSLC Query parsing and querying
164+
152165
** Reportable REST (incomplete for qm and ccm) - `represt.py` for user use, internally for each application in `_rm.py`, `_ccm.py`, `_qm.py`
153166

167+
154168
* GCM
169+
155170
** Process - `elmclient`
171+
156172
** OSLC including OSLC Query - `oslcquery.py` for user use, internally `oslcqueryapi.py` implements OSLC Query parsing and querying
157173

174+
158175
Reporting issues, and contributing
159176
==================================
160177

elmclient/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ._rm import *
1616
from ._gcm import *
1717
from ._qm import *
18+
from ._relm import *
1819
from .__meta__ import *
1920

2021
__app__ = __meta__.app

elmclient/_app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
logger = logging.getLogger(__name__)
1818

19-
2019
#################################################################################################
2120
# a generic jazz application
2221

@@ -122,10 +121,12 @@ def _load_projects(self,include_archived=False,force=False):
122121
if include_archived:
123122
params['includeArchived'] = 'true'
124123
self.project_areas_xml = self.execute_get_xml(uri, params=params)
125-
124+
logger.debug( f"{self.project_areas_xml=}" )
126125
for projectel in rdfxml.xml_find_elements(self.project_areas_xml,".//jp06:project-area" ):
126+
logger.debug( f"{projectel=}" )
127127
projectu = rdfxml.xmlrdf_get_resource_text(projectel,".//jp06:url")
128128
projectname = rdfxml.xmlrdf_get_resource_uri(projectel,attrib='jp06:name')
129+
logger.debug( f"{projectname=}" )
129130
is_optin = False
130131
singlemode = False
131132
if self.supports_configs:
@@ -152,6 +153,7 @@ def find_project(self, projectname_or_uri, include_archived=False):
152153
else:
153154
# must be a name
154155
projectu = self._projects.get(projectname_or_uri)
156+
print( f"{projectu=}" )
155157
if projectu is None:
156158
res = None
157159
else:

elmclient/_project.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defa
4141
self.services_xml = None
4242
self.services_uri = None
4343
self.appcatalog_xml = None
44-
# self._type_system = _typesystem.Type_System()
45-
# self._gettypecache = {}
4644
self.hooks = []
4745
# copy the server from the app - this is so OSLC query can be done on either a project including component) or app
4846
self.server = app.server

elmclient/_relm.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
##
2+
## © Copyright 2021- IBM Inc. All rights reserved
3+
# SPDX-License-Identifier: MIT
4+
##
5+
6+
7+
#################################################################################################
8+
9+
# ENI/RELM application
10+
11+
#
12+
# This is a skeleton implementation for ENI/RELM - just enough to support finding a project
13+
#
14+
15+
#################################################################################################
16+
17+
import logging
18+
19+
import requests
20+
import lxml.etree as ET
21+
import tqdm
22+
23+
from . import _app
24+
from . import _project
25+
from . import _typesystem
26+
from . import oslcqueryapi
27+
from . import rdfxml
28+
from . import server
29+
from . import utils
30+
31+
logger = logging.getLogger(__name__)
32+
33+
#################################################################################################
34+
35+
class _RELMProject(_project._Project):
36+
def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defaultinit=False):
37+
super().__init__(name, project_uri, app, is_optin,singlemode, defaultinit=defaultinit)
38+
self.hooks = []
39+
self._components = None # will become a dict keyed on component uri
40+
self._configurations = None # keyed on the config name
41+
self.default_query_resource = 'oslc_config:Configuration'
42+
43+
44+
#################################################################################################
45+
46+
#@utils.mixinomatic
47+
class RELMApp(_app._App):
48+
domain = 'relm'
49+
project_class = _RELMProject
50+
supports_configs = False
51+
supports_components = False
52+
supports_reportable_rest = False
53+
54+
relprefixes = (
55+
)
56+
57+
# identifier_name = 'Short ID'
58+
# identifier_uri = 'Identifier'
59+
60+
def __init__(self, server, contextroot, jts=None):
61+
super().__init__(server, contextroot, jts=jts)
62+
63+
self.rootservices_xml = self.execute_get_xml(self.reluri('rootservices'))
64+
# self.serviceproviders = 'gc:globalConfigServiceProviders'
65+
# self.default_query_resource = 'oslc_config:Configuration'
66+
# register some app-specific namespaces
67+
for prefix,reluri in self.relprefixes:
68+
rdfxml.addprefix(prefix,self.baseurl+reluri)
69+
self.hooks = []
70+
71+
def _get_headers(self, headers=None):
72+
result = super()._get_headers()
73+
result['net.jazz.jfs.owning-context'] = self.baseurl
74+
if headers:
75+
result.update(headers)
76+
return result
77+

elmclient/_rm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def load_components_and_configurations(self,force=False):
363363
return (ncomps, nconfs)
364364

365365
def get_local_config(self, name_or_uri):
366-
# self.load_components_and_configurations()
366+
self.load_components_and_configurations()
367367
result = None
368368
filter = None
369369
if name_or_uri.startswith("S:"):
@@ -931,7 +931,9 @@ def process_represt_arguments( self, args, allapps ):
931931
for k,v in modules.items():
932932
print( f'{k} {v.get("dcterms:title","")}' )
933933
raise Exception( "More than one module with that name in {args.project} {args.component}" )
934-
queryparams['moduleUri'] = list(modules.keys())[0]
934+
moduleuuid = list(modules.keys())[0].rsplit("/",1)[1]
935+
# queryparams['moduleUri'] = list(modules.keys())[0]
936+
queryparams['moduleUri'] = moduleuuid
935937

936938
if args.collection:
937939
raise Exception( "Not implemented yet" )
@@ -1007,7 +1009,7 @@ def process_represt_arguments( self, args, allapps ):
10071009

10081010
if args.history:
10091011
queryparams['history'] = True
1010-
1012+
10111013
queryurl = self.reluri(self.reportablerestbase) + "/"+ args.artifact_format
10121014

10131015
if args.all:

elmclient/examples/OSLCQUERY.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ BEFORE you start:
182182

183183
* If an option includes spaces surround it with " "
184184

185-
* On Windows at least, on the command line it is necessary to put " around values that include ", < or > and then double any " within a string. So a query like State="New" has to be entered as "State=""New""", or dcterms:identifier<23 has to be entered as "dcterms:identifier<23"
185+
* On Windows at least, on the command line it is necessary to put " around values that include space, ", < or > and then double any " within a string. So a query like State="New" has to be entered as "State=""New""", or dcterms:identifier<23 has to be entered as "dcterms:identifier<23"
186+
187+
* On Windows at least, if for example a title that you're searching for includes an embedded double-quote " then you have to escape each with a backslash \. Because of the way the Windows commandline works, this means you have to replace each embedded " with \\"". For example to query for a title `A "specification"` you have to put `"dcterms:title=""A \\""specification\\"""""`
186188

187189
* The query specified with the '-q' option supports extended OSLC query syntax, described below - in particular this adds syntactic support for referencing definition names, user names and folder names, and also allows combining results from two or more OSLC queries using set union (denoted by ||) and intersection (denoted by &&).
188190

@@ -356,6 +358,8 @@ If your DN application is not on context root /rm then use the -A option for exa
356358

357359
Use the typesystem report to see all the shapes, properties and enumeration names in your project: add `-typesystemreport file.html` to the commandline. Note not all properties are queryable.
358360

361+
If the title of a module (or anything) includes a double-quote " then you have to escape it with \\ and double the quote to "" so it becomes \\"" in the command line. For example to find a module with title `A "specification"` use `-q "dcterms:title=""A \\""specification\"""""`
362+
359363
You can add a filter like `-v rm_nav:parent` to only show results where parent isn't empty - i.e. to get only core artifacts - unfortunately this filters can only be done is by postprocessing the query results so it doesn't speed up the query itself.
360364

361365
The converse filter is `-n rm_nav:parent`, which filters out results where parent is empty, i.e. only returns module artifacts. You can use -n and -v but that only makes sense (i.e. if you want to possibly get some results) if they reference different attributes.

0 commit comments

Comments
 (0)