Report DSL

From OS.bee documentation
Revision as of 21:28, 28 March 2017 by Cmollik (Talk | contribs) (Formatters)

Jump to: navigation, search

Copyright Notice

All rights are reserved by Compex Systemhaus GmbH. In particular, duplications, translations, microfilming, saving and processing in electronic systems are protected by copyright. Use of this manual is only authorized with the permission of Compex Systemhaus GmbH. Infringements of the law shall be punished in accordance with civil and penal laws. We have taken utmost care in putting together texts and images. Nevertheless, the possibility of errors cannot be completely ruled out. The Figures and information in this manual are only given as approximations unless expressly indicated as binding. Amendments to the manual due to amendments to the standard software remain reserved. Please note that the latest amendments to the manual can be accessed through our helpdesk at any time. The contractually agreed regulations of the licensing and maintenance of the standard software shall apply with regard to liability for any errors in the documentation. Guarantees, particularly guarantees of quality or durability can only be assumed for the manual insofar as its quality or durability are expressly stipulated as guaranteed. If you would like to make a suggestion, the Compex Team would be very pleased to hear from you.

(c) 2016-2024 Compex Systemhaus GmbH

Documentation

ReportDSL.pdf

Introduction

Vaadin

Vaadin is a web application framework for Java. In contrast to Javascript libraries and browser-plugin based solutions, Vaadin features a complete stack that includes a robust server-side programming model as well as client-side development tools based on GWT and HTML5.

More information:

https://vaadin.com/home

Birt Report

The Business Intelligence and Reporting Tools (BIRT) Project is an open source software project that provides reporting and business intelligence capabilities for rich client and web applications, especially those based on Java and Java EE. BIRT is a top-level software project within the Eclipse Foundation, an independent not-for-profit consortium of software industry vendors and an open source community.

The project's stated goals are to address a wide range of reporting needs within a typical application, ranging from operational or enterprise reporting to multi-dimensional online analytical processing (OLAP). Initially, the project has focused on and delivered capabilities that allow application developers to easily design and integrate reports into applications. The project is supported by an active community of users at BIRT Developer Center and developers at the Eclipse.org BIRT Project page.

BIRT has two main components: a visual report designer within the Eclipse IDE for creating BIRT Reports, and a runtime component for generating reports that can be deployed to any Java environment. The BIRT project also includes a charting engine that is both fully integrated into the report designer and can be used standalone to integrate charts into an application.

BIRT Report designs are persisted as XML and can access a number of different data sources including JDO datastores, JFire Scripting Objects, POJOs, SQL databases, Web Services and XML.

https://en.wikipedia.org/wiki/BIRT_Project

http://developer.actuate.com/about/

Report DSL

ReportDSL generates the vaddin s ui and birt report.

The main semantic elements of the ReportDSL are:

  • “package” – the root element that contains all the other elements. A model can contain multiple packages.
  • “import” declarations – used to import external models or even Java classes.
  • “externalCssURI” – define the optional external CSS URI for all report .
  • “pagetemplate” – define the report page template, e.g. page size, orientation, margin, header, footer, etc.
  • “formatters” – define the formatter types for all report .
  • “colors” – define the color types for all report .
  • “fonts” – define the font types for all report .
  • “medias” – define the media types for all report .
  • “styles” – define the style types for all report .
  • “report” – define the data source details for the report, e.g. row/column configurations, legend details and tooltips configurations.

Syntax

Package definition

Syntax:

package <package name>  {
[import <import models/class name>]
...

[externalCssURI <URI string> [from bundle <bundle string>]]
[pagetemplate <pagetemplate name>
 {    	
...
    	}]
...

formatters {...}
	colors {...}
	fonts{...}
	medias{...}
	styles{...}
	
[report <report name> 
{    	
...
    	}]
...
}

Notes:

  • externalCssURI is used to define the external CSS for the all report in this package.
  • pagetemplate is used to define the page template formate for all report in this package.
  • User can also define different formatters, colors, fonts, medias and styles template for all reports in this package. All these definitions could be defined in a separated package and import to other report-packages as well.
  • For each report definition, a <reportname>+Report.java file will be generated, in which a java class named <reportname>+Report extended from java class CCBaseReport is defined. In this class, report and report configurations are defined. Additionally a <reportname>.rptdesign file will be also gererated, in which a birt report is defined.
