Пример #1
0
def generar_reporte(request):
    compiling()
    input_file = os.path.dirname(
        os.path.abspath(__file__)) + '/prueba_Template.jrxml'
    output = os.path.dirname(os.path.abspath(__file__)) + '/reporte'
    pdfFile = os.path.dirname(os.path.abspath(__file__)) + '/reporte.pdf'
    con = {
        'driver': 'postgres',
        'username': '******',
        'password': '******',
        'host': 'localhost',
        'database': 'blognautic',
        'schema': 'public',
        'port': '5432'
    }
    print(con)
    jasper = JasperPy()
    jasper.process(
        input_file,
        output_file=output,
        format_list=["pdf"],
        parameters={},
        db_connection=con,
        locale='en_US'  # LOCALE Ex.:(en_US, de_GE)
    )
    subprocess.Popen(pdfFile, shell=True)
    return render(request, 'articles/article_list.html')
def json_to_pdf(report_count):
    template = os.path.dirname(os.path.abspath(__file__)) + \
                 '/jasper/crisis_report_template.jrxml'

    output = os.path.dirname(
        os.path.abspath(__file__)) + '/reports/report' + str(report_count)
    json_query = 'cases'

    data_file = os.path.dirname(os.path.abspath(__file__)) + \
        '/json_summary/json'+str(report_count)+'.json'

    jasper = JasperPy()
    jasper.process(template,
                   output_file=output,
                   format_list=["pdf"],
                   parameters={},
                   db_connection={
                       'data_file': data_file,
                       'driver': 'json',
                       'json_query': json_query,
                   },
                   locale='en_US')

    print('Result is the file below.')
    print(output + '.pdf')
Пример #3
0
def json_to_pdf():
    input_file = os.path.dirname(os.path.abspath(__file__)) + \
                 '/examples/json.jrxml'

    output = os.path.dirname(os.path.abspath(__file__)) + '/output/_Contacts'
    json_query = 'contacts.person'

    data_file = os.path.dirname(os.path.abspath(__file__)) + \
        '/examples/contacts.json'

    jasper = JasperPy()
    jasper.process(
        input_file,
        output_file=output,
        format_list=["pdf"],
        parameters={},
        db_connection={
            'data_file': data_file,
            'driver': 'json',
            'json_query': json_query,
        },
        locale='pt_BR'  # LOCALE Ex.:(en_US, de_GE)
    )

    print('Result is the file below.')
    print(output + '.pdf')
Пример #4
0
    def create_report(self, reference_code, jasper_file):
        output_file = os.path.join(
            settings.BASE_DIR, 'clockwork', 'labels', 'output',
            '%s_%s' % (reference_code, jasper_file.replace(".jrxml", "")))

        if jasper_file:
            input_file = os.path.join(settings.BASE_DIR, 'clockwork', 'labels',
                                      'jasper', jasper_file)
            data_file = os.path.join(settings.BASE_DIR, 'clockwork', 'labels',
                                     'workdir', '%s.json' % reference_code)

            jasper = JasperPy()
            jasper.process(input_file,
                           output_file=output_file,
                           format_list=["pdf"],
                           parameters={},
                           db_connection={
                               'data_file': data_file,
                               'driver': 'json',
                               'json_query': 'labels',
                           },
                           locale='en_US')
        else:
            with open(output_file, 'w') as pdf:
                pass
Пример #5
0
def make_jasper_report(reporte, from_date, to_date, tipo):
    from_date = datetime.datetime.strptime(from_date,
                                           '%Y-%m-%d').strftime('%d/%m/%Y')
    to_date = datetime.datetime.strptime(to_date,
                                         '%Y-%m-%d').strftime('%d/%m/%Y')
    my_path = os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.pardir))
    my_path = os.path.abspath(os.path.join(my_path, os.pardir))
    input_file = os.path.dirname(
        my_path) + "/jasper_reports/" + reporte + ".jrxml"
    output = os.path.dirname(my_path) + '/reportes/' + tipo.lower(
    ) + "_" + str(datetime.datetime.now())
    con = {
        'driver': 'mysql',
        'username': frappe.conf.get("db_name"),
        'password': frappe.conf.get("db_password"),
        'host': frappe.conf.get("db_host"),
        'database': frappe.conf.get("db_name"),
        'port': '3306'
    }
    jasper = JasperPy()
    jasper.process(
        input_file,
        output_file=output,
        format_list=["pdf", "rtf", "xml"],
        parameters={
            'from_date': from_date,
            'to_date': to_date
        },
        db_connection=con,
        locale='en_US'  # LOCALE Ex.:(en_US, de_GE)
    )
    return output
