Author Topic: Validating tagged-values before import  (Read 5159 times)

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Validating tagged-values before import
« on: February 07, 2018, 08:02:26 pm »
Before importing elements from an Excel file, we would like to check whether the imported tagged values are compliant with the type defined in the element stereotype (part of a MDG).

Does anybody know how to validate the to-be-imported tagged values at runtime?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Validating tagged-values before import
« Reply #1 on: February 07, 2018, 08:08:12 pm »
I guess it depends on how you are importing them.
Basically you would need to add your validation to code that does the importing.

Geert

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Re: Validating tagged-values before import
« Reply #2 on: February 07, 2018, 08:33:33 pm »
But what API can we use to perform the validation (in a C# program)?

We can't find any equivalent to "Validate" in the "TaggedValue" class: http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/taggedvalue.html

The Validation features in the Project class are not looking useful either: http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/project_2.html

Since the tagged value type (e.g. enumeration, date...) has been defined in the MDG there should be something at run time that uses these definitions for validation????


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Validating tagged-values before import
« Reply #3 on: February 07, 2018, 08:51:56 pm »
I'm afraid you'll have to write your own validations.
AFAIk there is nothing in the API that will validate it for you.

In fact I think there is really no validation of tagged values at all in EA. It is only the GUI that will try to prevent you from entering invalid values.
But if you change the definition of a tagged value, EA will not complain about values that are now invalid according to the new definition.

Geert

Arshad

  • EA User
  • **
  • Posts: 286
  • Karma: +20/-1
    • View Profile
Re: Validating tagged-values before import
« Reply #4 on: February 07, 2018, 09:16:18 pm »
Hi

There isn't any pre defined validations for tags and you need to write your logic on your import addin as mentioned by Geert.
Kick start for your validation is
 
  • Get all the UML Tag types defined first
  • Validate before updating the tag

To Get Defined Tags
Code: [Select]
for(var i = 0;i < Repository.PropertyTypes.Count ;i++)
 {
    var prop as EA.PropertyType;
  Prop = Repository.PropertyTypes.GetAt(i);
  if(prop.Tag=="Your Enum Tag name") 
{
           prop.Detail  // property you will find the valid values. Based on this do your own validation
}
   }


Regards
Arshad


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Validating tagged-values before import
« Reply #5 on: February 07, 2018, 09:57:55 pm »
Problem with the defined tagged values is that this doesn't include the MDG tagged values IIRC.

To get those you would have to find the MDG xml file and parse that.
If it is you own MDG then you could have the checks hardcoded.

Geert

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Re: Validating tagged-values before import
« Reply #6 on: February 08, 2018, 03:38:15 am »
We can find the default property types in that table:
select * from t_propertytypes

And the tagged value in that table:
select * from t_objectproperties where property = 'vision'

and we have the possible values in the Notes column with equivalent access through the API.

I was hoping there would be some predefined validation. It is really weird that something as basic as that isn't available in the API.

adepreter

  • EA User
  • **
  • Posts: 187
  • Karma: +10/-9
    • View Profile
Re: Validating tagged-values before import
« Reply #7 on: February 08, 2018, 03:41:30 am »
Thank you Geert and Arshad