dump in more or less correct sort order with seprator pages
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 26 Apr 2016 13:50:57 +0000 (15:50 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 26 Apr 2016 13:50:57 +0000 (15:50 +0200)
star2016-contributions.pl

index 3c2869b..73fda57 100755 (executable)
@@ -48,7 +48,7 @@ foreach my $xml ( split(/\Q<?xml\E/, $xml) ) {
 
        my $abstract;
 
-print $xml;
+#print $xml;
 
        $abstract = $xs->XMLin( $xml, ForceArray => qw(PrimaryAuthor) );
 
@@ -61,16 +61,25 @@ print $xml;
                push @{ $stat->{$k}->{ $abstract->{$k}->[0] } }, $id;
        }
 
+       if ( $abstract->{'ContributionType'}->[0] eq 'Symposium proposal' ) {
+               my $t = $abstract->{Title}->[0];
+               push @{ $stat->{_symposium}->{ $t } }, -$id;
+       }
+
        if ( my $s = $abstract->{Symposium_title} ) {
                $s = $s->[0];
                push @{ $stat->{_symposium}->{$s} }, $id;
        }
 
+       if ( exists $abstract->{PrimaryAuthor}->[0]->{FamilyName} ) {
+               $stat->{_order_by}->{$id} = $abstract->{PrimaryAuthor}->[0]->{FamilyName}->[0];
+       }
+
        $abstracts->{ $id } = $abstract;
 
 }
 
-warn "# stat = ",dump($stat);
+#warn "# stat = ",dump($stat);
 
 sub abstract2doc {
        my $id = shift;
@@ -96,17 +105,62 @@ sub abstract2doc {
        }
 
        $doc->appendParagraph(text => "\nTheme: " . $abstract->{Theme}->[0], style => 'Theme');
-       
+
+       $doc->appendParagraph(text => "\nContributionType: " . $abstract->{ContributionType}->[0], style => 'Quotations');
 
        $doc->appendParagraph(text => "\nID: " . $abstract->{Id}->[0], style => 'Abstract');
 
        warn "# added $id to document\n";
 }
 
-foreach my $id ( keys %$abstracts ) {
-       abstract2doc($id);
+#foreach my $id ( keys %$abstracts ) {
+#      abstract2doc($id);
+#}
+
+foreach my $symposium ( keys %{ $stat->{'_symposium'} } ) {
+
+       my $t = $doc->appendParagraph(text => $symposium, style => 'Title');
+       $doc->setPageBreak( $t, position => 'before', style => 'Title');
+       $doc->appendParagraph(text => 'Symposium', style => 'Subtitle');
+
+       my @symposium_ids = sort @{ $stat->{'_symposium'}->{$symposium} };
+       warn "## [$symposium] symposium_ids ", dump( @symposium_ids );
+
+       my $proposal_id = shift @symposium_ids;
+       if ( $proposal_id < 0 ) {
+               $proposal_id = abs( $proposal_id );
+       } else {
+               warn "ERROR: symposium [$symposium] doesn't have proposal!";
+               
+       }
+#      @symposium_ids = sort { $stat->{_order_by}->{$a} cmp $stat->{_order_by}->{$b} } @symposium_ids;
+       @symposium_ids = sort @symposium_ids;
+       unshift @symposium_ids, $proposal_id;
+
+       $stat->{_order_symposium}->{$symposium} = [ @symposium_ids ];
+
+       foreach my $id ( @symposium_ids ) {
+               abstract2doc($id);
+       }
+
 }
 
+foreach my $type ( 'Oral presentation', 'Poster presentation' ) {
+
+       my $t = $doc->appendParagraph(text => $type, style => 'Title');
+       $doc->setPageBreak( $t, position => 'before', style => 'Title');
+
+       my @order = sort { lc $stat->{_order_by}->{$a} cmp lc $stat->{_order_by}->{$b} }
+               @{ $stat->{'ContributionType'}->{$type} };
+
+       $stat->{ '_order_' . $type } = [ @order ];
+
+       foreach my $id ( @order ) {
+               abstract2doc($id);
+       }
+}
+
+
 warn "# stat = ",dump($stat);
 
 $doc->save;