Author Topic: Model Validation if Category is ticked  (Read 7148 times)

Hoefler1

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Model Validation if Category is ticked
« on: March 01, 2016, 09:53:26 pm »
I created an Add-In which I want to use as a Validation.
The program shall only be called once when validating (that's why I can't use EA_OnRunPackageRule, EA_OnRunElementRule etc.)

So my thoughts were to call my main method in EA_OnStartValidation.
The problem I'm facing is, that that way the program is called each time I "Validate Current Package". Even if I disable the category in "Configure Validation Rules..."

Is there a way to find out if the category is ticked for the Validation?
« Last Edit: March 01, 2016, 11:53:12 pm by Hoefler1 »

qwerty

  • EA Guru
  • *****
  • Posts: 13574
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Model Validation if Category is ticked
« Reply #1 on: March 02, 2016, 01:07:10 am »
My guess is that it is stored in the registry. The repository does not seem to hold this information.

q.

P.S. Hmm. The registry does not change?!

P.P.S. But there's this key: "Simple UML Views::ModelValidation::W"="MVR010000=1;MVR020000=1;MVR030000=1;MVR040000=1;MVR050000=1;MVR060000=1;MVR070000=1;MVR080000=1;MVR090000=1;MVR0A0000=1;MVR0B0000=1;MVR7F0001=1;"
« Last Edit: March 02, 2016, 01:11:04 am by qwerty »

Hoefler1

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Model Validation if Category is ticked
« Reply #2 on: March 02, 2016, 11:39:19 pm »
I did now find that key. For me (EA Version 12) it is called "Basic UML 2 Technology::ModelValidation::W"="MVR010000=1;MVR020000=1....".
But it truly doesn't seem to change.
I manually changed the 1s to 0s, to see if this would disable the categories, but it had no effect at all...

qwerty

  • EA Guru
  • *****
  • Posts: 13574
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Model Validation if Category is ticked
« Reply #3 on: March 03, 2016, 03:42:35 am »
I'll try to investigate a bit more later. Maybe some kind Sparx supporter can comment?

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Model Validation if Category is ticked
« Reply #4 on: March 03, 2016, 09:09:02 am »
I did now find that key. For me (EA Version 12) it is called "Basic UML 2 Technology::ModelValidation::W"="MVR010000=1;MVR020000=1....".
But it truly doesn't seem to change.
I manually changed the 1s to 0s, to see if this would disable the categories, but it had no effect at all...
Those are the settings if you set "Basic UML 2 Technology" to be the active technology.
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13574
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Model Validation if Category is ticked
« Reply #5 on: March 03, 2016, 10:19:58 am »
Ok, but where are the validation rule settings stored?

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Model Validation if Category is ticked
« Reply #6 on: March 03, 2016, 10:53:22 am »
Global Resources::ModelValidation::W and Global Resources::ModelValidation::B
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13574
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Model Validation if Category is ticked
« Reply #7 on: March 03, 2016, 07:42:59 pm »
That leaves me as clueless as before. Those are not registry keys. And I would not know how to relate those to something else in EA.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Model Validation if Category is ticked
« Reply #8 on: March 04, 2016, 08:24:44 am »
That leaves me as clueless as before. Those are not registry keys. And I would not know how to relate those to something else in EA.

q.
Go to the Default Tools toolbar (View|Toolbars|Default Tools) and you will notice a listbox with all the technologies listed. The value of that listbox (i.e. the active technology) determines which registry keys are used for the model validation configuration. If there is no active technology (i.e. that listbox shows '<default>') then Global Resources::ModelValidation::W and Global Resources::ModelValidation::B are used. They won't appear in your registry until you change the model validation configuration with <default> set active.
The Sparx Team
[email protected]

Hoefler1

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Model Validation if Category is ticked
« Reply #9 on: March 04, 2016, 07:23:06 pm »
Now I see, the two Global Resources::ModelValidation registry keys were just created when selecting something else from the active technology list box, and then switching back to <default>. The "W-key" does now also hold the names of my self-defined categories.
But I'm afraid it does not change when I tick/untick any of the categories in EA. Am I just doing it wrong?

Back to my actual goal: I still want to find out the ticked and unticked categories to use this information in my Add-In.
This way I would be able to only run the program if a certain category is selected.

qwerty

  • EA Guru
  • *****
  • Posts: 13574
  • Karma: +395/-301
  • I'm no guru at all
    • View Profile
Re: Model Validation if Category is ticked
« Reply #10 on: March 04, 2016, 09:35:29 pm »
As I see it, you can't find it out. There's always the chance to ask for a new feature. But that might take a looong time. I have no idea how it could be accomplished.

q.

Hoefler1

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Model Validation if Category is ticked
« Reply #11 on: March 05, 2016, 12:00:57 am »
I'm getting closer!  :)

- The ticked categories are stored in the W-Key of the active technology (<default> = Global Resources)
- The unticked categories are stored in the B-Key

So I do the following:
0. Technology is set to <default>, All the actegories are active (meaning Global Resources::ModelValidation::W contains all of them, ...::B is empty)
1. By "Configure..." I unselect whatever categories I don't want to run in the validation
    Unfortunately (!!) after pressing OK the keys remain the same...
2. I Change the Technology to something else than <default>
    Now the Global Recources-Keys are updated.  (Ticked categories in W, unticked in B)
3. So I go back to <default>

Hoefler1

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Model Validation if Category is ticked
« Reply #12 on: March 05, 2016, 12:06:01 am »
If my keys were consistant with the current selection in EA all the time I could simply do this in my Add-In:

Code: [Select]
public bool Category_Active(string cat)
        {
            string reg_value = (string) Registry.GetValue("HKEY_CURRENT_USER\\Software\\Sparx Systems\\EA400\\EA\\OPTIONS",
                "Global Resources::ModelValidation::W", "Key not found");
            //MessageBox.Show(reg_value);
            string catNoBlanks = cat.Replace(" ","");
            return reg_value.Contains(catNoBlanks);
        }

public void EA_OnStartValidation(EA.Repository Repository, Object Args)
        {
            if (Category_Active("My Validation Category"))
            {
                //Run my Validation
            }
            return;
        }
« Last Edit: March 05, 2016, 12:08:16 am by Hoefler1 »