How to restrict validator to the active working file? [message #1865118] |
Fri, 26 April 2024 12:13  |
Eclipse User |
|
|
|
Hi,
I have 4 different model files (of the same metamodel) and my validation checks are applied on all on them while I am working on one of them. All the model files need to be in the same project folder.
Is it possible to restrict validator to one active working file only?
Thanks,
Ehsan
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: How to restrict validator to the active working file? [message #1865187 is a reply to message #1865178] |
Sat, 27 April 2024 15:41   |
Eclipse User |
|
|
|
Yes, the validator runs for one file now, as required.
@Check(CheckType.NORMAL)
public void checkOnlyOneInitialState(BehaviorState behaviorState) {
int initialStateCount = 0;
BehaviorStatesSection bss = (BehaviorStatesSection) behaviorState.eContainer();
for (BehaviorState bs : bss.getBehavior_states()) {
if(bs.getIsInitial().equals("initial"))
initialStateCount = initialStateCount +1;
}
if (initialStateCount > 1)
error(behaviorState.getName(), DevsPackage.Literals.BEHAVIOR_STATE__NAME);
}
But regardless to the size of the bss.getBehavior_states(), it only runs twice. As a result it only checks isInitial for the first and the second state. So, for the following model, it only produces error if the state Test1 and Test2 have 'initial'.
states
Test1: initial 0.0;
Test2: initial 0.0;
Test3: 1.0;
Test4: 2.0;
Test5: initial 3.0;
But does not produce error if the second state Test2 in case does not have initial. For example, no error is produces for the following model
states
Test1: initial 0.0;
Test2: 0.0;
Test3: initial 1.0;
Test4: 2.0;
Test5: initial 3.0;
Global declaration private int initialStateCount = 0; //for number of initial state
was add to tackle this issue as the initialSateCount was reset after 2 iterations but is of no use and still the loop only runs for the first two states.
Regards,
Ehsan
[Updated on: Sat, 27 April 2024 15:43] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06371 seconds