Book a Demo

Author Topic: Printing project issues  (Read 5673 times)

molla

  • EA User
  • **
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Printing project issues
« on: December 06, 2004, 02:55:57 am »
The RTF file generated from Project Issues contains all issues, even if the Status Filter is put on. I would like to have an RTF file that has only the filtered issues. Of course it would be nice to have other filters based on Developer and the Date of issue (or solution).

thomaskilian

  • Guest
Re: Printing project issues
« Reply #1 on: December 06, 2004, 03:32:11 am »
I dropped using the system issues amongst other things due to this restriction. Instead I use element issues where I can add a status like "DUE" and also tags. With the help of a few scripts this works much better for me.

molla

  • EA User
  • **
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Printing project issues
« Reply #2 on: December 07, 2004, 07:54:06 am »
I guess it is not possible to convert system issues to element issues...  :-/

thomaskilian

  • Guest
Re: Printing project issues
« Reply #3 on: December 08, 2004, 02:07:23 am »
I did so by using a little Perl macro  ;D

molla

  • EA User
  • **
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Printing project issues
« Reply #4 on: December 08, 2004, 02:35:07 am »
Can you please share it with us?    :)

thomaskilian

  • Guest
Re: Printing project issues
« Reply #5 on: December 08, 2004, 04:37:48 am »
I have the assumptions about my issues that they are located under root/Project Definition/Issues. You should try  this with a copy of your EAP file first  ;D

Prerequisite:http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1101985326;start=0#0

Code: [Select]
# testIssues.pl
#
# This is an alpha release! Use at your own risk
#

#########################################################
# some requirements
#
use strict;
use Win32::OLE;
use Win32::OLE::NLS qw(:LOCALE :DATE);
use EAparms;

my $eap = EAparms->new();


my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime();
$year += 1900;
$mon += 1;
my $nowCtime = ctime("$mday.$mon.$year");


sub GetByName {
 my ($o, $n) = @_;
 for (my $i = 0; $i < $o->{Count}; $i++) {
   my $ret = $o->GetAt($i);
   if ($ret->{Name} eq $n) {
#      print "At $i ";
     return $ret;
   }
 }
 return undef;
}

