| 1 | package InterMine::Model::TestModel; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use File::Basename; | ||
| 7 | |||
| 8 | use InterMine::Model; | ||
| 9 | |||
| 10 | my $model_file = dirname(__FILE__) . '/testmodel_model.xml'; | ||
| 11 | |||
| 12 | my $instance = __PACKAGE__->new; | ||
| 13 | |||
| 14 | sub new { | ||
| 15 | return InterMine::Model->new(source => $model_file, origin => "TestModel"); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub instance { | ||
| 19 | return $instance; | ||
| 20 | } | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | =head1 NAME | ||
| 25 | |||
| 26 | InterMine::Model::TestModel - A model to make testing easy for other modules. | ||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | use InterMine::Model::TestModel; | ||
| 31 | |||
| 32 | # For a shared instance: | ||
| 33 | my $singleton = InterMine::Model::TestModel->instance; | ||
| 34 | |||
| 35 | # For a freshly minted model: | ||
| 36 | my $model = InterMine::Model::TestModel->new; | ||
| 37 | |||
| 38 | =head1 DESCRIPTION | ||
| 39 | |||
| 40 | This module produces a predefined version of an L<InterMine::Model> for | ||
| 41 | testing purposes. The model itself has 19 classes based around | ||
| 42 | a hierarchical company structure. | ||
| 43 | |||
| 44 | To view the model as an xml file, see: | ||
| 45 | L<http://trac.flymine.org/browser/trunk/intermine/objectstore/model/testmodel/testmodel_model.xml> | ||
| 46 | |||
| 47 | Useful classes in the model are | ||
| 48 | |||
| 49 | =over 4 | ||
| 50 | |||
| 51 | =item Employee (analogous to Gene in genomic models) | ||
| 52 | |||
| 53 | name (Str) | ||
| 54 | age (Int) | ||
| 55 | fullTime (Bool) | ||
| 56 | department (Department) | ||
| 57 | address (Address) | ||
| 58 | |||
| 59 | =item Department (analogous to Chromosome in genomic models) | ||
| 60 | |||
| 61 | employees (ArrayRef[Employee]) | ||
| 62 | company (Company) | ||
| 63 | manager (Manager) | ||
| 64 | name (Str) | ||
| 65 | address (Address) | ||
| 66 | |||
| 67 | =item Company ( | ||
| 68 | |||
| 69 | departments (ArrayRef[Department]) | ||
| 70 | name (Str) | ||
| 71 | vatNumber (Int) | ||
| 72 | contractors (ArrayRef[Contractor]) | ||
| 73 | secretarys (ArrayRef[Secretary]) | ||
| 74 | address (Address) | ||
| 75 | |||
| 76 | =back | ||
| 77 | |||
| 78 | =head1 CLASS METHODS | ||
| 79 | |||
| 80 | =head2 new | ||
| 81 | |||
| 82 | returns a new instance of the test model | ||
| 83 | |||
| 84 | =head2 instance | ||
| 85 | |||
| 86 | returns a shared instance of the testmodel | ||
| 87 | |||
| 88 | In most cases you will want to use C<instance>, as | ||
| 89 | the model is for the most part read-only. | ||
| 90 | |||
| 91 | You only need to use C<new> if you are testing the | ||
| 92 | object cache. | ||
| 93 | |||
| 94 | =head1 SEE ALSO | ||
| 95 | |||
| 96 | =over 4 | ||
| 97 | |||
| 98 | =item L<InterMine::Model> | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | =head1 AUTHOR | ||
| 103 | |||
| 104 | FlyMine C<< <support@flymine.org> >> | ||
| 105 | |||
| 106 | =head1 BUGS | ||
| 107 | |||
| 108 | Please report any bugs or feature requests to C<support@flymine.org>. | ||
| 109 | |||
| 110 | =head1 SUPPORT | ||
| 111 | |||
| 112 | You can find documentation for this module with the perldoc command. | ||
| 113 | |||
| 114 | perldoc InterMine::Model::TestModel | ||
| 115 | |||
| 116 | You can also look for information at: | ||
| 117 | |||
| 118 | =over 4 | ||
| 119 | |||
| 120 | =item * FlyMine | ||
| 121 | |||
| 122 | L<http://www.flymine.org> | ||
| 123 | |||
| 124 | =back | ||
| 125 | |||
| 126 | =head1 COPYRIGHT & LICENSE | ||
| 127 | |||
| 128 | Copyright 2006,2007,2008,2009, 2010, 2011 FlyMine, all rights reserved. | ||
| 129 | |||
| 130 | This program is free software; you can redistribute it and/or modify it | ||
| 131 | under the same terms as Perl itself. | ||
| 132 |