Rule validation using JAVA

Other topics that do not fit in any of categories.

Moderator: Moderators

Rule validation using JAVA

Postby » Wed Jul 27, 2016 12:11 am

Could someone please help me with the rule validation using JAVA class.
I created a class file and copied it to the class path and created a constraint with the language as binary and set the body as: "com.nomagic.magicdraw.examples.validation.ModelHasReadMe.isValid".
"ModelHasReadMe" is my class.

But the validation is not happening as expected. I am just simply getting a message as validation successful.

The above constraint is for checking whether there is a content diagram with the name 'Readme'.
I tried without creating any content diagram as well as tried in another project having content diagram with name other than 'Readme'.

The code was compiled successfully.
Could anyone please help me with this.

Thanks in advance.
Forum Newbie
Forum Newbie
Posts: 1
Posts Rating:0
Joined: Tue Jul 05, 2016 6:24 am

Re: Rule validation using JAVA

Postby TomasJkn » Wed Jul 27, 2016 3:29 am

A couple of things to check:
First - what is the value of Constrained Element field of your validation rule?
Constrained Element field regulates on what elements the rule applies. So, e.g. if constrainedElement=Actor, and there are no actors in your project, your validation rule might never be called.

Second - is your validation rule in a separate module? and if so, do you have the "Exclude elements from projects used in read only mode" checked when doing validation?
It might be that your validation rule has some problem, but since it is in r/o module and r/o modules are not checked, MagicDraw does not report the rule as broken, but simply/silently does not run it.
For the sake of debugging, set the "exclude .. r/o ... " to false and see if there are any NXB ( non executable binary) errors reported, and if so, what is the error message?

I hope this helps.

Tomas Juknevičius
Tomas Juknevicius
Senior Systems Analyst
No Magic Europe
Customer Support
Customer Support
Posts: 60
Posts Rating:6
Joined: Mon May 10, 2010 9:24 am

Return to Other

Who is online

Users browsing this forum: No registered users and 0 guests