Book a Demo

Author Topic: Bulk Insert to component Attributes  (Read 5052 times)

vladap

  • EA User
  • **
  • Posts: 79
  • Karma: +0/-0
    • View Profile
Bulk Insert to component Attributes
« on: January 05, 2023, 07:40:51 pm »
Hello Guys,

I have an excel with some value, we are inserting to Component´s attributes.
(Name, Stereotype, Alias, Initial Value, Note)
Currently its a manual task , but I believe there can be some kind of bulk insert :)

I believe it can be achieved with DB insert - but that is not feasible for standard user.

Can I do it somehow using EA client?

thanks,
Vladimír

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk Insert to component Attributes
« Reply #1 on: January 05, 2023, 07:57:18 pm »
You can use my excel importer: https://bellekens.com/ea-excel-import-export/

Geert

vladap

  • EA User
  • **
  • Posts: 79
  • Karma: +0/-0
    • View Profile
Re: Bulk Insert to component Attributes
« Reply #2 on: January 05, 2023, 09:31:35 pm »
thanks Geert, the import and export works for me, but I am missing an Initial Value field in the Excel.
I tried to add it to the configuration select, but then I receive Runtime error , when I press "Export"

Code: [Select]
select '' as Action,o.Object_Type AS CLASSTYPE, o.ea_guid AS CLASSGUID,  o.ea_guid as ownerField, -1 as Pos,
o.Name, o.Stereotype, o.Note AS Notes_formatted,o.Alias, o.InitialValue, '' as Datatype, o.Multiplicity, o.Scope as Visibility,
tv1.Value as TAG_Tag1, tv2.Value as TAG_Tag2
from ((t_object o
left join t_objectproperties tv1 on (tv1.Object_ID = o.Object_ID
and tv1.Property = 'Tag1'))
left join t_objectproperties tv2 on (tv2.Object_ID = o.Object_ID
and tv2.Property = 'Tag1'))
where o.Package_ID in (#Branch#)
union all
select '' as Action, 'Attribute' as CLASSTYPE, a.ea_guid as CLASSGUID, o.ea_guid as ownerField,a.Pos as Pos,
a.name, a.Stereotype, a.Notes as Notes_Formatted, a.Style as Alias,  a.Default as InitialValue, a.Type as Datatype, a.LowerBound & '..' & a.UpperBound as Multiplcity, a.Scope as Visibility,
tv1.Value as TAG_Tag1, tv2.Value as TAG_Tag2
from (((t_attribute a
inner join t_object o on o.Object_ID = a.Object_ID)
left join t_attributetag tv1 on (tv1.ElementID = a.ID
and tv1.Property = 'Tag1'))
left join t_attributetag tv2 on (tv2.ElementID = a.ID
and tv2.Property = 'Tag2'))
where o.Package_ID in (#Branch#)
order by ownerField, Pos, name

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Bulk Insert to component Attributes
« Reply #3 on: January 05, 2023, 09:48:38 pm »
It would probably help to post the RT error as well.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk Insert to component Attributes
« Reply #4 on: January 05, 2023, 09:50:53 pm »
thanks Geert, the import and export works for me, but I am missing an Initial Value field in the Excel.
I tried to add it to the configuration select, but then I receive Runtime error , when I press "Export"

The select is only used in the export. The import looks at the names of the columns.

Geert

vladap

  • EA User
  • **
  • Posts: 79
  • Karma: +0/-0
    • View Profile
Re: Bulk Insert to component Attributes
« Reply #5 on: January 05, 2023, 11:36:39 pm »
ok. but still dont´t understand how to add InitialValue to the Excel. I understand that Initial Value is Default column in the Database., but when I update the SQL with the statement below , I receive:

Run-time error '-1072896680 (c00ce558)':
XML document must have a top level element.

and when I press debug:

I get to the line in Visual Basic editor with following text:     data = eaConn.getQueryResult(query, True)

select '' as Action,o.Object_Type AS CLASSTYPE, o.ea_guid AS CLASSGUID,  o.ea_guid as ownerField, -1 as Pos,
o.Name, o.Stereotype, o.InitialValue, o.Note AS Notes_formatted,o.Alias, '' as Datatype, o.Multiplicity, o.Scope as Visibility,
tv1.Value as TAG_Tag1, tv2.Value as TAG_Tag2
from ((t_object o
left join t_objectproperties tv1 on (tv1.Object_ID = o.Object_ID
and tv1.Property = 'Tag1'))
left join t_objectproperties tv2 on (tv2.Object_ID = o.Object_ID
and tv2.Property = 'Tag1'))
where o.Package_ID in (#Branch#)
union all
select '' as Action, 'Attribute' as CLASSTYPE, a.ea_guid as CLASSGUID, o.ea_guid as ownerField,a.Pos as Pos,
a.name, a.Stereotype, a.Default as InitialValue, a.Notes as Notes_Formatted, a.Style as Alias, a.Type as Datatype, a.LowerBound & '..' & a.UpperBound as Multiplcity, a.Scope as Visibility,
tv1.Value as TAG_Tag1, tv2.Value as TAG_Tag2
from (((t_attribute a
inner join t_object o on o.Object_ID = a.Object_ID)
left join t_attributetag tv1 on (tv1.ElementID = a.ID
and tv1.Property = 'Tag1'))
left join t_attributetag tv2 on (tv2.ElementID = a.ID
and tv2.Property = 'Tag2'))
where o.Package_ID in (#Branch#)
order by ownerField, Pos, name

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Bulk Insert to component Attributes
« Reply #6 on: January 05, 2023, 11:51:26 pm »
I would just guess that '' would not result in a valid XML name. Use a non-blank value.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk Insert to component Attributes
« Reply #7 on: January 06, 2023, 12:03:37 am »
ok. but still dont´t understand how to add InitialValue to the Excel. I understand that Initial Value is Default column in the Database., but when I update the SQL with the statement below , I receive:

Vladap, as I was trying to explain, the SQL Query is only used to Export data from EA to Excel, not to Import data to EA.
A simple excel with these columns should work to import an attribute with an initial value
CLASSTYPE   Name   InitialValue

https://imgur.com/a/qvE7aSJ

Geert

vladap

  • EA User
  • **
  • Posts: 79
  • Karma: +0/-0
    • View Profile
Re: Bulk Insert to component Attributes
« Reply #8 on: January 06, 2023, 12:50:50 am »
ok I understand for this one way, it will work. What about CLASSGUID , can I keep it empty and EA will handle it ?
My understanding it must be unique.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk Insert to component Attributes
« Reply #9 on: January 06, 2023, 12:58:18 am »
I did not include ClassGUID in my example did I?

Yes, if you keep it empty the tool will create a new element. The guid is always handled by EA itself.
This field is only used when updating existing elements (in case of name changes or something like that)

Geert

jcampos

  • EA Novice
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
    • Andes Architecture
Re: Bulk Insert to component Attributes
« Reply #10 on: February 04, 2023, 07:22:20 am »
Hi!

You could Use CSV export(Import thomake that bulk changes in EA.

At the moment to create the specification, include the GUID, stereotype, type and all those tags which are important.
Please read this article https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_exchange/csvimportexport.html

i'll hope that could works.
If you need any help, don't doubt in contact me.

Jhon Campos
Andes Architecture, Colombia.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Bulk Insert to component Attributes
« Reply #11 on: February 04, 2023, 07:30:42 pm »
Hi!

You could Use CSV export(Import thomake that bulk changes in EA.

At the moment to create the specification, include the GUID, stereotype, type and all those tags which are important.
Please read this article https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_exchange/csvimportexport.html

i'll hope that could works.
You can't use CSV Import/Export to import attributes. It only imports elements.

Geert