Beginner: how to reference attribute of entity (scope, context, ??) [message #987451] |
Mon, 26 November 2012 16:34 |
Günther Wieser Messages: 1 Registered: November 2012 |
Junior Member |
|
|
Hi,
sorry if this is a simple question, or if it has been answered already, but as I'm new to this topic, I might not have used the correct search terms to find the proper solution.
We're using two grammars that are mixed (only the important parts are copied here), the first one describes a data model, the second one should provide a mapping from an input layer to this data model:
grammar 1:
ConcreteEntity:
'entity' name = ID ('extends' superType = [ConcreteEntity])? 'belongs to' group=[Group] 'uses metadataType' metadataType = MetadataType '{'
('oracleName' oracleName=STRING)?
('oracleColumnPrefix' oracleColumnPrefix=STRING)?
pk=PrimaryKey
attributes += Attribute*
businessRules += BusinessRule*
'}'
;
grammar 2:
DocumentBasedUC:
'documentBasedUseCase' name=ID '{'
'uses' datastructure=[DataStructure]
'inputToHeader {'
inputToHeaderMappings+=InputToHeaderMapping*
'}'
'}'
;
InputToHeaderMapping:
name=ID '=>' ref=[hubmodel::Attribute]
;
In the end we would like to have something like this in the models:
entity PARTY belongs to BasicSetup uses metadataType SMALL {
ID : PK
CODE short 'CODE': VARCHAR2(20) mandatory
second model should refer to "CODE" attribute:
documentBasedUseCase MIP03 {
uses Document
inputToHeader {
Code => CODE
}
}
The problem now resides in the [hubmodel::Attribute] thingy: we want to reference to an attribute of the ConcreteEntity instance of the first domain model, and I guess we need some scope provider to make the editor aware of the relation (the "uses Document" thing would limit the sources for the attribute to reference to ConcreteEntity with ID="PARTY" in this case). I simply don't know where to start even though I've read the documentation - any help very much appreciated!
|
|
|
Re: Beginner: how to reference attribute of entity (scope, context, ??) [message #987485 is a reply to message #987451] |
Mon, 26 November 2012 20:18 |
|
HI,
your business case is disturbing me. i do not get it. (how is the documentBasedUseCase be connected to the ConcreteEntity???)
as a starting point:
xtext build qualified names by default => name of the attribute is PARTY.CODE
=> you may change the grammar to
ref=[hubmodel::Attribute|FQN];
FQN: ID ("."ID)*
or you have to write a scope method
IScope scope_ InputToHeaderMapping_ref(InputToHeaderMapping context, EReference r) {
List<Attribute> attrs = ....
return Scopes.scopeFor(attrs);
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03588 seconds