Figure 1 - Example birt report layout
CCElement

This element is used more than once in the package definition, syntax is as following defined:

Syntax:

CCElement:
  	title <title name> [style <existed Style ID>]
| subtitle <subtitle name> [style <existed Style ID>]
| subsubtitle <subsubtitle name> [style  <existed Style ID>]
| label <label name> [style <existed Style ID>]
| text <text> [style <existed Style ID>]
| autotext AutoTextEnum [style <existed Style ID>]
| image ImageSizeEnum [scale <number>] ImageSourceEnum <file name>
| datamarttable <existed Datamart> [as <datamart table ID>] [style <existed Style ID>] {
	[detailheader [style <existed Style ID>] ]
		[detailfooter [style <existed Style ID>] ]
		[group <group ID> by ([<existed Datamart property> {
			(header [style <existed Style ID>] {
row [as <row ID>] [style <existed Style ID>] {
cell [as <cell ID>] [columnspan <number>] { 
CCElement 
}
}
}]
			[detailheader [style <existed Style ID>] ]
			[detailfooter [style <existed Style ID>] ]
			[footer [style <existed Style ID>] {
row [as <row ID>] (style <existed Style ID>] {
cell [as <cell ID>] [columnspan <number>] {
CCElement 
}
}
}]
		}]
details [style <existed Style ID>] [all | [{CCDatamartTableProperty}]]
}
| CCDatamartTableProperty 
| grid [as <grid ID>] {
row [as <row ID>] [style <existed Style ID>] {
cell [as <cell ID>] [columnspan <number>] {CCElement}
}
}
CCDatamartTableProperty:
property <existed Datamart property>
|aggregate 
CCPureAggregationType 
| CCUnaryAggregationType of <existed Datamart property>
| concat of ([<existed Datamart property>] )
| divide of (<existed Datamart property> <existed Datamart property>)
[on-group <datamart group ID>] [title <title name>]
	[style <existed Style ID>]
[image path <path name> [[dynamic] [hidelabel] [resize <size>]]]
[intervals [hidelabel] { 
[up to <interval number> CCTableRangeElement
|days in past <interval number>CCTableRangeElement] 
}] 
		[lookups [hidelabel] {
[number <lookup number> CCTableRangeElement
|string <lookup string> CCTableRangeElement
|days in past <lookup number> CCTableRangeElement] 
}]		

CCTableRangeElement:
textcolor <existed Color ID>
| cellcolor <existed Color ID>
| icon <icon name>
| trend TrendIconEnum

AutoTextEnum: page-number | total-page | page-number-unfiltered | total-page-unfiltered | page-variable
ImageSizeEnum: size-to-image | scale-to-item | clip
ImageSourceEnum: file | url | embed
CCPureAggregationType : count | running-count
CCUnaryAggregationType: sum | average | minimum | maximum | running-sum
TrendIconEnum: rising | bad-rising | sloping | good-sloping | stagnating

Notes:

  • title, subtitle, subsubtitle, label text, autotext, image, datamarttable, datamarttableproperty and grid could be defined detailed using/ not using existed style template in this element.
  • All details of report are defined in xx.rptdesign file according to birt report syntax and semantics.

Example:

title "Employee Salary" style headerarea
datamarttable EmployeeSalary as salaryGrouped style bootstrap {
	detailheader style grouping_1_head
	group byEducationLevel by education_level {
		header style grouping_1_head {
			row {
				cell columnspan 7 {property education_level}
			}
		}
		footer style grouping_1_foot { row {} }
	}
	group byPositionTitle by position_title {
		header style grouping_2_head {
			row {
				cell {}
			      cell {property position_title}
			}
		}
		detailheader style grouping_2_head 
		footer style grouping_2_foot {
			row {
		       	cell columnspan 4 {label "sum"}
		            cell {aggregate count style integer}
		            cell {}
		      }
			row {
		      	cell columnspan 5 {label "average"}
		            cell {aggregate average of min_scale style ^currency}
		            cell {aggregate average of salary style ^currency}
		            cell {aggregate average of max_scale style ^currency}
			}
		      row style defaultrow { cell {} }
		}
	}
	details style defaultrow {
		property full_name
		property gender lookups hidelabel {
			string "M" icon "gender_male"
			string "F" icon "gender_female"
		}
		property marital_status lookups hidelabel {
			string "M" icon "marital_married"
			string "S" icon "marital_single"
		}
		property min_scale style ^currency
		property salary style ^currency intervals {
			up to 2000 textcolor red
			up to 2500 cellcolor orange
			up to 2500 textcolor darkblue
			up to 3000 cellcolor white
			up to 100000 cellcolor black
			up to 100000 textcolor lightblue
		}
		property max_scale style ^currency
		property hire_date style ^date
	}
}
Pagetemplate

Pagetamplete is used to define the basic format for different page layouts, it is defined as following:

Syntax:

pagetemplate <pagetemplate name> {
type PageSizeEnum
orientation OrientationEnum
topmargin <topMargin number> UnitEnum
leftmargin <leftMargin number> UnitEnum
bottommargin <bottomMargin number> UnitEnum
rightmargin <rightMargin number> UnitEnum
	[header {
		[showOnLast]
		height <height number> UnitEnum
		CCElement
}]
	[footer {
		[showOnLast]
		height <height number> UnitEnum
		CCElement
}]
}

UnitEnum: mm | cm | pt | inch | pc | em | ex | px | %
PageSizeEnum: a4 | a3 | a5 | us-letter | us-legal | us-ledger | us-super-b
OrientationEnum: portrait | landscape

Notes:

  • type is used to define the page size, e.g. a4, a3, ect.
  • orenetation is used to define the page orientation, e.g. portrait or landscape.
  • topmargin, leftmargin, bottommargin and rightmargin are used to define the margin size.
  • Header and footer are used to define the header and footer details, e.g.: height, if it will be show on last, ect.

Example:

pagetemplate A4_Landscape {
	type a4
	orientation landscape
	topmargin 11.5 mm
	leftmargin 12 mm
	bottommargin 13 mm
	rightmargin 14 mm
	header {
		// showOnFirst
		height 0.6 inch
		label "a A4 landscape page"
	}
	footer {
		showOnLast
		height 10 mm
		grid {
			row {
				cell {label "empty"}
			}
			row {
				cell {label "page"}
				cell {autotext page-number}
				cell {label "of"
				cell {autotext total-page}
				cell {label "end of the page"
			}
		}
	}
}
Formatters

Formatters is used to define the report format in detail, it is defined as following:

Syntax:

formatters {
[CCSomeFormat]
}

CCSomeFormat:
	uomo <uomo ID>{
ui <ui name> report <string> textalign TextAlign 
}
| number <number ID>{ 
ui <ui name> report NumberFormatCategory <string> textalign TextAlign 
}
| currency <currency ID>{ 
ui <ui name> report CurrencyFormatCategory <string> textalign TextAlign 
}
| date <date ID>{ 
ui <ui name> report custom <string> textalign TextAlign 
}
| date+time <date+time ID>{ 
ui <ui name> report custom <string> textalign TextAlign 
}
| time <time ID>{ 
ui <ui name> report custom <string> textalign TextAlign 
}

TextAlign: left | center | right
NumberFormatCategory:unformatted|general-number|fixed|percent|scientific|custom
CurrencyFormatCategory: unformatted | currency | custom

Notes:

  • The defined formatters are usually used in the definition for styles.
  • ui and report defines the layout format in ui and report.
  • textalign defines the text align definition on page.

Example:

formatters {
	/** empty UOMO format */
	uomo uomo_test {
		ui "test"
		report "test"
		textalign left
	}
		
	/** money in EURO, rounding half-up */
	currency money_euro {
		ui "###,##0.00 �"
		report currency "#,##0.00 EUR{RoundingMode=HALF_UP}"
		textalign right
	}
		
	/** date without time with weekday */
	date+time shortdate {
		ui "SHORTDATE"
		//report custom "EE dd. MM.yyyy"
		report custom "dd.MM.yyyy"
		textalign left
	}
		
	/** integer */
	number integer {
		ui "##0"
		report percent "##0"
		textalign right
	}
		
	/** percent */
	number ^percent {
		ui "##0.0'%'"
		report percent "##0.0'%'"
		textalign right
	}
}
styles {
	/** Bootstrap style */
	style bootstrap {
		textcolor schwarz
		backgroundcolor weiss
		font arial_8pt_regular
		media big {
			font arial_12pt_regular
		}
	}
	/** Standardzeile (unterste Ebene) */
	style defaultrow {
		extends bootstrap
		font arial_8pt_regular
		backgroundcolor weiss alternate hellblau
		padding-left 2 pt
		padding-right 2 pt
		media big {
			font arial_12pt_regular
		}
	}
	/** if a currency has to be rendered */
	style ^currency {
		extends defaultrow 
		formatter money_euro
	}
}
Colors

Colors is used to define the report colors in detail, it is defined as following:

Syntax:

colors {
	 [color <color name> 
["<color string>"
| darkens <existed Color ID> by-percent <number> 
| lightens <existed Color ID> by-percent <number>
| transforms <existed Color ID> by-percent <number> towards <existed Color ID>
]
	]
}

Notes:

  • The defined colors are usually used in the definition for styles.
  • color is defined with the RGB string.
  • darkens, lightens, and transforms could be used to defined the different color darkness of existed color type.

Example:

colors {
	/** the basic text color: BLACK */
	color schwarz "#000000"
	/** grau rgb(128,128,128) */
	color grau_128 "#808080"
	/** grau rgb(136,136,136) */
	color grau_136 "#888888"
	/** grau rgb(220,220,220) */
	color grau_220 "#dcdcdc"
	/** grau rgb(235,235,235) */
	color grau_235 "#ebebeb"
	/** grau rgb(250,250,250) */
	color grau_250 "#fafafa"
	/** weiß */
	color weiss "#ffffff"
	/** hellblau, laut Style-Guide eigentlich rgb(244,252,255), aber am Bildschirm zu schwach! */
	color hellblau "#e4ecff"
	color red "#ff3b30"
	color orange "#ffcc00"
	color darkblue "#007aff"
	color white darkens grau_136 by-percent 50
	color black lightens schwarz by-percent 30 
	color lightblue "#52edc7"
}
styles {
	/** Bootstrap style */
	style bootstrap {
		textcolor schwarz
		backgroundcolor weiss
		font arial_8pt_regular
		media big {
			font arial_12pt_regular
		}
	}
}
Fonts

Fonts is used to define the report fonts in detail, it is defined as following:

Syntax:

fonts {
 	[font <font name> {
[extends <existed Font ID>]
[family BuildInFontFamily | <string>] 
[FontStyle] 
[bold] 
[size <size number> UnitEnum]
}]
}
BuildInFontFamily: monospace | sans-serif | serif
FontStyle: normal | italic | oblique
UnitEnum: mm | cm | pt | inch | pc | em | ex | px | %

Notes:

  • The defined fonts are usually used in the definition for styles.
  • New font could be defined based on existed font type using extends.
  • family is used to define type of font and if it is monospace or sans-serif or serif.
  • If it is normal or italic or oblique or bold could be also defined directly.
  • size is used to define the font size.

Example:

fonts {
	font arial_14pt_bold {
		family "Arial"
		bold
		size 14 pt
	}
		
	font arial_12pt_regular {
		family "Arial"
		normal
		size 12 pt
	}
		
	font arial_12pt_bold {
		family "Arial"
		bold
		size 12 pt
	}

	font arial_8pt_regular {
		family "Arial"
		normal
		size 8 pt
	}
			
	font arial_7pt_bold {
		family "Arial"
		bold
		size 7 pt
	}
}
styles {
	/** Bootstrap style */
	style bootstrap {
		textcolor schwarz
		backgroundcolor weiss
		font arial_8pt_regular
		media big {
			font arial_12pt_regular
		}
	}
}
Medias