Book a Demo

Author Topic: Multiple occurence of component  (Read 15463 times)

Leoš Literák

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Multiple occurence of component
« on: March 19, 2014, 11:32:49 pm »
I would like to express in my diagram that some component is deployed multiple times. Is there some way how to do it except cloning the component nad pasting it over to get this effect? Thanks

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Multiple occurence of component
« Reply #1 on: March 19, 2014, 11:54:04 pm »
If you are talking 'deployment' then you are trying to depict more than one instances of those components.
You can create multiple instances of the component to model this. (Drag and drop as an instance, use control when you drag if the 'Paste Element' dialog isn't shown)
« Last Edit: March 19, 2014, 11:55:16 pm by nizammohamed »

Prab

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Multiple occurence of component
« Reply #2 on: March 27, 2014, 02:55:49 am »
Hi Nizam, your response is helpful if I need to keep multiple instances on the same diagram. But I have the opposite situation. I have central repository where people have created multiple components for the same entity. Example - I have component A three times in differnet heirarchies. What is the easiest way to merge these elements into one component?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Multiple occurence of component
« Reply #3 on: March 27, 2014, 10:17:14 am »
What do you mean by "multiple components for the same entity"? Instances?

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: Multiple occurence of component
« Reply #4 on: March 27, 2014, 05:29:57 pm »
Quote
Hi Nizam, your response is helpful if I need to keep multiple instances on the same diagram. But I have the opposite situation. I have central repository where people have created multiple components for the same entity. Example - I have component A three times in differnet heirarchies. What is the easiest way to merge these elements into one component?
There is no easy way to merge elements.
I once wrote a script to do so.
You would need to
- replace all references on diagrams
- replace the ID on all connectors
- replace the classifier on all instances
- replace the classifier on all attributes
- replace the classifier on all parameters.

Geert

Prab

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Multiple occurence of component
« Reply #5 on: March 27, 2014, 11:24:47 pm »
And would that 'once written' script be available for us non-coders? :)

Robert Sheridan

  • EA User
  • **
  • Posts: 105
  • Karma: +0/-0
    • View Profile
Re: Multiple occurence of component
« Reply #6 on: March 28, 2014, 12:42:36 am »
When there are not many I resolve this by having all the duplicates on one diagram, deciding which is the master and then using the right click functionality to work round each of the duplicates opening in turn the diagrams it appears on and replacing it with the master (i.e. move the links to the master).

When I have done this I make sure that all the data in the actual elements has been replicated to the master.

I then double check that the duplicates are not linked to any other elements and are not on any diagrams and then delete them.

Prior to doing this I make sure I have a baseline / backup in case I screw up.

Do not forget to chastise the relevant people for breaking rule one of modelling: no duplicate elements.
« Last Edit: March 28, 2014, 12:43:52 am by RobertS »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Multiple occurence of component
« Reply #7 on: March 28, 2014, 05:46:57 pm »
Quote
And would that 'once written' script be available for us non-coders? :)
I'm afraid not.
It was written in a very specific environment, using the framework I wrote for this client. Even if I would have the rights to share the code it wouldn't be of much use to you.

Geert

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Multiple occurence of component
« Reply #8 on: March 29, 2014, 07:28:07 pm »
Not a comprehensive script, like the one Geert has mentioned, but the below query can be used to identify elements with duplicate names, This could be a starting point to do the steps specified by Robert Sheridan.

Code: [Select]
SELECT
t_package.name AS Package, t_object.ea_guid AS CLASSGUID, t_object.Object_Type AS CLASSTYPE,t_object.Name AS Object, t_object.Object_Type AS [Type], t_object.Stereotype, t_object.Scope,t_object.Status, t_object.Phase, t_object.CreatedDate, t_object.ModifiedDate
FROM
t_object, t_package
WHERE t_object.package_id = t_package.package_id and t_object.name in
     (select name from t_object group by name having count (name) > 1) and t_object.Object_Type in ('Class','Component','Activity','Interface') order by t_object.Name

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Multiple occurence of component
« Reply #9 on: April 02, 2014, 04:45:39 am »
Hi,

See example SQL Server script below. Run at your own risk. But might be helpful as a starting point for your solution...


SQL Server Script
_______________

declare @f_name varchar(2048)
declare @f_id int
declare @f_guid varchar (2048)
declare @l_name varchar (2048)
declare @l_id int
declare @l_guid varchar (2048)
declare @root_guid varchar (2048)
declare @stereotype varchar (2048)

-- set the root guid and stereotype of the objects to be merged
SET @root_guid = '{12D2B424-9C14-4f64-AA68-3DF1ABCD9858}';
SET @stereotype = 'Application';
 
