Extracting data about an EntityDef (record type)
To illustrate that you can manipulate metadata, the following example of an external application prints the following:
- The name of the EntityDef
- The names and types of each field and action it contains
- The names of each state it contains
This subroutine makes use of a routine called StdOut,
which prints its arguments to a message box.
Perl
use strict;
use CQPerlExt;
my $sessionObj = CQSession::Build();
$sessionObj->UserLogon("admin", "", "SAMPL", "");
my $entityDefNames = $sessionObj->GetEntityDefNames();
#Iterate over the record types
foreach my $edef_name (@$entityDefNames) {
my $entityDefObj = $sessionObj->GetEntityDef($edef_name);
print_edef($entityDefObj);
}
sub print_edef {
my($edef)=@_;
# The parameter is an EntityDef object.
my($names, $name);
print "Dumping EntityDef ", $edef->GetName;
print "\nFieldDefs:";
$names = $edef->GetFieldDefNames;
foreach $name (@$names) {
print " " , $name , " type=" ,
$edef->GetFieldDefType($name);
}
print "\nActionDefs: ";
$names = $edef->GetActionDefNames;
foreach $name (@$names) {
print " " , $name , " type=" ,
$edef->GetActionDefType($name);
}
if ($edef->GetType == $CQPerlExt::CQ_REQ_ENTITY) {
# stated record type
print "\nEntityDef is a REQ entity def";
print "\nStateDefs:";
$names = $edef->GetStateDefNames;
foreach $name (@$names) {
print " " , $name;
}
}
else {
# stateless record type
print "\nEntityDef is an AUX entity def";
}
print "\n\n";
}
CQSession::Unbuild($sessionObj);