{# superset for Issues
 package Issue;
 use Win32::OLE::Variant;
 use Win32::OLE::NLS qw(:LOCALE :DATE);

 my $statusFromSys = { "Open" => "O", "Under Review" => "R", "Closed" => "C" };
 my $statusFromElement = { "Proposed" => "O", "Mandatory" => "R", "Implemented" => "C" };
 my $statusToSys = { "O" => "Open", "R" => "Under Review", "C" => "Closed" };
 my $statusToElement = { "O" => "Proposed", "R" => "Mandatory", "C" => "Implemented" };
 my $noDate = "30.12.1899";

 sub new {
   my ($self) = @_;

   $self->{SE_NAME} = "";
   $self->{SE_NOTES} = "";
   $self->{SE_STATUS} = "";
   $self->{SE_PRIORITY} = "";
   $self->{S_RESOLUTION} = "";
   $self->{S_DATEDUE} = "";
   $self->{S_DATERESOLVED} = "";
   $self->{S_DATE} = "";
   $self->{S_RESOLVER} = "";
   $self->{S_RESPONSIBLE} = "";
   $self->{S_OWNER_E_AUTHOR} = "";
   $self->{E_DIFFICULTY} = "";
   bless $self;
   return $self;
 }

 sub dateCopy {
   my ($self, $issue, $l) = @_;

   my $r = $issue->{$l}->Date(DATE_SHORTDATE);

   if ($r ne $noDate) {
     my $lr = "S_" . uc $l;
     $self->{$lr} = $r;
   }
 }

 sub fromSys {
   my ($self, $issue) = @_;

   $self->{SE_NAME} = $issue->{Name};
   $self->{SE_NOTES} = $issue->{Notes};
   $self->{SE_STATUS} = $statusFromSys->{$issue->{Status}};
   $self->{SE_PRIORITY} = $issue->{Priority};

   $self->{S_OWNER_E_AUTHOR} = $issue->{Owner};
   $self->{S_RESOLUTION} = $issue->{Resolution};
   dateCopy ($self, $issue, "DateDue");
   dateCopy ($self, $issue, "DateResolved");
   dateCopy ($self, $issue, "Date");
   $self->{S_RESOLVER} = $issue->{Resolver};
 }

 sub toSys {
   my ($self, $issues) = @_;
   my $i;

   if ($i = main::GetByName ($issues, $self->{SE_NAME})) {
#      print "Update to SysIssues\n";
   } else {
#      print "Add to SysIssues\n";
     $i = $issues->AddNew ("Issue", $self->{SE_NAME});
   }
   $i->{Notes} = $self->{SE_NOTES};
   $i->{Status} = $statusToSys->{$self->{SE_STATUS}};
   $i->{Priority} = $self->{SE_PRIORITY};

   $i->{Resolution} = $self->{S_RESOLUTION};
   $i->{DateDue} = Variant (VT_DATE, $self->{S_DATEDUE});
   $i->{DateResolved} = Variant (VT_DATE, $self->{S_DATERESOLVED});
   $i->{Date} = Variant (VT_DATE, $self->{S_DATE});
   $i->{Resolver} = $self->{RESOLVER};
   $i->Update();

   $issues->Refresh();
 }

 sub fromElement {
   my ($self, $issue) = @_;

   $self->{SE_NAME} = $issue->{Name};
   $self->{SE_NOTES} = $issue->{Notes};
   $self->{SE_STATUS} = $statusFromElement->{$issue->{Status}};
   $self->{SE_PRIORITY} = $issue->{Priority};

   $self->{S_OWNER_E_AUTHOR} = $issue->{Author};
   $self->{E_DIFFICULTY} = $issue->{Difficulty};
   $self->{S_DATE} = $issue->{Created};

   my $t = $issue->{TaggedValues};
   for (my $i = 0; $i < $t->{Count}; $i++) {
     my $tv = $t->GetAt($i);
     my $n = $tv->{Name};
     my $un = uc($n);

     if (defined ($self->{"S_" . $un})) {
       $self->{"S_" . $un} = $tv->{Value};
     }
   }
 }

 sub toTag {
   my ($self, $t, $n) = @_;


   my $nv = "S_" . uc $n;
   my $tv;
   if ($self->{$nv} eq "") { return; };

   if ($tv = main::GetByName ($t, $n)) {
#      print "Update tag $n\n";
     $tv->{Value} = $self->{$nv};
   } else {
#      print "Add tag $n\n";
     $tv = $t->AddNew ($n, $self->{$nv});
   }

   if (!($tv->Update())) {
     print "Error ", $tv->GetLastError(), "\n";
     $tv->{Notes} = $self->{$nv};
     $tv->{Value} = substr ($self->{$nv}, 1, 10);
     if (!($tv->Update())) {
       print "Error ", $tv->GetLastError(), "\n";
     }
   }
   $t->Refresh();
 }

 sub toElement {
   my ($self, $issues) = @_;
   my $i;

   if ($i = $issues->main::GetByName($self->{SE_NAME})) {
     print "Update to ElementIssues\n";
   } else {
     print "Add to ElementIssues\n";
     $i = $issues->AddNew ($self->{SE_NAME}, "Requirement");
   }

   $i->{Notes} = $self->{SE_NOTES};
   $i->{Status} = $statusToElement->{$self->{SE_STATUS}};
   $i->{Priority} = $self->{SE_PRIORITY};

   $i->{Author} = $self->{S_OWNER_E_AUTHOR};
   $i->{Difficulty} = $self->{E_DIFFICULTY};
#    $i->{Created} = $self->{S_DATE};

print $i, "\n";
   $i->Update() or print $i->GetLastError(), "\n";

   $issues->Refresh();

   my $t = $i->{TaggedValues};
   toTag ($self, $t, "Resolution");
   toTag ($self, $t, "DateDue");
   toTag ($self, $t, "DateResolved");
   toTag ($self, $t, "Date");
   toTag ($self, $t, "Resolver");
   
   $i->Update();

   $issues->Refresh();
 }

 sub check {
   my ($self) = @_;
   my $consistent = 1;
   if ($self->{SE_STATUS} eq "O") {
     if ($self->{S_DATERESOLVED} ne "" or
         $self->{S_RESOLVER} ne "" or
         $self->{S_RESOLUTION} ne "") {
       $consistent = 0;
     }
   } elsif ($self->{SE_STATUS} eq "R") {
     if ($self->{S_DATERESOLVED} ne "" or
         $self->{S_RESOLVER} ne "") {
       $consistent = 0;
     }
   } else {
     if ($self->{S_DATERESOLVED} eq "" or
         $self->{S_RESOLVER} eq "" or
         $self->{S_RESOLUTION} eq "") {
       $consistent = 0;
     }
   }
   if ($consistent) { return };
   print "check ", $self->{SE_NAME}, "\n";
 }

 sub debug {
   my ($self) = @_;

   print $self->{SE_NAME}, "\n";
   print "+NOTES=", $self->{SE_NOTES}, "\n";
   print "+STATUS=", $self->{SE_STATUS}, "\n";
   print "+PRIORITY=", $self->{SE_PRIORITY}, "\n";
   print "+RESOLUTION=", $self->{S_RESOLUTION}, "\n";
   print "+DATEDUE=", $self->{S_DATEDUE}, "\n";
   print "+DATERESOLVED=", $self->{S_DATERESOLVED}, "\n";
   print "+DATE=", $self->{S_DATE}, "\n";
   print "+RESOLVER=", $self->{S_RESOLVER}, "\n";
   print "+AUTHOR=", $self->{S_OWNER_E_AUTHOR}, "\n";
   print "+DIFFICULTY=", $self->{E_DIFFICULTY}, "\n";
   print "\n";
 }

 1;
}

