Skip to content

Standalone usage

Eugene Degtyarjov edited this page Dec 15, 2015 · 35 revisions

General info

One of YARG features is ability to use it as standalone application.

In this case you can run your reports from command line or from any types of applciations.

There are few steps to start use it this way.

  1. Download latest applciation distributive from releases
  2. Unzip the content to some folder
  3. Run the reporting engine with the following command:
yarg -rp PATH_TO_YOUR_REPORT_XML -op PATH_FOR_OUTPUT -PparamName=ParamValue

Please note, that if you path date to params, it should have one of the following formats: dd/MM/yyyy or dd/MM/yyyy hh:mm.

Database usage

If you need to use database queries, you should do the following steps (the example is for PostgreSQL database):

  1. Put JDBC driver JAR to the lib subfolder. For PostgreSQL it would be postgresql-9.4.jar
  2. Add the JDBC driver JAR's path to CLASSPATH variable in the executable script (yarg or yarg.bat). For PostgreSQL you should add %APP_HOME%\lib\postgresql-9.4.jar. Please note, that separators are different for Linux(:) and Windows(;)
  3. Create the reporting.properties file somewhere. The file should contain the following properties
cuba.reporting.sql.driver=org.postgresql.Driver                      #PostgreSQL driver name
cuba.reporting.sql.dbUrl=jdbc:postgresql://localhost/yarg            #database url  
cuba.reporting.sql.user=root                                         #login 
cuba.reporting.sql.password=root                                     #password
cuba.reporting.openoffice.path=/usr/lib/libreoffice/program          #path to OpenOffice, if you need to use doc and odt templates, and also if you need to convert result files to PDF 
cuba.reporting.openoffice.ports=8100|8101                            #OpenOffice ports to use
cuba.reporting.openoffice.timeout=60                                 #timeout for OpenOffice connections
cuba.reporting.openoffice.displayDeviceAvailable=false               #just leave it as is)

The path of the reporting.properties should be passed as -prop argument of command line.

yarg -prop PATH_TO_PROPERTIES/reporting.properties -rp PATH_TO_YOUR_REPORT_XML -op PATH_FOR_OUTPUT -PparamName=ParamValue

#Example

Let's consider the example of standalone usage:

We have the users table in the database.

create table users (
login varchar(50),
name varchar(50),
surname varchar(50),
role varchar(50),
primary key (login) 
);

We need to a report, showing users with specific role. The default role for the report is "admin" role.

<?xml version="1.0" encoding="UTF-8"?>
<report name="report">
    <templates>
        <template code="DEFAULT" documentName="users-template.xlsx" documentPath="D:/temp/yarg/users-template.xlsx" outputType="xlsx"
                  outputNamePattern="users.xlsx"/>
    </templates>
    <parameters>
        <parameter name="Role" alias="role" required="true" class="java.lang.String" defaultValue="admin"/>
    </parameters>
    <formats/>
    <rootBand name="Root" orientation="H">
        <bands>
            <band name="Header" orientation="H"/>
			<band name="Band" orientation="H">
                <bands/>
                <queries>
                    <query name="Data_set_1" type="sql">
                        <script>
							select u.login, u.name, u.surname from users u where u.role = ${role}
						</script>
                    </query>
                </queries>
            </band>
        </bands>
        <queries/>
    </rootBand>
</report>
Clone this wiki locally