This service is archived, please use www.eclipse.org/forums


Home » Capella » Capella Studio » Custom Validation Rules Not Working
Custom Validation Rules Not Working [message #3137] Wed, 08 May 2019 10:19 Go to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
I have followed the tutorial to develop custom validation rules ( https://wiki.polarsys.org/Capella/Tutorials/Extensibility/Va lidation_Rules). When deploying my plugin, I can see the custom rule appear under Model Validation in Preferences, and everything looks fine.

However, when I run the model it does not pop up any of my custom messages, even when they are set to true at all times.

I have tried this with the source code provided in the tutorial, and the exact same thing happens. I have tried this on Capella 1.2.1 and 1.3.0 with Java 1.8.

Has anyone had this issue? Am I missing something crucial that is not stated in the tutorial?

Thanks,
Daniil
Re: Custom Validation Rules Not Working [message #3140 is a reply to message #3137] Thu, 09 May 2019 06:22 Go to previous messageGo to next message
Jakub Mazur is currently offline  Jakub Mazur
Messages: 33
Registered: October 2017
Member
Hi Daniil,

in general custom rules work. I remember, that I had some issues after creating new category (they were not visible, new category as well), so I added them to existing category and they worked properly. Attached you will find exemplary screenshots and dropins for capella 1.2 as well as workspace for capella studio 1.2 - please review, maybe it will help in your case.

Jakub
  • Attachment: cust_rul.zip
    (Size: 130.57KB, Downloaded 56 times)
Re: Custom Validation Rules Not Working [message #3142 is a reply to message #3140] Thu, 09 May 2019 08:52 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
Thank you so much, it all works!!! I updated your files to 1.3 and it works on 1.3 as well!

It looks like my primary problem was that I was importing the namespaceURI package for Capella 1.1 since I didnt realize that the version number corresponded to capella version. Also, had some minor set up issues.

Thanks again, super helpful!

Best,
Daniil
Re: Custom Validation Rules Not Working [message #3161 is a reply to message #3140] Tue, 14 May 2019 11:05 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello I have a small follow up regarding the quick fixes.

The built-in Capella quickfixes automatically delete the warning message when they execute. Is there a way to code custom quick-fixes in the same way so that the rule automatically dissapears when it successfully makes a change?

Thank you in advance,
Daniil
Re: Custom Validation Rules Not Working [message #3166 is a reply to message #3161] Wed, 15 May 2019 03:28 Go to previous messageGo to next message
felix.dorner.gmail.com is currently offline  felix.dorner.gmail.com
Messages: 117
Registered: November 2015
Senior Member
What do you mean with "the rule disappears"?
Re: Custom Validation Rules Not Working [message #3167 is a reply to message #3166] Wed, 15 May 2019 07:36 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Sorry for being unclear. When I run a validation check, the errors will appear under the Information tab with the details about what went wrong, and for some rules a quick fix option. When I select a quick-fix for a built in rule and it executes, the error message line dissapears from under Infomration, since that error has been resolved.

My questions is: is there a way to have the error line dissapear for my custom validation rules/quick-fixes? I don't want to rerun the validation every time to see the Information tab updated for fixed errors.

Thank you,
Daniil
Re: Custom Validation Rules Not Working [message #3169 is a reply to message #3167] Wed, 15 May 2019 07:48 Go to previous messageGo to next message
felix.dorner.gmail.com is currently offline  felix.dorner.gmail.com
Messages: 117
Registered: November 2015
Senior Member
Well, it's the quickfix itself that deletes the 'line' (its marker) when it is run, and then the line should disappear automatically from the information view. So in your quickfix execution you get the marker as a parameter and when you can resolve the problem just call marker.delete() in the end and you should be good.
Re: Custom Validation Rules Not Working [message #3172 is a reply to message #3169] Wed, 15 May 2019 08:00 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
Thanks for the tip, it works exactly as you said with the .delete() method! I had not realized what the marker actually represented before.

Best,
Daniil
Re: Custom Validation Rules Not Working [message #3195 is a reply to message #3172] Tue, 21 May 2019 09:47 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
Apologies I have another question, this one about creation of new Capella validation categories. The only information I can seem to find about creating new categories is from the tutorial. But all it says is:

"Note: categories are <capella_source_code_tree> \core\plugins\org.polarsys.capella.core.validation\plugin.xm l
Modify this file to add new categories (they must be children of capella.category)"

I cannot seem to locate this plugin.xml file and cant find a way to create a new category.

Thank you in advance, any help will be appreciated.

Best,
Daniil
Re: Custom Validation Rules Not Working [message #3199 is a reply to message #3195] Wed, 22 May 2019 01:34 Go to previous messageGo to next message
Jakub Mazur is currently offline  Jakub Mazur
Messages: 33
Registered: October 2017
Member
Hi Daniil,

you need to unzip this jar file:

index.php/fa/1049/0/

As mentioned in my 1st post, this didn't work for me. Added "MyRules" category:

index.php/fa/1050/0/

doesn't appear in Capella category tree:

index.php/fa/1051/0/

No idea if a new category shall be registered somewhere else to be visible...
  • Attachment: validjar.png
    (Size: 9.07KB, Downloaded 150 times)
  • Attachment: myrules.png
    (Size: 11.38KB, Downloaded 158 times)
  • Attachment: mycatmiss.png
    (Size: 6.67KB, Downloaded 154 times)
Re: Custom Validation Rules Not Working [message #3200 is a reply to message #3199] Wed, 22 May 2019 10:13 Go to previous messageGo to next message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
Thank you for the response. I have also tried out several things based off of that and have not had any success with having it be represented unfortunately.

Hopefully this will be possible at some point.

Thanks,
Daniil
Re: Custom Validation Rules Not Working [message #3203 is a reply to message #3200] Thu, 23 May 2019 05:16 Go to previous messageGo to next message
felix.dorner.gmail.com is currently offline  felix.dorner.gmail.com
Messages: 117
Registered: November 2015
Senior Member
You don't have to unzip anything. You can just create a new constraintProvider in your own plugin and then add a new category with an id like this:
capella.category/MyOwnStuff:
<plugin>
   <extension
         point="org.eclipse.emf.validation.constraintProviders">
      <category
            id="capella.category/MyOwnStuff"
            name="My Own Stuff">
      </category>
      <constraintProvider
            cache="true">
         <package
               namespaceUri="http://www.polarsys.org/capella/core/common/1.3.0">
         </package>
         <constraints
               categories="capella.category/MyOwnStuff">
            <constraint
                  class="testCustomCategory.MyRule"
                  id="testCustomCategory.constraint1"
                  isEnabledByDefault="true"
                  lang="Java"
                  mode="Batch"
                  name="name"
                  severity="ERROR"
                  statusCode="1">
               <message>
                  Test test {0}
               </message>
            </constraint>
         </constraints>
      </constraintProvider>
   </extension>

</plugin>

Re: Custom Validation Rules Not Working [message #3217 is a reply to message #3203] Fri, 24 May 2019 10:13 Go to previous message
Daniil200 is currently offline  Daniil200
Messages: 32
Registered: December 2018
Member
Hello,
This worked, very simple fix! Thank you!

Best,
Daniil
Previous Topic: VPDSL set default superClass
Next Topic: Link PC datas with customized viewpoint
Goto Forum:
  


Current Time: Sat Mar 28 03:54:17 EST 2020

Total time taken to generate the page: 0.01868 seconds