DB/Schema/Result/Collection.pm

filter: Statementstmt 100% 29 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 37 / 37 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« DB/Schema/Result/Charset.pm ↑ Summary DB/Schema/Result/CollectionItem.pm »
1 13 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Biblio::Zotero::DB::Schema::Result::Collection;
3 13 $Biblio::Zotero::DB::Schema::Result::Collection::VERSION = '0.004';
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
6  
7  
8 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 ▶use base 'DBIx::Class::Core';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 13 __PACKAGE__->table("collections");
15  
16  
17 13 __PACKAGE__->add_columns(
18 "collectionid",
19 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
20 "collectionname",
21 { data_type => "text", is_nullable => 0 },
22 "parentcollectionid",
23 {
24 data_type => "int",
25 default_value => \"null",
26 is_foreign_key => 1,
27 is_nullable => 1,
28 },
29 "dateadded",
30 {
31 data_type => "timestamp",
32 default_value => \"current_timestamp",
33 is_nullable => 0,
34 },
35 "datemodified",
36 {
37 data_type => "timestamp",
38 default_value => \"current_timestamp",
39 is_nullable => 0,
40 },
41 "clientdatemodified",
42 {
43 data_type => "timestamp",
44 default_value => \"current_timestamp",
45 is_nullable => 0,
46 },
47 "libraryid",
48 { data_type => "int", is_nullable => 1 },
49 "key",
50 { data_type => "text", is_nullable => 0 },
51 );
52  
53  
54 13 __PACKAGE__->set_primary_key("collectionid");
55  
56  
57 13 __PACKAGE__->add_unique_constraint("libraryid_key_unique", ["libraryid", "key"]);
58  
59  
60 13 __PACKAGE__->has_many(
61 "collection_items",
62 "Biblio::Zotero::DB::Schema::Result::CollectionItem",
63 { "foreign.collectionid" => "self.collectionid" },
64 { cascade_copy => 0, cascade_delete => 0 },
65 );
66  
67  
68 13 __PACKAGE__->has_many(
69 "collections",
70 "Biblio::Zotero::DB::Schema::Result::Collection",
71 { "foreign.parentcollectionid" => "self.collectionid" },
72 { cascade_copy => 0, cascade_delete => 0 },
73 );
74  
75  
76 13 __PACKAGE__->belongs_to(
77 "parentcollectionid",
78 "Biblio::Zotero::DB::Schema::Result::Collection",
79 { collectionid => "parentcollectionid" },
80 {
81 is_deferrable => 0,
82 join_type => "LEFT",
83 on_delete => "NO ACTION",
84 on_update => "NO ACTION",
85 },
86 );
87  
88  
89 # Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-07-02 23:02:38
90 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yKzZ7kQPHQsrMv2FSL8wrQ
91  
92 # NOTE: extended DBIC schema below
93  
94  
95  
96 3 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
97 3 my $self = shift;
98 3 return $self->collectionname;
99 }
100  
101 3 ▶sub items {
Subroutine items: called CC=1 SCAR=0.0
Pod documented
102 3 my $self = shift;
103 3 my $schema = $self->result_source->schema;
104 3 my $items = $self->collection_items
105 ->get_column('itemid')->as_query;
106 3 $schema->resultset('StoredItem')->search( { itemid => { -in => $items } });
107 }
108  
109  
110 13 __PACKAGE__->load_components("Tree::AdjacencyList");
111 13 __PACKAGE__->parent_column('parentcollectionid');
112  
113 13 1;
114  
115 __END__
« DB/Schema/Result/Charset.pm ↑ Summary DB/Schema/Result/CollectionItem.pm »