added an accessor for db backend information
[cxgn-corelibs.git] / lib / CXGN / People / UserMapData.pm
blobaff82f47a85fcf06927a48f042bc4a3c798147bb
2 use strict;
4 package CXGN::People::UserMapData;
6 use CXGN::DB::Object;
7 use CXGN::DB::ModifiableI;
9 use base qw | CXGN::Class::DBI CXGN::DB::Object CXGN::DB::ModifiableI |;
11 BEGIN {
13 my %q = (
15 fetch =>
18 SELECT
19 marker_name, user_map_id, protocol, marker_id,
20 linkage_group, position, confidence, sp_person_id,
21 obsolete, modified_date, create_date
22 FROM
23 sgn_people.user_map_data
24 WHERE
25 user_map_data_id=?
26 AND obsolete='f'
29 update =>
32 UPDATE sgn_people.user_map_data SET
33 marker_name = ?,
34 user_map_id = ?,
35 protocol = ?,
36 marker_id = ?,
37 linkage_group =?,
38 position = ?,
39 confidence = ?,
40 sp_person_id = ?,
41 obsolete = ?,
42 modified_date = now()
43 WHERE
44 user_map_data_id = ?
47 insert =>
50 INSERT INTO sgn_people.user_map_data
51 (marker_name, user_map_id, protocol, marker_id,
52 linkage_group, position, confidence, sp_person_id,
53 modified_date, create_date, obsolete)
54 VALUES
55 (?, ?, ?, ?,
56 ?, ?, ?, ?,
57 now(), now(), 'f')
60 currval =>
62 " SELECT currval('sgn_people.user_map_user_map_id_seq') ",
64 delete =>
67 UPDATE
68 sgn_people.user_map_date
69 SET
70 obsolete ='f'
71 WHERE
72 user_map_data_id=?
78 while(my($k,$v) = each %q){
79 __PACKAGE__->set_sql($k,$v);
83 sub new {
84 my $class = shift;
85 my $map_id = shift;
86 my $self = CXGN::DB::Object->new();
87 bless $self, $class;
88 $self->set_user_map_id($map_id);
89 $self->fetch();
90 return $self;
93 sub fetch {
94 my $self =shift;
95 my $sth= $self->get_sql('fetch');
96 $sth->execute($self->get_user_map_data_id());
97 my ($marker_name, $user_map_id, $protocol, $marker_id, $linkage_group, $position, $confidence, $sp_person_id, $obsolete, $modified_date, $create_date) = $sth->fetchrow_array();
98 $self->set_marker_name($marker_name);
99 $self->set_user_map_id($user_map_id);
100 $self->set_protocol($protocol);
101 $self->set_marker_id($marker_id);
102 $self->set_linkage_group($linkage_group);
103 $self->set_position($position);
104 $self->set_confidence($confidence);
105 $self->set_sp_person_id($sp_person_id);
106 $self->set_obsolete($obsolete);
107 $self->set_modification_date($modified_date);
108 $self->set_create_date($create_date);
111 =head2 store
113 Usage:
114 Desc:
115 Ret:
116 Args:
117 Side Effects:
118 Example:
120 =cut
122 sub store {
123 my $self = shift;
124 if ($self->get_user_map_data_id()) {
126 my $sth = $self->get_sql('update');
127 $sth->execute(
128 $self->get_marker_name(),
129 $self->get_user_map_id(),
130 $self->get_protocol(),
131 $self->get_marker_id(),
132 $self->get_linkage_group(),
133 $self->get_position(),
134 $self->get_confidence(),
135 $self->get_sp_person_id(),
136 $self->get_obsolete(),
137 $self->get_user_map_data_id()
139 return $self->get_user_map_data_id();
141 else {
142 print STDERR "MARKER ID: ".$self->get_marker_id()."\n";
144 my $sth = $self->get_sql("insert");
145 $sth->execute(
146 $self->get_marker_name(),
147 $self->get_user_map_id(),
148 $self->get_protocol(),
149 $self->get_marker_id(),
150 $self->get_linkage_group(),
151 $self->get_position(),
152 $self->get_confidence(),
153 $self->get_sp_person_id(),
157 my $user_map_data_id = $self->get_sql("currval");
159 # my $dbh = $self->DBH();
160 # my ($user_map_data_id) = $dbh->get_currval("sgn_people.user_map_data_user_map_data_id_seq");
161 $self->set_user_map_data_id($user_map_data_id);
162 return $user_map_data_id;
166 =head2 get_user_map_data_id
168 Usage:
169 Desc:
170 Ret:
171 Args:
172 Side Effects:
173 Example:
175 =cut
177 sub get_user_map_data_id {
178 my $self=shift;
179 return $self->{user_map_data_id};
183 =head2 set_user_map_data_id
185 Usage:
186 Desc:
187 Ret:
188 Args:
189 Side Effects:
190 Example:
192 =cut
194 sub set_user_map_data_id {
195 my $self=shift;
196 $self->{user_map_data_id}=shift;
200 =head2 accessors set_user_map_id, get_user_map_id
202 Property:
203 Setter Args:
204 Getter Args:
205 Getter Ret:
206 Side Effects:
207 Description:
209 =cut
211 sub get_user_map_id {
212 my $self=shift;
213 return $self->{user_map_id};
216 sub set_user_map_id {
217 my $self=shift;
218 $self->{user_map_id}=shift;
221 =head2 accessors set_marker_name, get_marker_name
223 Property:
224 Setter Args:
225 Getter Args:
226 Getter Ret:
227 Side Effects:
228 Description:
230 =cut
232 sub get_marker_name {
233 my $self=shift;
234 return $self->{marker_name};
237 sub set_marker_name {
238 my $self=shift;
239 $self->{marker_name}=shift;
242 =head2 accessors set_marker_id, get_marker_id
244 Property:
245 Setter Args:
246 Getter Args:
247 Getter Ret:
248 Side Effects:
249 Description:
251 =cut
253 sub get_marker_id {
254 my $self=shift;
255 if (!exists($self->{marker_id}) || !($self->{marker_id})) {
256 $self->{marker_id}=undef;
258 return $self->{marker_id};
261 sub set_marker_id {
262 my $self=shift;
263 $self->{marker_id}=shift;
266 =head2 accessors set_linkage_group, get_linkage_group
268 Property:
269 Setter Args:
270 Getter Args:
271 Getter Ret:
272 Side Effects:
273 Description:
275 =cut
277 sub get_linkage_group {
278 my $self=shift;
279 return $self->{linkage_group};
282 sub set_linkage_group {
283 my $self=shift;
284 $self->{linkage_group}=shift;
287 =head2 accessors set_position, get_position
289 Property:
290 Setter Args:
291 Getter Args:
292 Getter Ret:
293 Side Effects:
294 Description:
296 =cut
298 sub get_position {
299 my $self=shift;
300 return $self->{position};
303 sub set_position {
304 my $self=shift;
305 $self->{position}=shift;
308 =head2 get_protocol
310 Usage:
311 Desc:
312 Ret:
313 Args:
314 Side Effects:
315 Example:
317 =cut
319 sub get_protocol {
320 my $self=shift;
321 return $self->{protocol};
325 =head2 set_protocol
327 Usage:
328 Desc:
329 Ret:
330 Args:
331 Side Effects:
332 Example:
334 =cut
336 sub set_protocol {
337 my $self=shift;
338 $self->{protocol}=shift;
342 =head2 get_confidence
344 Usage:
345 Desc:
346 Ret:
347 Args:
348 Side Effects:
349 Example:
351 =cut
353 sub get_confidence {
354 my $self=shift;
355 return $self->{confidence};
359 =head2 set_confidence
361 Usage:
362 Desc:
363 Ret:
364 Args:
365 Side Effects:
366 Example:
368 =cut
370 sub set_confidence {
371 my $self=shift;
372 $self->{confidence}=shift;
375 =head2 delete
377 Usage:
378 Desc: Deletes an entry in the user_map_data table. Note
379 that deleting entire maps is dealt with from the
380 UserMap object, not here.
381 Ret:
382 Args:
383 Side Effects:
384 Example:
386 =cut
388 sub delete {
389 my $self = shift;
390 my $sth = $self->get_sql('delete');
391 $sth->execute($self->get_user_map_data_id());