Пример #6
0
def advanced_example_using_database():
    input_file = 'C:/output/report2.jrxml'
    output = 'c:/output/examples'
    con = sqlite3.connect('C:/output/checkrecived.sqlite')
    data = pd.read_sql_query("select code,PartyAccount from tblPartyAccount",
                             con)
    print(data)
    jasper = JasperPy()
    jasper.process(input_file,
                   output_file=output,
                   format_list=["pdf", "rtf"],
                   db_connection=con)
Пример #7
0
 def get_inoive_pdf(self, InvoiceNumber):
     input_file = os.path.dirname(os.path.abspath(
         __file__)) + '/Reports/RptFiles/RptInvoicePrint.jrxml'
     output = os.path.dirname(os.path.abspath(
         __file__)) + '/Reports/OutPutFiles/' + InvoiceNumber
     con = {
         'driver': 'mysql',
         'username': '******',
         'password': '******',
         'host': 'localhost',
         'database': 'imsapp',
         'port': '3306'
     }
     jasper = JasperPy()
     jasper.process(input_file,
                    output_file=output,
                    format_list=["pdf"],
                    db_connection=con,
                    locale='en_US',
                    parameters={'InvoiceNO': str(InvoiceNumber)})
     return output
Пример #8
0
def json_to_reports():
    users = {'results': [{"name": "User {}".format(i)} for i in range(1, 11)]}
    input_file = os.path.join(CURRENT_DIR, 'users-list.jrxml')

    with open(JSON_FILENAME, 'w') as f:
        json.dump(users, f)

    json_query = 'results.name'

    jasper = JasperPy()
    jasper.process(
        input_file,
        output_file=OUTPUT_FILENAME,
        format_list=['pdf', 'docx', 'html'],
        parameters={},
        db_connection={
            'data_file': JSON_FILENAME,
            'driver': 'json',
            'json_query': json_query,
        },
        locale='pt_BR'
    )
    print('Files available in /tmp/ directory.')
Пример #9
0
def order_results_print(request,pk):
    order = Orders.objects.get(pk=pk)
    
    input_file_header = settings.RESULT_REPORT_FILE_HEADER
    input_file_main = settings.RESULT_REPORT_FILE_MAIN
    input_file = settings.RESULT_REPORT_FILE
    
    ts = datetime.today().strftime('%Y%m%d%H%M%S')
    parameters ={'ORDER_ID': pk}
    output = settings.MEDIA_ROOT+'\\report\\'+str(order.number)+'_'+ts
    con = settings.JASPER_CONN
    
    jasper = JasperPy()

    jasper.compile(input_file_header)
    jasper.compile(input_file_main)
    
    jasper.process(
                input_file,
                output_file=output,
                format_list=["pdf"],
                parameters=parameters,
                db_connection=con,
                locale='en_US',  
                resource= settings.RESULT_REPORT_DIR
            )

    base_url =  request.build_absolute_uri('/')[:-1].strip("/")
    url_pdf = base_url+'/media/report/'+str(order.number)+'_'+ts+'.pdf'
    
    # save report URL
    oe, _created = models.OrderExtended.objects.get_or_create(order_id=pk)

    oe.result_pdf_url = url_pdf
    oe.save()
    
    # set validation printed
    if request.user.is_authenticated():
        order_res = models.OrderResults.objects.filter(order_id=pk,validation_status=3).update(validation_status=4,print_user=str(request.user),print_date=datetime.now())
    
    

    template = 'middleware/result_pdf_preview.html'
    context = {'order':order,'url_pdf' : url_pdf}
    return render(request,template,context)
