package ExampleSubClass; use ArsBaseClass; @ISA = 'ArsBaseClass'; #---------------------------------------------------------------- # the CLASS_DATA structure was generated semi-automatically using # "ars-gen-field-table". It has many porpoises: # 1. it maps my private field-keys to the official ones # (example: private = "status_confirmed", official = "Status Confirmed" # 2. it describes the fields as ARS knows them. This makes it # possible to perform a "sanity check" later as insurance that # the ARS data-structure hasn't been secretly changed. # 3. it determines whether fields will be retrieved during a query. # This is controlled, oddly enough, by setting "query => 1" to # retrieve. # # the keys to the hash are as follows: # # schema => 'the-name-of-the-schema', # query_field => 'the fieldname to be used for finding a single record', # priv_keys => { # "private-key" => { # real => "real-key", # id => ARS-field-id, # type => (char/enum/time/diary), # query => 0|1, # } # }, # # # this part is generated automatically # reverse_map => { # 'ARS-field-id' => 'private-key', # } # # if type is "enum", there are two additional hash-keys: # enum => { # "private-enum-val-1" => [ internal-position, "ARS-name" ], # "private-enum-val-2" => [ internal-position, "ARS-name" ], # "private-enum-val-n" => [ internal-position, "ARS-name" ], # } #---------------------------------------------------------------- my $CLASS_DATA = { schema => 'Example-Schema', query_field => 'domain_name', priv_keys => { 'create_date' => { real => 'Create-date', id => '3', type => 'time', query => 1, }, 'created_by' => { real => 'Created By', id => '4', type => 'char', query => 0, }, 'last_modified_by' => { real => 'Last-modified-by', id => '5', type => 'char', query => 0, }, 'modified_date' => { real => 'Modified-date', id => '6', type => 'time', query => 0, }, 'status' => { real => 'Status', id => '7', type => 'enum', query => 1, # 'Status' is of type enum, (special handing) enum => { 'reserved' => [ 0, 'Reserved (R)' ], 'mail_only' => [ 1, 'Mail Only (MX)' ], 'delegated' => [ 2, 'Delegated (I)' ], 'transfer' => [ 3, 'Transfer (KK)' ], 'released' => [ 4, 'Released' ], 'waiting_list' => [ 5, 'Waiting List' ], 'close_pending' => [ 6, 'Close Pending' ], }, }, 'connection_status_history' => { real => 'Connection Status-History', id => '15', type => 'char', query => 0, }, 'date_delegated' => { real => 'Date Delegated', id => '536870913', type => 'time', query => 1, }, 'ns_info' => { real => 'NS Info', id => '536870914', type => 'char', query => 0, }, 'status_confirmed' => { real => 'Status Confirmed', id => '536870915', type => 'enum', query => 0, # 'Status Confirmed' is of type enum, (special handing) enum => { 'yes' => [ 0, '?' ], }, }, 'monthly_charge' => { real => 'Monthly Charge', id => '536870916', type => 'enum', query => 1, # 'Monthly Charge' is of type enum, (special handing) enum => { 'yes' => [ 0, '?' ], }, }, 'notify_email' => { real => 'Notify Email', id => '536870918', type => 'char', query => 1, }, 'pending_since' => { real => 'Pending Since', id => '536870920', type => 'time', query => 1, }, 'domain_name' => { real => 'Domain Name', id => '536870923', type => 'char', query => 1, }, 'last_requested_email' => { real => 'Last Requested Email', id => '536870931', type => 'char', query => 1, }, 'company_name' => { real => 'Company Name', id => '536870950', type => 'char', query => 1, }, 'cust_id' => { real => 'Cust ID', id => '536870951', type => 'char', query => 1, }, 'log' => { real => 'Log', id => '536870953', type => 'diary', query => 0, }, 'notes' => { real => 'Notes', id => '536870954', type => 'char', query => 0, }, 'domain_provider' => { real => 'DomainProvider', id => '536870955', type => 'char', query => 0, }, 'change_in_progress' => { real => 'change_in_progress', id => '536871283', type => 'enum', query => 1, # 'change_in_progress' is of type enum, (special handing) enum => { 'true' => [ 0, 'True' ], 'false' => [ 1, 'False' ], }, }, 'type_of_change' => { real => 'type_of_change', id => '536871284', type => 'enum', query => 1, # 'type_of_change' is of type enum, (special handing) enum => { 'register' => [ 0, 'Register' ], 'update' => [ 1, 'Update' ], 'update_descr' => [ 2, 'Update-Descr' ], 'close' => [ 3, 'Close' ], 'kk' => [ 4, 'KK' ], }, }, 'change_initiated' => { real => 'change_initiated', id => '536871285', type => 'time', query => 1, }, 'date_of_last_kk_answer' => { real => 'date_of_last_kk_answer', id => '536871370', type => 'time', query => 1, }, 'last_kk_answer' => { real => 'last_kk_answer', id => '536871371', type => 'enum', query => 1, # 'last_kk_answer' is of type enum, (special handing) enum => { 'ack' => [ 0, 'ACK' ], 'nack' => [ 1, 'NACK' ], 'lateack' => [ 2, 'LATEACK' ], }, }, }, }; # initialization ArsBaseClass::init($CLASS_DATA); sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = $class->SUPER::new(@_); if (!defined($self)) { return undef; } bless($self, $class); $self; } sub _getClassData { $CLASS_DATA; } sub schemaChanged { return ArsBaseClass::schemaChanged($CLASS_DATA); } #==================================================================== # methods for retrieving records #==================================================================== #-------------------------------------------------------------------- # getRecordsByCustomerName() is called using the syntax: # # @list = ExampleSubClass::getRecordsByCustomerName('customer-name'); # # @list contains a list of objects of type ExampleSubClass. #-------------------------------------------------------------------- sub getRecordsByCustomerName { my ($cust_id) = @_; my @rids = ArsBaseClass::query($CLASS_DATA, cust_id => $cust_id); if (!@rids) { return (); } my @res; my $obj; foreach my $rid (@rids) { $obj = ExampleSubClass->new; if (!defined($obj->getRecordById($rid))) { die "getRecordsByCustomerName: record disappeared"; } push(@res, $obj); } @res; } 1;