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

(-)a/C4/AuthoritiesMarc.pm (-69 / +67 lines)
Lines 991-998 sub BuildSummary { Link Here
991
        use C4::Heading::MARC21;
991
        use C4::Heading::MARC21;
992
        my $handler = C4::Heading::MARC21->new();
992
        my $handler = C4::Heading::MARC21->new();
993
        my $subfields_to_report;
993
        my $subfields_to_report;
994
        my $subfields_to_subdivision="";
994
        my $subfields_to_subdivision = "";
995
        my $delimiter = C4::Context->preference('AuthoritySeparator');
995
        my $delimiter                = C4::Context->preference('AuthoritySeparator');
996
996
997
        foreach my $field ($record->field('1..')) {
997
        foreach my $field ($record->field('1..')) {
998
            my $tag = $field->tag();
998
            my $tag = $field->tag();
Lines 1071-1140 sub BuildSummary { Link Here
1071
            push @notes, { note => $field->as_string(), field => $field->tag() };
1071
            push @notes, { note => $field->as_string(), field => $field->tag() };
1072
        }
1072
        }
1073
1073
1074
        foreach my $field ($record->field('7..'))
1074
     foreach my $field ( $record->field('7..') ) {
1075
        {
1075
        my $tag = $field->tag();
1076
            my $tag = $field->tag();
1076
1077
1077
        if ( $tag eq '700' ) {
1078
            if ($tag eq '700') {
1078
            $subfields_to_report      = 'abcdefghjklmnopqrst';
1079
                $subfields_to_report = 'abcdefghjklmnopqrst';
1079
            $subfields_to_subdivision = 'vxyz';
1080
                $subfields_to_subdivision='vxyz';
1080
        } elsif ( $tag eq '710' ) {
1081
            } elsif ($tag eq '710') {
1081
            $subfields_to_report      = 'abcdefghklmnoprst';
1082
                $subfields_to_report = 'abcdefghklmnoprst';
1082
            $subfields_to_subdivision = 'vxyz';
1083
                $subfields_to_subdivision='vxyz';
1083
        } elsif ( $tag eq '711' ) {
1084
            } elsif ($tag eq '711') {
1084
            $subfields_to_report      = 'acdefghklnpqst';
1085
                $subfields_to_report = 'acdefghklnpqst';
1085
            $subfields_to_subdivision = 'vxyz';
1086
                $subfields_to_subdivision='vxyz';
1086
        } elsif ( $tag eq '730' ) {
1087
            } elsif ($tag eq '730') {
1087
            $subfields_to_report      = 'adfghklmnoprst';
1088
                $subfields_to_report = 'adfghklmnoprst';
1088
            $subfields_to_subdivision = 'vxyz';
1089
                $subfields_to_subdivision='vxyz';
1089
        } elsif ( $tag eq '748' ) {
1090
            } elsif ($tag eq '748') {
1090
            $subfields_to_report      = 'ab';
1091
                $subfields_to_report = 'ab';
1091
            $subfields_to_subdivision = 'vxyz';
1092
                $subfields_to_subdivision='vxyz';
1092
        } elsif ( $tag eq '750' ) {
1093
            } elsif ($tag eq '750') {
1093
            $subfields_to_report      = 'ab';
1094
                $subfields_to_report = 'ab';
1094
            $subfields_to_subdivision = 'vxyz';
1095
                $subfields_to_subdivision='vxyz';
1095
        } elsif ( $tag eq '751' ) {
1096
            } elsif ($tag eq '751') {
1096
            $subfields_to_report      = 'a';
1097
                $subfields_to_report = 'a';
1097
            $subfields_to_subdivision = 'vxyz';
1098
                $subfields_to_subdivision='vxyz';
1098
        } elsif ( $tag eq '755' ) {
1099
            } elsif ($tag eq '755') {
1099
            $subfields_to_report      = 'abvxyz';
1100
                $subfields_to_report = 'abvxyz';
1100
            $subfields_to_subdivision = 'vxyz';
1101
                $subfields_to_subdivision='vxyz';
1101
        } elsif ( $tag eq '780' ) {
1102
            } elsif ($tag eq '780') {
1102
            $subfields_to_report = 'vxyz';
1103
                $subfields_to_report = 'vxyz';
1103
            $delimiter           = " ";
1104
                $delimiter=" ";
1104
        } elsif ( $tag eq '781' ) {
1105
            } elsif ($tag eq '781') {
1105
            $subfields_to_report = 'vxyz';
1106
                $subfields_to_report = 'vxyz';
1106
            $delimiter           = " ";
1107
                $delimiter=" ";
1107
        } elsif ( $tag eq '782' ) {
1108
            } elsif ($tag eq '782') {
1108
            $subfields_to_report = 'vxyz';
1109
                $subfields_to_report = 'vxyz';
1109
            $delimiter           = " ";
1110
                $delimiter=" ";
1110
        } elsif ( $tag eq '785' ) {
1111
            } elsif ($tag eq '785') {
1111
            $subfields_to_report = 'vxyz';
1112
                $subfields_to_report = 'vxyz';
1112
            $delimiter           = " ";
1113
                $delimiter=" ";
1113
        }
1114
            }
1115
1114
1116
            my $heading = $field->as_string($subfields_to_report);
1115
        my $heading = $field->as_string($subfields_to_report);
1117
1116
1118
            my $subheading = $field->as_string($subfields_to_subdivision,$delimiter);
1117
        my $subheading = $field->as_string( $subfields_to_subdivision, $delimiter );
1119
            if(length $subheading > 0 )
1118
        if ( length $subheading > 0 ) {
1120
            {
1119
            $heading .= $delimiter . $subheading;
1121
                $heading.=$delimiter.$subheading;
1120
        }
1122
            }
1123
1121
1124
            if ($subfields_to_report) {
1122
        if ($subfields_to_report) {
1125
                push @equalterm, {
1123
            push @equalterm, {
1126
                    heading => $heading,
1124
                heading => $heading,
1127
                    hemain  => ( $field->subfield( substr($subfields_to_report, 0, 1) ) // undef ),
1125
                hemain  => ( $field->subfield( substr( $subfields_to_report, 0, 1 ) ) // undef ),
1128
                    field   => $tag,
1126
                field   => $tag,
1129
                };
1127
            };
1130
            } else {
1128
        } else {
1131
                push @equalterm, {
1129
            push @equalterm, {
1132
                    heading => $field->as_string(),
1130
                heading => $field->as_string(),
1133
                    hemain  => ( $field->subfield( 'a' ) // undef ),
1131
                hemain  => ( $field->subfield('a') // undef ),
1134
                    field   => $tag,
1132
                field   => $tag,
1135
                };
1133
            };
1136
            }
1137
        }
1134
        }
1135
    }
1138
1136
1139
        foreach my $field ($record->field('880')) {
1137
        foreach my $field ($record->field('880')) {
1140
            my $linkage = $field->subfield('6');
1138
            my $linkage = $field->subfield('6');
Lines 1156-1169 sub BuildSummary { Link Here
1156
            push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage };
1154
            push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage };
1157
        }
1155
        }
1158
    }
1156
    }
1159
    $summary{mainentry} = $authorized[0]->{heading};
1157
    $summary{mainentry}     = $authorized[0]->{heading};
1160
    $summary{mainmainentry} = $authorized[0]->{hemain};
1158
    $summary{mainmainentry} = $authorized[0]->{hemain};
1161
    $summary{authorized} = \@authorized;
1159
    $summary{authorized}    = \@authorized;
1162
    $summary{notes} = \@notes;
1160
    $summary{notes}         = \@notes;
1163
    $summary{seefrom} = \@seefrom;
1161
    $summary{seefrom}       = \@seefrom;
1164
    $summary{seealso} = \@seealso;
1162
    $summary{seealso}       = \@seealso;
1165
    $summary{otherscript} = \@otherscript;
1163
    $summary{otherscript}   = \@otherscript;
1166
    $summary{equalterm} = \@equalterm;
1164
    $summary{equalterm}     = \@equalterm;
1167
    return \%summary;
1165
    return \%summary;
1168
}
1166
}
1169
1167
(-)a/t/db_dependent/AuthoritiesMarc.t (-40 / +39 lines)
Lines 130-161 $dbh->do(q{ Link Here
130
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
130
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
131
my $expected_marc21_summary = {
131
my $expected_marc21_summary = {
132
    'authorized' => [
132
    'authorized' => [
133
                      {
133
        {
134
                        'field' => '151',
134
            'field'   => '151',
135
                        'heading' => 'New York (State)',
135
            'heading' => 'New York (State)',
136
                        'hemain' => 'New York (State)'
136
            'hemain'  => 'New York (State)'
137
                      }
137
        }
138
                    ],
138
    ],
139
    'authtypecode' => 'GEOGR_NAME',
139
    'authtypecode'  => 'GEOGR_NAME',
140
    'mainentry' => 'New York (State)',
140
    'mainentry'     => 'New York (State)',
141
    'mainmainentry' => 'New York (State)',
141
    'mainmainentry' => 'New York (State)',
142
    'notes' => [],
142
    'notes'         => [],
143
    'otherscript' => [],
143
    'otherscript'   => [],
144
    'seealso' => [
144
    'seealso'       => [
145
                   {
145
        {
146
                     'authid' => '1',
146
            'authid'  => '1',
147
                     'field' => '551',
147
            'field'   => '551',
148
                     'heading' => 'United States',
148
            'heading' => 'United States',
149
                     'hemain' => 'United States',
149
            'hemain'  => 'United States',
150
                     'search' => 'United States',
150
            'search'  => 'United States',
151
                     'type' => 'broader'
151
            'type'    => 'broader'
152
                   }
152
        }
153
                 ],
153
    ],
154
    'seefrom' => [],
154
    'seefrom'   => [],
155
    'label' => 'Geographic Name',
155
    'label'     => 'Geographic Name',
156
    'type' => 'Geographic Name',
156
    'type'      => 'Geographic Name',
157
    'equalterm' => []
157
    'equalterm' => []
158
};
158
};
159
159
is_deeply(
160
is_deeply(
160
    BuildSummary(C4::AuthoritiesMarc::GetAuthority(2), 2, 'GEOGR_NAME'),
161
    BuildSummary(C4::AuthoritiesMarc::GetAuthority(2), 2, 'GEOGR_NAME'),
161
    $expected_marc21_summary,
162
    $expected_marc21_summary,
Lines 183-205 $unimarc_name_auth->add_fields( Link Here
183
);
184
);
184
my $expected_unimarc_name_summary = {
185
my $expected_unimarc_name_summary = {
185
    'authorized' => [
186
    'authorized' => [
186
                      {
187
        {
187
                        'field' => '200',
188
            'field'   => '200',
188
                        'heading' => 'Fossey Brigitte',
189
            'heading' => 'Fossey Brigitte',
189
                        'hemain' => 'Fossey'
190
            'hemain'  => 'Fossey'
190
                      }
191
        }
191
                    ],
192
    ],
192
    'authtypecode' => 'NP',
193
    'authtypecode'  => 'NP',
193
    'mainentry' => 'Fossey Brigitte',
194
    'mainentry'     => 'Fossey Brigitte',
194
    'mainmainentry' => 'Fossey',
195
    'mainmainentry' => 'Fossey',
195
    'notes' => [],
196
    'notes'         => [],
196
    'otherscript' => [],
197
    'otherscript'   => [],
197
    'seealso' => [],
198
    'seealso'       => [],
198
    'seefrom' => [],
199
    'seefrom'       => [],
199
    'summary' => 'Fossey, Brigitte',
200
    'summary'       => 'Fossey, Brigitte',
200
    'type' => 'Auteur',
201
    'type'          => 'Auteur',
201
    'equalterm' => []
202
    'equalterm'     => []
202
203
};
203
};
204
204
205
is_deeply(
205
is_deeply(
206
- 

Return to bug 27943