Discussion:
Finding classes that extend from another class
(too old to reply)
Adam
2009-12-03 21:11:27 UTC
Permalink
Hello,

What is the best way to find the classes that extend from another class?
For example, if I want to find all the classes that extend from
SalesTableType, currently, I'm doing this.

==================================================
UtilIdELements utilidelements;
SysDictClass sysdictclass;
;
while select utilidelements
where utilidelements.recordtype == UtilElementType::Class
&& utilidelements.name like 'SalesTableType*'
{
sysdictclass = new SysDictClass(utilidelements.id);
if((sysdictclass != null)
&& !sysdictclass.isAbstract()
&& sysdictclass.isExtending(classnum(SalesTableType)))
{
info(sysdictclass.name());
}
}
==================================================

I'm just curious if there's a better way. I hate doing the while select and
checking for the name, then instantiating the sysdictclass object just to
check if it extends from the class I'm looking for. Also this has a flaw
that there could be classes extending from SalesTableType which do not have a
name like "SalesTableType*". Is there a better way of getting this
information from the UtilIdElements table?

Thanks,
Adam
shivraj
2009-12-04 05:43:01 UTC
Permalink
Hi Adam,

The potential drawback in using while loop in utilidelements is sometimes
the extended class is not started with the same name as of parent. So, to get
the list of extended classes use

<List object> = new DictClass(classnum(<className>)).extendedBy();

This will give the list of class ids which is extended with your selected
class.

use these ids to create object of dictClass and you it in your code.

Hope this will help you out.


Ax Technical Consultant
-Shiv
Post by Adam
Hello,
What is the best way to find the classes that extend from another class?
For example, if I want to find all the classes that extend from
SalesTableType, currently, I'm doing this.
==================================================
UtilIdELements utilidelements;
SysDictClass sysdictclass;
;
while select utilidelements
where utilidelements.recordtype == UtilElementType::Class
&& utilidelements.name like 'SalesTableType*'
{
sysdictclass = new SysDictClass(utilidelements.id);
if((sysdictclass != null)
&& !sysdictclass.isAbstract()
&& sysdictclass.isExtending(classnum(SalesTableType)))
{
info(sysdictclass.name());
}
}
==================================================
I'm just curious if there's a better way. I hate doing the while select and
checking for the name, then instantiating the sysdictclass object just to
check if it extends from the class I'm looking for. Also this has a flaw
that there could be classes extending from SalesTableType which do not have a
name like "SalesTableType*". Is there a better way of getting this
information from the UtilIdElements table?
Thanks,
Adam
Adam
2009-12-04 09:01:01 UTC
Permalink
Perfect! This is exactly what I was looking for. Thanks a lot!
Post by shivraj
Hi Adam,
The potential drawback in using while loop in utilidelements is sometimes
the extended class is not started with the same name as of parent. So, to get
the list of extended classes use
<List object> = new DictClass(classnum(<className>)).extendedBy();
This will give the list of class ids which is extended with your selected
class.
use these ids to create object of dictClass and you it in your code.
Hope this will help you out.
Ax Technical Consultant
-Shiv
Post by Adam
Hello,
What is the best way to find the classes that extend from another class?
For example, if I want to find all the classes that extend from
SalesTableType, currently, I'm doing this.
==================================================
UtilIdELements utilidelements;
SysDictClass sysdictclass;
;
while select utilidelements
where utilidelements.recordtype == UtilElementType::Class
&& utilidelements.name like 'SalesTableType*'
{
sysdictclass = new SysDictClass(utilidelements.id);
if((sysdictclass != null)
&& !sysdictclass.isAbstract()
&& sysdictclass.isExtending(classnum(SalesTableType)))
{
info(sysdictclass.name());
}
}
==================================================
I'm just curious if there's a better way. I hate doing the while select and
checking for the name, then instantiating the sysdictclass object just to
check if it extends from the class I'm looking for. Also this has a flaw
that there could be classes extending from SalesTableType which do not have a
name like "SalesTableType*". Is there a better way of getting this
information from the UtilIdElements table?
Thanks,
Adam
Eduardo Arias
2011-03-28 19:49:39 UTC
Permalink
Take a look at this -

http://axwonders.blogspot.com/2011/03/find-aot-classes-through-x.html
Post by Adam
Hello,
What is the best way to find the classes that extend from another class?
For example, if I want to find all the classes that extend from
SalesTableType, currently, I am doing this.
==================================================
UtilIdELements utilidelements;
SysDictClass sysdictclass;
;
while select utilidelements
where utilidelements.recordtype == UtilElementType::Class
&& utilidelements.name like 'SalesTableType*'
{
sysdictclass = new SysDictClass(utilidelements.id);
if((sysdictclass != null)
&& !sysdictclass.isAbstract()
&& sysdictclass.isExtending(classnum(SalesTableType)))
{
info(sysdictclass.name());
}
}
==================================================
I am just curious if there is a better way. I hate doing the while select and
checking for the name, then instantiating the sysdictclass object just to
check if it extends from the class I am looking for. Also this has a flaw
that there could be classes extending from SalesTableType which do not have a
name like "SalesTableType*". Is there a better way of getting this
information from the UtilIdElements table?
Thanks,
Adam
Post by shivraj
Hi Adam,
The potential drawback in using while loop in utilidelements is sometimes
the extended class is not started with the same name as of parent. So, to get
the list of extended classes use
<List object> = new DictClass(classnum(<className>)).extendedBy();
This will give the list of class ids which is extended with your selected
class.
use these ids to create object of dictClass and you it in your code.
Hope this will help you out.
Ax Technical Consultant
-Shiv
Post by Adam
Perfect! This is exactly what I was looking for. Thanks a lot!
Loading...