Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Beginner: how to reference attribute of entity (scope, context, ??)
Beginner: how to reference attribute of entity (scope, context, ??) [message #987451] Mon, 26 November 2012 16:34 Go to next message
Günther Wieser is currently offline Günther WieserFriend
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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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
Re: Beginner: how to reference attribute of entity (scope, context, ??) [message #987792 is a reply to message #987451] Wed, 28 November 2012 08:10 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

From where should it be known that "CODE" belongs to PARTY? I see no context here:
documentBasedUseCase MIP03 {
	uses Document
	inputToHeader {
		Code => CODE
	}
}


Christian is right, either allow qualified names or you need a scope implementation that collects the attributes of a ConcreteEntity. First approach would look like this:
documentBasedUseCase MIP03 {
	uses Document
	inputToHeader {
		Code => PARTY.CODE
	}
}



Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de

[Updated on: Wed, 28 November 2012 08:10]

Report message to a moderator

Previous Topic:Introduce factory created EObjects
Next Topic:Custom validator in launched Eclipse cannot find classes from project workspace sources
Goto Forum:
  


Current Time: Fri Apr 26 13:47:49 GMT 2024

Powered by FUDForum. Page generated in 0.04204 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top