Пример #10
0
def do_print_pdf(request):
    post_id = request.matchdict['id']
    input_file = c_report_paths['jasper'] + '/hello-world.jrxml'

    jasper = JasperPy()
    jasper.compile(input_file)
    jasper.process(input_file, c_report_paths['pdf'], format_list=['pdf'])

    response = FileResponse(c_report_paths['pdf'] + '/hello-world.pdf',
                            request=request)
    response.headers['Content-Disposition'] = 'inline; filename={}'.format(
        c_report_paths['pdf'] + '/hello-world.pdf')
    response.headers['Content-Type'] = 'application/pdf'

    # delete generated pdf file
    if os.path.exists(c_report_paths['pdf'] + '/hello-world.pdf'):
        os.remove(c_report_paths['pdf'] + '/hello-world.pdf')

    return response
Пример #11
0
class TestJasperPy(TestCase):
    EXAMPLES_DIR = os.path.join(
        os.path.dirname(os.path.abspath(os.path.dirname(__file__))),
        'examples')

    @ignore_warnings
    def setUp(self):
        self.input_file = os.path.join(self.EXAMPLES_DIR, 'hello_world.jrxml')
        self.jasper = JasperPy()

    @ignore_warnings
    def test_compile(self):
        self.assertRaises(NameError, self.jasper.compile, False)
        self.assertEqual(self.jasper.compile(self.input_file), 0)

    @ignore_warnings
    def test_process(self):
        self.assertRaises(NameError, self.jasper.process, False)

        # test invalid format input. Must be list ['pdf']
        kwargs = {'input_file': self.input_file, 'format_list': 'pdf'}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid input format
        kwargs = {'input_file': self.input_file, 'format_list': 5}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid report format
        kwargs = {'input_file': self.input_file, 'format_list': ['mp3']}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test
        kwargs = {'input_file': self.input_file, 'format_list': ['pdf']}
        self.assertEqual(self.jasper.process(**kwargs), 0)

    @ignore_warnings
    def test_subreports(self):

        input_file_header = os.path.join(self.EXAMPLES_DIR, 'subreports',
                                         'header.jrxml')

        input_file_details = os.path.join(self.EXAMPLES_DIR, 'subreports',
                                          'details.jrxml')

        input_file_main = os.path.join(self.EXAMPLES_DIR, 'subreports',
                                       'main.jrxml')

        self.input_file = os.path.join(self.EXAMPLES_DIR, 'subreports',
                                       'main.jasper')

        data_file = os.path.join(self.EXAMPLES_DIR, 'subreports',
                                 'contacts.xml')

        resources = os.path.join(self.EXAMPLES_DIR, 'subreports') + os.sep

        self.jasper.compile(input_file_header)
        self.jasper.compile(input_file_details)
        self.jasper.compile(input_file_main)

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'xml',
                    'xml_xpath': '/',
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
                resource=resources),
            0)

    @ignore_warnings
    def test_jsonql(self):
        self.input_file = os.path.join(self.EXAMPLES_DIR, 'jsonql.jrxml')

        data_file = os.path.join(self.EXAMPLES_DIR, 'contacts.json')

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'jsonql',
                    'jsonql_query': 'contacts.person',
                    'json_locale': 'es_ES'
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
            ),
            0)

    @ignore_warnings
    def test_json_process(self):
        self.input_file = os.path.join(self.EXAMPLES_DIR, 'jsonql.jrxml')

        data_file = os.path.join(self.EXAMPLES_DIR, 'contacts.json')

        self.assertEqual(
            self.jasper.process_json(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                connection={
                    'data_file': data_file,
                    'driver': 'jsonql',
                    'jsonql_query': 'contacts.person',
                    'json_locale': 'es_ES',
                    'json_date_pattern': 'yyyy-MM-dd',
                    'json_number_pattern': '#,##0.##"'
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
            ),
            0)

    @ignore_warnings
    def test_json_url(self):
        self.input_file = os.path.join(self.EXAMPLES_DIR, 'jsonql.jrxml')

        self.assertEqual(
            self.jasper.process_json(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                connection={
                    'url_file':
                    'https://acesseonline-arquivos-publicos.s3.us-east-2.amazonaws.com/contacts.json',
                    'url_method': 'GET',  # POST, PUT
                    # 'url_params': {'param1': 'test'},
                    # 'url_data': {'data_field': 'abc123'},
                    # 'url_header': {'Authorization': 'Bearer xxxxxxxxxxxxxxxxxx'},
                    'driver': 'jsonql',
                    'jsonql_query': 'contacts.person',
                    'json_locale': 'es_ES',
                    'json_date_pattern': 'yyyy-MM-dd',
                    'json_number_pattern': '#,##0.##"'
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
            ),
            0)

    @ignore_warnings
    def test_csv(self):
        self.input_file = os.path.join(self.EXAMPLES_DIR, 'csvMeta.jrxml')

        data_file = os.path.join(self.EXAMPLES_DIR, 'csvExampleHeaders.csv')

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'csv',
                    'csv_charset': 'utf8',
                    'csv_field_del': '|',
                    'csv_record_del': '\r\n',
                    'csv_columns': 'Name,Street,City,Phone'
                },
                locale='en_US',  # LOCALE Ex.:(en_US, de_GE)
            ),
            0)
