|
Lines 26-40
use Koha::Serials;
Link Here
|
| 26 |
use Koha::Reports; |
26 |
use Koha::Reports; |
| 27 |
use C4::Context; |
27 |
use C4::Context; |
| 28 |
|
28 |
|
| 29 |
=head1 DESCRIPTION |
29 |
=head1 SharedContent |
|
|
30 |
|
| 31 |
Koha::SharedContent - Set of methods to quering Mana KB server |
| 30 |
|
32 |
|
| 31 |
Package for accessing shared content via Mana |
33 |
=head1 DESCRIPTION |
| 32 |
|
34 |
|
| 33 |
=head2 Package Functions |
35 |
Package for accessing shared content via Mana KB. Methods here are intended |
|
|
36 |
to build and process queries for requesting Mana KB server. |
| 34 |
|
37 |
|
| 35 |
=cut |
38 |
=cut |
| 36 |
|
39 |
|
| 37 |
=head3 process_request |
40 |
=head2 process_request |
|
|
41 |
|
| 42 |
Koha::SharedContent::process_request($request); |
| 43 |
|
| 44 |
Send a request to Mana KB server. URL is defined in koha-conf.xml in mana_config |
| 45 |
tag. $request parameter must be a HTTP::Request object. See build_request method. |
| 38 |
|
46 |
|
| 39 |
=cut |
47 |
=cut |
| 40 |
|
48 |
|
|
Lines 70-76
sub process_request {
Link Here
|
| 70 |
return $result ; |
78 |
return $result ; |
| 71 |
} |
79 |
} |
| 72 |
|
80 |
|
| 73 |
=head3 increment_entity_value |
81 |
=head2 increment_entity_value |
|
|
82 |
|
| 83 |
Koha::SharedContent::increment_entity_value($entity_type, $mana_entity_id, $field); |
| 84 |
|
| 85 |
Increment of 1 the field $field of a Mana entity. I.e, this is used to count the number |
| 86 |
of Koha instance using a specific entity. |
| 74 |
|
87 |
|
| 75 |
=cut |
88 |
=cut |
| 76 |
|
89 |
|
|
Lines 78-84
sub increment_entity_value {
Link Here
|
| 78 |
return process_request(build_request('increment', @_)); |
91 |
return process_request(build_request('increment', @_)); |
| 79 |
} |
92 |
} |
| 80 |
|
93 |
|
| 81 |
=head3 send_entity |
94 |
=head2 send_entity |
|
|
95 |
|
| 96 |
my $result = Koha::SharedContent::send_entity($language, $borrowernumber, $mana_entity_id, $entity_type); |
| 97 |
|
| 98 |
Share a Koha entity (i.e subscription or report) to Mana KB. |
| 82 |
|
99 |
|
| 83 |
=cut |
100 |
=cut |
| 84 |
|
101 |
|
|
Lines 99-105
sub send_entity {
Link Here
|
| 99 |
return $result; |
116 |
return $result; |
| 100 |
} |
117 |
} |
| 101 |
|
118 |
|
| 102 |
=head3 prepare_entity_data |
119 |
=head2 prepare_entity_data |
|
|
120 |
|
| 121 |
$data = prepare_entity_data($language, $borrowernumber, $mana_entity_id, $entity_type); |
| 122 |
|
| 123 |
Prepare Koha entity data to be sent to Mana KB. |
| 103 |
|
124 |
|
| 104 |
=cut |
125 |
=cut |
| 105 |
|
126 |
|
|
Lines 133-139
sub prepare_entity_data {
Link Here
|
| 133 |
return $ressource_mana_info; |
154 |
return $ressource_mana_info; |
| 134 |
} |
155 |
} |
| 135 |
|
156 |
|
| 136 |
=head3 get_entity_by_id |
157 |
=head2 get_entity_by_id |
|
|
158 |
|
| 159 |
my $entity = Koha::SharedContent::get_entity_by_id($entity_type, $mana_entity_id, [{usecomments => 1}]); |
| 160 |
|
| 161 |
Retrieve a Mana entity to be imported into Koha. Add {usecomments => 1} to tell Mana to |
| 162 |
embed all user reviews. |
| 137 |
|
163 |
|
| 138 |
=cut |
164 |
=cut |
| 139 |
|
165 |
|
|
Lines 141-147
sub get_entity_by_id {
Link Here
|
| 141 |
return process_request(build_request('getwithid', @_)); |
167 |
return process_request(build_request('getwithid', @_)); |
| 142 |
} |
168 |
} |
| 143 |
|
169 |
|
| 144 |
=head3 search_entities |
170 |
=head2 search_entities |
|
|
171 |
|
| 172 |
my $result = Koha::SharedContent::search_entities( $entity_type, $search_params ); |
| 173 |
my $entities = $result->{data}; |
| 174 |
|
| 175 |
Search entities on ManaKB. |
| 145 |
|
176 |
|
| 146 |
=cut |
177 |
=cut |
| 147 |
|
178 |
|
|
Lines 149-155
sub search_entities {
Link Here
|
| 149 |
return process_request(build_request('get', @_)); |
180 |
return process_request(build_request('get', @_)); |
| 150 |
} |
181 |
} |
| 151 |
|
182 |
|
| 152 |
=head3 build_request |
183 |
=head2 build_request |
|
|
184 |
|
| 185 |
$request = build_request($mana_method, [$param1, $param2, ...]); |
| 186 |
|
| 187 |
Create a HTTP::Request object to be passed to process_request. |
| 153 |
|
188 |
|
| 154 |
=cut |
189 |
=cut |
| 155 |
|
190 |
|
|
Lines 208-214
sub build_request {
Link Here
|
| 208 |
} |
243 |
} |
| 209 |
} |
244 |
} |
| 210 |
|
245 |
|
| 211 |
=head3 get_sharing_url |
246 |
=head2 get_sharing_url |
|
|
247 |
|
| 248 |
my $mana_url = get_sharing_url(); |
| 249 |
|
| 250 |
Get the Mana KB server URL set in koha config file. |
| 212 |
|
251 |
|
| 213 |
=cut |
252 |
=cut |
| 214 |
|
253 |
|
| 215 |
- |
|
|