Skip to content

Commit c6f81c0

Browse files
committed
0.19.0 - see what's new in README.md - RM-only: changeset create/deliver, create folder, both with simple examples
1 parent 49791f8 commit c6f81c0

Some content is hidden

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

44 files changed

+4146
-3070
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.18.0
2+
current_version = 0.19.0
33
commit = True
44
tag = True
55

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@
88

99
SPDX-License-Identifier: MIT
1010

11-
version="0.18.0"
11+
version="0.19.0"
1212

13+
What's New?
14+
===========
15+
16+
0.19.0 4-May-2023
17+
* Deprecated RM load_folders() - use find_folder() instead.
18+
* Added RM create_folder() - this doesn't require doing a forced reload of all folders, because it inserts the new folder into the internal info about folders
19+
* Added example dn_simple_createfolderpath.py - allows exercising the create_folders() function
20+
* Added rm-only implementation of create/deliver changeset NOTE these aren't fully finished, specifically hte delivery result may not be obvious(!)
21+
* Added example dn_simple_typesystemimport_cs.py which shows creating/delivering a changeset around typesystem import
1322

1423
Introduction
1524
============

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.18.0'
12+
version = '0.19.0'
1313
license = 'MIT'
1414
author_name = 'Ian Barnard'
1515
author_mail = 'ian.barnard@uk.ibm.com'

elmclient/_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ def set_local_config(self, name_or_uri, global_config_uri=None):
241241
# retrieve the services.xml in the current config!
242242
self.services_xml = self.execute_get_rdf_xml(self.component_project.services_uri, intent="Retrieve project's services.xml")
243243

244+
# create a changeset in the current config (must be a stream)
245+
def create_changeset( self, name ):
246+
raise Exception( "Can't create a changeset on a project!" )
247+
248+
def discard_changeset( self ):
249+
raise Exception( "Can't discard a changeset on a project!" )
250+
251+
def deliver_changeset( self ):
252+
raise Exception( "Can't deliver a changeset on a project!" )
253+
244254
def _load_types(self,force=False):
245255
logger.info( f"{self=}" )
246256
raise Exception( "This must be implemented by the app-specific project class!" )

elmclient/_rm.py

Lines changed: 263 additions & 42 deletions
Large diffs are not rendered by default.

elmclient/examples/basic/dn_basic_oslcquery.py

Lines changed: 0 additions & 373 deletions
This file was deleted.

elmclient/examples/dn_basic_oslcquery.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# a self-contained example for 7.0.2/7.0.2SR1 not using elmclient - does all low-level HTTP GETs to discover to find the project+component_config and then do OSLC Query
77
# and then does a very basic save to CSV
88

9+
# NOTE the very primitive authentication in this code only works with Liberty form authentication, i.e. NOT with JAS!
10+
911
# You see all the fun of picking stuff out of the RDF XML
1012
# It's quite possible this could be simpler or at least more readable using rdflib
1113

1214
# CONTRAST this with dn_simple_oslcquery.py which uses elmclient
1315

14-
# NOTE the authentication in this code only works with Liberty form authentication, i.e. NOT with JAS!
15-
1616
# this brutally minimal example has many limitations:
1717
# only works for a query which doesn't involve custom attributes/links - because otherwise you have to find the URIs of these - hardcoded to get all resuls with no oslc.where
1818
# only works for RM - it's hardcoded to rm
@@ -145,6 +145,8 @@ def getconfigtype( configuri ):
145145
#
146146
# low-level version NOT using elmclient AT ALL - everything including authentication for basic Liberty form auth is done here
147147
#
148+
# NOTE THIS ONLY WORKS FOR FORM-BASED login, i.e. doesn't work with JAS!
149+
#
148150

149151
# generic HTTP GET with login if auth is needed
150152
def get_with_optional_login( sess, url, *, params=None, headers=None, username="", password="", verify=False):

elmclient/examples/dn_simple_createartifact.py

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

9696
# load the folder (using folder query capability)
9797
# NOTE this returns as soon as it finds a matching folder - i.e. doesn't load them all!
98-
thefolder = c.load_folders(sys.argv[3])
98+
thefolder = c.find_folder(sys.argv[3])
9999
if thefolder is None:
100100
raise Exception( f"Folder '{sys.argv[3]}' not found!" )
101101
print( f"Folder URL = {thefolder.folderuri}" )

elmclient/examples/dn_simple_createfolderandartifact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@
105105
if not fullnewfoldername.endswith( "/" ):
106106
fullnewfoldername += "/"
107107
fullnewfoldername += sys.argv[4]
108-
thefolder = c.load_folders(fullnewfoldername)
108+
thefolder = c.find_folder(fullnewfoldername)
109109

