3 Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
4 Copyright [2016-2022] EMBL-European Bioinformatics Institute
6 Licensed under the Apache License,
Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
28 package Bio::EnsEMBL::Hive::Cacheable;
33 use Scalar::Util qw(weaken);
40 $self->{
'_hive_pipeline'} = shift @_;
41 weaken($self->{
'_hive_pipeline'});
43 return $self->{
'_hive_pipeline'};
49 my $rel_pipeline = shift @_;
51 return $self->hive_pipeline == $rel_pipeline;
55 sub count_local_and_remote_objects {
57 my $objects = shift @_;
59 my $this_pipeline = $self->hive_pipeline;
63 foreach my $object (@$objects) {
64 if($object->hive_pipeline == $this_pipeline) {
71 return ($local_count, $remote_count);
75 sub relative_display_name {
76 my ($self, $ref_pipeline) = @_; #
if 'reference' hive_pipeline is the same as
'my' hive_pipeline, a shorter display_name is generated
78 my $my_pipeline = $self->hive_pipeline;
79 my $my_dba = $my_pipeline && $my_pipeline->hive_dba;
81 if ($my_dba and !$self->is_local_to($ref_pipeline)) {
82 if (($my_dba->dbc->driver eq
'sqlite') and ($my_dba->dbc->dbname =~ /([^\/]*)$/)) {
83 return $1 .
'/' . $self->display_name;
85 return $my_dba->dbc->dbname .
'/' . $self->display_name;
88 return $self->display_name;
94 my ($self, $ref_pipeline) = @_; #
if 'reference' hive_pipeline is the same as
'my' hive_pipeline, a shorter url is generated
96 my $my_pipeline = $self->hive_pipeline;
97 my $my_dba = $my_pipeline && $my_pipeline->hive_dba;
98 my $url_hash = ($my_dba and !$self->is_local_to($ref_pipeline) ) ? $my_dba->dbc->to_url_hash : {};
100 $url_hash->{
'query_params'} = $self->url_query_params; # calling a specific method
for each class that supports URLs
102 my $object_type = ref($self);
103 $object_type=~s/^.+::
104 $url_hash->{
'query_params'}{
'object_type'} = $object_type;
112 return "$self"; # Default implementation
116 sub unikey { # to be redefined by individual
Cacheable classes