File Coverage

blib/lib/CaCORE/Common.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # ------------------------------------------------------------------------------------------
2             package CaCORE::Common::DatabaseCrossReference;
3            
4 1     1   32 use 5.005;
  1         4  
  1         44  
5             #use strict;
6 1     1   7 use warnings;
  1         3  
  1         41  
7            
8             require Exporter;
9            
10 1     1   3032 use XML::DOM;
  0            
  0            
11            
12             ## begin import objects ##
13             use CaCORE::ApplicationService;
14             ## end import objects ##
15            
16             $VERSION = '3.2';
17            
18             @ISA = qw(CaCORE::DomainObjectI);
19            
20             our %EXPORT_TAGS = ( 'all' => [ qw(
21            
22             ) ] );
23            
24             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25            
26             our @EXPORT = qw(
27             );
28            
29             # create an instance of the DatabaseCrossReference object
30             # returns: a DatabaseCrossReference object
31             sub new {
32             my $class = shift;
33             my $self = {};
34             bless($self, $class);
35             #print "new DatabaseCrossReference\n";
36             return $self;
37             }
38            
39             # Construct the specific section of the WSDL request corresponding
40             # to this DatabaseCrossReference intance
41             # returns: XML in string format
42             sub toWebserviceXML {
43             my $self = shift;
44             my $result = shift;
45             my $assigned_id = shift;
46             my $current_id = shift;
47             my $l = shift;
48             my %worklist = %$l;
49            
50             # prefix portion of the xml
51             $result .= "";
52             my $tmpstr = "";
53             $current_id ++;
54            
55             ## begin attribute to XML ##
56             # crossReferenceId;
57             if( defined( $self->getCrossReferenceId ) ) {
58             $tmpstr = "" . $self->getCrossReferenceId . "";
59             } else {
60             $tmpstr = "";
61             }
62             $result .= $tmpstr;
63              
64             # dataSourceName;
65             if( defined( $self->getDataSourceName ) ) {
66             $tmpstr = "" . $self->getDataSourceName . "";
67             } else {
68             $tmpstr = "";
69             }
70             $result .= $tmpstr;
71              
72             # id;
73             if( defined( $self->getId ) ) {
74             $tmpstr = "" . $self->getId . "";
75             } else {
76             $tmpstr = "";
77             }
78             $result .= $tmpstr;
79              
80             # sourceType;
81             if( defined( $self->getSourceType ) ) {
82             $tmpstr = "" . $self->getSourceType . "";
83             } else {
84             $tmpstr = "";
85             }
86             $result .= $tmpstr;
87              
88             # summary;
89             if( defined( $self->getSummary ) ) {
90             $tmpstr = "" . $self->getSummary . "";
91             } else {
92             $tmpstr = "";
93             }
94             $result .= $tmpstr;
95              
96             # type;
97             if( defined( $self->getType ) ) {
98             $tmpstr = "" . $self->getType . "";
99             } else {
100             $tmpstr = "";
101             }
102             $result .= $tmpstr;
103              
104             ## end attribute to XML ##
105            
106             ## begin association to XML ##
107             ## end association to XML ##
108            
109             # add trailing close tags
110             $result .= "";
111            
112             return ($result, $current_id, %worklist);
113             }
114            
115             # parse a given webservice response xml, construct a list of DatabaseCrossReference objects
116             # param: xml doc
117             # returns: list of DatabaseCrossReference objects
118             sub fromWebserviceXML {
119             my $self = shift;
120             my $parser = new XML::DOM::Parser;
121             my $docnode = $parser->parse(shift);
122             my $root = $docnode->getFirstChild->getFirstChild->getFirstChild->getFirstChild;
123            
124             return $self->fromWSXMLListNode($root);
125             }
126            
127             # parse a given xml node, construct a list of DatabaseCrossReference objects
128             # param: xml node
129             # returns: a list of DatabaseCrossReference objects
130             sub fromWSXMLListNode {
131             my $self = shift;
132             my $listNode = shift;
133             my @obj_list = ();
134            
135             # get all children for this node
136             for my $childrenNode ($listNode->getChildNodes) {
137             if ($childrenNode->getNodeType == XML::DOM::ELEMENT_NODE()) {
138             my $newobj = $self->fromWSXMLNode($childrenNode);
139             push @obj_list, $newobj;
140             }
141             }
142            
143             return @obj_list;
144             }
145            
146             # parse a given xml node, construct one DatabaseCrossReference object
147             # param: xml node
148             # returns: one DatabaseCrossReference object
149             sub fromWSXMLNode {
150             my $DatabaseCrossReferenceNode = $_[1];
151            
152             ## begin ELEMENT_NODE children ##
153             my $crossReferenceId;
154             my $dataSourceName;
155             my $id;
156             my $sourceType;
157             my $summary;
158             my $type;
159             ## end ELEMENT_NODE children ##
160            
161             # get all children for this node
162             for my $childrenNode ($DatabaseCrossReferenceNode->getChildNodes) {
163             if ($childrenNode->getNodeType == XML::DOM::ELEMENT_NODE()) {
164             if( ! defined($childrenNode->getFirstChild) ){ next; };
165             my $textNode = $childrenNode->getFirstChild;
166             ## begin iterate ELEMENT_NODE ##
167             if (0) {
168             # do nothing, just a place holder for "if" component
169             }
170             elsif ($childrenNode->getNodeName eq "crossReferenceId") {
171             $crossReferenceId=$textNode->getNodeValue;
172             }
173             elsif ($childrenNode->getNodeName eq "dataSourceName") {
174             $dataSourceName=$textNode->getNodeValue;
175             }
176             elsif ($childrenNode->getNodeName eq "id") {
177             $id=$textNode->getNodeValue;
178             }
179             elsif ($childrenNode->getNodeName eq "sourceType") {
180             $sourceType=$textNode->getNodeValue;
181             }
182             elsif ($childrenNode->getNodeName eq "summary") {
183             $summary=$textNode->getNodeValue;
184             }
185             elsif ($childrenNode->getNodeName eq "type") {
186             $type=$textNode->getNodeValue;
187             }
188             ## end iterate ELEMENT_NODE ##
189             }
190             }
191             my $newobj = new CaCORE::Common::DatabaseCrossReference;
192             ## begin set attr ##
193             $newobj->setCrossReferenceId($crossReferenceId);
194             $newobj->setDataSourceName($dataSourceName);
195             $newobj->setId($id);
196             $newobj->setSourceType($sourceType);
197             $newobj->setSummary($summary);
198             $newobj->setType($type);
199             ## end set attr ##
200            
201             return $newobj;
202             }
203            
204             ## begin getters and setters ##
205            
206             sub getCrossReferenceId {
207             my $self = shift;
208             return $self->{crossReferenceId};
209             }
210              
211             sub setCrossReferenceId {
212             my $self = shift;
213             $self->{crossReferenceId} = shift;
214             }
215              
216             sub getDataSourceName {
217             my $self = shift;
218             return $self->{dataSourceName};
219             }
220              
221             sub setDataSourceName {
222             my $self = shift;
223             $self->{dataSourceName} = shift;
224             }
225              
226             sub getId {
227             my $self = shift;
228             return $self->{id};
229             }
230              
231             sub setId {
232             my $self = shift;
233             $self->{id} = shift;
234             }
235              
236             sub getSourceType {
237             my $self = shift;
238             return $self->{sourceType};
239             }
240              
241             sub setSourceType {
242             my $self = shift;
243             $self->{sourceType} = shift;
244             }
245              
246             sub getSummary {
247             my $self = shift;
248             return $self->{summary};
249             }
250              
251             sub setSummary {
252             my $self = shift;
253             $self->{summary} = shift;
254             }
255              
256             sub getType {
257             my $self = shift;
258             return $self->{type};
259             }
260              
261             sub setType {
262             my $self = shift;
263             $self->{type} = shift;
264             }
265              
266             ## end getters and setters ##
267            
268             ## begin bean association methods ##
269            
270             sub getSNP {
271             my $self = shift;
272             my $appSvc = CaCORE::ApplicationService->instance();
273             my @results = $appSvc->queryObject("CaCORE::CaBIO::SNP", $self);
274             return $results[0];
275             }
276              
277             sub getGene {
278             my $self = shift;
279             my $appSvc = CaCORE::ApplicationService->instance();
280             my @results = $appSvc->queryObject("CaCORE::CaBIO::Gene", $self);
281             return $results[0];
282             }
283              
284             sub getNucleicAcidSequence {
285             my $self = shift;
286             my $appSvc = CaCORE::ApplicationService->instance();
287             my @results = $appSvc->queryObject("CaCORE::CaBIO::NucleicAcidSequence", $self);
288             return $results[0];
289             }
290              
291             ## end bean association methods ##
292            
293             1;
294             #end
295             # Below is module documentation for DatabaseCrossReference
296            
297             =pod
298            
299             =head1 DatabaseCrossReference
300            
301             CaCORE::Common::DatabaseCrossReference - Perl extension for DatabaseCrossReference.
302            
303             =head2 ABSTRACT
304            
305             The CaCORE::Common::DatabaseCrossReference is a Perl object representation of the
306             CaCORE DatabaseCrossReference object.
307            
308            
309             =head2 SYNOPSIS
310            
311             See L.
312            
313             =head2 DESCRIPTION
314            
315            
316            
317             =head2 ATTRIBUTES of DatabaseCrossReference
318            
319             The following are all the attributes of the DatabaseCrossReference object and their data types:
320            
321             =over 4
322            
323             =item crossReferenceId
324              
325             data type: C
326              
327             =item dataSourceName
328              
329             data type: C
330              
331             =item id
332              
333             data type: C
334              
335             =item sourceType
336              
337             data type: C
338              
339             =item summary
340              
341             data type: C
342              
343             =item type
344              
345             data type: C
346              
347            
348             =back
349            
350             Note: Although you can also use the corresponding setter methods to set the
351             attribute values, it is not recommended to do so unless you absolutely have
352             to change the object's attributes.
353            
354             =head2 ASSOCIATIONS of DatabaseCrossReference
355            
356             The following are all the objects that are associated with the DatabaseCrossReference:
357            
358             =over 4
359            
360             =item Collection of L:
361              
362             Many to one assoication, use C to get the associated SNP.
363              
364             =item Collection of L:
365              
366             Many to one assoication, use C to get the associated Gene.
367              
368             =item Collection of L:
369              
370             Many to one assoication, use C to get the associated NucleicAcidSequence.
371              
372            
373             =back
374            
375             =cut
376            
377            
378             =pod
379            
380             =head1 SUPPORT
381            
382             Please do not contact author directly. Send email to ncicb@pop.nci.nih.gov to request
383             support or report a bug.
384            
385             =head1 AUTHOR
386            
387             Shan Jiang
388            
389             =head1 COPYRIGHT AND LICENSE
390            
391             The CaCORE Software License, Version 1.0
392            
393             Copyright 2001-2005 SAIC. This software was developed in conjunction with the National Cancer Institute, and so to the extent government employees are co-authors, any rights in such works shall be subject to Title 17 of the United States Code, section 105. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
394            
395             =over 1
396            
397             =item 1
398            
399             Redistributions of source code must retain the above copyright notice, this list of conditions and the disclaimer of Article 5, below. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the disclaimer of Article 5 in the documentation and/or other materials provided with the distribution.
400            
401             =item 2
402            
403             The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by SAIC and the National Cancer Institute." If no such end-user documentation is to be included, this acknowledgment shall appear in the software itself, wherever such third-party acknowledgments normally appear.
404            
405             =item 3
406            
407             The names "The National Cancer Institute", "NCI" and "SAIC" must not be used to endorse or promote products derived from this software. This license does not authorize the licensee to use any trademarks owned by either NCI or SAIC.
408            
409             =item 4
410            
411             This license does not authorize or prohibit the incorporation of this software into any third party proprietary programs. Licensee is expressly made responsible for obtaining any permission required to incorporate this software into third party proprietary programs and for informing licensee's end-users of their obligation to secure any required permissions before incorporating this software into third party proprietary software programs.
412            
413             =item 5
414            
415             THIS SOFTWARE IS PROVIDED "AS IS," AND ANY EXPRESSED OR IMPLIED WARRANTIES, (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. IN NO EVENT SHALL THE NATIONAL CANCER INSTITUTE, SAIC, OR THEIR AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
416            
417             =back
418            
419             =cut
420            
421