View | Details | Raw Unified | Return to bug 37389
Collapse All | Expand All

(-)a/Koha/ILL/Request.pm (+7 lines)
Lines 2247-2252 sub AUTOLOAD { Link Here
2247
        # Call the newly defined method
2247
        # Call the newly defined method
2248
        return $self->$name();
2248
        return $self->$name();
2249
    }
2249
    }
2250
    my $wt = 'SUPER::'.$name;
2251
    return $self->$wt;
2252
}
2253
2254
sub get_column(){
2255
    my ($self, $column_name) = @_;
2256
    return $self->_result->get_column($column_name);
2250
}
2257
}
2251
2258
2252
=head3 _type
2259
=head3 _type
(-)a/Koha/ILL/Requests.pm (-3 / +11 lines)
Lines 122-137 Returns a list of relation accessor names. Link Here
122
sub _build_extended_attributes_relations {
122
sub _build_extended_attributes_relations {
123
    my ($self) = @_;
123
    my ($self) = @_;
124
124
125
    my @distinct_types = $self->_resultset->search(
125
    my @distinct_types = Koha::ILL::Request::Attributes->_resultset->search(
126
        {},    # No specific conditions
126
        {},    # No specific conditions
127
        {
127
        {
128
            select   => ['type'],
128
            select   => ['type'],
129
            distinct => 1,
129
            group_by => ['type']
130
        }
130
        }
131
    )->get_column('type')->all;
131
    )->get_column('type')->all;
132
132
133
    for my $type (@distinct_types) {
133
    for my $type (@distinct_types) {
134
        $self->_resultset->has_many(
134
        my $test = $self->_resultset->_result_class->has_many(
135
            "extended_attributes_$type",
135
            "extended_attributes_$type",
136
            "Koha::Schema::Result::Illrequestattribute",
136
            "Koha::Schema::Result::Illrequestattribute",
137
            sub {
137
            sub {
Lines 144-149 sub _build_extended_attributes_relations { Link Here
144
            },
144
            },
145
            { cascade_copy => 0, cascade_delete => 0 },
145
            { cascade_copy => 0, cascade_delete => 0 },
146
        );
146
        );
147
148
        my $schema = $self->_resultset->result_source->schema;
149
150
        $schema->unregister_source('Koha::Schema::Result::Illrequest');
151
        $schema->register_class( 'Koha::Schema::Result::Illrequest', $test );
152
153
        # Testing to check if the dynamically added method has been aded. It's not been!!
154
        $self->find(1)->extended_attributes_article_title;
147
    }
155
    }
148
156
149
    return map { 'extended_attributes_'.$_ } @distinct_types;
157
    return map { 'extended_attributes_'.$_ } @distinct_types;
(-)a/Koha/REST/Plugin/Objects.pm (-1 / +2 lines)
Lines 291-297 controller, and thus shouldn't be called twice in it. Link Here
291
            $c->dbic_extended_attributes_join(
291
            $c->dbic_extended_attributes_join(
292
                {
292
                {
293
                    attributes      => $attributes,
293
                    attributes      => $attributes,
294
                    filtered_params => $filtered_params
294
                    filtered_params => $filtered_params,
295
                    result_set      => $result_set
295
                }
296
                }
296
            );
297
            );
297
298
(-)a/Koha/REST/Plugin/Query.pm (-7 / +19 lines)
Lines 173-188 Generates the DBIC join attribute based on extended_attributes query entries, an Link Here
173
173
174
            my $attributes      = $args->{attributes};
174
            my $attributes      = $args->{attributes};
175
            my $filtered_params = $args->{filtered_params};
175
            my $filtered_params = $args->{filtered_params};
176
            my $result_set      = $args->{result_set};
176
177
177
            if (   reftype( $attributes->{prefetch} )
178
            if (   reftype( $attributes->{prefetch} )
178
                && reftype( $attributes->{prefetch} ) eq 'ARRAY'
179
                && reftype( $attributes->{prefetch} ) eq 'ARRAY'
179
                && grep ( /extended_attributes/, @{ $attributes->{prefetch} } ) )
180
                && grep ( /extended_attributes/, @{ $attributes->{prefetch} } ) )
180
            {
181
            {
181
                my $ea_entries = $self->_get_extended_attributes_entries( $filtered_params, 0 );
182
                # my $ea_entries = $self->_get_extended_attributes_entries( $filtered_params, 0 );
182
                while ( $ea_entries > 0 ) {
183
                
183
                    push( @{ $attributes->{join} }, 'extended_attributes' );
184
                # Calling our private method to build the extended attributes relations
184
                    $ea_entries--;
185
                $result_set->_build_extended_attributes_relations();
186
187
                # Testing out the extended attributes join (hardcoded for now)
188
                my @test = qw( extended_attributes_article_title extended_attributes_issue extended_attributes_volume );
189
                foreach my $test (@test) {
190
                    push( @{ $attributes->{join} }, $test );
185
                }
191
                }
192
193
                # while ( $ea_entries > 0 ) {
194
                #     push( @{ $attributes->{join} }, 'extended_attributes_title' );
195
                #     push( @{ $attributes->{join} }, 'extended_attributes_author' );
196
                #     $ea_entries--;
197
                # }
198
186
            }
199
            }
187
        }
200
        }
188
    );
201
    );
Lines 630-640 sub _rewrite_related_metadata_query { Link Here
630
    $extended_attributes_entries++;
643
    $extended_attributes_entries++;
631
    if ( $extended_attributes_entries > 1 ) {
644
    if ( $extended_attributes_entries > 1 ) {
632
        my $old_key_value = delete $params->{ 'extended_attributes.' . $key };
645
        my $old_key_value = delete $params->{ 'extended_attributes.' . $key };
633
        my $new_key_value = "extended_attributes_$extended_attributes_entries" . "." . $key;
646
        my $new_key_value = "extended_attributes_$key" . "." . $key;
634
        $params->{$new_key_value} = $old_key_value;
647
        $params->{$new_key_value} = $old_key_value;
635
648
636
        my $old_value_value = delete $params->{ 'extended_attributes.' . $value };
649
        my $old_value_value = delete $params->{ 'extended_attributes.' . $value };
637
        my $new_value_value = "extended_attributes_$extended_attributes_entries" . "." . $value;
650
        my $new_value_value = "extended_attributes_$key" . "." . $value;
638
        $params->{$new_value_value} = $old_value_value;
651
        $params->{$new_value_value} = $old_value_value;
639
    }
652
    }
640
653
641
- 

Return to bug 37389