blob: 80c5a6cd03cb9c69bafdc24d481fface5c5df32d [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
grammar org.eclipse.osbp.xtext.reportdsl.ReportDSL with org.eclipse.osbp.xtext.oxtype.OXtype
import "http://osbp.eclipse.org/xtext/reportdsl/ReportDSL"
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://osbp.eclipse.org/dsl/common/types/v1"as types
import "http://osbp.eclipse.org/dsl/entity/v1" as entity
import "http://osbp.eclipse.org/xtext/datamartdsl/DatamartDSL" as datamart
import "http://osbp.eclipse.org/xtext/action/ActionDSL" as action
ReportModel:
importSection=XImportSection?
pckg+=ReportPackage*;
ReportPackage:
{ReportPackage} 'package' name=QualifiedName '{'
('layout-data' '{'
('externalCssURI' externalCssURI=STRING ('fromBundle' externalCssURIBundle=STRING)?)?
formatters=SomeFormats
colors=Colors
fonts=Fonts
medias=Medias
styles=Styles
pagetemplates=PageTemplates
'}')?
(reports+=Report)*
'}';
PageTemplates:
{PageTemplates} (pagetemplates+=PageTemplate)*;
SomeFormats:
{SomeFormats} 'formatters' '{'
(formatters+=SomeFormat)*
'}';
Colors:
{Colors} 'colors' '{'
(colors+=Color)*
'}';
Fonts:
{Fonts} 'fonts' '{'
(fonts+=Font)*
'}';
Medias:
{Medias} 'medias' '{'
(medias+=Media)*
'}';
Media:
'media' name=ID;
Styles:
{Styles} 'styles' '{'
(styles+=Style)*
'}';
PageTemplate:
'pagetemplate' name=ID '{'
'type' size=PageSizeEnum
'orientation' orientation=OrientationEnum
'topmargin' topMarginValue=UnsignedNumber
'leftmargin' leftMarginValue=UnsignedNumber
'bottommargin' bottomMarginValue=UnsignedNumber
'rightmargin' rightMarginValue=UnsignedNumber
(header=PageHeader)?
(footer=PageFooter)?
'}';
UnsignedNumber returns ecore::EDouble:
Number;
enum UnitEnum:
MM='mm' | CM='cm' | PT='pt' | IN='inch' | PC='pc' | EM='em' | EX='ex' | PX='px' | PERCENTAGE='%';
enum PageSizeEnum:
A4='a4' | A3='a3' | A5='a5' | US_LETTER = "us-letter" | US_LEGAL = "us-legal" | US_LEDGER = "us-ledger" | US_SUPER_B = "us-super-b";
enum OrientationEnum:
PORTRAIT='portrait' | LANDSCAPE='landscape';
Color:
'color' name=ID (color=STRING | 'darkens' basecolor=[Color] 'by-percent' darkensby=INT | 'lightens' basecolor=[Color] 'by-percent' lightensby=INT | 'transforms' basecolor=[Color] 'by-percent' transformsby=INT 'towards' targetcolor=[Color]);
Font:
'font' name=ID ('extends' extends=[Font])? '{' (('family' family=FontFamily)? & (style=FontStyleEnum)? & (bold?='bold')? & ('size' sizevalue=UnsignedNumber sizeunit=UnitEnum)?) '}';
enum FontStyleEnum:
NORMAL='normal' | ITALIC='italic' | OBLIQUE='oblique';
FontFamily:
BuildInFontFamily | CustomFontFamily;
BuildInFontFamily:
custom=BuildInFontFamilyEnum;
enum BuildInFontFamilyEnum:
MONOSPACE='monospace' | SANS_SERIF='sans-serif' | SERIF='serif';
CustomFontFamily:
custom=STRING;
BorderStyle:
type=BorderTypeEnum
widthValue=UnsignedNumber
(color=[Color])?
;
Style:
'style' name=ID '{'
('extends' extends=[Style])?
(
('formatter' format=[SomeFormat])? &
('font' font=[Font])? &
('backgroundcolor' backgroundcolor=[Color] ('alternate' backgroundcolor_alternate=[Color])?)? &
('textcolor' textcolor=[Color])? &
('textalign' textalign=TextAlignEnum)? &
('verticalalign' verticalalign=VerticalTextAlignEnum)? &
('border-top' borderTop=BorderStyle)? &
('border-bottom' borderBottom=BorderStyle)? &
('border-left' borderLeft=BorderStyle)? &
('border-right' borderRight=BorderStyle)? &
('padding-top' paddingTopValue=UnsignedNumber)? &
('padding-bottom' paddingBottomValue=UnsignedNumber)? &
('padding-left' paddingLeftValue=UnsignedNumber)? &
('padding-right' paddingRightValue=UnsignedNumber)? &
('margin-top' marginTopValue=UnsignedNumber)? &
('margin-bottom' marginBottomValue=UnsignedNumber)? &
('margin-left' marginLeftValue=UnsignedNumber )? &
('margin-right' marginRightValue=UnsignedNumber)?
)
(mediastyles+=MediaStyle)*
'}';
MediaStyle:
'media' media=[Media] '{'
(
('formatter' format=[SomeFormat])? &
('font' font=[Font])? &
('backgroundcolor' backgroundcolor=[Color] ('alternate' backgroundcolor_alternate=[Color])?)? &
('textcolor' textcolor=[Color])? &
('textalign' textalign=TextAlignEnum)? &
('verticalalign' verticalalign=VerticalTextAlignEnum)? &
('border-top' borderTop=BorderStyle)? &
('border-bottom' borderBottom=BorderStyle)? &
('border-left' borderLeft=BorderStyle)? &
('border-right' borderRight=BorderStyle)? &
('padding-top' paddingTopValue=UnsignedNumber)? &
('padding-bottom' paddingBottomValue=UnsignedNumber)? &
('padding-left' paddingLeftValue=UnsignedNumber)? &
('padding-right' paddingRightValue=UnsignedNumber)? &
('margin-top' marginTopValue=UnsignedNumber)? &
('margin-bottom' marginBottomValue=UnsignedNumber)? &
('margin-left' marginLeftValue=UnsignedNumber)? &
('margin-right' marginRightValue=UnsignedNumber)?
)
'}';
enum TextAlignEnum:
LEFT='left' | CENTER='center' | RIGHT='right';
enum VerticalTextAlignEnum:
BOTTOM='bottom' | MIDDLE='middle' | TOP='top';
SomeFormat:
UomoFormat | NumberFormat | CurrencyFormat | DateFormat | DateTimeFormat | TimeFormat;
UomoFormat:
'uomo' name=ID '{' 'ui' ui_pattern=STRING 'report' report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
NumberFormat:
'number' name=ID '{' 'ui' ui_pattern=STRING 'report' report_category=NumberFormatCategoryEnum report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
enum NumberFormatCategoryEnum:
UNFORMATTED='unformatted' | GENERAL_NUMBER='general-number' | FIXED='fixed' | PERCENT='percent' | SCIENTIFIC='scientific' | CUSTOM='custom';
CurrencyFormat:
'currency' name=ID '{' 'ui' ui_pattern=STRING 'report' report_category=CurrencyFormatCategoryEnum report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
enum CurrencyFormatCategoryEnum:
UNFORMATTED='unformatted' | CURRENCY='currency' | CUSTOM='custom';
DateFormat:
'date' name=ID '{' 'ui' ui_pattern=STRING 'report' report_category=DateFormatCategoryEnum report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
enum DateFormatCategoryEnum:
CUSTOM='custom';
DateTimeFormat:
'date+time' name=ID '{' 'ui' ui_pattern=STRING 'report' report_category=DateTimeFormatCategoryEnum report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
enum DateTimeFormatCategoryEnum:
CUSTOM='custom';
TimeFormat:
'time' name=ID '{' 'ui' ui_pattern=STRING 'report' report_category=TimeFormatCategoryEnum report_pattern=STRING 'textalign' textalign=TextAlignEnum '}';
enum TimeFormatCategoryEnum:
CUSTOM='custom';
Report:
'report' name=ID
(description?='describedBy' descriptionValue=TRANSLATABLESTRING)?
('toolbar' toolbar=[action::ActionToolbar])?
'{'
'rendering' rendering=RenderingEnum
('externalCssURI' externalCssURI=STRING ('fromBundle' externalCssURIBundle=STRING)?)?
(('datamart' datamartRef=[datamart::DatamartDefinition]
(selectById?='selectById')?
('defaultUnit' defaultUnit=UnitEnum)?
'pagetemplate' pageTemplate=[PageTemplate]
'media' media=[Media]
design=ReportDesign) | (parametrized?='parametrized' persistenceUnit=PersistenceUnit))
'}';
PersistenceUnit:
'persistenceUnit' name=STRING;
enum RenderingEnum:
HTML='html' | PDF='pdf';
ReportDesign:
ReportDesignFile | ReportDesignTemplate;
ReportDesignFile:
'file' name=STRING;
ReportDesignTemplate:
'template' '{'
('describedBy' description=STRING)?
(header=PageHeader)?
detail=PageDetail
(footer=PageFooter)?
'}';
Container:
PageHeader | PageDetail | PageFooter | GridCell;
PageHeader:
{PageHeader} 'header' '{'
(showOnFirst?='showOnFirst')?
'height' heightValue=UnsignedNumber
elements+=Element
'}';
PageDetail:
{PageDetail} 'detail' '{' elements+=Element* '}';
PageFooter:
{PageFooter} 'footer' '{'
(showOnLast?='showOnLast')?
'height' heightValue=UnsignedNumber
elements+=Element
'}';
Element:
Title | SubTitle | SubSubTitle | Label | Text | NonTranslatableText | AutoText | StringBinder | Image | DatamartTable | DatamartTableAttribute | Grid;
Grid:
{Grid} 'grid' ('as' name=ID)? (('style' style=[Style])? & ('width' widthValue=UnsignedNumber)? & (visibilityItem=Visibility)?) '{' rows+=GridRow* '}';
GridRow:
{GridRow} 'row' ('as' name=ID)? (('style' style=[Style])? & ('height' heightValue=UnsignedNumber)? & (visibilityItem=Visibility)?) '{' cells+=GridCell* '}';
GridCell:
{GridCell} 'cell' ('as' name=ID)? (('style' style=[Style])? & ('width' widthValue=UnsignedNumber)? & ('columnspan' columnspan=INT)? & (visibilityItem=Visibility)?) '{' elements+=Element* '}';
DatamartTable:
'table' ('datamart' datamartRef=[datamart::DatamartDefinition] ('as' name=ID)?)? (('style' style=[Style])? & (visibilityItem=Visibility)? & (pageBreak=PageBreak)?) '{'
(header=DatamartTableHeader)?
(groups+=DatamartTableGroup)*
detail=DatamartTableDetail
(footer=DatamartTableFooter)?
'}';
DatamartTableGroup:
'group' name=ID 'by' groupingRef=[datamart::DatamartAttribute] ((visibilityItem=Visibility)? & (pageBreak=PageBreak)?) '{'
(header=DatamartTableHeader)?
(footer=DatamartTableFooter)?
'}';
DatamartTableHeader:
{DatamartTableHeader} 'header' (('style' style=[Style])? & (pageBreak=PageBreak)?) ('{' rows+=GridRow* '}')?;
DatamartTableFooter:
{DatamartTableFooter} 'footer' (('style' style=[Style])? & (pageBreak=PageBreak)?) ('{' rows+=GridRow* '}')?;
DatamartTableDetail:
{DatamartTableDetail} 'details' ('style' style=[Style])? ('all' | ('{' columnFormatters+=DatamartTableAttribute* '}'));
DatamartTableAttribute:
column=TableValueElement
(
('width' widthValue=UnsignedNumber)? &
('style' style=[Style])? &
// (hasImage?='image' image=TableImage)? &
('intervals' (hideLabelInterval?='hidelabel')? '{' (intervals+=TableInterval)* '}')? &
('lookups' (hideLabelLookup?='hidelabel')? '{' (lookups+=TableLookup)* '}')?
)
;
enum PureAggregationTypeEnum:
COUNT='count' | RUNNINGCOUNT='running-count';
enum UnaryAggregationTypeEnum:
SUM='sum' | AVE='average' | MIN='minimum' | MAX='maximum' | RUNNINGSUM='running-sum';
enum BinaryAggregationTypeEnum:
DIV='divide';
enum MultipleAggregationTypeEnum:
CONCATENATE='concat';
TableFormatter:
{TableFormatter} 'formatter' format=STRING;
TableImage:
{TableImage} 'path' imagePathPattern=STRING ((hasParameter?='dynamic')? & (hideImageLabel?='hidelabel')? & (resize?='resize' resizeString=STRING)?);
TableValueElement:
TableAttribute|TableAggregation;
/*|TableBinaryAggregation*/
/*TableMeasure|TableDerived|TableHierarchy|TableOrdinal|TableColumn|TableTask*/
TableAttribute:
'attribute' valueRef=[datamart::DatamartAttribute];
TableAggregation:
'aggregate' aggregation=TableBaseAggregation (('on-group' onGroup=[DatamartTableGroup])? & ('title' text=TRANSLATABLESTRING)?);
TableBaseAggregation:
TablePureAggregation|TableUnaryAggregation|TableMultipleAggregation|TableBinaryAggregation;
TablePureAggregation:
aggregation=PureAggregationTypeEnum;
TableUnaryAggregation:
aggregation=UnaryAggregationTypeEnum valueRefs+=[datamart::DatamartAttribute];
TableMultipleAggregation:
aggregation=MultipleAggregationTypeEnum '(' (valueRefs+=[datamart::DatamartAttribute])* ')';
StringBinderValue:
TableAttribute | TranslatableText | NonTranslatableText ;
TranslatableText:
'translatable' value = TRANSLATABLESTRING;
NonTranslatableText:
'nontranslatable' value = STRING;
StringBinder:
{StringBinder} 'stringBinder' '(' (elements+=StringBinderValue)* ')' ('style' style=[Style])?;
PageBreak:
{PageBreak} 'pageBreak' '(' ('before' beforePageBreak=BeforeAfterPageBreakEnum)? ('after' afterPageBreak=BeforeAfterPageBreakEnum)? ('inside' insidePageBreak=InsidePageBreakEnum)? ')';
enum BeforeAfterPageBreakEnum:
AUTO='auto' | ALWAYS='always' | AVOID = 'avoid';
enum InsidePageBreakEnum:
AUTO='auto' | AVOID = 'avoid';
TableBinaryAggregation:
aggregation=BinaryAggregationTypeEnum '(' valueRefs+=[datamart::DatamartAttribute] valueRefs+=[datamart::DatamartAttribute] ')';
TableInterval:
(TableNumberInterval|TableDateDayInterval);
TableNumberInterval:
{TableNumberInterval} 'upTo' numberIntervalValue=SignedNumber numberRange=TableRangeElement;
TableDateDayInterval:
{TableDateDayInterval} 'daysInPast' dateIntervalValue=SignedNumber dateRange=TableRangeElement;
TableLookup:
(TableNumberLookup|TableStringLookup|TableDateDayLookup);
TableNumberLookup:
{TableNumberLookup} 'number' lookupValue=SignedNumber discrete=TableRangeElement;
TableStringLookup:
{TableStringLookup} 'string' lookupValue=STRING discrete=TableRangeElement;
TableDateDayLookup:
{TableDateDayLookup} 'daysInPast' lookupValue=SignedNumber discrete=TableRangeElement;
TableRangeElement:
TableTextColor | TableCellColor | TableIcon | TableTrend;
Visibility:
visibility?='visibility' visibilityAttribute=[datamart::DatamartAttribute];
SignedNumber returns ecore::EDouble:
'-'? Number;
TableTextColor:
'textcolor' color=[Color];
TableCellColor:
'cellcolor' color=[Color];
TableIcon:
'icon' icon=STRING;
TableTrend:
'trend' icon=TrendIconEnum;
enum TrendIconEnum:
RISING='rising' | BADRISING='bad-rising' | SLOPING='sloping' | GOODSLOPING='good-sloping'| STAGNATING='stagnating';
Title:
{Title} 'title' text=TRANSLATABLESTRING ('style' style=[Style])?;
SubTitle:
{SubTitle} 'subtitle' text=TRANSLATABLESTRING ('style' style=[Style])?;
SubSubTitle:
{SubSubTitle} 'subsubtitle' text=TRANSLATABLESTRING ('style' style=[Style])?;
Label:
{Label} 'label' text=TRANSLATABLESTRING ('style' style=[Style])?;
Text:
{Text} 'text' (textContentType=TextContentTypeEnum)? text=TRANSLATABLESTRING ('style' style=[Style])?;
AutoText:
'autotext' type=AutoTextEnum ('style' style=[Style])?;
enum BorderTypeEnum:
NONE='none' | SOLID='solid' | DOTTED='dotted' | DASHED='dashed' | DOUBLE='double' | GROOVE='groove' | RIDGE='ridge' | INSET='inset' | OUTSET='outset';
enum AutoTextEnum:
PAGE_NUMBER="page-number" | TOTAL_PAGE="total-page" | PAGE_NUMBER_UNFILTERED="page-number-unfiltered" | TOTAL_PAGE_UNFILTERED="total-page-unfiltered" | PAGE_VARIABLE="page-variable" | ACTUAL_DATE="actual-date" | ACTUAL_TIME="actual-time" | REPORT_NAME="report-name";
Image:
'image' (size=ImageSizeEnum)? ('scale' scale=UnsignedNumber)? ('height' heightValue=UnsignedNumber heightUnit=UnitEnum)? ('width' widthValue=UnsignedNumber widthUnit=UnitEnum)? sourceType=ImageSourceEnum filename=STRING;
enum ImageSizeEnum:
SIZE_TO_IMAGE='size-to-image' | SCALE_TO_ITEM='scale-to-item' | CLIP='clip';
enum ImageSourceEnum:
/*FILE='file' | */URL = 'url' | EMBED = 'embed';
enum TextContentTypeEnum:
AUTO='auto' | PLAIN='plain' | HTML='html';
TRANSLATABLESTRING: STRING;