Skip to main content



      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 11:34 Go to next message
Eclipse UserFriend
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 15:18 Go to previous messageGo to next message
Eclipse UserFriend
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);
} 
Re: Beginner: how to reference attribute of entity (scope, context, ??) [message #987792 is a reply to message #987451] Wed, 28 November 2012 03:10 Go to previous message
Eclipse UserFriend
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
	}
}

[Updated on: Wed, 28 November 2012 03:10] by 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: Thu Jul 03 21:07:01 EDT 2025

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

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

Back to the top