Author Topic: Import of CSV not working for a tag value that is a member of a complex type  (Read 11837 times)

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
All, using CSV, I'm trying to import a tag value that is part of a complex type, and cannot get it working. 
Note:
- I can import a regular tagged value just fine. 
- I can import a tag value that is part of a tag group just fine.
- My struggle relates to a tag value that is an attribute of a complex type: in this case, Address.

Please be patient with this explanation.  Thanks in advance to any brave sole willing to read this.

A. SETUP THE PROFILE
1) I have a meta model (aka profile) called "myProfile".
2) In myProfile, I have a meta class for an actor, extended by a new stereotype called "User".
3) In myProfile, I have a class called "Address".
4) Address has two attributes: "postal code" and "city".
5) On stereotype User, add an attribute call "home Address" of local type "Address".
6) Save the profile and import the profile.

B. USE THE PROFILE
1) Create a TestPackage, and create a class "Foo" of stereotype "User".
2) Open Foo properties and see the "Main", "Tags", and "myProfile" tabs. Good!
3) Go the the myProfile tab, there is a tag group called "home address". Still Good!
N.B. On the user interface, this looks just like a tag group, even though it's not really.
4) Expand "home address" and specify values for "postal code" and "city".
5) All is good, so far.  :) :) :)

C. SET UP THE I/O SPECIFICATION
1) Create a new I/O Specification called "IO".
2) Click on the "Add Tagged Value Field" button.
3) Choose "value".
4) Click on the "Other Element" button.
5) Select my class "Foo". Good, it shows up!
6) Select "Home Address" from the pick list.
7) Click OK.

D. DO THE EXPORT
1) Highlight Test Package.
2) Select "CSV Export/Import" from the Publish ribbon, and select the I/O specification called "IO".
3) Perform the export.
4) Check the output CSV and it looks great!  :) :) :)

E. CHANGE THE EXPORT FILE
1) Open the export file.
2) Locate the record/row for class "Foo".
3) Locate the column called "TagValue_Work Address".  Notice that the value is a comma-separated list enclosed in double quotes.
  Example: "90807,London"
  where 90807 is the postal code, and London is the city.
4) Change the city value from London to "Paris"
5) Save the file.

F. DO THE IMPORT
1) Highlight Test Package.
2) Select "CSV Export/Import" from the Publish ribbon, and select the I/O specification called "IO".
3) Select the "IO" spec and the file I previously exported.
4) Perform the input.  Sparx reports success.
5) PROBLEM :(  The tag value for city is still "London".

So, the imported data is getting stored somewhere; just not in the right place.K
This process works perfectly for a stand along tag value, or a tag group member,  but not for attributes of a complex type.
Any suggestions? Can I set this up better? Should it work?


« Last Edit: March 09, 2017, 08:10:12 am by adama »

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Re: Import CSV for a tag value group member not working
« Reply #1 on: March 09, 2017, 06:35:20 am »
***********************************
INTERESTING TROUBLESHOOTING FINDINGS
***********************************
Looks like the import is working, but not showing up in the user interface.
Given:
- In the user interface, city is London.
- Export CSV file shows city is London.

1) In the CSV file, change the city from London to Paris.
2) Do an import.
3) UI still shows London.
4) Do an export again.
5) The new CSV has Paris (changed value)... not London (old value).
6) Do an import again.
7) UI still shows London.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Hi Adama,

This is quite usual.  When you don't use the API to do things, the UI is not updated correctly.  Sometimes it's not updated correctly regardless, but that's what we call EAUI.  :)

The import/export doesn't go through the normal APIs I guess.

You need to refresh the UI.  This can be done in a number of ways.  Usually reloading the diagram will do it.  Otherwise, reloading the contents of the package will be the next place to look.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
I don' use the CSV import, but a guess would be that you should check for double tagged values. Tick the Show Duplicate Tags in the TV window (2nd icon from right).

q.

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Paolo and qwerty, thanks much for the thoughtful replies. I really appreciate it.

1) Regarding Paolo's reasonable suggestion: I closed and opened the project file, and no change in the UI.  Did more exports and imports with changed value, but the situation persists.  Guess I'll have to learn the API. I became a whiz in Visio, but have not tried any programming here yet.

2) Regarding qwerty's reasonable suggestion, I suspected as much for object instances.  Tried with a new class instance (no duplicates), and still have the same problem after numerous exports/imports.

Gents, I'm gonna play around with this idea. ...still no luck.
--Adama
« Last Edit: March 10, 2017, 12:55:03 am by adama »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Paolo and qwerty, thanks much for the thoughtful replies. I really appreciate it.

1) Regarding Paolo's reasonable suggestion: I closed and opened the project file, and no change in the UI.  Did more exports and imports with changed value, but the situation persists.  Guess I'll have to learn the API. I became a whiz in Visio, but have not tried any programming here yet.

2) Regarding qwerty's reasonable suggestion, I suspected as much for object instances.  Tried with a new class instance (no duplicates), and still have the same problem after numerous exports/imports.

Gents, I'm gonna play around with this idea. ...still no luck.
--Adama
Adama,

