Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting model elements of other file for validation
Getting model elements of other file for validation [message #894998] Wed, 11 July 2012 11:22 Go to next message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hello everyone,

A short question: I have to model files (A and B for ease). In B I can reference to entities which I declared in A. So it seams that the model of A is known in B. But if I want to validate the model from B by checking for equal names in A I am not able to. In the validator methods I only get delivered the model elements of B by default. That is why my question: How can I get the model elements of file A while the validator methods are called while changing something in model file B?

Thanks again for any answer
Hannes
Re: Getting model elements of other file for validation [message #895006 is a reply to message #894998] Wed, 11 July 2012 11:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Hannes,

Comments below.
On 11/07/2012 1:22 PM, Hannes Müller wrote:
> Hello everyone,
>
> A short question: I have to model files (A and B for ease). In B I can
> reference to entities which I declared in A. So it seams that the
> model of A is known in B. But if I want to validate the model from B
> by checking for equal names in A I am not able to.
Can't you follow the references in B?
> In the validator methods I only get delivered the model elements of B
> by default.
Validators are generally applied to all the contents of each resource.
When you open A directly the validator will validate those, and, if you
have an Xtext nature in the project, the validator will run for each
resource in that project.
> That is why my question: How can I get the model elements of file A
> while the validator methods are called while changing something in
> model file B?
Would things in A really become invalid because of changes to B? It
sounds like all the problems should be in B when you change B, unless A
is referencing B...
>
> Thanks again for any answer
> Hannes


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting model elements of other file for validation [message #895019 is a reply to message #895006] Wed, 11 July 2012 12:26 Go to previous messageGo to next message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hello,

Thx Ed for your answer - for the rest see below
Ed Merks wrote on Wed, 11 July 2012 07:39
Hannes,

Comments below.
On 11/07/2012 1:22 PM, Hannes Müller wrote:
> Hello everyone,
>
> A short question: I have to model files (A and B for ease). In B I can
> reference to entities which I declared in A. So it seams that the
> model of A is known in B. But if I want to validate the model from B
> by checking for equal names in A I am not able to.
Can't you follow the references in B?
-> My validator starts with the root - so all elements should be reachable.
> In the validator methods I only get delivered the model elements of B
> by default.
Validators are generally applied to all the contents of each resource.
When you open A directly the validator will validate those, and, if you
have an Xtext nature in the project, the validator will run for each
resource in that project.
-> hm, this sounds like that I need: But if I debug than the followin happens:
A)In A are two measurements (here named ZigZag and Other)
measurements {
measurement ZigZag {
parameter BeginPos{
recalculates {
Customer & Finished ==> NOP;
}
}
state transitions {
Customer & Finished& FinishedAction ==> Customer & Finished;
}
}
end measurement;
measurement Other{
parameter BeginPos2{
recalculates {
Customer & Finished ==> NOP;
}
}
state transitions {
Customer & Finished& FinishedAction ==> Customer & Finished;
}
}
end measurement;
}

B) in B their is only one measurement
measurements {
measurement ZigZag {
parameter BeginPos2 {
recalculates {
Customer & Finished ==> 34;
}
}
state transitions {
Customer & Finished & FinishedAction ==> Customer & Finished;
}
}
end measurement;
}
If I make a change in A the validator starts and gets the root element of my model:
Here I get for A that I have one measurements element and two measurement elements. If I change B than I get one measurments element and one measurement element.
Also maybe interesting: The validation method will only be called one time (like I said before - the argument is the root element ...)
I also have other checks for other elements: The effect is the same for other elements! (two recalculates for A and one for B).

> That is why my question: How can I get the model elements of file A
> while the validator methods are called while changing something in
> model file B?
Would things in A really become invalid because of changes to B? It
sounds like all the problems should be in B when you change B, unless A
is referencing B...
-> B should be an extension to model A. A should represent the core functionalities and B C and D are individual models which use A and add their specific parts. An Example would be that a normal car has only the core functionalities like lights or wheels and the luxus edition has aircondition. That is the thought behind this.
>
> Thanks again for any answer
> Hannes

Re: Getting model elements of other file for validation [message #895031 is a reply to message #895019] Wed, 11 July 2012 13:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Hannes,

Comments below.


On 11/07/2012 2:26 PM, Hannes Müller wrote:
> Hello,
>
> Thx Ed for your answer - for the rest see below
> Ed Merks wrote on Wed, 11 July 2012 07:39
>> Hannes,
>>
>> Comments below.
>> On 11/07/2012 1:22 PM, Hannes Müller wrote:
>> > Hello everyone,
>> >
>> > A short question: I have to model files (A and B for ease). In B I
>> can > reference to entities which I declared in A. So it seams that
>> the > model of A is known in B. But if I want to validate the model
>> from B > by checking for equal names in A I am not able to. Can't you
>> follow the references in B?
>> -> My validator starts with the root - so all elements should be
>> reachable.
>> > In the validator methods I only get delivered the model elements of
>> B > by default. Validators are generally applied to all the contents
>> of each resource. When you open A directly the validator will
>> validate those, and, if you have an Xtext nature in the project, the
>> validator will run for each resource in that project.
>> -> hm, this sounds like that I need: But if I debug than the followin
>> happens:
>> A)In A are two measurements (here named ZigZag and Other)
>> measurements {
>> measurement ZigZag {
>> parameter BeginPos{
>> recalculates {
>> Customer & Finished ==> NOP;
>> }
>> }
>> state transitions { Customer & Finished&
>> FinishedAction ==> Customer & Finished;
>> }
>> }
>> end measurement;
>> measurement Other{
>> parameter BeginPos2{ recalculates {
>> Customer & Finished ==> NOP;
>> }
>> }
>> state transitions { Customer & Finished&
>> FinishedAction ==> Customer & Finished;
>> }
>> }
>> end measurement;
>> }
>>
>> B) in B their is only one measurement
>> measurements {
>> measurement ZigZag {
>> parameter BeginPos2 {
>> recalculates {
>> Customer & Finished ==> 34;
>> }
>> }
>> state transitions { Customer & Finished &
>> FinishedAction ==> Customer & Finished;
>> }
>> }
>> end measurement;
>> }
>> If I make a change in A the validator starts and gets the root
>> element of my model: Here I get for A that I have one measurements
>> element and two measurement elements. If I change B than I get one
>> measurments element and one measurement element.
>> Also maybe interesting: The validation method will only be called one
>> time (like I said before - the argument is the root element ...)
>> I also have other checks for other elements: The effect is the same
>> for other elements! (two recalculates for A and one for B).
>>
>> > That is why my question: How can I get the model elements of file A
>> > while the validator methods are called while changing something in
>> > model file B?
Are you saying B references A because B defines a measurement with the
same name as does A? Or is there actually a reference between the two
resources?
>> Would things in A really become invalid because of changes to B? It
>> sounds like all the problems should be in B when you change B, unless
>> A is referencing B...
>> -> B should be an extension to model A. A should represent the core
>> functionalities and B C and D are individual models which use A and
>> add their specific parts. An Example would be that a normal car has
>> only the core functionalities like lights or wheels and the luxus
>> edition has aircondition. That is the thought behind this.
There's no clear answer to any of your questions until you make it clear
how it is that B references A. I don't see anything in your example to
imply there's a reference between them.
>> >
>> > Thanks again for any answer
>> > Hannes
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Getting model elements of other file for validation [message #895080 is a reply to message #895031] Wed, 11 July 2012 15:50 Go to previous messageGo to next message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hi,

Sorry, if I did not descripe the problem clearly enough.

If I introduce a NEW measurement in file B (no reference)than I simply want to ensure that the name of the new measurement in B must not be equal to any measurements which are defined in A. That is why I want to check this in my validator. And in the validator I only get elements which are contained in B if I change something in B. That is why I wanted to ask how I get model elements of the A file while validating after B changed (to ensure unique names for example of measurements).

>Are you saying B references A because B defines a measurement with the
>same name as does A? Or is there actually a reference between the two
>resources?

B should extend the model of A with new model elements! But B may not redefine Elements which are listed in A.

I hope I descriped it a little bit clearer now
Hannes
Re: Getting model elements of other file for validation [message #895082 is a reply to message #895080] Wed, 11 July 2012 15:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi this is usually done using the index. Have a look at
http://www.eclipse.org/forums/index.php/mv/msg/261440/754503/#msg_75450
3

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Getting model elements of other file for validation [message #896224 is a reply to message #895082] Tue, 17 July 2012 16:01 Go to previous message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hi Christian,

It works Smile (for other interested - just follow the link of the last post).

Many thanks
Hannes
Previous Topic:Chain generation from language1 -> language2 -> java
Next Topic:Easy way to get cross references?
Goto Forum:
  


Current Time: Tue Apr 23 13:17:31 GMT 2024

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

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

Back to the top