Nelly has asked for the wisdom of the Perl Monks concerning the following question:


Hello everybody, I'm trying to make a report of all Filters (from tags like: File,Change Requests,Tasks,Topic..) in Starteam.My trials are:
use Win32::OLE; use Win32::OLE::Enum; use Data::Dumper; use strict; # Alow for command-line parameters my $STServer= defined($ARGV[0]) ? $ARGV[0] : 'localhost'; my $STPort = defined($ARGV[1]) ? $ARGV[1] : '49201'; my $STUser = defined($ARGV[2]) ? $ARGV[2] : "Administrator"; my $STPw = defined($ARGV[3]) ? $ARGV[3] : 'Administrator'; my $STServerFactory = CreateObject Win32::OLE "StarTeam.StServerFactor +y"; my $STServer = $STServerFactory->Create($STServer, $STPort); if (! defined $STServer) { print STDERR "Error: Cannot create STServer object!\n"; } $STServer->connect(); my $user = $STServer->logOn($STUser, $STPw); if (! defined ($user) ) { print STDERR "Error: Cannot logon!\n"; } my $FileTypeName = $STServer->TypeNames->FILE; my $CRTypeName = $STServer->TypeNames->CHANGEREQUEST; my $TaskTypeName = $STServer->TypeNames->TASK; my $TopicTypeName = $STServer->TypeNames->TOPIC; my $AuditTypeName = $STServer->TypeNames->AUDIT; my @projects = getProjectObjects($STServer); $STServer->disconnect; #______________________________________________________________ sub getProjectObjects { my @projects = Win32::OLE::Enum->All($STServer->Projects); foreach my $p (@projects) { my $project = $p->Name(); print "\nPROJECT: $project\n"; runViewsOfProject($p); } return @projects; } #______________________________________________________________ sub runViewsOfProject { my ($project) = @_; my $DefaultView = $project->DefaultView()->Name(); my @views = Win32::OLE::Enum->All($project->Views); print "\tDEFAULT-VIEW: $DefaultView\n"; foreach my $v (@views) { # print "\tVIEW: " . $v->Name() . "\tPath: ". $v->Path() . "\n"; # runLabelsOfView($v); runFoldersOfView($v->RootFolder); } return @views; } #___________________________________________________________ sub runFoldersOfView { my ($folder) = @_; my $folder_name = $folder->Name(); # print "\n\t\t\tROOTFOLDER: $folder_name\n"; runSubFoldersOfFolder($folder); } #______________________________________________________________ sub runSubFoldersOfFolder { my ($folder) = @_; runItemsOfFolder($folder); my @subfolder = Win32::OLE::Enum->All($folder->SubFolders); foreach my $subf (@subfolder) { # print "\t\t\tSUBFOLDER : " . $subf->Name() . "(" . $subf->Fold +erHierarchy . ")\n"; runSubFoldersOfFolder($subf); } } #___________________________________________________________ sub runItemsOfFolder { my ($folder) = @_; my $id; my $name; #my @files = $folder->getItems("File"); my @files = Win32::OLE::Enum->All($folder->getItems($FileTypeName)) +; my @ua=Win32::OLE::Enum->All($STServer->Users); my $tag_files=$STServer->$FileTypeName; print $tag_files; my @filters= Win32::OLE::Enum->All($tag_files->Filters); foreach my $f (@files) { #my @filters=Win32::OLE::Enum->All($f->Filter); foreach my $filter (@filters) { print $filter."\n"; } } }

As you you can see I've tried to extract the Filters from File which extracts from Stserver => And I've tried to extract the Filters from each file in each folder====> None of this works!
Can you help me with this and tell me from what should I extract the Strarteam's Filters?

Replies are listed 'Best First'.
Re: Making reports from Starteam in perl
by graff (Chancellor) on May 16, 2004 at 12:39 UTC
    I don't have a clue what StarTeam is, and I'm not familiar at all with Win32::OLE, but the first thing I noticed was that you use the same variable name for two different things -- and both are declared with "my":
    my $STServer = defined($ARGV[0]) ? $ARGV[0] : 'localhost'; ... my $STServer = $STServerFactory->Create($STServer, $STPort);
    How about changing the first one to "my $STHost" or something like that -- even though it probably won't fix the problem, it will make your code easier to understand.

    You might also want to check the Win32::OLE man page, to see whether it provides anything in terms of diagnostic messages when things don't work as intended.

    When you say "None of this works", you aren't telling us enough. In what particular way does it not work? What exactly does it do? If you're not getting any messages or other behavior that would answer these questions, then you need to add some more verbose reporting at various points in the code, and/or you need to step through it with the perl debugger, to see what's going on as the script executes.

      Thanks for replying, but I've just solved this problem, thanks any way.