メタデータを操作できることを示すために、外部アプリケーションの以下の例では、次の項目を印刷します。
このサブルーチンは StdOut と呼ばれるルーチンを使用します。このルーチンは、引数をメッセージ ボックスに出力します。
Sub DumpOneEntityDef(edef) ' the parameter is an EntityDef object
Dim names ' a Variant
Dim name ' a String
Dim limit ' a Long
Dim index ' a Long
StdOut "Dumping EntityDef " & edef.GetName
StdOut " FieldDefs:"
names = edef.GetFieldDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name & " type=" & edef.GetFieldDefType(name)
index = index + 1
Loop
End If
names = edef.GetActionDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name & " type=" & _
edef.GetActionDefType(name)
index = index + 1
Loop
End If
If edef.GetType() = AD_REQ_ENTITY Then
' stated record type
StdOut " EntityDef is a REQ entity def"
StdOut " StateDefs:"
names = edef.GetStateDefNames
If IsArray(names) Then
index = LBound(names)
limit = UBound(names) + 1
Do While index < limit
name = names(index)
StdOut " " & name
index = index + 1
Loop
End If
Else
' stateless record type
StdOut " EntityDef is an AUX entity def"
End If
StdOut ""
End Sub
REM Start of Global Script StdOut
sub StdOut(Msg)
msgbox Msg
end sub
REM End of Global Script StdOut
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);