Пример #12
0
from flask_restful import Resource
from api.rest.quick_parser import quick_parse
from api.rest.extensions.response import response_checker
from flask import make_response

from pyreportjasper import JasperPy
import tempfile
import json
import os

jasper = JasperPy()

FILE_NAME = 'advising_form'
input_file = ''


def reset_input_file(_dir):
    input_file = _dir


def check_and_create_dir(_dir):
    if not os.path.isdir(_dir):
        os.mkdir(_dir)
    return True


def compiling():
    jasper.compile(input_file)


def processing(parameters, directory, db_conn=None, fname=''):
def compiling():
    template = os.path.dirname(os.path.abspath(__file__)) + \
                 '/jasper/crisis_report_template.jrxml'
    jasper = JasperPy()
    jasper.compile(template)
Пример #14
0
def compiling():
    input_file = os.path.dirname(
        os.path.abspath(__file__)) + '/prueba_Template.jrxml'
    jasper = JasperPy()
    jasper.compile(input_file)
Пример #15
0
def getReportDatabase():
    try:
        now = datetime.datetime.now()
        datetimeStr = now.strftime('%Y%m%d_%H%M%S%f')

        isSuccess = True
        reasonCode = 200
        reasonText = ""

        dataInput = request.json
        paramList = ['report_name', "param"]
        paramCheckStringList = ['report_name']

        msgError = checkParamDataInput(dataInput, paramList,
                                       paramCheckStringList)
        if msgError != None:
            return jsonify(msgError)

        reportName = dataInput['report_name']
        param = dataInput['param']

        input_file = '{}/report/{}.jrxml'.format(
            os.path.dirname(os.path.abspath(__file__)), reportName)
        compile_file = '{}/report/{}.jasper'.format(
            os.path.dirname(os.path.abspath(__file__)), reportName)
        output_file = '{}/output/{}'.format(
            os.path.dirname(os.path.abspath(__file__)), datetimeStr)
        resource_file = '{}/font/THSarabunPSK.jar'.format(
            os.path.dirname(os.path.abspath(__file__)))

        con = {
            'driver':
            'generic',
            'jdbc_driver':
            'com.microsoft.sqlserver.jdbc.SQLServerDriver',
            'jdbc_url':
            'jdbc:sqlserver://{};databaseName={}'.format(
                mssql_server, mssql_database),
            'username':
            mssql_user,
            'password':
            mssql_password
        }

        jasper = JasperPy()
        jasper.process(compile_file,
                       output_file=output_file,
                       format_list=["pdf"],
                       parameters=param,
                       db_connection=con,
                       locale='en_US',
                       resource=resource_file)

        with open(output_file + '.pdf', "rb") as pdf_file:
            encoded_string = base64.b64encode(pdf_file.read())

        os.remove(output_file + '.pdf')
        errColumns = ['isSuccess', 'reasonCode', 'reasonText', 'pdf_base64']
        errData = [(isSuccess, reasonCode, reasonText, encoded_string)]

        return jsonify(toJsonOne(errData, errColumns))
    except Exception as e:
        isSuccess = False
        reasonCode = 500

        errColumns = ['isSuccess', 'reasonCode', 'reasonText']
        errData = [(isSuccess, reasonCode, str(e))]

        return jsonify(toJsonOne(errData, errColumns))
