blob: ce78ce5d86db285daf1d50f950b3171ee3fb1652 [file] [log] [blame]
/**
* Copyright (c) 2011, 2014 - Lunifera GmbH (Gross Enzersdorf), Loetz GmbH&Co.KG (Heidelberg), Robert Handschmann (Vienna)
* 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:
* Florian Pirchner - Initial implementation
* Robert Handschmann - V2
*/
grammar org.eclipse.osbp.dsl.entity.xtext.EntityGrammar with org.eclipse.osbp.dsl.common.xtext.CommonGrammar
import "http://osbp.eclipse.org/dsl/common/types/v1"
import "http://osbp.eclipse.org/dsl/entity/v1" as entity
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/xbase/Xtype" as xtype
import "http://www.eclipse.org/Xtext/Xbase/XAnnotations" as xannotation
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
EntityModel returns entity::LEntityModel:
importSection=XImportSection?
packages+=TypedPackage*;
Class returns LClass:
{LClass} annotations+=AnnotationDef*
(
{entity::LEntity.annotationInfo=current}
(abstract?='abstract')?
((historized?='historized')|(timedependent?='timedependent' ('(' timedependentDateType=LHistorizedDateType ')')?))?
(cacheable?="cacheable")?
'entity' name=TRANSLATABLEID ('extends' superType=[entity::LEntity|TYPE_CROSS_REFERENCE])?
'{'
(persistenceInfo=EntityPersistenceInfo)
(inheritanceStrategy=EntityInheritanceStrategy)?
('persistenceUnit' persistenceUnit=STRING)?
('stateClass' stateClass=[LStateClass])?
features+=EntityFeature*
(
(indexes+=Index) |
(superIndex+=EntitySuperIndex)
)*
'}'
|
{entity::LEntity.annotationInfo=current}
(
(historized?='historized') | (timedependent?='timedependent'))?
mappedSuperclass?='mappedSuperclass' ('extends' superType=[entity::LEntity|TYPE_CROSS_REFERENCE])?
name=ValidIDWithKeywords
'{'
('persistenceUnit' persistenceUnit=STRING)?
features+=EntityFeature*
'}'
|
{entity::LBean.annotationInfo=current}
'bean' name=TRANSLATABLEID ('extends' superType=[entity::LBean|TYPE_CROSS_REFERENCE])?
(beanOnTab?='onTab')?
'{'
features+=BeanFeature*
'}'
);
Index returns entity::LIndex:
(unique?='unique')? 'index' name=ID '{'
features+=[entity::LEntityFeature] (',' features+=[entity::LEntityFeature])*
'}';
EntityPersistenceInfo returns entity::LEntityPersistenceInfo:
{entity::LEntityPersistenceInfo}
('schemaName' schemaName=ValidIDWithKeywords)?
('tableName' tableName=ValidIDWithKeywords)?;
ColumnPersistenceInfo returns entity::LEntityColumnPersistenceInfo:
{entity::LEntityColumnPersistenceInfo}
'(' columnName=ValidIDWithKeywords ')';
EntityFeature returns entity::LEntityFeature:
{entity::LEntityFeature}
annotations+=AnnotationDef*
(
(
{entity::LEntityReference.annotationInfo=current}
(
'ref'
(cascadeMergePersist?='cascadeMergePersist')?
(cascadeRemove?='cascadeRemove')?
(cascadeRefresh?='cascadeRefresh')?
('filterDepth' filterDepth=INT)?
type=[entity::LEntity|TYPE_CROSS_REFERENCE]
multiplicity=Multiplicity?
('[' constraints+=AllConstraints* ']')?
name=TRANSLATABLEID
(persistenceInfo=ColumnPersistenceInfo)?
('opposite' opposite=[entity::LEntityReference|LFQN] (asGrid?='asGrid'|asTable?='asTable')?)?
(sideKick?='sideKick')?
((referenceHidden?='hidden')|(referenceReadOnly?='readOnly'))?
(isGrouped?='group' groupName=TRANSLATABLEID)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?
(resultFilters=ResultFilters?)
)
)
|
(
{entity::LEntityAttribute.annotationInfo=current}
(
(
transient?='transient'
((attributeHidden?='hidden')|(attributeReadOnly?='readOnly'))?
type=[LScalarType|TYPE_CROSS_REFERENCE] ('[' constraints+=AllConstraints* ']')?
name=TRANSLATABLEID
(
(isGrouped?='group' groupName=TRANSLATABLEID)?
('extraStyle' extraStyle=STRING)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?
)
)
|
(
derived?='derived'
(domainDescription?='domainDescription')?
((attributeHidden?='hidden')|(attributeReadOnly?='readOnly'))?
type=[LScalarType|TYPE_CROSS_REFERENCE]
name=TRANSLATABLEID
(isGrouped?='group' groupName=TRANSLATABLEID)?
('extraStyle' extraStyle=STRING)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?
derivedGetterExpression=XBlockExpression
)
|
(
('var' | id?='id' | uuid?='uuid' | version?='version' | domainDescription?='domainDescription' | domainKey?='domainKey')
(uniqueEntry?='unique')?
(filtering?='filter' | rangeFiltering?='range')?
((attributeHidden?='hidden')|(attributeReadOnly?='readOnly'))?
type=[LScalarType|TYPE_CROSS_REFERENCE]
multiplicity=Multiplicity?
('[' constraints+=AllConstraints* ']')?
name=TRANSLATABLEID
(onKanbanCard?='onKanbanCard' (onKanbanCardStates=KanbanStateDetail))?
(asKanbanState?='asKanbanState' )?
(asKanbanOrdering?='asKanbanOrdering' (decentKanbanOrder?='decentOrder')?)?
(persistenceInfo=ColumnPersistenceInfo)?
('opposite' opposite=[entity::LBeanReference|LFQN])?
(isGrouped?='group' groupName=TRANSLATABLEID)?
('extraStyle' extraStyle=STRING)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?
)
)
)
|
(
{entity::LOperation.annotationInfo=current}
(
'def'
type=JvmTypeReference
name=ValidIDWithKeywords
'(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')'
body=XExpression
)
)
);
KanbanStateDetail returns entity::LKanbanStateDetail:
{entity::LKanbanStateDetail}
'states' '('
(infos+=KanbanEnumInfo (',' infos+=KanbanEnumInfo)*)?
')';
KanbanEnumInfo returns entity::LKanbanEnumInfo:
literal=[LEnumLiteral] ('=' i18nKey=STRING)?
;
BeanFeature returns entity::LBeanFeature:
{entity::LBeanFeature}
annotations+=AnnotationDef*
(({entity::LBeanReference.annotationInfo=current}
('ref' (cascadeMergePersist?='cascadeMergePersist')? (cascadeRemove?='cascadeRemove')? type=[LType|TYPE_CROSS_REFERENCE] multiplicity=Multiplicity? ('['
constraints+=AllConstraints* ']')? name=TRANSLATABLEID
('opposite' opposite=[LReference|LFQN] (asGrid?='asGrid'|asTable?='asTable')?)?
(sideKick?='sideKick')?
(isGrouped?='group' groupName=TRANSLATABLEID)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)*')')?
(resultFilters=ResultFilters?)))
|
({entity::LBeanAttribute.annotationInfo=current}
((transient?='transient' type=[LScalarType|TYPE_CROSS_REFERENCE] ('[' constraints+=AllConstraints* ']')?
name=TRANSLATABLEID
(isGrouped?='group' groupName=TRANSLATABLEID)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?)
|
(('var' | id?='id' | version?="version") (filtering?='filter' | rangeFiltering?='range')?
type=[LScalarType|TYPE_CROSS_REFERENCE] multiplicity=Multiplicity? ('[' constraints+=AllConstraints* ']')?
name=TRANSLATABLEID
(isGrouped?='group' groupName=TRANSLATABLEID)?
('properties' '(' properties+=KeyAndValue (',' properties+=KeyAndValue)* ')')?)))
|
({entity::LOperation.annotationInfo=current}
('def' type=JvmTypeReference name=ValidIDWithKeywords
'(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')'
body=XExpression)));
EntitySuperIndex returns entity::LEntitySuperIndex:
'superIndex' name=TRANSLATABLEID '{'
attributes+=EntitySuperIndexAttribute*
'}';
EntitySuperIndexAttribute returns entity::LNestedFeature:
'ref' feature=[LFeature] (tail=EntityFeaturePathSegment)?;
EntityFeaturePathSegment returns entity::LNestedFeature:
{entity::LNestedFeature}
'.' feature=[LFeature] (tail=EntityFeaturePathSegment)?;
EntityInheritanceStrategy returns entity::LEntityInheritanceStrategy:
TablePerClassStrategy | TablePerSubclassStrategy;
TablePerClassStrategy returns entity::LTablePerClassStrategy:
{entity::LTablePerClassStrategy}
'inheritancePerClass' '{'
('discriminatorColumn' discriminatorColumn=ValidIDWithKeywords)?
('discriminatorType' discriminatorType=DiscriminatorType)?
('discriminatorValue' discriminatorValue=ValidIDWithKeywords)? '}';
TablePerSubclassStrategy returns entity::LTablePerSubclassStrategy:
{entity::LTablePerSubclassStrategy} 'inheritancePerSubclass' '{'
('discriminatorColumn' discriminatorColumn=ValidIDWithKeywords)?
('discriminatorType' discriminatorType=DiscriminatorType)?
('discriminatorValue' discriminatorValue=ValidIDWithKeywords)? '}';
enum DiscriminatorType returns entity::LDiscriminatorType:
INHERIT="INHERIT" | STRING="STRING" | CHAR="CHAR" | INTEGER="INT";
enum LHistorizedDateType returns LDateType:
DATE="DATE" | TIMESTAMP="TIMESTAMP";
TRANSLATABLEID:
ValidIDWithKeywords;