Author: spadkins
Date: Fri Oct 29 10:55:57 2010
New Revision: 14510

Modified:
   p5ee/trunk/App-Repository/lib/App/Authentication/Repository.pm
   p5ee/trunk/App-Repository/lib/App/Repository.pm
   p5ee/trunk/App-Repository/lib/App/RepositoryObject.pm
   p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm
   p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectDomain.pm
   p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectSet.pm
   p5ee/trunk/App-Repository/lib/App/SharedDatastore/Repository.pm
   p5ee/trunk/App-Repository/lib/App/ValueDomain/Repository.pm
   p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm
   p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTables.pm

Log:
added copyright statements. also added support for dash to do 'describe' 
commands

Modified: p5ee/trunk/App-Repository/lib/App/Authentication/Repository.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Authentication/Repository.pm      
(original)
+++ p5ee/trunk/App-Repository/lib/App/Authentication/Repository.pm      Fri Oct 
29 10:55:57 2010
@@ -114,6 +114,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/Repository.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository.pm     (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository.pm     Fri Oct 29 10:55:57 2010
@@ -4947,6 +4947,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/RepositoryObject.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/RepositoryObject.pm       (original)
+++ p5ee/trunk/App-Repository/lib/App/RepositoryObject.pm       Fri Oct 29 
10:55:57 2010
@@ -263,6 +263,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm        (original)
+++ p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm        Fri Oct 29 
10:55:57 2010
@@ -581,6 +581,53 @@
     &App::sub_exit() if ($App::trace);
 }
 