Пример #16
0
def getReportByJSONBase64():
    try:
        now = datetime.datetime.now()
        datetimeStr = now.strftime('%Y%m%d_%H%M%S%f')

        isSuccess = True
        reasonCode = 200
        reasonText = ""

        dataInput = request.json
        paramList = ['report_name', 'data_json']
        paramCheckStringList = ['report_name', 'data_json']

        msgError = checkParamDataInput(dataInput, paramList,
                                       paramCheckStringList)
        if msgError != None:
            return jsonify(msgError)

        dataJson = dataInput['data_json']
        reportName = dataInput['report_name']

        input_file = '{}/report/{}.jrxml'.format(
            os.path.dirname(os.path.abspath(__file__)), reportName)
        compile_file = '{}/report/{}.jasper'.format(
            os.path.dirname(os.path.abspath(__file__)), reportName)
        output_file = '{}/output/{}'.format(
            os.path.dirname(os.path.abspath(__file__)), datetimeStr)
        data_file = '{}/data/data_tmp{}.json'.format(
            os.path.dirname(os.path.abspath(__file__)), datetimeStr)
        resource_file = '{}/font/THSarabunPSK.jar'.format(
            os.path.dirname(os.path.abspath(__file__)))

        file = codecs.open(data_file, "w", "utf-8")
        file.write(json.dumps(dataJson[0]))
        # file.write(str(dataJson))
        file.close()
        con = {
            'data_file': data_file,
            'driver': 'json',
            'json_query': 'data',
        }

        jasper = JasperPy()
        # jasper.compile(input_file)
        jasper.process(compile_file,
                       output_file=output_file,
                       format_list=['pdf'],
                       parameters={},
                       db_connection=con,
                       locale='en_US',
                       resource=resource_file)

        with open(output_file + '.pdf', "rb") as pdf_file:
            encoded_string = base64.b64encode(pdf_file.read())

        os.remove(output_file + '.pdf')
        os.remove(data_file)
        errColumns = ['isSuccess', 'reasonCode', 'reasonText', 'pdf_base64']
        errData = [(isSuccess, reasonCode, reasonText, encoded_string)]

        return jsonify(toJsonOne(errData, errColumns))
    except Exception as e:
        isSuccess = False
        reasonCode = 500

        errColumns = ['isSuccess', 'reasonCode', 'reasonText']
        errData = [(isSuccess, reasonCode, str(e))]

        return jsonify(toJsonOne(errData, errColumns))
Пример #17
0
 def setUp(self):
     self.input_file = os.path.join(self.EXAMPLES_DIR, 'hello_world.jrxml')
     self.jasper = JasperPy()
Пример #18
0
 def setUp(self):
     self.input_file = 'examples/hello_world.jrxml'
     self.jasper = JasperPy()
