jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

How to get a document at a specific revision? #113

Closed krishtej23 closed 1 year ago

krishtej23 commented 1 year ago

Hi Jesper,

I have been trying to get the document at a specific revision. I tried to use getModuleByLocation(project ID, location) function documented by Polarion here. Polarion documentation says Use the location with a revision set to retrieve a particular revision of the Module/Document. I used the following steps but with no luck.

  1. projObj = polarionServices.getProject(project ID)
  2. based on the document ID and project object, I get the module URI without any revision.
  3. get the revision from the user (assume it is valid for now)
  4. module = polarionServices.getModuleByUri(uri)
  5. doc2 = projectObj.getDocument(module.location+":1234"). The location here is default:/repo/projectID/modules/SpaceName/DocumentID/module.xml
  6. Error: Exception: Cannot find the document at location default:/repo/projectID/modules/SpaceName/DocumentID/module.xml:1234 in project projectID. I tried different ways of adding version to the location and always end up in error.
    • module.location+"[1234]"
    • module.location+"&rev=1234"
    • module.location+"&revision=1234"
  7. I also tried as ?revision=12345. I get the same error: Exception: Cannot find the document at location default:/repo/projectID/modules/SpaceName/DocumentID/module.xml?revision=12345 in project projectID
  8. I tried doc = polarionServices.getModuleByLocation(projectObj, module.location). URI in the doc object is only filled as: subterra:data-service:objects:/default/Polarion project projectID prefix XYZ${Module}{moduleFolder}documentID#module.xml and all other attributes are None.
  9. I appended the revision to the location as doc = polarionServices.getModuleByLocation(projectObj, module.location+"?revision=1234"). URI in the doc object is only filled with revision as: subterra:data-service:objects:/default/Polarion project projectID prefix XYZ${Module}{moduleFolder}documentID#module.xml?revision=1234 and all other attributes are None.

Is there a way to retrieve a document at the specific revision?

krishtej23 commented 1 year ago

I could retrieve the document at a specific revision as follows:

  1. projObj = polarion.getProject(project ID)
  2. based on the document ID and project object, I get the module URI without any revision.
  3. get the revision from user. Example: 12345
  4. module = polarion.getModuleByUri(uri+'%'+12345). This loads the module at the specific revision. Final uri becomes subterra:data-service:objects:/default/Polarion project projectID prefix XYZ${Module}{moduleFolder}SpaceName#documentID%12345
  5. If the revision provided is invalid then module.id will be None. This can be checked for revision validity.
  6. workitem_uri_list = polarion.getModuleWorkItemUris(module.uri, title_uri, True). title_uri is the heading work item under which work items need to be retrieved.

Closing this issue, as this solution works.