From 3568f2f8cb1f21031ee5255f054c0431544c5607 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 6 Jun 2013 12:36:34 +0200 Subject: [PATCH] RDBO: Setups der Auth*-Instanzen vereinheitlicht --- SL/DB/AuthClient.pm | 10 ++-------- SL/DB/AuthClientGroup.pm | 6 ------ SL/DB/AuthClientUser.pm | 6 ------ SL/DB/AuthGroup.pm | 7 +------ SL/DB/AuthGroupRight.pm | 7 ------- SL/DB/AuthUser.pm | 20 ++++++++++++++------ SL/DB/AuthUserConfig.pm | 7 ------- SL/DB/AuthUserGroup.pm | 20 -------------------- SL/DB/MetaSetup/AuthClient.pm | 1 + SL/DB/MetaSetup/AuthClientGroup.pm | 1 + SL/DB/MetaSetup/AuthClientUser.pm | 1 + SL/DB/MetaSetup/AuthGroup.pm | 1 + SL/DB/MetaSetup/AuthGroupRight.pm | 1 + SL/DB/MetaSetup/AuthUser.pm | 1 + SL/DB/MetaSetup/AuthUserConfig.pm | 1 + SL/DB/MetaSetup/AuthUserGroup.pm | 13 +++++++++++++ 16 files changed, 37 insertions(+), 66 deletions(-) diff --git a/SL/DB/AuthClient.pm b/SL/DB/AuthClient.pm index a37c93011..bf016a646 100644 --- a/SL/DB/AuthClient.pm +++ b/SL/DB/AuthClient.pm @@ -1,6 +1,3 @@ -# 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::AuthClient; use strict; @@ -8,19 +5,16 @@ use strict; use SL::DB::MetaSetup::AuthClient; use SL::DB::Manager::AuthClient; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->schema('auth'); - __PACKAGE__->meta->add_relationship( users => { type => 'many to many', - map_class => 'SL::DB::AuthUserGroup', + map_class => 'SL::DB::AuthClientUser', map_from => 'client', map_to => 'user', }, groups => { type => 'many to many', - map_class => 'SL::DB::AuthUserGroup', + map_class => 'SL::DB::AuthClientGroup', map_from => 'client', map_to => 'group', }, diff --git a/SL/DB/AuthClientGroup.pm b/SL/DB/AuthClientGroup.pm index 758841bbf..8d31fbf4c 100644 --- a/SL/DB/AuthClientGroup.pm +++ b/SL/DB/AuthClientGroup.pm @@ -1,15 +1,9 @@ -# 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::AuthClientGroup; use strict; use SL::DB::MetaSetup::AuthClientGroup; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->schema('auth'); - __PACKAGE__->meta->make_manager_class; 1; diff --git a/SL/DB/AuthClientUser.pm b/SL/DB/AuthClientUser.pm index b2063dc53..c01447e88 100644 --- a/SL/DB/AuthClientUser.pm +++ b/SL/DB/AuthClientUser.pm @@ -1,15 +1,9 @@ -# 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::AuthClientUser; use strict; use SL::DB::MetaSetup::AuthClientUser; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->schema('auth'); - __PACKAGE__->meta->make_manager_class; 1; diff --git a/SL/DB/AuthGroup.pm b/SL/DB/AuthGroup.pm index ce47bd32f..2bb168eaf 100644 --- a/SL/DB/AuthGroup.pm +++ b/SL/DB/AuthGroup.pm @@ -1,6 +1,3 @@ -# 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; @@ -9,8 +6,6 @@ use SL::DB::MetaSetup::AuthGroup; use SL::DB::Manager::AuthGroup; use SL::DB::AuthGroupRight; -__PACKAGE__->meta->schema('auth'); - __PACKAGE__->meta->add_relationship( users => { type => 'many to many', @@ -25,7 +20,7 @@ __PACKAGE__->meta->add_relationship( }, clients => { type => 'many to many', - map_class => 'SL::DB::AuthClient', + map_class => 'SL::DB::AuthClientGroup', map_from => 'group', map_to => 'client', }, diff --git a/SL/DB/AuthGroupRight.pm b/SL/DB/AuthGroupRight.pm index 49e434434..1ba9ae199 100644 --- a/SL/DB/AuthGroupRight.pm +++ b/SL/DB/AuthGroupRight.pm @@ -1,16 +1,9 @@ -# 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 index 41644eb1f..a11248ec6 100644 --- a/SL/DB/AuthUser.pm +++ b/SL/DB/AuthUser.pm @@ -1,6 +1,3 @@ -# 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; @@ -9,9 +6,9 @@ use List::Util qw(first); use SL::DB::MetaSetup::AuthUser; use SL::DB::Manager::AuthUser; +use SL::DB::AuthClient; use SL::DB::AuthUserGroup; - -__PACKAGE__->meta->schema('auth'); +use SL::DB::Helper::Util; __PACKAGE__->meta->add_relationship( groups => { @@ -27,7 +24,7 @@ __PACKAGE__->meta->add_relationship( }, clients => { type => 'many to many', - map_class => 'SL::DB::AuthClient', + map_class => 'SL::DB::AuthUserClient', map_from => 'user', map_to => 'client', }, @@ -35,6 +32,17 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->initialize; +sub validate { + my ($self) = @_; + + my @errors; + push @errors, $::locale->text('The login is missing.') if !$self->login; + push @errors, $::locale->text('The login is not unique.') if !SL::DB::Helper::Util::is_unique($self, 'login'); + push @errors, "chunky bacon"; + + return @errors; +} + sub get_config_value { my ($self, $key) = @_; diff --git a/SL/DB/AuthUserConfig.pm b/SL/DB/AuthUserConfig.pm index 2cb8e6b96..b52a1a1e7 100644 --- a/SL/DB/AuthUserConfig.pm +++ b/SL/DB/AuthUserConfig.pm @@ -1,16 +1,9 @@ -# 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 index 495cb66fc..be88c4e99 100644 --- a/SL/DB/AuthUserGroup.pm +++ b/SL/DB/AuthUserGroup.pm @@ -1,29 +1,9 @@ -# 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/MetaSetup/AuthClient.pm b/SL/DB/MetaSetup/AuthClient.pm index 1b0a81a54..b78050cf0 100644 --- a/SL/DB/MetaSetup/AuthClient.pm +++ b/SL/DB/MetaSetup/AuthClient.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'clients', + schema => 'auth', columns => [ id => { type => 'serial', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthClientGroup.pm b/SL/DB/MetaSetup/AuthClientGroup.pm index e9226394e..f4e2f8756 100644 --- a/SL/DB/MetaSetup/AuthClientGroup.pm +++ b/SL/DB/MetaSetup/AuthClientGroup.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'clients_groups', + schema => 'auth', columns => [ client_id => { type => 'integer', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthClientUser.pm b/SL/DB/MetaSetup/AuthClientUser.pm index b36577207..85d0ef953 100644 --- a/SL/DB/MetaSetup/AuthClientUser.pm +++ b/SL/DB/MetaSetup/AuthClientUser.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'clients_users', + schema => 'auth', columns => [ client_id => { type => 'integer', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthGroup.pm b/SL/DB/MetaSetup/AuthGroup.pm index 31d49153a..9e75aac33 100644 --- a/SL/DB/MetaSetup/AuthGroup.pm +++ b/SL/DB/MetaSetup/AuthGroup.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'group', + schema => 'auth', columns => [ id => { type => 'serial', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthGroupRight.pm b/SL/DB/MetaSetup/AuthGroupRight.pm index 0cf5d7211..677796631 100644 --- a/SL/DB/MetaSetup/AuthGroupRight.pm +++ b/SL/DB/MetaSetup/AuthGroupRight.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'group_rights', + schema => 'auth', columns => [ group_id => { type => 'integer', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthUser.pm b/SL/DB/MetaSetup/AuthUser.pm index 04bc23ef5..217519041 100644 --- a/SL/DB/MetaSetup/AuthUser.pm +++ b/SL/DB/MetaSetup/AuthUser.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'user', + schema => 'auth', columns => [ id => { type => 'serial', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthUserConfig.pm b/SL/DB/MetaSetup/AuthUserConfig.pm index 2d132eb6a..688998b57 100644 --- a/SL/DB/MetaSetup/AuthUserConfig.pm +++ b/SL/DB/MetaSetup/AuthUserConfig.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'user_config', + schema => 'auth', columns => [ user_id => { type => 'integer', not_null => 1 }, diff --git a/SL/DB/MetaSetup/AuthUserGroup.pm b/SL/DB/MetaSetup/AuthUserGroup.pm index f185014a9..86a0ed571 100644 --- a/SL/DB/MetaSetup/AuthUserGroup.pm +++ b/SL/DB/MetaSetup/AuthUserGroup.pm @@ -8,6 +8,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->setup( table => 'user_group', + schema => 'auth', columns => [ user_id => { type => 'integer', not_null => 1 }, @@ -15,6 +16,18 @@ __PACKAGE__->meta->setup( ], primary_key_columns => [ 'user_id', 'group_id' ], + + foreign_keys => [ + user => { + class => 'SL::DB::AuthUser', + key_columns => { user_id => 'id' }, + }, + + group => { + class => 'SL::DB::AuthGroup', + key_columns => { group_id => 'id' }, + }, + ], ); 1; -- 2.20.1