Пример #19
0
class TestJasperPy(TestCase):

    def setUp(self):
        self.input_file = 'examples/hello_world.jrxml'
        self.jasper = JasperPy()

    def test_compile(self):
        self.assertRaises(NameError, self.jasper.compile, False)
        self.assertEqual(self.jasper.compile(self.input_file), 0)

    def test_process(self):
        self.assertRaises(NameError, self.jasper.process, False)

        # test invalid format input. Must be list ['pdf']
        kwargs = {
            'input_file': self.input_file,
            'format_list': 'pdf'
        }
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid input format
        kwargs = {
            'input_file': self.input_file,
            'format_list': 5
        }
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid report format
        kwargs = {
            'input_file': self.input_file,
            'format_list': ['mp3']
        }
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test
        self.assertEqual(
            self.jasper.process(self.input_file,
                                format_list=['pdf']), 0)

    def test_list_parameters(self):
        self.input_file = 'examples/hello_world_params.jrxml'
        self.assertRaises(NameError, self.jasper.list_parameters, False)
        self.assertEqual(self.jasper.list_parameters(self.input_file),
                         {
                             'myString': ['java.lang.String', ''],
                             'myInt': ['java.lang.Integer', ''],
                             'myDate': ['java.util.Date', ''],
                             'myImage': ['java.awt.Image',
                                         'This is the description'
                                         ' of parameter myImage']
                         })

    def test_execute(self):
        self.assertEqual(self.jasper.execute(), 0)

        self.jasper.path_executable = ''
        self.assertRaises(NameError, self.jasper.execute, False)


    def test_subreports(self):
        input_file_header = 'examples/subreports/header.jrxml'

        input_file_details = 'examples/subreports/details.jrxml'

        input_file_main = 'examples/subreports/main.jrxml'

        self.input_file = 'examples/subreports/main.jasper'

        data_file = 'examples/subreports/contacts.xml'


        self.jasper.compile(input_file_header)
        self.jasper.compile(input_file_details)
        self.jasper.compile(input_file_main)

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'xml',
                    'xml_xpath': '"/"',
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
                resource='examples/subreports/'
            ), 0)

    def test_jsonql(self):
        self.input_file = 'examples/jsonql.jrxml'

        data_file = 'examples/contacts.json'

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'jsonql',
                    'jsonql_query': 'contacts.person',
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
            ), 0)

    def test_csv(self):
        self.input_file = 'examples/csvMeta.jrxml'

        data_file = 'examples/csvExampleHeaders.csv'

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'csv',
                    'csv_charset': 'utf8',
                    'csv_field_del': '|',
                    'csv_record_del': '\r\n',
                    #'csv_first_row': True,
                    'csv_columns': 'Name,Street,City,Phone'
                },
                locale='en_US',  # LOCALE Ex.:(en_US, de_GE)
            ), 0)
Пример #20
0
class TestJasperPy(TestCase):
    def setUp(self):
        self.input_file = 'examples/hello_world.jrxml'
        self.jasper = JasperPy()

    def test_compile(self):
        self.assertRaises(NameError, self.jasper.compile, False)
        self.assertEqual(self.jasper.compile(self.input_file), 0)

    def test_process(self):
        self.assertRaises(NameError, self.jasper.process, False)

        # test invalid format input. Must be list ['pdf']
        kwargs = {'input_file': self.input_file, 'format_list': 'pdf'}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid input format
        kwargs = {'input_file': self.input_file, 'format_list': 5}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test invalid report format
        kwargs = {'input_file': self.input_file, 'format_list': ['mp3']}
        self.assertRaises(NameError, self.jasper.process, **kwargs)

        # test
        self.assertEqual(
            self.jasper.process(self.input_file,
                                format_list=['pdf', 'odt', 'xls']), 0)

    def test_list_parameters(self):
        self.input_file = 'examples/hello_world_params.jrxml'
        self.assertRaises(NameError, self.jasper.list_parameters, False)
        self.assertEqual(
            self.jasper.list_parameters(self.input_file), {
                'myString': ['java.lang.String', ''],
                'myInt': ['java.lang.Integer', ''],
                'myDate': ['java.util.Date', ''],
                'myImage': [
                    'java.awt.Image', 'This is the description'
                    ' of parameter myImage'
                ]
            })

    def test_execute(self):
        self.assertEqual(self.jasper.execute(), 0)

        self.jasper.path_executable = ''
        self.assertRaises(NameError, self.jasper.execute, False)

    def test_subreports(self):
        input_file_header = 'examples/subreports/header.jrxml'

        input_file_details = 'examples/subreports/details.jrxml'

        input_file_main = 'examples/subreports/main.jrxml'

        self.input_file = 'examples/subreports/main.jasper'

        data_file = 'examples/subreports/contacts.xml'

        self.jasper.compile(input_file_header)
        self.jasper.compile(input_file_details)
        self.jasper.compile(input_file_main)

        self.assertEqual(
            self.jasper.process(
                self.input_file,
                format_list=["pdf"],
                parameters={},
                db_connection={
                    'data_file': data_file,
                    'driver': 'xml',
                    'xml_xpath': '"/"',
                },
                locale='pt_BR',  # LOCALE Ex.:(en_US, de_GE)
                resource='examples/subreports/'),
            0)