There's an option in the tagged values window to show duplicate tags. If you leve that unticked it only shows the first entry of the tagged value, although you might have 10 tv's with that same name and different values. That is what qwerty was referring too.

Geert

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Right. Thanks Geert. I looked at that already. The object I'm dropping onto the diagram is a class that has the "home address" listed only once in the tag values.


I'm trying to import the following snippet:
Name,Type,GUID,Notes,Stereotype,Fully Qualified Stereotype,Profile Metatype,TagValue_WorkAddress,TagValue_state,CSV_KEY,CSV_PARENT_KEY
BPMN2 Collaboration DataStore1,Artifact,{2376C571-3031-4307-96BD-5630A8FD25D7},,DataStore,BPMN2.0::DataStore,BPMN2.0::DataStore,,,CSV16997F59,
Actor3,Actor,{EAB8FDE5-3DBE-421e-8AC1-FAEB65B725E7},,User,Structured Analysis::User,Actor,"90909,,,Rome",,CSVC077B98B,
Jeffrey,Actor,{58283AD4-4F46-4c42-82E3-6C8D880AC27C},,User,Structured Analysis::User,Actor,"10101,,,Roanoke",Active,CSV047F219A,


You see that I changed "Libertytown" to "Roanoke", but it won't stick. When I export, I see "Roanoke".  I know that this import is working, because of this and because I can change the value of the "state" tag successfully many times over.

VKN

  • EA User
  • **
  • Posts: 187
  • Karma: +9/-1
    • View Profile
After the import, run this to see if you find anything interesting..
Code: [Select]
select * from t_objectproperties where ea_guid='{58283AD4-4F46-4c42-82E3-6C8D880AC27C}'

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
VKN, I get nothing with that particular query.
A simple
Code: [Select]
select * from t_object ...finds the object and gets all the usual object information. I'm not yet familiar with the database. Is there a different query that might work?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
The guid must match the one from the import. t_objectproperties contains the tagged values. t_object the elements.

q.

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Geert, Paolo, VKN, qwerty, et al:
More bizarre findings:
Givens:
1. Export File includes the following lines:
Code: [Select]
Name,Type,GUID,Notes,Stereotype,Fully Qualified Stereotype,Profile Metatype,TagValue_WorkAddress,TagValue_state,CSV_KEY,CSV_PARENT_KEY
Actor3,Actor,{EAB8FDE5-3DBE-421e-8AC1-FAEB65B725E7},,User,Structured Analysis::User,Actor,"90909,,,Rome",,CSVFDE0334F,
Jeffrey,Actor,{58283AD4-4F46-4c42-82E3-6C8D880AC27C},,User,Structured Analysis::User,Actor,"10101,,,Roanoke",Active,CSV836537AB,

2. Search on "Jeffrey" and "Actor3" using following SQL:
     
Code: [Select]
select * from t_objectproperties where ea_guid='{58283AD4-4F46-4c42-82E3-6C8D880AC27C}'Yields *no results*

3. Search on all tagged values using..
   
Code: [Select]
select * from t_objectproperties;shows the following line:
Code: [Select]
PropertyID,Object_ID,Property,Value,Notes,ea_guid,

407,1410,WorkAddress,10101,,,Roanoke,<tagStructure><property name="PostalCode">10101</property><property name="Town">Libertytown</property></tagStructure>
,{79023189-5589-4e55-ACFD-063318A1C863},
      4. Showing the Relationships window, one sees it is for the object "Jeffrey", where:
          - the EAUI shows values that match the above line in item #3.

      So...
      • the database matches the EAUI
      • but the guid of the object in the export file does not match the guid on the object in the database
      • and, this situation applies to Actor3 also
      • ?? Is the import/export broken, or did I lose referential integrity somehow?


adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
OK, I think I've identified a repeatable symptom, but still not the cause.
 1) Changes made to the WorkAddress fields on "Jeffrey" are faithfully exported (e.g. Postal code, town, street).
2) The export for "Jeffrey" has the guid={58283AD4-4F46-4c42-82E3-6C8D880AC27C}, but the database has a different guid={79023189-5589-4e55-ACFD-063318A1C863}.
3) Changes made in the export file have no impact on the database or the EAUI when imported, probably because there is not tagged value on that guid.  The guid for the object "Jeffrey" in the database is truly {58283AD4-4F46-4c42-82E3-6C8D880AC27C}.

So....I think what I learned is:
A) The guid={79023189-5589-4e55-ACFD-063318A1C863} is probably for the tagged value, not the object.

Any takers on explaining how to accomplish the export->import then?
Thanks much.


Some progress.

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
All, should I report this as a bug? Should I call it a feature request? Or, is this how it should work?

adama

  • EA User
  • **
  • Posts: 62
  • Karma: +0/-0
    • View Profile
Here's  a screen shot of a query that shows the database value does not match the EA UI value.
  • Notice that the value for postal code is 90101. This was imported from the changed export CSV.
  • Notice that the value for the EA UI is 10101.  This was the original value that was exported.
  • Not shown is the fact that the ea-uid for this row DOES NOT MATCH the guid for the MyOrg object. I've documented this above.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
What is this XML structure in the tag memo field? I've never seen that before.

q.