110110
# check if the folder doesn't exist
111111
if thefolder is None:
112112
# have to create it!
113113
# get the parent
114-
thefolder = c.load_folders(sys.argv[3])
114+
thefolder = c.find_folder(sys.argv[3])
115115
if not thefolder:
116116
raise Exception( f"Parent folder '{sys.argv[3]}' doesn't exist!" )
117117

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
##
2+
## © Copyright 2023- IBM Inc. All rights reserved
3+
# SPDX-License-Identifier: MIT
4+
##
5+
6+
# example of creating a folder path
7+
# provide on the commandline (each surrounded by " if it contains a space) the apths of folders you want to create - paths MUST start with /
8+
9+
# For info about folder create API see https://rhnaranjo.wordpress.com/2012/06/25/folder-support-added-to-rrc-4-0-oslc-rm-api-implementation/
10+
11+
# Also see section 2 of https://jazz.net/library/article/1197
12+
13+
#
14+
# folders are found using a OSLC Query capability for folders - this returns one level at a time
15+
# so will likely need a series of queries to find an existing folder
16+
# this is all implemented in load_fodlers()
17+
# new create_folders() will create a folder path and update the loaded folders so a full reload isn't needed
18+
#
19+
20+
import logging
21+
import os.path
22+
import sys
23+
import time
24+
25+
import lxml.etree as ET
26+
27+
import elmclient.server as elmserver
28+
import elmclient.utils as utils
29+
import elmclient.rdfxml as rdfxml
30+
31+
# setup logging - see levels in utils.py
32+
#loglevel = "INFO,INFO"
33+
loglevel = "TRACE,OFF"
34+
levels = [utils.loglevels.get(l,-1) for l in loglevel.split(",",1)]
35+
if len(levels)<2:
36+
# assert console logging level OFF if not provided
37+
levels.append(None)
38+
if -1 in levels:
39+
raise Exception( f'Logging level {loglevel} not valid - should be comma-separated one or two values from DEBUG, INFO, WARNING, ERROR, CRITICAL, OFF' )
40+
utils.setup_logging( filelevel=levels[0], consolelevel=levels[1] )
41+
42+
logger = logging.getLogger(__name__)
43+
44+
utils.log_commandline( os.path.basename(sys.argv[0]) )
45+
46+
jazzhost = 'https://jazz.ibm.com:9443'
47+
48+
username = 'ibm'
49+
password = 'ibm'
50+
51+
jtscontext = 'jts'
52+
rmcontext = 'rm'
53+
54+
# the project+compontent+config that will be updated
55+
proj = "rm_optout_p1"
56+
comp = proj
57+
conf = f"{comp} Initial Stream"
58+
59+
# caching control
60+
# 0=fully cached (but code below specifies queries aren't cached) - if you need to clear the cache, delet efolder .web_cache
61+
# 1=clear cache initially then continue with cache enabled
62+
# 2=clear cache and disable caching
63+
caching = 2
64+
65+
##################################################################################
66+
if __name__=="__main__":
67+
if len(sys.argv) < 2:
68+
raise Exception( 'Provide one or more space-separated paths on the commandline' )
69+
70+
71+
print( f"Attempting to create paths '{sys.argv[1:]}' in project '{proj}' in configuration {conf}" )
72+
print( f"Using credentials user '{username}' password '{password}'")
73+
74+
# create our "server" which is how we connect to DOORS Next
75+
# first enable the proxy so if a proxy is running it can monitor the communication with server (this is ignored if proxy isn't running)
76+
elmserver.setupproxy(jazzhost,proxyport=8888)
77+
theserver = elmserver.JazzTeamServer(jazzhost, username, password, verifysslcerts=False, jtsappstring=f"jts:{jtscontext}", appstring='rm', cachingcontrol=caching)
78+
79+
# create the RM application interface
80+
dnapp = theserver.find_app( f"rm:{rmcontext}", ok_to_create=True )
81+
82+
# open the project
83+
p = dnapp.find_project(proj)
84+
85+
# find the component
86+
c = p.find_local_component(comp)
87+
comp_u = c.project_uri
88+
print( f"{comp_u=}" )
89+
90+
# select the configuration
91+
config_u = c.get_local_config(conf)
92+
print( f"{config_u=}" )
93+
c.set_local_config(config_u)
94+
95+
for path in sys.argv[1:]:
96+
97+
thefolder = c.find_folder(path)
98+
99+
# check if the path doesn't exist
100+
if thefolder is None:
101+
# have to create it!
102+
# get the parent
103+
thefolder = c.create_folder( path )
104+
print( f"Folder '{path}' created uri is {thefolder.folderuri}" )
105+
else:
106+
print( f"Folder '{path}' already exists" )
107+

0 commit comments

Comments
 (0)