RDBO-Models für die Klassen im auth-Schema
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 25 Oct 2010 13:05:42 +0000 (15:05 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 13 Jan 2011 11:28:20 +0000 (12:28 +0100)
13 files changed:
SL/DB/AuthGroup.pm [new file with mode: 0644]
SL/DB/AuthGroupRight.pm [new file with mode: 0644]
SL/DB/AuthUser.pm [new file with mode: 0644]
SL/DB/AuthUserConfig.pm [new file with mode: 0644]
SL/DB/AuthUserGroup.pm [new file with mode: 0644]
SL/DB/Helper/Mappings.pm
SL/DB/Helpers/ALLAuth.pm [new file with mode: 0644]
SL/DB/MetaSetup/AuthGroup.pm [new file with mode: 0644]
SL/DB/MetaSetup/AuthGroupRight.pm [new file with mode: 0644]
SL/DB/MetaSetup/AuthUser.pm [new file with mode: 0644]
SL/DB/MetaSetup/AuthUserConfig.pm [new file with mode: 0644]
SL/DB/MetaSetup/AuthUserGroup.pm [new file with mode: 0644]
scripts/rose_auto_create_model.pl

diff --git a/SL/DB/AuthGroup.pm b/SL/DB/AuthGroup.pm
new file mode 100644 (file)
index 0000000..8bd5450
--- /dev/null
@@ -0,0 +1,32 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::AuthGroup;
+
+use strict;
+
+use SL::DB::MetaSetup::AuthGroup;
+use SL::DB::AuthGroupRight;
+
+# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
+__PACKAGE__->meta->make_manager_class;
+
+__PACKAGE__->meta->schema('auth');
+
+__PACKAGE__->meta->add_relationship(
+  users => {
+    type      => 'many to many',
+    map_class => 'SL::DB::AuthUserGroup',
+    map_from  => 'group',
+    map_to    => 'user',
+  },
+  rights => {
+    type       => 'one to many',
+    class      => 'SL::DB::AuthGroupRight',
+    column_map => { id => 'group_id' },
+  },
+);
+
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/SL/DB/AuthGroupRight.pm b/SL/DB/AuthGroupRight.pm
new file mode 100644 (file)
index 0000000..49e4344
--- /dev/null
@@ -0,0 +1,16 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::AuthGroupRight;
+
+use strict;
+
+use SL::DB::MetaSetup::AuthGroupRight;
+
+# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
+__PACKAGE__->meta->make_manager_class;
+
+__PACKAGE__->meta->schema('auth');
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/SL/DB/AuthUser.pm b/SL/DB/AuthUser.pm
new file mode 100644 (file)
index 0000000..0d22be9
--- /dev/null
@@ -0,0 +1,32 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::AuthUser;
+
+use strict;
+
+use SL::DB::MetaSetup::AuthUser;
+use SL::DB::AuthUserGroup;
+
+# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
+__PACKAGE__->meta->make_manager_class;
+
+__PACKAGE__->meta->schema('auth');
+
+__PACKAGE__->meta->add_relationship(
+  groups => {
+    type      => 'many to many',
+    map_class => 'SL::DB::AuthUserGroup',
+    map_from  => 'user',
+    map_to    => 'group',
+  },
+  configs => {
+    type       => 'one to many',
+    class      => 'SL::DB::AuthUserConfig',
+    column_map => { id => 'user_id' },
+  },
+);
+
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/SL/DB/AuthUserConfig.pm b/SL/DB/AuthUserConfig.pm
new file mode 100644 (file)
index 0000000..2cb8e6b
--- /dev/null
@@ -0,0 +1,16 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::AuthUserConfig;
+
+use strict;
+
+use SL::DB::MetaSetup::AuthUserConfig;
+
+# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
+__PACKAGE__->meta->make_manager_class;
+
+__PACKAGE__->meta->schema('auth');
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/SL/DB/AuthUserGroup.pm b/SL/DB/AuthUserGroup.pm
new file mode 100644 (file)
index 0000000..495cb66
--- /dev/null
@@ -0,0 +1,29 @@
+# This file has been auto-generated only because it didn't exist.
+# Feel free to modify it at will; it will not be overwritten automatically.
+
+package SL::DB::AuthUserGroup;
+
+use strict;
+
+use SL::DB::MetaSetup::AuthUserGroup;
+
+# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
+__PACKAGE__->meta->make_manager_class;
+
+__PACKAGE__->meta->schema('auth');
+
+__PACKAGE__->meta->add_foreign_keys(
+  user => {
+    class       => 'SL::DB::AuthUser',
+    key_columns => { user_id => 'id' },
+  },
+
+  group => {
+    class       => 'SL::DB::AuthGroup',
+    key_columns => { group_id => 'id' },
+  },
+);
+
+__PACKAGE__->meta->initialize;
+
+1;
index 2b79bfe..4771904 100644 (file)
@@ -26,6 +26,11 @@ my @lxoffice_blacklist = (@lxoffice_blacklist_permanent, @lxoffice_blacklist_tem
 my %lxoffice_package_names = (
   acc_trans                      => 'acc_transaction',
   audittrail                     => 'audit_trail',
+  auth_group                     => 'auth_groups',
+  auth_group_right               => 'auth_group_rights',
+  auth_user                      => 'auth_users',
+  auth_user_config               => 'auth_user_configs',
+  auth_user_group                => 'auth_user_groups',
   ar                             => 'invoice',
   ap                             => 'purchase_invoice',
   background_jobs                => 'background_job',
diff --git a/SL/DB/Helpers/ALLAuth.pm b/SL/DB/Helpers/ALLAuth.pm
new file mode 100644 (file)
index 0000000..b74952e
--- /dev/null
@@ -0,0 +1,36 @@
+package SL::DB::Helpers::ALLAuth;
+
+use strict;
+
+use SL::DB::AuthGroup;
+use SL::DB::AuthGroupRight;
+use SL::DB::AuthUserConfig;
+use SL::DB::AuthUser;
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+SL::DB::Helpers::ALLAuth: Dependency-only package for all SL::DB::Auth* modules
+
+=head1 SYNOPSIS
+
+  use SL::DB::Helpers::ALLAuth;
+
+=head1 DESCRIPTION
+
+This module depends on all modules in SL/DB/Auth*.pm for the
+convenience of being able to write a simple \C<use
+SL::DB::Helpers::ALLAuth> and having everything loaded. This is
+supposed to be used only in the Lx-Office console. Normal modules
+should C<use> only the modules they actually need.
+
+=head1 AUTHOR
+
+Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
+
+=cut
diff --git a/SL/DB/MetaSetup/AuthGroup.pm b/SL/DB/MetaSetup/AuthGroup.pm
new file mode 100644 (file)
index 0000000..31d4915
--- /dev/null
@@ -0,0 +1,24 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::AuthGroup;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'group',
+
+  columns => [
+    id          => { type => 'serial', not_null => 1 },
+    name        => { type => 'text', not_null => 1 },
+    description => { type => 'text' },
+  ],
+
+  primary_key_columns => [ 'id' ],
+
+  unique_key => [ 'name' ],
+);
+
+1;
+;
diff --git a/SL/DB/MetaSetup/AuthGroupRight.pm b/SL/DB/MetaSetup/AuthGroupRight.pm
new file mode 100644 (file)
index 0000000..0cf5d72
--- /dev/null
@@ -0,0 +1,22 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::AuthGroupRight;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'group_rights',
+
+  columns => [
+    group_id => { type => 'integer', not_null => 1 },
+    right    => { type => 'text', not_null => 1 },
+    granted  => { type => 'boolean', not_null => 1 },
+  ],
+
+  primary_key_columns => [ 'group_id', 'right' ],
+);
+
+1;
+;
diff --git a/SL/DB/MetaSetup/AuthUser.pm b/SL/DB/MetaSetup/AuthUser.pm
new file mode 100644 (file)
index 0000000..04bc23e
--- /dev/null
@@ -0,0 +1,24 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::AuthUser;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'user',
+
+  columns => [
+    id       => { type => 'serial', not_null => 1 },
+    login    => { type => 'text', not_null => 1 },
+    password => { type => 'text' },
+  ],
+
+  primary_key_columns => [ 'id' ],
+
+  unique_key => [ 'login' ],
+);
+
+1;
+;
diff --git a/SL/DB/MetaSetup/AuthUserConfig.pm b/SL/DB/MetaSetup/AuthUserConfig.pm
new file mode 100644 (file)
index 0000000..2d132eb
--- /dev/null
@@ -0,0 +1,22 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::AuthUserConfig;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'user_config',
+
+  columns => [
+    user_id   => { type => 'integer', not_null => 1 },
+    cfg_key   => { type => 'text', not_null => 1 },
+    cfg_value => { type => 'text' },
+  ],
+
+  primary_key_columns => [ 'user_id', 'cfg_key' ],
+);
+
+1;
+;
diff --git a/SL/DB/MetaSetup/AuthUserGroup.pm b/SL/DB/MetaSetup/AuthUserGroup.pm
new file mode 100644 (file)
index 0000000..f185014
--- /dev/null
@@ -0,0 +1,21 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::AuthUserGroup;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+  table   => 'user_group',
+
+  columns => [
+    user_id  => { type => 'integer', not_null => 1 },
+    group_id => { type => 'integer', not_null => 1 },
+  ],
+
+  primary_key_columns => [ 'user_id', 'group_id' ],
+);
+
+1;
+;
index f222cfa..8ef9f5f 100755 (executable)
@@ -71,17 +71,24 @@ sub setup {
 sub process_table {
   my @spec       =  split(/=/, shift, 2);
   my $table      =  $spec[0];
+  my $schema     = '';
+  ($schema, $table) = split(m/\./, $table) if $table =~ m/\./;
   my $package    =  ucfirst($spec[1] || $spec[0]);
   $package       =~ s/_+(.)/uc($1)/ge;
   my $meta_file  =  "${meta_path}/${package}.pm";
   my $file       =  "SL/DB/${package}.pm";
 
+  $schema        = <<CODE if $schema;
+    __PACKAGE__->meta->schema('$schema');
+CODE
+
   my $definition =  eval <<CODE;
     package SL::DB::AUTO::$package;
     use SL::DB::Object;
     use base qw(SL::DB::Object);
 
     __PACKAGE__->meta->table('$table');
+$schema
     __PACKAGE__->meta->auto_initialize;
 
     __PACKAGE__->meta->perl_class_definition(indent => 2); # , braces => 'bsd'