declare c1 scroll cursor for
select distinct o2.alias, o2.object_id, o2.ea_guid from (
      select distinct t.alias, t.stereotype from t_object t
            where t.Package_ID IN (select distinct Package_ID from branch where
                  root_guid = @root_guid)
            and t.alias is not null
            and t.stereotype = @stereotype
      group by t.alias, t.stereotype having count (*) > 1)
 o1 join t_object o2 on o1.alias = o2.alias and o1.stereotype = o2.stereotype and o2.Package_ID IN (
      select distinct Package_ID from branch where root_guid = @root_guid)
 order by o2.alias, o2.object_id
open c1

while (1=1)
begin
      fetch next from c1 into @f_name, @f_id, @f_guid
      print 'first = ' + @f_name + '(' + cast (@f_id as varchar (8)) + ')'
      while (1=1)
            begin
                  fetch next from c1 into @l_name, @l_id, @l_guid
                  if @f_name = @l_name
                        begin
                              print 'last = ' + @l_name + '(' + cast (@l_id as varchar (8)) + ')'
                              
                              delete from t_object where object_id = @l_id;
                              delete from t_xref where Client = @l_guid;
                              update t_diagramobjects set object_id = @f_id where object_id = @l_id;
                              update t_attribute set object_id = @f_id where object_id = @l_id;
                              update t_attributeconstraints set object_id = @f_id where object_id = @l_id;
                              update t_method set object_id = @f_id where object_id = @l_id;
                              update t_objectconstraint set object_id = @f_id where object_id = @l_id;
                              update t_objecteffort set object_id = @f_id where object_id = @l_id;
                              update t_objectfiles set object_id = @f_id where object_id = @l_id;
                              update t_objectmetrics set object_id = @f_id where object_id = @l_id;
                              update t_objectproblems set object_id = @f_id where object_id = @l_id;
                              update t_objectproperties set object_id = @f_id where object_id = @l_id;
                              update t_objectrequires set object_id = @f_id where object_id = @l_id;
                              update t_objectresource set object_id = @f_id where object_id = @l_id;
                              update t_objectrisks set object_id = @f_id where object_id = @l_id;
                              update t_objectscenarios set object_id = @f_id where object_id = @l_id;
                              update t_objecttests set object_id = @f_id where object_id = @l_id;
                              update t_objecttrx set object_id = @f_id where object_id = @l_id;
                              update t_operation set object_id = @f_id where object_id = @l_id;
                              update t_object set ParentID = @f_id where ParentID = @l_id
                              
                              update t_connector set start_object_id = @f_id where start_object_id = @l_id;
                              update t_connector set end_object_id = @f_id where end_object_id = @l_id;
                              
                              delete from t_objectproperties where Object_ID = @f_id and propertyId IN (
                                    select o2.PropertyID from t_objectproperties o2 where o2.Object_ID = @f_id AND EXISTS
                                          (select o3.Object_ID, o3.Property from t_objectproperties o3 where o2.Object_ID = o3.Object_ID and o2.Property = o3.Property
                                                group by o3.Object_ID, o3.Property, o3.Value
                                                having COUNT (*) > 1))
                                          and PropertyID not in (
                                                select MIN (o2.propertyID) from t_objectproperties o2 where o2.Object_ID = @f_id AND EXISTS
                                                      (select o3.Object_ID, o3.Property from t_objectproperties o3 where o2.Object_ID = o3.Object_ID and o2.Property = o3.Property
                                                            group by o3.Object_ID, o3.Property, o3.Value
                                                            having COUNT (*) > 1)
                                                group by Object_ID , Property, Value);
                        end
                  else
                        begin
                              if @@fetch_status != 0
                                    break
                                    
                              fetch prior from c1 into @l_name, @l_id, @l_guid
                              break
                        end
                        
                  if @@fetch_status != 0
                        break
            end
      
      if @@fetch_status != 0
            break
end

close c1
deallocate c1

go



_______________
View used by Script:

CREATE VIEW branch AS WITH branch (root_guid, package_id, package_name, Level) AS  (SELECT t_package.ea_guid, t_package.Package_ID, t_package.Name, 0 AS Level FROM t_package UNION ALL SELECT branch.root_guid, t_package.Package_ID, t_package.Name, Level + 1 FROM t_package INNER JOIN  branch ON t_package.Parent_ID = branch.package_id) SELECT t_object.ea_guid AS CLASSGUID, t_object.Object_Type CLASSTYPE, branch.root_guid, branch.Level, branch.package_id, branch.package_name, t_object.name, t_object.Stereotype, t_object.Object_Type FROM t_object, branch WHERE t_object.Package_ID = branch.package_id