| 1 | package MARC::Convert::Wikidata::Object::People; | ||||||||||
| 2 | |||||||||||
| 3 | 22 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 22 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 22 | ▶ | use Mo qw(build default is); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 22 | ▶ | use Mo::utils::Array qw(check_array_object); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 22 | ▶ | use Mo::utils::Date 0.04 qw(check_date check_date_order); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 22 | our $VERSION = 0.15; | |||||||||
| 11 | |||||||||||
| 12 | 22 | has date_of_birth => ( | |||||||||
| 13 | is => 'ro', | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 22 | has date_of_death => ( | |||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | 22 | has external_ids => ( | |||||||||
| 21 | default => [], | ||||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 22 | has name => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | 22 | has surname => ( | |||||||||
| 30 | is => 'ro', | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 22 | has work_period_start => ( | |||||||||
| 34 | is => 'ro', | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 22 | has work_period_end => ( | |||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | ); | ||||||||||
| 40 | |||||||||||
| 41 | sub full_name { | ||||||||||
| 42 | 4 | ▶ | my $self = shift; | ||||||||
|
Subroutine
full_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 43 | |||||||||||
| 44 | 4 | my $full_name = $self->name; | |||||||||
| 45 | 4 | ▶ | if (defined $self->surname) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 2 | ▶ | if ($full_name) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 1 | $full_name .= ' '; | |||||||||
| 48 | } | ||||||||||
| 49 | 2 | $full_name .= $self->surname; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 4 | return $full_name; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub BUILD { | ||||||||||
| 56 | 39 | ▶ | my $self = shift; | ||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 57 | |||||||||||
| 58 | # Check 'date_of_birth'. | ||||||||||
| 59 | 39 | check_date($self, 'date_of_birth'); | |||||||||
| 60 | |||||||||||
| 61 | # Check 'date_of_death'. | ||||||||||
| 62 | 38 | check_date($self, 'date_of_death'); | |||||||||
| 63 | |||||||||||
| 64 | # Check date order. | ||||||||||
| 65 | 38 | check_date_order($self, 'date_of_birth', 'date_of_death'); | |||||||||
| 66 | |||||||||||
| 67 | # Check 'external_ids'. | ||||||||||
| 68 | 37 | check_array_object($self, 'external_ids', 'MARC::Convert::Wikidata::Object::ExternalId'); | |||||||||
| 69 | |||||||||||
| 70 | # Check 'work_period_start'. | ||||||||||
| 71 | 37 | check_date($self, 'work_period_start'); | |||||||||
| 72 | |||||||||||
| 73 | # Check 'work_period_end'. | ||||||||||
| 74 | 36 | check_date($self, 'work_period_end'); | |||||||||
| 75 | |||||||||||
| 76 | # Check date workd date order. | ||||||||||
| 77 | 35 | check_date_order($self, 'work_period_start', 'work_period_end'); | |||||||||
| 78 | |||||||||||
| 79 | 34 | return; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 22 | 1; | |||||||||
| 83 | |||||||||||
| 84 | __END__ | ||||||||||
| 85 | |||||||||||
| 86 | =pod | ||||||||||
| 87 | |||||||||||
| 88 | =encoding utf8 | ||||||||||
| 89 | |||||||||||
| 90 | =head1 NAME | ||||||||||
| 91 | |||||||||||
| 92 | MARC::Convert::Wikidata::Object::People - Bibliographic Wikidata object for people defined by MARC record. | ||||||||||
| 93 | |||||||||||
| 94 | =head1 SYNOPSIS | ||||||||||
| 95 | |||||||||||
| 96 | use MARC::Convert::Wikidata::Object::People; | ||||||||||
| 97 | |||||||||||
| 98 | my $obj = MARC::Convert::Wikidata::Object::People->new(%params); | ||||||||||
| 99 | my $date_of_birth = $obj->date_of_birth; | ||||||||||
| 100 | my $date_of_death = $obj->date_of_death; | ||||||||||
| 101 | my $external_ids_ar = $obj->external_ids; | ||||||||||
| 102 | my $full_name = $obj->full_name; | ||||||||||
| 103 | my $name = $obj->name; | ||||||||||
| 104 | my $surname = $obj->surname; | ||||||||||
| 105 | my $work_period_start = $obj->work_period_start; | ||||||||||
| 106 | my $work_period_end = $obj->work_period_end; | ||||||||||
| 107 | |||||||||||
| 108 | =head1 METHODS | ||||||||||
| 109 | |||||||||||
| 110 | =head2 C<new> | ||||||||||
| 111 | |||||||||||
| 112 | my $obj = MARC::Convert::Wikidata::Object::People->new(%params); | ||||||||||
| 113 | |||||||||||
| 114 | Constructor. | ||||||||||
| 115 | |||||||||||
| 116 | Returns instance of object. | ||||||||||
| 117 | |||||||||||
| 118 | =over 8 | ||||||||||
| 119 | |||||||||||
| 120 | =item * C<date_of_birth> | ||||||||||
| 121 | |||||||||||
| 122 | Date of birth of people. | ||||||||||
| 123 | |||||||||||
| 124 | Parameter is string with date. See L<Mo::utils::Date/check_date> for more information. | ||||||||||
| 125 | |||||||||||
| 126 | Default value is undef. | ||||||||||
| 127 | |||||||||||
| 128 | =item * C<date_of_death> | ||||||||||
| 129 | |||||||||||
| 130 | Date of death of people. | ||||||||||
| 131 | |||||||||||
| 132 | Parameter is string with date. See L<Mo::utils::Date/check_date> for more information. | ||||||||||
| 133 | |||||||||||
| 134 | Default value is undef. | ||||||||||
| 135 | |||||||||||
| 136 | =item * C<external_ids> | ||||||||||
| 137 | |||||||||||
| 138 | External ids. | ||||||||||
| 139 | |||||||||||
| 140 | Need to be a reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances. | ||||||||||
| 141 | |||||||||||
| 142 | Default value is []. | ||||||||||
| 143 | |||||||||||
| 144 | =item * C<name> | ||||||||||
| 145 | |||||||||||
| 146 | Given name of people. | ||||||||||
| 147 | |||||||||||
| 148 | Default value is undef. | ||||||||||
| 149 | |||||||||||
| 150 | =item * C<surname> | ||||||||||
| 151 | |||||||||||
| 152 | Surname of people. | ||||||||||
| 153 | |||||||||||
| 154 | Default value is undef. | ||||||||||
| 155 | |||||||||||
| 156 | =back | ||||||||||
| 157 | |||||||||||
| 158 | =head2 C<date_of_birth> | ||||||||||
| 159 | |||||||||||
| 160 | my $date_of_birth = $obj->date_of_birth; | ||||||||||
| 161 | |||||||||||
| 162 | Get date of birth. | ||||||||||
| 163 | |||||||||||
| 164 | Returns string. | ||||||||||
| 165 | |||||||||||
| 166 | =head2 C<date_of_death> | ||||||||||
| 167 | |||||||||||
| 168 | my $date_of_death = $obj->date_of_death; | ||||||||||
| 169 | |||||||||||
| 170 | Get date of death. | ||||||||||
| 171 | |||||||||||
| 172 | Returns string. | ||||||||||
| 173 | |||||||||||
| 174 | =head2 C<external_ids> | ||||||||||
| 175 | |||||||||||
| 176 | my $external_ids_ar = $obj->external_ids; | ||||||||||
| 177 | |||||||||||
| 178 | Get list of external ids. | ||||||||||
| 179 | |||||||||||
| 180 | Returns reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances. | ||||||||||
| 181 | |||||||||||
| 182 | =head2 C<full_name> | ||||||||||
| 183 | |||||||||||
| 184 | my $full_name = $obj->full_name; | ||||||||||
| 185 | |||||||||||
| 186 | Get full name. | ||||||||||
| 187 | |||||||||||
| 188 | Returns string. | ||||||||||
| 189 | |||||||||||
| 190 | =head2 C<name> | ||||||||||
| 191 | |||||||||||
| 192 | my $name = $obj->name; | ||||||||||
| 193 | |||||||||||
| 194 | Get given name. | ||||||||||
| 195 | |||||||||||
| 196 | Returns string. | ||||||||||
| 197 | |||||||||||
| 198 | =head2 C<surname> | ||||||||||
| 199 | |||||||||||
| 200 | my $surname = $obj->surname; | ||||||||||
| 201 | |||||||||||
| 202 | Get surname. | ||||||||||
| 203 | |||||||||||
| 204 | Returns string. | ||||||||||
| 205 | |||||||||||
| 206 | =head2 C<work_period_start> | ||||||||||
| 207 | |||||||||||
| 208 | my $work_period_start = $obj->work_period_start; | ||||||||||
| 209 | |||||||||||
| 210 | Get start date of work period. | ||||||||||
| 211 | |||||||||||
| 212 | Returns string. | ||||||||||
| 213 | |||||||||||
| 214 | =head2 C<work_period_end> | ||||||||||
| 215 | |||||||||||
| 216 | my $work_period_end = $obj->work_period_end; | ||||||||||
| 217 | |||||||||||
| 218 | Get end date of work period. | ||||||||||
| 219 | |||||||||||
| 220 | Returns string. | ||||||||||
| 221 | |||||||||||
| 222 | =head1 ERRORS | ||||||||||
| 223 | |||||||||||
| 224 | new(): | ||||||||||
| 225 | From Mo::utils::Array::check_array_object(): | ||||||||||
| 226 | Parameter 'external_ids' must be a array. | ||||||||||
| 227 | Value: %s | ||||||||||
| 228 | Reference: %s | ||||||||||
| 229 | Parameter 'external_ids' with array must contain 'MARC::Convert::Wikidata::Object::ExternalId' objects. | ||||||||||
| 230 | Value: %s | ||||||||||
| 231 | Reference: %s | ||||||||||
| 232 | |||||||||||
| 233 | From Mo::utils::Date::check_date(): | ||||||||||
| 234 | Parameter 'date_of_birth' for date is in bad format. | ||||||||||
| 235 | Parameter 'date_of_birth' has year greater than actual year. | ||||||||||
| 236 | Parameter 'date_of_death' for date is in bad format. | ||||||||||
| 237 | Parameter 'date_of_death' has year greater than actual year. | ||||||||||
| 238 | |||||||||||
| 239 | From Mo::utils::Date::check_date_order(): | ||||||||||
| 240 | Parameter 'date_of_birth' has date greater or same as parameter 'date_of_death' date. | ||||||||||
| 241 | |||||||||||
| 242 | =head1 EXAMPLE1 | ||||||||||
| 243 | |||||||||||
| 244 | =for comment filename=create_and_dump_people.pl | ||||||||||
| 245 | |||||||||||
| 246 | use strict; | ||||||||||
| 247 | use warnings; | ||||||||||
| 248 | |||||||||||
| 249 | use Data::Printer; | ||||||||||
| 250 | use MARC::Convert::Wikidata::Object::ExternalId; | ||||||||||
| 251 | use MARC::Convert::Wikidata::Object::People; | ||||||||||
| 252 | use Unicode::UTF8 qw(decode_utf8); | ||||||||||
| 253 | |||||||||||
| 254 | my $obj = MARC::Convert::Wikidata::Object::People->new( | ||||||||||
| 255 | 'date_of_birth' => '1952-12-08', | ||||||||||
| 256 | 'external_ids' => [ | ||||||||||
| 257 | MARC::Convert::Wikidata::Object::ExternalId->new( | ||||||||||
| 258 | 'name' => 'nkcr_aut', | ||||||||||
| 259 | 'value' => 'jn20000401266', | ||||||||||
| 260 | ), | ||||||||||
| 261 | ], | ||||||||||
| 262 | 'name' => decode_utf8('Jiří'), | ||||||||||
| 263 | 'surname' => 'Jurok', | ||||||||||
| 264 | ); | ||||||||||
| 265 | |||||||||||
| 266 | p $obj; | ||||||||||
| 267 | |||||||||||
| 268 | # Output: | ||||||||||
| 269 | # MARC::Convert::Wikidata::Object::People { | ||||||||||
| 270 | # parents: Mo::Object | ||||||||||
| 271 | # public methods (5): | ||||||||||
| 272 | # BUILD, full_name | ||||||||||
| 273 | # Mo::utils::Array: | ||||||||||
| 274 | # check_array_object | ||||||||||
| 275 | # Mo::utils::Date: | ||||||||||
| 276 | # check_date, check_date_order | ||||||||||
| 277 | # private methods (0) | ||||||||||
| 278 | # internals: { | ||||||||||
| 279 | # date_of_birth "1952-12-08" (dualvar: 1952), | ||||||||||
| 280 | # external_ids [ | ||||||||||
| 281 | # [0] MARC::Convert::Wikidata::Object::ExternalId | ||||||||||
| 282 | # ], | ||||||||||
| 283 | # name "Jiří", | ||||||||||
| 284 | # surname "Jurok" | ||||||||||
| 285 | # } | ||||||||||
| 286 | # } | ||||||||||
| 287 | |||||||||||
| 288 | =head1 DEPENDENCIES | ||||||||||
| 289 | |||||||||||
| 290 | L<Mo>, | ||||||||||
| 291 | L<Mo::utils::Array>, | ||||||||||
| 292 | L<Mo::utils::Date>. | ||||||||||
| 293 | |||||||||||
| 294 | =head1 SEE ALSO | ||||||||||
| 295 | |||||||||||
| 296 | =over | ||||||||||
| 297 | |||||||||||
| 298 | =item L<MARC::Convert::Wikidata> | ||||||||||
| 299 | |||||||||||
| 300 | Conversion class between MARC record and Wikidata object. | ||||||||||
| 301 | |||||||||||
| 302 | =back | ||||||||||
| 303 | |||||||||||
| 304 | =head1 REPOSITORY | ||||||||||
| 305 | |||||||||||
| 306 | L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata-Object> | ||||||||||
| 307 | |||||||||||
| 308 | =head1 AUTHOR | ||||||||||
| 309 | |||||||||||
| 310 | Michal Josef Špaček L<mailto:skim@cpan.org> | ||||||||||
| 311 | |||||||||||
| 312 | L<http://skim.cz> | ||||||||||
| 313 | |||||||||||
| 314 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 315 | |||||||||||
| 316 | © Michal Josef Špaček 2021-2025 | ||||||||||
| 317 | |||||||||||
| 318 | BSD 2-Clause License | ||||||||||
| 319 | |||||||||||
| 320 | =head1 VERSION | ||||||||||
| 321 | |||||||||||
| 322 | 0.15 | ||||||||||
| 323 | |||||||||||
| 324 | =cut | ||||||||||