Changeset 42 for LATMOS-Accounts
- Timestamp:
- 04/25/09 09:04:34 (15 years ago)
- Location:
- LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r41 r42 146 146 my ($self, $otype, $id, %data) = @_; 147 147 my $pclass = $self->_load_obj_class($otype); 148 $pclass-> create($id, %data) or return;148 $pclass->_create($self, $id, %data) or return; 149 149 $self->get_object($otype, $id); 150 150 } … … 162 162 my %data; 163 163 foreach my $cfield (keys %cdata) { 164 my $field = $self-> base->get_field_name($self->type, $cfield) or next;164 my $field = $self->get_field_name($otype, $cfield) or next; 165 165 $data{$field} = $cdata{$cfield}; 166 166 } 167 keys %data or return 1; # TODO: return an error ?167 keys %data or return 0; # TODO: return an error ? 168 168 $self->create_object($otype, $id, %data); 169 169 } -
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r28 r42 26 26 List object supported by this module existing in base $base 27 27 28 =cut 29 30 sub list { 31 my ($class) = @_; 32 return; 33 } 28 Must be provide by object class 29 30 sub list { 31 my ($class) = @_; 32 } 33 34 =cut 34 35 35 36 =head2 new($base, $id) … … 64 65 } 65 66 67 =head2 _create($class, $base, $id, %data) 68 69 Must create a new object in database. 70 71 Is called if underling base does not override create_object 72 73 sub _create( 74 my ($class, $base, $id, %data) 75 } 76 77 =cut 78 66 79 =head2 type 67 80 … … 85 98 } 86 99 100 =head2 list_canonical_fields 101 102 Object shortcut to get the list of field supported by the object. 103 104 =cut 105 106 sub list_canonical_fields { 107 my ($self) = @_; 108 $self->base->list_canonical_fields($self->type); 109 } 110 87 111 =head2 _canonical_fields 88 112 … … 90 114 91 115 Notice this query will always come from the upstream data base, 92 this function is just a f icility to store data in the module, but the116 this function is just a facility to store data in the module, but the 93 117 underling database can reply themself. 94 118 119 Is call if underling base doesn't override list_canonical_fields() 120 95 121 See list_canonical_fields(). 96 122 97 =cut 98 99 sub _canonical_fields { 100 my ($self) = @_; 101 return; 102 } 123 sub _canonical_fields { 124 my ($self) = @_; 125 } 126 127 =cut 103 128 104 129 =head2 _get_fields_name($field) … … 106 131 Return the fields name for canonical field $field 107 132 108 =cut 109 110 sub _get_field_name { 111 my ($self, $field) = @_; 112 return; 113 } 133 sub _get_field_name { 134 my ($self, $field) = @_; 135 } 136 137 =cut 114 138 115 139 =head2 get_field($field) … … 117 141 Return the value for $field, must be provide by data base. 118 142 119 =cut 120 121 sub get_field { return } 143 sub get_field { 144 my ($self, $field) 145 } 146 147 =cut 122 148 123 149 =head2 get_c_fields($cfield) 124 150 125 Return the value for canonical field $cfield 151 Return the value for canonical field $cfield. 152 153 Call driver specific get_field_name() and get_field() 126 154 127 155 =cut … … 137 165 Set values for this object. %data is a list or peer field => values. 138 166 139 =cut 140 141 sub set_fields { 142 return; 143 } 144 145 =head2 set_ fields(%data)167 sub set_fields { 168 my ($self, %data) = @_; 169 } 170 171 =cut 172 173 =head2 set_c_fields(%data) 146 174 147 175 Set values for this object. %data is a list or peer … … 194 222 at your option, any later version of Perl 5 you may have available. 195 223 196 197 =cut 224 =cut
Note: See TracChangeset
for help on using the changeset viewer.