File Coverage

blib/lib/WebEditor/OldController/TBPJobManager.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             # -*- perl -*-
2              
3             #
4             # $Id: TBPJobManager.pm,v 1.3 2005/03/22 09:59:50 eserte Exp $
5             # Author: Slaven Rezic
6             #
7             # Copyright (C) 2004 Slaven Rezic. All rights reserved.
8             # This package is free software; you can redistribute it and/or
9             # modify it under the same terms as Perl itself.
10             #
11             # Mail: slaven@rezic.de
12             # WWW: http://www.rezic.de/eserte/
13             #
14              
15             package WebEditor::OldController::TBPJobManager;
16              
17 1     1   1135 use strict;
  1         4  
  1         29  
18 1     1   5 use vars qw($VERSION);
  1         2  
  1         65  
19             $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
20              
21 1     1   5 use base qw(Class::Accessor);
  1         3  
  1         100  
22             __PACKAGE__->mk_accessors(qw(AJM Controller DBFile DB));
23              
24 1     1   7 use MLDBM;
  1         3  
  1         8  
25 1     1   27 use Data::Dumper;
  1         2  
  1         76  
26 1     1   570 use DB_File::Lock;
  0            
  0            
27              
28             use WE::Util::AtJobManager;
29              
30             =head1 NAME
31              
32             WebEditor::OldController::TBPJobManager - manager for time based publishing jobs
33              
34             =cut
35              
36             sub new {
37             my($class, $ctrl) = @_;
38             my $self = bless {}, $class;
39             $self->AJM (WE::Util::AtJobManager->new(queue => "w"));
40             $self->Controller($ctrl);
41             $self->DBFile ($ctrl->Root->RootDir . "/tbp.db");
42             $self->open_db;
43             $self;
44             }
45              
46             sub open_db {
47             my $self = shift;
48             local $MLDBM::Serializer = "Data::Dumper";
49             local $MLDBM::UseDB = "DB_File::Lock";
50             tie my %db, "MLDBM", $self->DBFile, O_RDWR|O_CREAT, 0644, $DB_File::DB_HASH, "write"
51             or die "Can't tie to " . $self->DBFile . ": $!";
52             $self->DB(\%db);
53             }
54              
55             sub synchronize_at_jobs {
56             my $self = shift;
57              
58             my $ctrl = $self->Controller;
59             my $objdb = $ctrl->Root->ObjDB;
60             my(%to_events, %te_events);
61             $objdb->walk($objdb->root_object->Id, sub {
62             my $id = shift;
63             my $obj = $objdb->get_object($id);
64             if ($obj->TimeOpen) {
65             push @{ $to_events{$obj->TimeOpen} }, [$id, $obj->Title];
66             }
67             if ($obj->TimeExpire) {
68             push @{ $to_events{$obj->TimeExpire} }, [$id, $obj->Title];
69             }
70             });
71              
72             my %done_events; # Events done since the last visit. Will be deleted after presenting them.
73             my %new_events; # New events to be inserted in the queue
74             my %expired_events; # Events which are expired , %new_events,
75             # %pend
76             }
77              
78             1;
79              
80             __END__