/[transports]/trunk/lib/Transports/Bootstrap.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Transports/Bootstrap.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (show annotations)
Mon Jun 5 14:06:58 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 2614 byte(s)
added landscapes (collection of source and destination clients) to the mix
instead of specifing users for sources (and destinations which wasn't
implemented anyway)
1 use warnings;
2 use strict;
3
4 package Transports::Bootstrap;
5 use base qw(Jifty::Bootstrap);
6
7 =head1 Bootstrap application data
8
9 Create initial data
10
11 =cut
12
13 sub run {
14 my $self = shift;
15
16 my $system_user = Transports::CurrentUser->superuser( _bootstrap => 1 );
17
18 my $u_admin = Transports::Model::User->new(current_user => $system_user);
19 $u_admin->create(
20 name => 'System administrator',
21 email => 'admin@example.com',
22 password => 'admin',
23 admin => 1,
24 );
25
26 my $u_import = Transports::Model::User->new(current_user => $system_user);
27 $u_import->create(
28 name => 'Import operator',
29 email => 'import@example.com',
30 password => 'import',
31 can_import => 1,
32 );
33
34 my $u;
35 foreach my $i ( 0 ... 2 ) {
36 $u->{$i} = Transports::Model::User->new(current_user => $system_user);
37 my $nr = $i + 1;
38 $u->{$i}->create(
39 name => "Normal User $nr",
40 email => "user${nr}\@example.com",
41 password => 'user',
42 );
43 }
44
45 my $l;
46 foreach my $i ( 0 ... 2 ) {
47 $l->{$i} = Transports::Model::Landscape->new(current_user => $system_user);
48 $l->{$i}->create(
49 name => 'Landscape ' . ( $i + 1 ),
50 );
51
52 Transports::Model::UserOnLandscape->new(current_user => $system_user)->create(
53 user_on => $u->{$i},
54 landscape => $l->{$i},
55 );
56
57 }
58
59 my $s;
60
61 foreach my $i ( 0 ... 5 ) {
62 $s->{$i} = Transports::Model::Source->new(current_user => $system_user);
63
64 $s->{$i}->create(
65 name => 'SRC/' . ($i + 1),
66 landscape => $l->{ ( $i % 3 ) },
67 );
68
69 }
70
71 my $d;
72
73 foreach my $i ( 0 ... 2 ) {
74 $d->{$i} = Transports::Model::Destination->new(current_user => $system_user);
75 $d->{$i}->create(
76 name => 'DEST/' . ($i + 1),
77 landscape => $l->{ ( $i % 3 ) },
78 );
79 }
80
81 my $tc1 = Transports::Model::TransportClass->new(current_user => $system_user);
82 $tc1->create(
83 name => 'Default',
84 );
85
86 my $tc2 = Transports::Model::TransportClass->new(current_user => $system_user);
87 $tc2->create(
88 name => 'Upgrade',
89 );
90
91 my @rc;
92 foreach my $s (
93 '0: Transport (export and import test) was successful',
94 '4: Warning messages were generated',
95 '8: Error messages were generated',
96 '12: Fatal error has occured',
97 ) {
98 my $rc = Transports::Model::ReturnCode->new(current_user => $system_user);
99 $rc->create( name => $s );
100 push @rc, $rc;
101 }
102
103 foreach my $i ( 1 ... 7 ) {
104 my $t = Transports::Model::Transport->new(current_user => $system_user);
105 my $rc = shift @rc;
106 $t->create(
107 class => $i % 4 == 0 ? $tc2 : $tc1,
108 source => $s->{ $i % 5 },
109 destination => $d->{ $i % 2 },
110 request_nr => $i,
111 client_dependent => $i % 3 == 0 ? 0 : 1,
112 created_by => $u->{ $i % 3 },
113 return_code => $rc,
114 );
115 }
116
117 }
118
119
120 1;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26