« blib/lib/UR/Namespace/Command/Old/Redescribe.pm
↑ Summary
blib/lib/UR/Namespace/Command/Show/Schema.pm »
| 1 | package UR::Namespace::Command::Show::Properties; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use UR; | ||
| 5 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 6 | |||
| 7 | UR::Object::Type->define( | ||
| 8 | class_name => __PACKAGE__, | ||
| 9 | is => 'UR::Namespace::Command::RunsOnModulesInTree', | ||
| 10 | has => [ | ||
| 11 | classes_or_modules => { | ||
| 12 | is_optional => 0, | ||
| 13 | is_many => 1, | ||
| 14 | shell_args_position => 99, | ||
| 15 | doc => 'classes to describe by class name or module path', | ||
| 16 | }, | ||
| 17 | ], | ||
| 18 | doc => 'show class properties, relationships, meta-data', | ||
| 19 | ); | ||
| 20 | |||
| 21 | sub sub_command_sort_position { 3 } | ||
| 22 | |||
| 23 | sub help_synopsis { | ||
| 24 | return <<EOS | ||
| 25 | ur show properties UR::Object | ||
| 26 | |||
| 27 | ur show properties Acme::Order Acme::Product Acme::Order::LineItem | ||
| 28 | |||
| 29 | EOS | ||
| 30 | } | ||
| 31 | |||
| 32 | sub for_each_class_object { | ||
| 33 | my $self = shift; | ||
| 34 | my $class_meta = shift; | ||
| 35 | |||
| 36 | my $view = UR::Object::Type->create_view( | ||
| 37 | perspective => 'default', | ||
| 38 | toolkit => 'text', | ||
| 39 | aspects => [ | ||
| 40 | 'namespace', 'table_name', 'data_source_id', 'is_abstract', 'is_final', | ||
| 41 | 'is_singleton', 'is_transactional', 'schema_name', 'meta_class_name', | ||
| 42 | { | ||
| 43 | label => 'Inherits from', | ||
| 44 | name => 'ancestry_class_names', | ||
| 45 | }, | ||
| 46 | |||
| 47 | { | ||
| 48 | label => 'Properties', | ||
| 49 | name => 'properties', | ||
| 50 | subject_class_name => 'UR::Object::Property', | ||
| 51 | perspective => 'description line item', | ||
| 52 | toolkit => 'text', | ||
| 53 | aspects => ['is_id', 'property_name', 'column_name', 'data_type', 'is_optional' ], | ||
| 54 | }, | ||
| 55 | { | ||
| 56 | label => "References", | ||
| 57 | name => 'all_id_by_property_metas', | ||
| 58 | subject_class_name => 'UR::Object::Property', | ||
| 59 | perspective => 'reference description', | ||
| 60 | toolkit => 'text', | ||
| 61 | aspects => [], | ||
| 62 | }, | ||
| 63 | { | ||
| 64 | label => "Referents", | ||
| 65 | name => 'all_reverse_as_property_metas', | ||
| 66 | subject_class_name => 'UR::Object::Property', | ||
| 67 | perspective => 'reference description', | ||
| 68 | toolkit => 'text', | ||
| 69 | aspects => [], | ||
| 70 | }, | ||
| 71 | ], | ||
| 72 | ); | ||
| 73 | unless ($view) { | ||
| 74 | $self->error_message("Can't initialize view"); | ||
| 75 | return; | ||
| 76 | } | ||
| 77 | |||
| 78 | $view->subject($class_meta); | ||
| 79 | $view->show(); | ||
| 80 | } | ||
| 81 | |||
| 82 | 1; |