IBM / ELM-Python-Client

Python client for IBM Enterprise Lifecycle Management applications with example commandline applications for OSLC Query export to CSV from DOORS Next (DN/DNG), Enterprise Workflow Management (EWM/RTC) and Enterprise Test Management (ETM/RQM), ReqIF import/export, and DOORS Next Reportable REST export to CSV/XML
Other
26 stars 13 forks source link

RM how to retrieve value/label from enumerated attribute #64

Open struggling-dev0 opened 5 months ago

struggling-dev0 commented 5 months ago

I've been working in a project that has made extensive use of custom artifacts and attributes, and was wondering if there was a way to translate the URI returned for enumerated attributes by oslc_query methods into the corresponding value/label.

In the artifact XML returned by theartifact_x, etag = self.config.component.execute_get_rdf_xml( theartifact_u, return_etag=True, intent="Retrieve the artifact" ) we've been able to retrieve and modify our custom attributes by parsing the output, but for enumerated attributes the only return value is an 'rdf:resource' URI (example provided below).

<j.0:enumAttribute rdf:resource="https://jazz.external.company.com/rm/types/AT_YizZiKjKEe2vXr_tc4cF9Q#_9s-KxivuIym9A1QTfgQjpA"/>

How can I retrieve the value and label associated with this enumerated URI?

barny commented 5 months ago

You can retrieve the definitions of artifacts through the shapes referenced in the CreationFactory in the configuration-specific services.xml document.

The example oslcquery.py uses these to generate a typesystem report which will show enumerations and their values, when using option --typesystemreport

barny commented 5 months ago

NOTE there are some limitations on the typesystem support implemented in elmclient - for example there's no resolution of URIs across different components to recognise the types are equivalent - this in particular would affect OSLC Query across more than one component.

struggling-dev0 commented 5 months ago

This is just what I was looking for, thank you!

To follow on, I notice that when performing the oslc query the typesystemreport is generated near-instantly, but the full query is taking substantially longer. For my purposes I only need the typesystemreport to get the enumeration values; is there a way to inhibit the full query and only return the typesystemreport?

barny commented 5 months ago

oslcquery caches the typesystem for 7 days - the first time you access it will take a long time then it will be a lot quicker for 7 days because the shapes are coming from the cache withput having to contact the server.. Add -W to the oslcquery command to clear the cache and it will be slower as it has to get the results from the server.

It's this line in oslcquery.py that sets the caching level:

# create our "server" theserver = server.JazzTeamServer(args.jazzurl, args.username, args.password, verifysslcerts=args.certs, jtsappstring=f"jts:{approots['jts']}", cachingcontrol=args.cachecontrol, cachefolder=cachefolder )

It's the line in oslcquery.py which loads the types from the project/component being queried:

queryon.load_types()