def get_reports_list_from_server(self, force=False): ret = {} s = Search(self.session) result = s.search(path=self.doc.get("jasper_report_root_path").strip(), type="reportUnit") reports = result.getDescriptor().json_descriptor() for report in reports: ics = [] d = Details(self.session, report.get("uri")) r_details = d.details(expanded=False) r_param = r_details.getDescriptor().json_descriptor() uri = r_param[0].get('jrxml').get('jrxmlFileReference').get('uri') file_content = self.get_jrxml_from_server(uri) xmldoc = JasperXmlReport(BytesIO(file_content)) params = xmldoc.get_params() query = self.get_query_jrxmlFile_from_server(file_content) for param in params: pname = param.xpath('./@name') pclass = param.xpath('./@class') ptype = pclass[0].split(".") c = len(ptype) - 1 ics.append({"label":pname[0], "type":ptype[c].lower()}) updateDate = report.get("updateDate", None) if not updateDate: updateDate = report.get("creationDate", frappe.utils.now()) ret[report.get("label")] = {"uri":report.get("uri"), "inputControls": ics, "updateDate": updateDate, "queryString": query} return ret
from jasperserverlib.resource_details import Details from jasperserverlib.resource_download import DownloadBinary from jasperserverlib.report import Report from jasperserverlib.core.resource_search_param import ResourceSearchParameter as rsp pp = pprint.PrettyPrinter(indent=4) session = jasper.session('http://localhost:8090/jasperserverlib', 'jasperadmin', 'jasperadmin') #s = Search(session) #s.search(path="/reports/erpnext") #pp.pprint(s.getDescriptor()) d = Details(session, "/reports/testFolder/Example") pp.pprint(d.serverInfo()) #pp.pprint(d.details().getDescriptor()) #print "desc: {}".format(d.details().getDescriptor()) #/themes/default/buttons.css #dl = DownloadBinary(session, "/reports/testFolder/Example_files/main_jrxml") #dl.downloadBinary() #pp.pprint(dl.downloadBinary().getDescriptor().getContent(dl.downloadBinary().getDescriptor().getLabels()[0])) #pp.pprint(dl.downloadBinary().getDescriptor().getType(dl.downloadBinary().getDescriptor().getLabels()[0])) #r = Report(session, "/reports/testFolder/Example") #r = Report(session, "/reports/testFolder/Silhouette") #r = Report(session, "/reports/testFolder/Flower") #r = Report(session, "/reports/testFolder/Cherry_Table_Based") #r.parameter("Cascading_name_single_select", "A & U Stalker Telecommunications, Inc")
def get_server_info(self): details = Details(self.session) serverInfo = details.serverInfo() return serverInfo