#########################################################
# Open the model file
#
my $ex = $eap->{MODEL};
my $issues = $ex->{Issues};
my $mo = $ex->{Models};
my $mo0 = $mo->GetAt(0);

#########################################################
# locate the package containing the documentation stuff
#
my $pk = enterPackage ($mo0, 0);
$pk = enterPackage ($pk, "Project Definition");
$pk = enterPackage ($pk, "Issues");

#########################################################
# copy SysIssues to ElementIssues
#
doIssuesCopy($pk, $issues); # you need this only once!
#doIssues1($pk, $issues);


#########################################################
#########################################################

#########################################################
#
# helper to copy system issues to element issues
sub doIssuesCopy {
 my ($pk, $sysIssues) = @_;
 my $i;
 my $issue = Issue::new();
 my $issues = $pk->{Elements};

 for (my $i = 0; $i < $sysIssues->{Count}; $i++) {
   $issue->fromSys ($sysIssues->GetAt($i));
   $issue->debug();
   $issue->toElement($issues);
   $issue->new();
 }

}

sub ctime {
 my ($date) = @_;
 my ($d, $m, $y);

#print "Ctime($date) ";
 if ($date =~ /(.*) (.*)/) { $date = $1; }
 if ($date =~ /(.*)\.(.*)\.(.*)/) {
   $d = $1; $m = $2; $y = $3;
   return (($y-2000)*12+$m)*32+$d;
 }
#  print STDERR "Invalid date $date\n";
 return 0;
}

sub doIssues1 {
 my ($pk) = @_;
 my $i;
 my $issue = Issue::new();
 my $issues = $pk->{Elements};

 for (my $i = 0; $i < $issues->{Count}; $i++) {
   if ($issues->GetAt($i)->{Type} eq "Issue") {
     $issue->fromElement ($issues->GetAt($i));
#$issue->debug();
     my $ct = ctime ($issue->{S_DATEDUE});
     if (0 == $ct) {
       print "OPN -------", $issue->{SE_NAME}, "\n";
#        $issue->debug();
     } elsif ($nowCtime >= $ct) {
       print "DUE -------", $issue->{SE_NAME}, "\n";
#        $issue->debug();
     } elsif (!$issue->{S_RESPONSIBLE}) {
       print "RES -------", $issue->{SE_NAME}, "\n";
     }
     $issue->new();
   }
 }

 for ($i = 0; $i < $pk->{Packages}->{Count}; $i++) {
   doIssues1($pk->{Packages}->GetAt($i));
 }  
}


#########################################################
# descend to a contained package
#
sub enterPackage {
 my $currPackage = shift;
 my $nextPackage = shift;
 my $pk = $currPackage->{Packages};
 if ($nextPackage eq int ($nextPackage)) {
   return $pk->GetAt($nextPackage);
 } else {
   return GetByName($pk, $nextPackage);
 }
}