File Coverage

blib/lib/Biblio/Zotero/DB/Schema/Result/Item.pm
Criterion Covered Total %
statement 18 21 85.7
branch n/a
condition n/a
subroutine 7 8 87.5
pod 0 4 0.0
total 25 33 75.7


line stmt bran cond sub pod time code
1 13     13   6358 use utf8;
  13         29  
  13         91  
2             package Biblio::Zotero::DB::Schema::Result::Item;
3             $Biblio::Zotero::DB::Schema::Result::Item::VERSION = '0.003';
4             # Created by DBIx::Class::Schema::Loader
5             # DO NOT MODIFY THE FIRST PART OF THIS FILE
6              
7              
8 13     13   702 use strict;
  13         25  
  13         379  
9 13     13   66 use warnings;
  13         23  
  13         404  
10              
11 13     13   110 use base 'DBIx::Class::Core';
  13         35  
  13         10275  
12              
13              
14             __PACKAGE__->table("items");
15              
16              
17             __PACKAGE__->add_columns(
18             "itemid",
19             { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
20             "itemtypeid",
21             { data_type => "int", is_nullable => 0 },
22             "dateadded",
23             {
24             data_type => "timestamp",
25             default_value => \"current_timestamp",
26             is_nullable => 0,
27             },
28             "datemodified",
29             {
30             data_type => "timestamp",
31             default_value => \"current_timestamp",
32             is_nullable => 0,
33             },
34             "clientdatemodified",
35             {
36             data_type => "timestamp",
37             default_value => \"current_timestamp",
38             is_nullable => 0,
39             },
40             "libraryid",
41             { data_type => "int", is_foreign_key => 1, is_nullable => 1 },
42             "key",
43             { data_type => "text", is_nullable => 0 },
44             );
45              
46              
47             __PACKAGE__->set_primary_key("itemid");
48              
49              
50             __PACKAGE__->add_unique_constraint("libraryid_key_unique", ["libraryid", "key"]);
51              
52              
53             __PACKAGE__->has_many(
54             "collection_items",
55             "Biblio::Zotero::DB::Schema::Result::CollectionItem",
56             { "foreign.itemid" => "self.itemid" },
57             { cascade_copy => 0, cascade_delete => 0 },
58             );
59              
60              
61             __PACKAGE__->might_have(
62             "fulltext_item",
63             "Biblio::Zotero::DB::Schema::Result::FulltextItem",
64             { "foreign.itemid" => "self.itemid" },
65             { cascade_copy => 0, cascade_delete => 0 },
66             );
67              
68              
69             __PACKAGE__->has_many(
70             "fulltext_item_words",
71             "Biblio::Zotero::DB::Schema::Result::FulltextItemWord",
72             { "foreign.itemid" => "self.itemid" },
73             { cascade_copy => 0, cascade_delete => 0 },
74             );
75              
76              
77             __PACKAGE__->might_have(
78             "item_attachments_itemid",
79             "Biblio::Zotero::DB::Schema::Result::ItemAttachment",
80             { "foreign.itemid" => "self.itemid" },
81             { cascade_copy => 0, cascade_delete => 0 },
82             );
83              
84              
85             __PACKAGE__->has_many(
86             "item_attachments_sourceitemids",
87             "Biblio::Zotero::DB::Schema::Result::ItemAttachment",
88             { "foreign.sourceitemid" => "self.itemid" },
89             { cascade_copy => 0, cascade_delete => 0 },
90             );
91              
92              
93             __PACKAGE__->has_many(
94             "item_creators",
95             "Biblio::Zotero::DB::Schema::Result::ItemCreator",
96             { "foreign.itemid" => "self.itemid" },
97             { cascade_copy => 0, cascade_delete => 0 },
98             );
99              
100              
101             __PACKAGE__->has_many(
102             "item_datas",
103             "Biblio::Zotero::DB::Schema::Result::ItemData",
104             { "foreign.itemid" => "self.itemid" },
105             { cascade_copy => 0, cascade_delete => 0 },
106             );
107              
108              
109             __PACKAGE__->might_have(
110             "item_notes_itemid",
111             "Biblio::Zotero::DB::Schema::Result::ItemNote",
112             { "foreign.itemid" => "self.itemid" },
113             { cascade_copy => 0, cascade_delete => 0 },
114             );
115              
116              
117             __PACKAGE__->has_many(
118             "item_notes_sourceitemids",
119             "Biblio::Zotero::DB::Schema::Result::ItemNote",
120             { "foreign.sourceitemid" => "self.itemid" },
121             { cascade_copy => 0, cascade_delete => 0 },
122             );
123              
124              
125             __PACKAGE__->has_many(
126             "item_see_also_itemids",
127             "Biblio::Zotero::DB::Schema::Result::ItemSeeAlso",
128             { "foreign.itemid" => "self.itemid" },
129             { cascade_copy => 0, cascade_delete => 0 },
130             );
131              
132              
133             __PACKAGE__->has_many(
134             "item_see_also_linkeditemids",
135             "Biblio::Zotero::DB::Schema::Result::ItemSeeAlso",
136             { "foreign.linkeditemid" => "self.itemid" },
137             { cascade_copy => 0, cascade_delete => 0 },
138             );
139              
140              
141             __PACKAGE__->has_many(
142             "item_tags",
143             "Biblio::Zotero::DB::Schema::Result::ItemTag",
144             { "foreign.itemid" => "self.itemid" },
145             { cascade_copy => 0, cascade_delete => 0 },
146             );
147              
148              
149             __PACKAGE__->belongs_to(
150             "libraryid",
151             "Biblio::Zotero::DB::Schema::Result::Library",
152             { libraryid => "libraryid" },
153             {
154             is_deferrable => 0,
155             join_type => "LEFT",
156             on_delete => "NO ACTION",
157             on_update => "NO ACTION",
158             },
159             );
160              
161              
162             __PACKAGE__->many_to_many("itemids", "item_see_also_linkeditemids", "itemid");
163              
164              
165             __PACKAGE__->many_to_many("linkeditemids", "item_see_also_linkeditemids", "linkeditemid");
166              
167              
168             __PACKAGE__->many_to_many("tagids", "item_tags", "tagid");
169              
170              
171             __PACKAGE__->many_to_many("wordids", "fulltext_item_words", "wordid");
172              
173              
174             # Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-07-02 23:02:38
175             # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OcWFl3GnRhMxSUTwxOnJCw
176              
177             # NOTE: extended DBIC schema below
178              
179             sub is_attachment {
180 7     7 0 41791 my $self = shift;
181 7         50 !! defined $self->item_attachments_itemid;
182             }
183              
184             sub is_source_item {
185 7     7 0 8489 my $self = shift;
186 7         53 !! $self->item_attachments_sourceitemids->count;
187             }
188              
189             # TODO: document
190             sub tag_names {
191 0     0 0 0 my ($self) = @_;
192 0         0 [map { $_->name } $self->tagids];
  0         0  
193             }
194              
195             # TODO: document
196             sub fields {
197 20     20 0 622352 my ($self) = @_;
198 20         166 $self->item_datas_rs->fields_for_itemid($self->itemid);
199             }
200              
201              
202             __PACKAGE__->has_many(
203             "stored_item_attachments_sourceitemids",
204             "Biblio::Zotero::DB::Schema::Result::StoredItemAttachment",
205             { "foreign.sourceitemid" => "self.itemid" },
206             { cascade_copy => 0, cascade_delete => 0 },
207             );
208              
209              
210             __PACKAGE__->has_many(
211             "trash_item_attachments_sourceitemids",
212             "Biblio::Zotero::DB::Schema::Result::TrashItemAttachment",
213             { "foreign.sourceitemid" => "self.itemid" },
214             { cascade_copy => 0, cascade_delete => 0 },
215             );
216              
217             1;
218              
219             __END__