From a5ba22d29e683629d731fc0bfdfb72719e59a0b9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 25 Oct 2010 15:05:42 +0200 Subject: [PATCH] =?utf8?q?RDBO-Models=20f=C3=BCr=20die=20Klassen=20im=20au?= =?utf8?q?th-Schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/AuthGroup.pm | 32 +++++++++++++++++++++++++++ SL/DB/AuthGroupRight.pm | 16 ++++++++++++++ SL/DB/AuthUser.pm | 32 +++++++++++++++++++++++++++ SL/DB/AuthUserConfig.pm | 16 ++++++++++++++ SL/DB/AuthUserGroup.pm | 29 +++++++++++++++++++++++++ SL/DB/Helper/Mappings.pm | 5 +++++ SL/DB/Helpers/ALLAuth.pm | 36 +++++++++++++++++++++++++++++++ SL/DB/MetaSetup/AuthGroup.pm | 24 +++++++++++++++++++++ SL/DB/MetaSetup/AuthGroupRight.pm | 22 +++++++++++++++++++ SL/DB/MetaSetup/AuthUser.pm | 24 +++++++++++++++++++++ SL/DB/MetaSetup/AuthUserConfig.pm | 22 +++++++++++++++++++ SL/DB/MetaSetup/AuthUserGroup.pm | 21 ++++++++++++++++++ scripts/rose_auto_create_model.pl | 7 ++++++ 13 files changed, 286 insertions(+) create mode 100644 SL/DB/AuthGroup.pm create mode 100644 SL/DB/AuthGroupRight.pm create mode 100644 SL/DB/AuthUser.pm create mode 100644 SL/DB/AuthUserConfig.pm create mode 100644 SL/DB/AuthUserGroup.pm create mode 100644 SL/DB/Helpers/ALLAuth.pm create mode 100644 SL/DB/MetaSetup/AuthGroup.pm create mode 100644 SL/DB/MetaSetup/AuthGroupRight.pm create mode 100644 SL/DB/MetaSetup/AuthUser.pm create mode 100644 SL/DB/MetaSetup/AuthUserConfig.pm create mode 100644 SL/DB/MetaSetup/AuthUserGroup.pm diff --git a/SL/DB/AuthGroup.pm b/SL/DB/AuthGroup.pm new file mode 100644 index 000000000..8bd54506c --- /dev/null +++ b/SL/DB/AuthGroup.pm @@ -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 index 000000000..49e434434 --- /dev/null +++ b/SL/DB/AuthGroupRight.pm @@ -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 index 000000000..0d22be94f --- /dev/null +++ b/SL/DB/AuthUser.pm @@ -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 index 000000000..2cb8e6b96 --- /dev/null +++ b/SL/DB/AuthUserConfig.pm @@ -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 index 000000000..495cb66fc --- /dev/null +++ b/SL/DB/AuthUserGroup.pm @@ -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; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index 2b79bfe36..477190448 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -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 index 000000000..b74952ee9 --- /dev/null +++ b/SL/DB/Helpers/ALLAuth.pm @@ -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 and having everything loaded. This is +supposed to be used only in the Lx-Office console. Normal modules +should C only the modules they actually need. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut diff --git a/SL/DB/MetaSetup/AuthGroup.pm b/SL/DB/MetaSetup/AuthGroup.pm new file mode 100644 index 000000000..31d49153a --- /dev/null +++ b/SL/DB/MetaSetup/AuthGroup.pm @@ -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 index 000000000..0cf5d7211 --- /dev/null +++ b/SL/DB/MetaSetup/AuthGroupRight.pm @@ -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 index 000000000..04bc23ef5 --- /dev/null +++ b/SL/DB/MetaSetup/AuthUser.pm @@ -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 index 000000000..2d132eb6a --- /dev/null +++ b/SL/DB/MetaSetup/AuthUserConfig.pm @@ -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 index 000000000..f185014a9 --- /dev/null +++ b/SL/DB/MetaSetup/AuthUserGroup.pm @@ -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; +; diff --git a/scripts/rose_auto_create_model.pl b/scripts/rose_auto_create_model.pl index f222cfa97..8ef9f5fb0 100755 --- a/scripts/rose_auto_create_model.pl +++ b/scripts/rose_auto_create_model.pl @@ -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 = <meta->schema('$schema'); +CODE + my $definition = eval <meta->table('$table'); +$schema __PACKAGE__->meta->auto_initialize; __PACKAGE__->meta->perl_class_definition(indent => 2); # , braces => 'bsd' -- 2.20.1