cvsuser     05/10/12 07:03:22

  Added:       App-Repository/lib/App/ValueDomain RepositoryTableColumns.pm
                        RepositoryTables.pm
  Log:
  new
  
  Revision  Changes    Path
  1.1                  
p5ee/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm
  
  Index: RepositoryTableColumns.pm
  ===================================================================
  
  #############################################################################
  ## $Id: RepositoryTableColumns.pm,v 1.1 2005/10/12 14:03:22 spadkins Exp $
  #############################################################################
  
  package App::ValueDomain::RepositoryTableColumns;
  
  use App;
  use App::ValueDomain;
  @ISA = ( "App::ValueDomain" );
  
  use strict;
  
  =head1 NAME
  
  App::ValueDomain::RepositoryTableColumns - List of columns from a table in a 
repository
  
  =head1 SYNOPSIS
  
   ... tbd ...
  
  =head1 DESCRIPTION
  
  A RepositoryTableColumn ValueDomain represents a list of columns from a
  table in a repository
  
  =cut
  
  #############################################################################
  # CLASS
  #############################################################################
  
  =head1 Class: App::ValueDomain::RepositoryTableColumns
  
  A RepositoryTableColumn ValueDomain represents a list of columns from a
  table in a repository
  
  =cut
  
  #############################################################################
  # PUBLIC METHODS
  #############################################################################
  
  =head1 Public Methods:
  
  =cut
  
  #############################################################################
  # _load()
  #############################################################################
  
  =head2 _load()
  
  The _load() method is called to get the list of valid values in a data
  domain and the labels that should be used to represent these values to
  a user.
  
      * Signature: $self->_load()
      * Signature: $self->_load($values_string)
      * Param:     $values_string    string
      * Return:    void
      * Throws:    App::Exception
      * Since:     0.01
  
      Sample Usage: 
  
      $self->_load();
  
  =cut
  
  sub _load {
      &App::sub_entry if ($App::trace);
      my ($self, $values_string) = @_;
      my $context = $self->{context};
      my $rep = $context->repository($self->{repository});
      my $table = $self->{table} || die "No table specified in $self->{name} 
ValueDomain";
      my $values = $rep->get_column_names($table);
      my $labels = $rep->get_column_labels($table);
      $labels = { %$labels };
      if ($self->{sort}) {
          @$values = sort { $labels->{$a} cmp $labels->{$b} } @$values;
      }
      $self->{values} = $values;
      $self->{labels} = $labels;
  
      $self->{values} = [] if (!$self->{values});
      $self->{labels} = {} if (!$self->{labels});
      foreach my $value (@$values) {
          if (!defined $labels->{$value}) {
              $labels->{$value} = $value;
          }
          else {
              $labels->{$value} =~ s/<br>//g;
          }
      }
      &App::sub_exit() if ($App::trace);
  }
  
  =head1 ACKNOWLEDGEMENTS
  
   * Author:  Stephen Adkins <[EMAIL PROTECTED]>
   * License: This is free software. It is licensed under the same terms as 
Perl itself.
  
  =head1 SEE ALSO
  
  L<C<App::Context>|App::Context>,
  L<C<App::Service>|App::Service>
  
  =cut
  
  1;
  
  
  
  
  1.1                  
p5ee/App-Repository/lib/App/ValueDomain/RepositoryTables.pm
  
  Index: RepositoryTables.pm
  ===================================================================
  
  #############################################################################
  ## $Id: RepositoryTables.pm,v 1.1 2005/10/12 14:03:22 spadkins Exp $
  #############################################################################
  
  package App::ValueDomain::RepositoryTables;
  
  use App;
  use App::ValueDomain;
  @ISA = ( "App::ValueDomain" );
  
  use strict;
  
  =head1 NAME
  
  App::ValueDomain::RepositoryTables - List of tables in a repository
  
  =head1 SYNOPSIS
  
   ... tbd ...
  
  =head1 DESCRIPTION
  
  A RepositoryTables ValueDomain represents a list of tables from a
  repository
  
  =cut
  
  #############################################################################
  # CLASS
  #############################################################################
  
  =head1 Class: App::ValueDomain::RepositoryTables
  
  A RepositoryTables ValueDomain represents a list of tables from a
  repository
  
  =cut
  
  #############################################################################
  # PUBLIC METHODS
  #############################################################################
  
  =head1 Public Methods:
  
  =cut
  
  #############################################################################
  # _load()
  #############################################################################
  
  =head2 _load()
  
  The _load() method is called to get the list of valid values in a data
  domain and the labels that should be used to represent these values to
  a user.
  
      * Signature: $self->_load()
      * Signature: $self->_load($values_string)
      * Param:     $values_string    string
      * Return:    void
      * Throws:    App::Exception
      * Since:     0.01
  
      Sample Usage: 
  
      $self->_load();
  
  =cut
  
  sub _load {
      &App::sub_entry if ($App::trace);
      my ($self, $values_string) = @_;
      my $context = $self->{context};
      my $rep = $context->repository($self->{repository});
      my $values = $rep->get_table_names();
      my $labels = $rep->get_table_labels();
      $labels = { %$labels };
      if ($self->{sort}) {
          @$values = sort { $labels->{$a} cmp $labels->{$b} } @$values;
      }
      $self->{values} = $values;
      $self->{labels} = $labels;
  
      $self->{values} = [] if (!$self->{values});
      $self->{labels} = {} if (!$self->{labels});
      foreach my $value (@$values) {
          if (!defined $labels->{$value}) {
              $labels->{$value} = $value;
          }
      }
      &App::sub_exit() if ($App::trace);
  }
  
  =head1 ACKNOWLEDGEMENTS
  
   * Author:  Stephen Adkins <[EMAIL PROTECTED]>
   * License: This is free software. It is licensed under the same terms as 
Perl itself.
  
  =head1 SEE ALSO
  
  L<C<App::Context>|App::Context>,
  L<C<App::Service>|App::Service>
  
  =cut
  
  1;
  
  
  
  

Reply via email to