From 818be9ea454f1aef72fe3a24acca058b08431524 Mon Sep 17 00:00:00 2001 From: the-working-rene <88379617+the-working-rene@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:03:55 +0200 Subject: [PATCH] add global queryWorkitems method queries workitem globally independent of the project implements #178 --- polarion/polarion.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/polarion/polarion.py b/polarion/polarion.py index f7f45d7..e1a62df 100644 --- a/polarion/polarion.py +++ b/polarion/polarion.py @@ -8,6 +8,7 @@ from zeep.plugins import HistoryPlugin from .project import Project +from .workitem import Workitem import logging logger = logging.getLogger(__name__) @@ -119,7 +120,7 @@ def _createSession(self): else: raise Exception( 'Cannot login because WSDL has no SessionWebService') - + def get_client(self,service,plugins=[]): client = None if self.cache: @@ -241,6 +242,25 @@ def getProject(self, project_id): """ return Project(self, project_id) + def queryWorkitems(self, query: str, sort: str): + """Get List of workitems based on a query. + Query is global and not project specific, so it will return workitems from all projects. Use with caution. + Uses the Polarion query language. Documented as 'Advanced Work Item querying' in the Polarion documentation. + + :param query: The query. + :param sort: The field to be used for sorting. + :return: The workitems matching the query + :rtype: Workitem[] + """ + service = self.getService("Tracker") + results = service.queryWorkItems(query, sort, fields=["project.id"]) + workitems = [] + for result in results: + project = self.getProject(result.project.id) + workitems.append(Workitem(self, project, uri=result.uri)) + return workitems + + def downloadFromSvn(self, url): if self.svn_repo_url is not None: