comparison makemeta-lib.pl @ 29:f77f6cb40c4f

now with access-conditions tag
author casties
date Tue, 16 May 2006 21:56:32 +0200
parents 3ff9da4b7c87
children 398ef4b8f072
comparison
equal deleted inserted replaced
28:3ff9da4b7c87 29:f77f6cb40c4f
8 8
9 # make output unbuffered 9 # make output unbuffered
10 $|=1; 10 $|=1;
11 11
12 # program version 12 # program version
13 my $version = "0.2.3 (16.5.2006 ROC)"; 13 my $version = "0.2.4 (16.5.2006 ROC)";
14 my $help = 14 my $help =
15 "use: makemeta-lib [options] file.xml 15 "use: makemeta-lib [options] file.xml
16 options: 16 options:
17 -debug show debugging info 17 -debug show debugging info
18 -dry-run simulate, dont'do anything 18 -dry-run simulate, dont'do anything
19 -online-mode mode for creating online/permanent files 19 -online-mode mode for creating online/permanent files
20 -cw-mode mode for copying einstein_cw archive documents 20 -cw-mode mode for copying einstein_cw archive documents
21 -digifiles-mode mode for copying files from digifiles 21 -digifiles-mode mode for copying files from digifiles
22 -map-file=mapfile.xml digilib mapping file (for digifiles mode) 22 -map-file=mapfile.xml digilib mapping file (for digifiles mode)
23 -access=free adds free access tag (use access=mpiwg for restricted access)
23 "; 24 ";
24 logger("INFO", "makemeta-lib $version"); 25 logger("INFO", "makemeta-lib $version");
25 26
26 ########################################### 27 ###########################################
27 # mappings 28 # mappings
151 my $map_file_name = (exists $$args{'map-file'}) ? $$args{'map-file'} : ""; 152 my $map_file_name = (exists $$args{'map-file'}) ? $$args{'map-file'} : "";
152 logger('DEBUG', "map_file_name: $map_file_name"); 153 logger('DEBUG', "map_file_name: $map_file_name");
153 my $mapping_doc; 154 my $mapping_doc;
154 my $mapping_root; 155 my $mapping_root;
155 156
157 # access type
158 my $access_type = (exists $$args{'access'}) ? $$args{'access'} : "";
159
156 # index.meta namespace (not really implemented!) 160 # index.meta namespace (not really implemented!)
157 my $namespace = ""; 161 my $namespace = "";
158 162
159 163
160 my $xml_changed = 0; 164 my $xml_changed = 0;
274 sub find_permanent_dir { 278 sub find_permanent_dir {
275 my ($input_node) = @_; 279 my ($input_node) = @_;
276 my $online_base = '/mpiwg/online/permanent'; 280 my $online_base = '/mpiwg/online/permanent';
277 my $src_dir = find_online_dir($input_node, $online_base, 'pageimg'); 281 my $src_dir = find_online_dir($input_node, $online_base, 'pageimg');
278 my $dest_id = sstrip($input_node->findvalue("fm:$online_id_field")); 282 my $dest_id = sstrip($input_node->findvalue("fm:$online_id_field"));
279 if (! $dest_id) { 283 if ((! $dest_id)||(! $src_dir)) {
280 logger('ERROR', "no ID field for online permanent entry"); 284 logger('ERROR', "no ID field for online permanent entry");
281 $errcnt++; 285 $errcnt++;
282 return; 286 return;
283 } 287 }
284 my $dir = "$online_base/$src_dir"; 288 my $dir = "$online_base/$src_dir";
453 create_text_path('media-type', 'image', $index_root, $namespace); 457 create_text_path('media-type', 'image', $index_root, $namespace);
454 create_text_path('meta/content-type', 'scanned document', $index_root, $namespace); 458 create_text_path('meta/content-type', 'scanned document', $index_root, $namespace);
455 # derived-from 459 # derived-from
456 if ($derived_from) { 460 if ($derived_from) {
457 create_text_path('derived-from/archive-path', $derived_from, $index_root, $namespace); 461 create_text_path('derived-from/archive-path', $derived_from, $index_root, $namespace);
458 } 462 }
463 # access
464 if ($access_type) {
465 if ($access_type eq "free") {
466 create_element_path('access-conditions/access@type=free', $index_root, $namespace);
467 } else {
468 my $acc_tag = create_element_path('access-conditions/access@type=institution', $index_root, $namespace);
469 create_text_path('name', $access_type, $acc_tag, $namespace);
470 }
471 }
459 472
460 # convert bib entries 473 # convert bib entries
461 my $cnt = convert_bib($input_node, $index_root, $index_doc); 474 my $cnt = convert_bib($input_node, $index_root, $index_doc);
462 if ($cnt == 0) { 475 if ($cnt == 0) {
463 # error or nothing to convert 476 # error or nothing to convert