+################################################################################################################
+# MySQL
+################################################################################################################
+# lc_data_source: 
dbexpr|lower(hc.data_source)|name|lc_data_source|idx|13|label|lc_data_source|alias|lcds
+# brand_grp_cd: 
sqltype|12|quoted|1|name|brand_grp_cd|is_key|1|dbexpr|hc.brand_grp_cd|metadata|ARRAY(0x24f8b58)|idx|5|type|string|label|brand_grp_cd
+#    meta: 
[|mvh|hotel_chain|brand_grp_cd|12|VARCHAR|2||||1|||12|||6|YES||||||||||||||||||||varchar(2)||0]
+# mkt_chain_ind: 
sqltype|12|quoted|1|name|mkt_chain_ind|is_key|1|dbexpr|hc.mkt_chain_ind|metadata|ARRAY(0x24f90b0)|idx|7|type|string|label|mkt_chain_ind
+#    meta: 
[|mvh|hotel_chain|mkt_chain_ind|12|VARCHAR|1||||1|||12|||8|YES||||||||||||||||||||varchar(1)||0]
+# segment_cd: 
sqltype|12|quoted|1|name|segment_cd|is_key|1|dbexpr|hc.segment_cd|metadata|ARRAY(0x25150a0)|idx|6|type|string|label|segment_cd
+#    meta: 
[|mvh|hotel_chain|segment_cd|12|VARCHAR|12||||1|||12|||7|YES||||||||||||||||||||varchar(12)||0]
+# prov_cd: 
sqltype|12|quoted|1|name|prov_cd|is_key|1|dbexpr|hc.prov_cd|metadata|ARRAY(0x2515490)|idx|4|type|string|label|prov_cd
+#    meta: 
[|mvh|hotel_chain|prov_cd|12|VARCHAR|5||||1|||12|||5|YES||||||||||||||||||||varchar(5)||0]
+# data_source: 
sqltype|12|quoted|1|name|data_source|is_key|1|dbexpr|hc.data_source|metadata|ARRAY(0x2515880)|idx|3|type|string|label|data_source
+#    meta: 
[|mvh|hotel_chain|data_source|12|VARCHAR|5||||1|||12|||4|YES||||||||||||||||||||varchar(5)||0]
+# required_keywords: 
sqltype|12|quoted|1|name|required_keywords|is_key|1|dbexpr|hc.required_keywords|metadata|ARRAY(0x2515c70)|idx|9|type|string|label|required_keywords
+#    meta: 
[|mvh|hotel_chain|required_keywords|12|VARCHAR|255||||1|||12|||10|YES||||||||||||||||||||varchar(255)||0]
+# chain_id: 
sqltype|4|quoted|0|name|chain_id|is_key|1|dbexpr|hc.chain_id|metadata|ARRAY(0x2516848)|idx|0|type|integer|label|chain_id
+#    meta: 
[|mvh|hotel_chain|chain_id|4|INT|11|||10|0|||4|||1|NO|||||||||||||||||||1|int(11)||1]
+# chain_nm: 
sqltype|12|quoted|1|name|chain_nm|is_key|1|dbexpr|hc.chain_nm|metadata|ARRAY(0x2516c38)|idx|2|type|string|label|chain_nm
+#    meta: 
[|mvh|hotel_chain|chain_nm|12|VARCHAR|255||||1|||12|||3|YES||||||||||||||||||||varchar(255)||0]
+# rep_company_ind: 
sqltype|12|quoted|1|name|rep_company_ind|is_key|1|dbexpr|hc.rep_company_ind|metadata|ARRAY(0x2517028)|idx|8|type|string|label|rep_company_ind
+#    meta: 
[|mvh|hotel_chain|rep_company_ind|12|VARCHAR|1||||1|||12|||9|YES||||||||||||||||||||varchar(1)||0]
+# chain_cd: 
sqltype|1|quoted|1|name|chain_cd|is_key|1|dbexpr|hc.chain_cd|metadata|ARRAY(0x2517418)|idx|1|type|string|label|chain_cd
+#    meta: 
[|mvh|hotel_chain|chain_cd|1|CHAR|3||||0|||1|||2|NO||||||||||||||||||||char(3)||0]
+# modify_dttm: 
sqltype|11|quoted|1|name|modify_dttm|dbexpr|hc.modify_dttm|metadata|ARRAY(0x2518190)|idx|12|type|datetime|label|modify_dttm
+#    meta: 
[|mvh|hotel_chain|modify_dttm|11|TIMESTAMP|14||0||0||CURRENT_TIMESTAMP|9|-79||13|NO||||||||||||||||||||timestamp||0]
+# website_url: 
sqltype|12|quoted|1|name|website_url|is_key|1|dbexpr|hc.website_url|metadata|ARRAY(0x2518580)|idx|11|type|string|label|website_url
+#    meta: 
[|mvh|hotel_chain|website_url|12|VARCHAR|255||||1|||12|||12|YES||||||||||||||||||||varchar(255)||0]
+# illegal_keywords: 
sqltype|12|quoted|1|name|illegal_keywords|is_key|1|dbexpr|hc.illegal_keywords|metadata|ARRAY(0x2518970)|idx|10|type|string|label|illegal_keywords
+#    meta: 
[|mvh|hotel_chain|illegal_keywords|12|VARCHAR|255||||1|||12|||11|YES||||||||||||||||||||varchar(255)||0]
+
+################################################################################################################
+# Oracle
+################################################################################################################
+# create_dttm: 
sqltype|12|quoted|1|name|create_dttm|dbexpr_raw|t1.create_dttm|dbexpr|to_char(t1.create_dttm,'YYYY-MM-DD
 HH24:MI:SS')|dbexpr_update|to_date(%s,'YYYY-MM-DD 
HH24:MI:SS')|metadata|ARRAY(0x2c425d8)|idx|4|type|datetime|label|create_dttm
+#    meta: 
[|MVHCDP|HOTEL_BRAND_GRP|CREATE_DTTM|93|DATE|19|16|0||1||CURRENT_DATE 
|9|3||5|YES]
+# brand_grp_id: 
sqltype|3|quoted|0|name|brand_grp_id|is_key|1|dbexpr|t1.brand_grp_id|metadata|ARRAY(0x2aa4048)|idx|0|type|integer|label|brand_grp_id
+#    meta: 
[|MVHCDP|HOTEL_BRAND_GRP|BRAND_GRP_ID|3|NUMBER|5|7|0|10|0|||3|||1|NO]
+# brand_grp_cd: 
sqltype|12|quoted|1|name|brand_grp_cd|is_key|1|dbexpr|t1.brand_grp_cd|metadata|ARRAY(0x2c27290)|idx|1|type|string|label|brand_grp_cd
+#    meta: 
[|MVHCDP|HOTEL_BRAND_GRP|BRAND_GRP_CD|12|VARCHAR2|16|16|||0|||12|||2|NO]
+# user_id: 
sqltype|12|quoted|1|name|user_id|is_key|1|dbexpr|t1.user_id|metadata|ARRAY(0x2c427b8)|idx|5|type|string|label|user_id
+#    meta: [|MVHCDP|HOTEL_BRAND_GRP|USER_ID|12|VARCHAR2|32|32|||1|||12|||6|YES]
+# modify_dttm: 
sqltype|12|quoted|1|name|modify_dttm|dbexpr_raw|t1.modify_dttm|dbexpr|to_char(t1.modify_dttm,'YYYY-MM-DD
 HH24:MI:SS')|dbexpr_update|to_date(%s,'YYYY-MM-DD 
HH24:MI:SS')|metadata|ARRAY(0x2c423f8)|idx|3|type|datetime|label|modify_dttm
+#    meta: 
[|MVHCDP|HOTEL_BRAND_GRP|MODIFY_DTTM|93|DATE|19|16|0||0||CURRENT_DATE 
|9|3||4|NO]
+# brand_grp_desc: 
sqltype|12|quoted|1|name|brand_grp_desc|is_key|1|dbexpr|t1.brand_grp_desc|metadata|ARRAY(0x2c41c10)|idx|2|type|string|label|brand_grp_desc
+#    meta: 
[|MVHCDP|HOTEL_BRAND_GRP|BRAND_GRP_DESC|12|VARCHAR2|255|255|||0|||12|||3|NO]
+
 sub execute_describe_command {
     &App::sub_entry if ($App::trace);
     my ($self, $command_entry, $options) = @_;
@@ -588,14 +635,49 @@
         my $table     = lc($1);
         my $context   = $self->{context};
         my $db        = $context->repository($self->{repository});
-#print "REPOSITORY: name=[$db->{name}] dbh=[$db->{dbh}] rep=[$db]\n";
         my $table_def = $db->get_table_def($table);
-#print "TABLEDEF[$table]: ", join("|", %$table_def), "\n";
         my $column_defs = $table_def->{column};
         my ($column_def);
-        foreach my $column (keys %$column_defs) {
-            $column_def = $column_defs->{$column};
-            print "$column: ", join("|", %$column_def), "\n";
+        my $headings = [ "COLUMN", "TYPE", "NULLABLE" ];
+        my $columns  = [ "column", "type", "nullable" ];
+        my $table_columns = $table_def->{phys_columns};
+        if ($table_columns) {
+            my $rows     = [];
+            my ($metadata);
+            my ($schema, $table_name, $column_name, $type, $size, $precision, 
$nullable);
+            my $fh = $self->open_tempfile("describe");
+            # print $fh "REPOSITORY: name=[$db->{name}] dbh=[$db->{dbh}] 
rep=[$db]\n";
+            # print $fh "TABLEDEF[$table_name]: ", join("|", %$table_def), 
"\n";
+            foreach my $column (@$table_columns) {
+                $column_def = $column_defs->{$column};
+                # print $fh "$column: ", join("|", %$column_def), "\n" if 
($column_def);
+                # print $fh "   meta: [", join("|", 
@{$column_def->{metadata}}), "]\n" if ($column_def->{metadata});
+                $metadata = $column_def->{metadata};
+                next if (!$metadata);
+                ($schema, $table_name, $column_name, $type, $size, $precision, 
$nullable) = @{$metadata}[(1,2,3,5,6,7,17)];
+                if ($type =~ /(INT|CHAR)/i && $size) {
+                    $type = "$type($size)";
+                }
+                $nullable = ($nullable && $nullable eq "NO") ? "NOT NULL" : 
"NULL";
+                push(@$rows, [ $column_name, $type, $nullable ]);
+            }
+            $self->print_table($fh, $rows, $columns, [], { compact => 
$options->{compact}, headings => $headings, silent => $options->{silent} });
+            print $fh "\n";
+            my $primary_key    = $table_def->{primary_key};
+            my $alternate_keys = $table_def->{alternate_key};
+            if ($primary_key) {
+                print $fh "PRIMARY KEY\n";
+                print $fh "   ", join(", ", @$primary_key), "\n";
+                print $fh "\n";
+            }
+            if ($alternate_keys && $#$alternate_keys > -1) {
+                print $fh "ALTERNATE KEYS\n";
+                foreach my $alternate_key (@$alternate_keys) {
+                    print $fh "   ", join(", ", @$alternate_key), "\n";
+                }
+                print $fh "\n";
+            }
+            system("less -Sin $self->{describe}");
         }
     }
     else {
@@ -624,6 +706,7 @@
         $fh = \*App::RepositoryShell::FILE;
     }
     else {
+        close($self->{$file_use}) if (ref($self->{$file_use}));
         my $tempdir = $self->{tempdir};
         ($fh, $filename) = tempfile("${file_use}-XXXXXX", DIR => $tempdir, 
SUFFIX => ".txt", UNLINK => 1);
         $self->{$file_use} = $filename;
@@ -849,6 +932,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: 
p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectDomain.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectDomain.pm   
(original)
+++ p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectDomain.pm   
Fri Oct 29 10:55:57 2010
@@ -174,6 +174,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectSet.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectSet.pm      
(original)
+++ p5ee/trunk/App-Repository/lib/App/SessionObject/RepositoryObjectSet.pm      
Fri Oct 29 10:55:57 2010
@@ -567,6 +567,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/SharedDatastore/Repository.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/SharedDatastore/Repository.pm     
(original)
+++ p5ee/trunk/App-Repository/lib/App/SharedDatastore/Repository.pm     Fri Oct 
29 10:55:57 2010
@@ -242,6 +242,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/ValueDomain/Repository.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/ValueDomain/Repository.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/ValueDomain/Repository.pm Fri Oct 29 
10:55:57 2010
@@ -258,6 +258,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: 
p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm     
(original)
+++ p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTableColumns.pm     
Fri Oct 29 10:55:57 2010
@@ -162,6 +162,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Modified: p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTables.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTables.pm   
(original)
+++ p5ee/trunk/App-Repository/lib/App/ValueDomain/RepositoryTables.pm   Fri Oct 
29 10:55:57 2010
@@ -95,6 +95,7 @@
 
 =head1 ACKNOWLEDGEMENTS
 
+ * (c) 2010 Stephen Adkins
  * Author:  Stephen Adkins <[email protected]>
  * License: This is free software. It is licensed under the same terms as Perl 
itself.
 

Reply via email to