Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Janic Vachon on November 24, 2015, 12:21:13 pm

Title: Viewing instance when deleting a classifier
Post by: Janic Vachon on November 24, 2015, 12:21:13 pm
Hi there,

Is there a way to view the instances of a classifier using the UI? (beside doing a "find in all diagrams" on the classifier or doing a sql query on the ClassifierID on the t_object)?

I want to be sure that I don't delete a classifier that has multiples instances that might not appear in diagrams...

If you ask me why I need to do that, its because we have a large project with a lot of users and there is sometimes duplication between classifier. So from times to times, we need to merge (manually because we are using 9.3) these classifiers and instances.

Thanks for your time,

Janic
Title: Re: Viewing instance when deleting a classifier
Post by: qwerty on November 24, 2015, 08:50:12 pm
You need an individual SQL like this:
Code: [Select]
SELECT i.ea_GUID AS CLASSGUID, i.Object_Type As CLASSTYPE, i.name, c.name
FROM t_object i, t_object c
WHERE i.classifier_guid = c.ea_guid OR i.PDATA1 = c.ea_guid
This will not list the use of the class as type in properties etc.

q.
Title: Re: Viewing instance when deleting a classifier
Post by: Janic Vachon on November 27, 2015, 05:30:29 am
Thank you for your answer. Am I the only one that would need that feature?

Janic
Title: Re: Viewing instance when deleting a classifier
Post by: qwerty on November 27, 2015, 06:32:29 am
I guess not. But for that reason EA has the possibility to expand the searches at your wish. There are quite a number of queries being asked for. E.g. the information flow. It would probably be nice to have a customizable toolbox with searches (I don't need most of the pre-defined ones and wished to get rid of them).

q.
Title: Re: Viewing instance when deleting a classifier
Post by: natvig on November 30, 2015, 04:36:18 pm
I use the Traceability windows (Ctrl+Shit+4) to find instances of a classifier. You can jump to each instance of a classifier by right clicking an instance in the Traceability window and choose Switch to Related Element. Make sure you have Classifier selected in the selection list at the top of the Traceability window.
Title: Re: Viewing instance when deleting a classifier
Post by: Janic Vachon on December 24, 2015, 04:01:25 am
I use the Traceability windows (Ctrl+Shit+4) to find instances of a classifier. You can jump to each instance of a classifier by right clicking an instance in the Traceability window and choose Switch to Related Element. Make sure you have Classifier selected in the selection list at the top of the Traceability window.

Hi there, thanks for your response. From what I understand, you see see your instances in Tracability view because you do make a relationship between your classifier and your newly created instance?

Since we dont make that relationship, I dont see any of my classifier in Tracability view. So, I got to run some sql query to get the list of my instances for a given classifier.

I got a question for the community, it is common to make a relationship between the instances and the classifiers? I dont find anything on the UML stating that explicitly.

Thanks for your time,

Janic

Title: Re: Viewing instance when deleting a classifier
Post by: Geert Bellekens on December 24, 2015, 04:17:29 am
It is not common to make an (extra and redundant) relation between instances and their classifier.

Geert
Title: Re: Viewing instance when deleting a classifier
Post by: Geert Bellekens on December 24, 2015, 04:33:00 am
I use this SQL Search

Instances by ClassifierName
Code: [Select]
select instance.ea_guid as CLASSGUID,instance.Object_Type as CLASSTYPE,instance.name as InstanceName, classifier.name as ClassifierName
,package.name as PackageName ,package_p1.name as PackageLevel1,package_p2.name as PackageLevel2,package_p3.name as PackageLevel3
from (((((t_object instance
inner join t_object classifier on instance.classifier = classifier.object_id )
inner join t_package package on instance.package_id = package.package_id)
left join t_package package_p1 on package_p1.package_id = package.parent_id)
left join t_package package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package package_p3 on package_p3.package_id = package_p2.parent_id)
where classifier.name like '#WC#<Search Term>#WC#'

Geert
Title: Re: Viewing instance when deleting a classifier
Post by: Janic Vachon on December 24, 2015, 05:31:29 am
Hi there,

Thanks a lot for the info Geert. I upgraded your SQL search query. A lot simpler to sort by package hierarchy (Model root to children package) when it is in a column. I drill down to 11 packages. It is really useful when you want to show objects that are under a certain package. You can add few "like" clauses with package name to specify what you want to get.

Give it a try ;)

Thank you

Code: [Select]
select * from
(select 
instance.ea_guid as CLASSGUID, instance.Object_Type as CLASSTYPE, instance.name as InstanceName, classifier.name as ClassifierName ,
case when package_p11.name is null then '' else package_p11.name + ' > '  end +
case when package_p10.name is null then '' else package_p10.name + ' > '  end +
case when package_p9.name is null then '' else package_p9.name + ' > '  end +
case when package_p8.name is null then '' else package_p8.name + ' > '  end +
case when package_p7.name is null then '' else package_p7.name + ' > '  end +
case when package_p6.name is null then '' else package_p6.name + ' > '  end +
case when package_p5.name is null then '' else package_p5.name + ' > '  end +
case when package_p4.name is null then '' else package_p4.name + ' > '  end +
case when package_p3.name is null then '' else package_p3.name + ' > '  end +
case when package_p2.name is null then '' else package_p2.name + ' > '  end +
case when package_p1.name is null then '' else package_p1.name + ' > '  end +
case when package.name is null then '' else package.name end
as 'Package'
from (((((((((((((t_object instance
inner join t_object classifier on instance.classifier = classifier.object_id )
inner join t_package package on instance.package_id = package.package_id)
left join t_package package_p1 on package_p1.package_id = package.parent_id)
left join t_package package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package package_p3 on package_p3.package_id = package_p2.parent_id)
left join t_package package_p4 on package_p4.package_id = package_p3.parent_id)
left join t_package package_p5 on package_p5.package_id = package_p4.parent_id)
left join t_package package_p6 on package_p6.package_id = package_p5.parent_id)
left join t_package package_p7 on package_p7.package_id = package_p6.parent_id)
left join t_package package_p8 on package_p8.package_id = package_p7.parent_id)
left join t_package package_p9 on package_p9.package_id = package_p8.parent_id)
left join t_package package_p10 on package_p10.package_id = package_p9.parent_id)
left join t_package package_p11 on package_p11.package_id = package_p10.parent_id)) t1
where
t1.Package not like '#WC#obsolete#WC#'
and t1.ClassifierName like '#WC#<Search Term>#WC#'
Title: Re: Viewing instance when deleting a classifier
Post by: Geert Bellekens on December 24, 2015, 06:16:07 am
Nice :) but I don't think that one works on a .eap file does it?

Jet is rather limited when it comes to advanced SQL queries

Geert
Title: Re: Viewing instance when deleting a classifier
Post by: Janic Vachon on December 24, 2015, 06:30:48 am
Well, it works on SQL Server. You are right, the JET engine probably do not support temporary table. I would have to edit it so it would work on JET engine. That will be next year ;)

Thanks,

Janic
Title: Re: Viewing instance when deleting a classifier
Post by: natvig on December 24, 2015, 07:22:23 am
It is not common to make an (extra and redundant) relation between instances and their classifier.

Of course not, and you don't have to. To see the relationship between the instance and its classifier in the traceability windows as I suggested you need to tell EA to show it. To do that you need to select 'Classifier' in the Traceability filter list (fourth icon from left in top row of the Traceability window).
Title: Re: Viewing instance when deleting a classifier
Post by: Janic Vachon on December 24, 2015, 08:13:09 am
Wow, that just made my day.

Didn't know that option existed!!

Thank you very much!! No SQL needed!!

Janic