annotate makemeta-lib.pl @ 35:e27d097a9d87

still issues with "while read"
author casties
date Fri, 23 Jun 2006 11:40:12 +0200
parents ae8b0506498a
children 27f273329930
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
1 #!/usr/local/bin/perl -w
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
2
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
3 use strict;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
4 use XML::LibXML;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
5
22
c3defe3e2780 corrected perl lib path
casties
parents: 17
diff changeset
6 use lib '/usr/local/mpiwg/archive';
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
7 use MPIWGStor;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
8
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
9 # make output unbuffered
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
10 $|=1;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
11
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
12 # program version
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
13 my $version = "0.2.5 (9.6.2006 ROC)";
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
14 my $help =
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
15 "use: makemeta-lib [options] file.xml
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
16 options:
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
17 -debug show debugging info
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
18 -dry-run simulate, dont'do anything
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
19 -online-mode mode for creating online/permanent files
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
20 -online-base=dir base directory for online ids (for online mode)
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
21 -cw-mode mode for copying einstein_cw archive documents
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
22 -digifiles-mode mode for copying files from digifiles
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
23 -map-file=mapfile.xml digilib mapping file (for digifiles mode)
29
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
24 -access=free adds free access tag (use access=mpiwg for restricted access)
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
25 ";
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
26 logger("INFO", "makemeta-lib $version");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
27
13
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
28 ###########################################
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
29 # mappings
13
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
30
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
31 # generic mappings at top level
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
32 my %gen_map = (
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
33 'Device' => 'meta/image-acquisition/device',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
34 'Image_Type' => 'meta/image-acquisition/image-type',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
35 'Production_Comment' => 'meta/image-acquisition/production-comment',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
36 'Postproduction' => 'meta/image-acquisition/production-comment',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
37 'Language' => 'meta/lang'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
38 );
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
39 # sub type switch tag
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
40 my %type_map = (
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
41 'Reference_Type' => 'meta/bib@type'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
42 );
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
43 # sub type mappings
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
44 my %subtype_map = (
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
45 'Book' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
46 '_name' => 'book',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
47 'Author' => 'meta/bib/author',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
48 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
49 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
50 'Place_Published' => 'meta/bib/city',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
51 'Publisher' => 'meta/bib/publisher',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
52 'Edition' => 'meta/bib/edition'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
53 },
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
54 'Journal Article' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
55 '_name' => 'journal-article',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
56 'Author' => 'meta/bib/author',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
57 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
58 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
59 'Secondary_Title' => 'meta/bib/journal',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
60 'Volume' => 'meta/bib/volume',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
61 'Number' => 'meta/bib/issue',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
62 'Pages' => 'meta/bib/pages'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
63 },
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
64 'In Book' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
65 '_name' => 'inbook',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
66 'Author' => 'meta/bib/author',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
67 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
68 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
69 'Secondary_Title' => 'meta/bib/book-title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
70 'Pages' => 'meta/bib/pages'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
71 },
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
72 'Newspaper Article' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
73 '_name' => 'newspaper-article',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
74 'Author' => 'meta/bib/author',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
75 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
76 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
77 'Secondary_Title' => 'meta/bib/newspaper',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
78 'Place_Published' => 'meta/bib/city',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
79 'Number' => 'meta/bib/issue-date',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
80 'Pages' => 'meta/bib/pages'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
81 },
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
82 'Edited Book' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
83 '_name' => 'edited-book',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
84 'Author' => 'meta/bib/editor',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
85 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
86 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
87 'Place_Published' => 'meta/bib/city',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
88 'Publisher' => 'meta/bib/publisher',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
89 'Edition' => 'meta/bib/edition'
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
90 },
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
91 'Manuscript' => {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
92 '_name' => 'manuscript',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
93 'Author' => 'meta/bib/author',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
94 'Title' => 'meta/bib/title',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
95 'Year' => 'meta/bib/year',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
96 'Place_Published' => 'meta/bib/location',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
97 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
98 );
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
99 # language element
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
100 my $lang_field = 'Language';
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
101 # languages to iso codes
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
102 my %lang_map = (
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
103 'German' => 'de',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
104 'English' => 'en',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
105 'Italian' => 'it',
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
106 'French' => 'fr',
13
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
107 'Latin' => 'la',
14
018e7c913b32 lang japanese
casties
parents: 13
diff changeset
108 'Japanese' => 'ja',
15
8d2f0586eca6 new helper script for calling archiver on many directories
casties
parents: 14
diff changeset
109 'Dutch' => 'nl',
32
ae8b0506498a language type for swedish
casties
parents: 30
diff changeset
110 'Spanish' => 'es',
ae8b0506498a language type for swedish
casties
parents: 30
diff changeset
111 'Swedish' => 'sv'
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
112 );
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
113 # storage fields
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
114 my $arch_id_field = 'ID_Archive';
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
115 my $online_url_field = 'URL';
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
116 my $online_id_field = 'ID_OnlinePermanent';
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
117
13
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
118 #######################################################
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
119 # internal parameters
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
120 #
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
121
f33fb7f1898e added mapping for spanish lang
casties
parents: 12
diff changeset
122 # storage
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
123 my $lib_arch_dir = '/mpiwg/archive/data/library';
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
124 my $lib_online_dir = '/mpiwg/online/permanent';
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
125 my $lib_digilib_path = 'permanent';
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
126 my $digifiles_dir = "/net/digifiles.mpiwg-berlin.mpg.de/Volumes/raid";
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
127
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
128 # read command line parameters
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
129 my $args = MPIWGStor::parseargs;
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
130 if (! scalar(%$args)) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
131 print $help, "\n";
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
132 exit 1;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
133 }
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
134
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
135 # debug level
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
136 $debug = (exists $$args{'debug'}) ? $$args{'debug'} : 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
137
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
138 # simulate action only
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
139 my $dry_run = (exists $$args{'dry-run'}) ? $$args{'dry-run'} : 0;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
140 logger('DEBUG', "dry-run: $dry_run");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
141
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
142 # use online mode
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
143 my $online_mode = (exists $$args{'online-mode'}) ? $$args{'online-mode'} : 0;
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
144 logger('DEBUG', "online_mode: $online_mode");
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
145 # online base dir
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
146 my $online_base_dir = (exists $$args{'online-base'}) ? $$args{'online-base'} : "";
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
147 logger('DEBUG', "online_base_dir: $online_base_dir");
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
148
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
149 # use einstein-cw mode
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
150 my $cw_mode = (exists $$args{'cw-mode'}) ? $$args{'cw-mode'} : 0;
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
151 logger('DEBUG', "cw_mode: $cw_mode");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
152
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
153 # use digifiles mode
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
154 my $digifiles_mode = (exists $$args{'digifiles-mode'}) ? $$args{'digifiles-mode'} : 0;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
155 logger('DEBUG', "digifiles_mode: $digifiles_mode");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
156 # digilib mapping file
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
157 my $map_file_name = (exists $$args{'map-file'}) ? $$args{'map-file'} : "";
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
158 logger('DEBUG', "map_file_name: $map_file_name");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
159 my $mapping_doc;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
160 my $mapping_root;
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
161
29
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
162 # access type
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
163 my $access_type = (exists $$args{'access'}) ? $$args{'access'} : "";
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
164
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
165 # index.meta namespace (not really implemented!)
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
166 my $namespace = "";
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
167
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
168
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
169 my $xml_changed = 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
170 my $errcnt = 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
171 my $warncnt = 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
172
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
173 #######################################################
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
174 # check parameters that were passed to the program
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
175 #
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
176 my $infile = $$args{'path'};
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
177 if (! $infile) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
178 logger("ABORT", "no input file given!");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
179 exit 1;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
180 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
181 # strip double slashes
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
182 $infile = sstrip($infile, 1);
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
183 if (! -f $infile) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
184 logger("ABORT", "input file \'$infile\' doesn't exist!");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
185 exit 1;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
186 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
187
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
188
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
189 #######################################################
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
190 # subroutines
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
191 #
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
192
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
193
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
194 sub add_digilib_mapping {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
195 my ($src_dir, $dest_dir) = @_;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
196 my $elem = $mapping_root->addNewChild($namespace, 'mapping');
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
197 $elem->addChild($mapping_doc->createAttributeNS($namespace, 'link', $src_dir));
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
198 $elem->addChild($mapping_doc->createAttributeNS($namespace, 'dir', $dest_dir));
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
199 if ($map_file_name) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
200 write_xml($mapping_doc, $map_file_name);
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
201 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
202 logger('ABORT', "unable to write mapping file!");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
203 exit 1;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
204 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
205 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
206
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
207 sub find_digifiles_dir {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
208 my ($input_node) = @_;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
209 my $digifiles_base = '/net/digifiles.mpiwg-berlin.mpg.de/Volumes/raid';
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
210 my $src_dir = find_online_dir($input_node, $digifiles_base, '');
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
211 if (! $src_dir) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
212 logger('ERROR', "no online directory for digifiles entry");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
213 $errcnt++;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
214 return;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
215 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
216 my $dest_id = sstrip($input_node->findvalue("fm:$online_id_field"));
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
217 if (! $dest_id) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
218 logger('ERROR', "no ID field for digifiles entry");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
219 $errcnt++;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
220 return;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
221 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
222 my $dir = "$lib_online_dir/library/$dest_id";
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
223 my $map_dir = "$lib_digilib_path/library/$dest_id";
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
224 if ($dry_run) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
225 logger('DEBUG', "would move $digifiles_base/$src_dir to $dir");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
226 add_digilib_mapping($src_dir, "$map_dir/pageimg");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
227 return $dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
228 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
229 logger('INFO', "moving $digifiles_base/$src_dir to $dir");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
230 logger('DEBUG', "mkdir $dir/pageimg");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
231 if (system("mkdir -p $dir/pageimg && chmod -R 0775 $dir") == 0) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
232 logger('DEBUG', "cp $digifiles_base/$src_dir $dir/pageimg");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
233 if (system("cp -rp $digifiles_base/$src_dir/* $dir/pageimg/") == 0) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
234 if (-d "$dir/pageimg") {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
235 logger('DEBUG', "directory $dir OK");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
236 add_digilib_mapping($src_dir, "$map_dir/pageimg");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
237 if (system("rm -rf $digifiles_base/$src_dir/* && rm -rf $digifiles_base/$src_dir") == 0) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
238 logger('DEBUG', "directory $digifiles_base/$src_dir removed");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
239 return $dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
240 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
241 logger('ERROR', "unable to remove source directory $digifiles_base/$src_dir!");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
242 $errcnt++;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
243 return $dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
244 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
245 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
246 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
247 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
248 logger('ABORT', "unable to copy directory $src_dir to $dir!");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
249 exit 1;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
250 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
251 return;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
252 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
253
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
254 sub find_cw_dir {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
255 my ($input_node) = @_;
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
256 my $cw_base = '/mpiwg/archive/data/library/inbox/zwischen_backup';
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
257 my $src_dir = find_online_dir($input_node, $cw_base, 'pageimg');
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
258 my $dest_id = sstrip($input_node->findvalue("fm:$arch_id_field"));
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
259 if (! $dest_id) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
260 logger('ERROR', "no ID field for einstein-cw entry");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
261 $errcnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
262 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
263 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
264 my $dir = "$lib_arch_dir/$dest_id";
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
265 if ($dry_run) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
266 logger('DEBUG', "would move $cw_base/$src_dir to $dir");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
267 return $dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
268 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
269 logger('DEBUG', "moving $cw_base/$src_dir to $dir");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
270 if (rename "$cw_base/$src_dir", $dir) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
271 if (-d $dir) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
272 logger('DEBUG', "directory $dir OK");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
273 return $dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
274 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
275 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
276 logger('ABORT', "unable to rename directory $cw_base/$src_dir to $dir!");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
277 exit 1;
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
278 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
279 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
280 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
281 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
282
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
283 sub find_permanent_dir {
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
284 my ($input_node) = @_;
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
285 my $online_id = sstrip($input_node->findvalue("fm:$online_id_field"));
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
286 # try online_base_dir + online_id first
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
287 if (($online_base_dir)&&($online_id)) {
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
288 my $dir = sstrip("$online_base_dir/$online_id", 1);
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
289 return $dir;
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
290 }
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
291 # then online_url
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
292 my $online_base = '/mpiwg/online/permanent';
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
293 my $online_dir = find_online_dir($input_node, $online_base, 'pageimg');
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
294 if ((! $online_dir)) {
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
295 logger('ERROR', "no ID or URL for online permanent entry");
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
296 $errcnt++;
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
297 return;
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
298 }
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
299 my $dir = sstrip("$online_base/$online_dir", 1);
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
300 return $dir;
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
301 }
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
302
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
303 #
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
304 # $dir = find_online_dir($input_node, $base_dir, $page_dir)
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
305 #
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
306 # Takes the path from the $online_url_field of the $input_node document
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
307 # and looks in the directory $base_dir for it. Strips $page_dir from the end.
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
308 # Returns the directory path sans $base_dir if it exists
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
309 #
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
310 sub find_online_dir {
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
311 my ($input_node, $base_dir, $page_dir) = @_;
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
312 $base_dir = $lib_online_dir unless ($base_dir);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
313
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
314 my $online_url = $input_node->findvalue("fm:$online_url_field");
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
315 logger('DEBUG', "checking URL: $online_url");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
316 my $online_dir;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
317 if ($online_url =~ /fn=permanent\/(.+)/) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
318 # new style digilib URL
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
319 $online_dir = $1;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
320 } elsif ($online_url =~ /\?([^\+]+)\+/) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
321 # old style digilib URL
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
322 $online_dir = $1;
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
323 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
324 #logger('DEBUG', "online_dir1: $online_dir");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
325 if ($online_dir) {
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
326 $online_dir =~ s/\/$//; # strip ending slashes
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
327 if ($page_dir) {
30
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
328 # strip page_dir
398ef4b8f072 added -online-base option to makemeta-lib
casties
parents: 29
diff changeset
329 $online_dir =~ s/\/${page_dir}$//;
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
330 }
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
331 #logger("DEBUG", "dir: $base_dir/$online_dir");
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
332 if (-d "$base_dir/$online_dir") {
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
333 logger('DEBUG', "directory $base_dir/$online_dir exists");
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
334 return $online_dir;
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
335 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
336 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
337 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
338 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
339
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
340 sub find_arch_dir {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
341 my ($input_node) = @_;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
342 my $dir = "";
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
343
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
344 my $bib_dir = $input_node->findvalue("fm:$arch_id_field");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
345 #logger('DEBUG', "bibdir: $bib_dir");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
346 if ($bib_dir) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
347 $dir = "$lib_arch_dir/$bib_dir";
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
348 if (-d $dir) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
349 logger('DEBUG', "directory $dir exists");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
350 return $dir;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
351 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
352 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
353 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
354 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
355
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
356
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
357 sub convert_bib {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
358 my ($input_node, $index_root, $index_doc) = @_;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
359 my $cnt = 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
360 my $type = "";
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
361 my $type_path = "";
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
362
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
363 # process general stuff first
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
364 foreach my $n ($input_node->getChildNodes()) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
365 my $name = $n->nodeName();
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
366 my $val = $n->textContent();
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
367 #logger('DEBUG', " NODE: $name = '$val'");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
368 if (exists $gen_map{$name}) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
369 # is a general field
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
370 if ($name eq $lang_field) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
371 # language field -> convert to iso code
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
372 if (exists $lang_map{$val}) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
373 $val = $lang_map{$val};
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
374 } else {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
375 logger('ERROR', "unknown language: $val! skipping...");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
376 $errcnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
377 return 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
378 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
379 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
380 create_element_path($gen_map{$name}, $index_root, $namespace)
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
381 ->appendTextNode($val);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
382 $cnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
383 } elsif (exists $type_map{$name}) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
384 # is a type field
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
385 $type_path = $type_map{$name};
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
386 $type = $val;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
387 # check with known types
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
388 if (exists $subtype_map{$val}) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
389 my $indextype = $subtype_map{$val}->{'_name'};
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
390 create_element_path("$type_path=$indextype", $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
391 $cnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
392 } else {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
393 logger('ERROR', 'unknown bib type $val! skipping...');
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
394 $errcnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
395 return 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
396 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
397 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
398 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
399 # process sub type fields
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
400 if ($type) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
401 foreach my $n ($input_node->getChildNodes()) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
402 my $name = $n->nodeName();
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
403 my $val = $n->textContent();
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
404 #logger('DEBUG', " NODE: $name = '$val'");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
405 if (exists $subtype_map{$type}->{$name}) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
406 create_element_path($subtype_map{$type}->{$name}, $index_root, $namespace)
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
407 ->appendTextNode($val);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
408 $cnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
409 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
410 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
411 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
412 return $cnt;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
413 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
414
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
415
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
416
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
417 sub process_all_fm_entries {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
418 my ($input_root) = @_;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
419 my $cnt = 0;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
420
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
421 foreach my $n ($input_root->findnodes('fm:ROW')) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
422 logger('INFO', "processing entry $cnt ...");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
423 process_fm_entry($n);
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
424 $cnt++;
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
425 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
426 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
427
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
428
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
429 sub process_fm_entry {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
430 my ($input_node) = @_;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
431 my $index_doc = XML::LibXML::Document->createDocument('1.0', 'UTF-8');
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
432 my $index_root = $index_doc->createElementNS($namespace, 'resource');
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
433 $index_root->addChild($index_doc->createAttributeNS($namespace, 'version', '1.1'));
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
434 $index_root->addChild($index_doc->createAttributeNS($namespace, 'type', 'MPIWG'));
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
435 $index_doc->setDocumentElement($index_root);
28
3ff9da4b7c87 added derived-from
casties
parents: 22
diff changeset
436 my $derived_from = "";
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
437
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
438 # try to find the document directory
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
439 my $doc_dir = "";
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
440 if ($online_mode) {
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
441 $doc_dir = find_permanent_dir($input_node);
28
3ff9da4b7c87 added derived-from
casties
parents: 22
diff changeset
442 $derived_from = find_arch_dir($input_node);
17
6c5c7743acb1 new version with new -onlinne-mode for online/permanent.
casties
parents: 16
diff changeset
443 } elsif ($cw_mode) {
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
444 $doc_dir = find_cw_dir($input_node);
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
445 } elsif ($digifiles_mode) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
446 $doc_dir = find_digifiles_dir($input_node);
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
447 } else {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
448 $doc_dir = find_arch_dir($input_node);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
449 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
450 if (! $doc_dir) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
451 logger('ERROR', "document directory not found! skipping...");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
452 $errcnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
453 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
454 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
455
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
456 # add standard stuff to index.meta
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
457 my ($docname, $docpath) = split_file_path($doc_dir);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
458 # name and date
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
459 create_text_path('name', $docname, $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
460 create_text_path('archive-path', $doc_dir, $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
461 create_text_path('archive-creation-date', stime(time), $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
462 create_text_path('creator', 'digigroup', $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
463 create_text_path('description', 'a scanned document', $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
464 # acquisition
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
465 create_text_path('meta/acquisition/date', stime(time), $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
466 create_text_path('meta/acquisition/provider/provider-id', 'digigroup', $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
467 create_text_path('meta/acquisition/provider/address', 'Max Planck Institute for the History of Science', $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
468 # media
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
469 create_text_path('media-type', 'image', $index_root, $namespace);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
470 create_text_path('meta/content-type', 'scanned document', $index_root, $namespace);
28
3ff9da4b7c87 added derived-from
casties
parents: 22
diff changeset
471 # derived-from
3ff9da4b7c87 added derived-from
casties
parents: 22
diff changeset
472 if ($derived_from) {
3ff9da4b7c87 added derived-from
casties
parents: 22
diff changeset
473 create_text_path('derived-from/archive-path', $derived_from, $index_root, $namespace);
29
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
474 }
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
475 # access
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
476 if ($access_type) {
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
477 if ($access_type eq "free") {
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
478 create_element_path('access-conditions/access@type=free', $index_root, $namespace);
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
479 } else {
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
480 my $acc_tag = create_element_path('access-conditions/access@type=institution', $index_root, $namespace);
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
481 create_text_path('name', $access_type, $acc_tag, $namespace);
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
482 }
f77f6cb40c4f now with access-conditions tag
casties
parents: 28
diff changeset
483 }
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
484
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
485 # convert bib entries
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
486 my $cnt = convert_bib($input_node, $index_root, $index_doc);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
487 if ($cnt == 0) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
488 # error or nothing to convert
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
489 logger('ERROR', "no bibliographic metadata!");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
490 $errcnt++;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
491 return;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
492 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
493
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
494 # write new index.meta file
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
495 if ($dry_run) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
496 logger('DEBUG', "would write $doc_dir/index.meta");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
497 logger('DEBUG', $index_doc->toString(1));
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
498 } else {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
499 write_xml($index_doc, "$doc_dir/index.meta");
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
500 }
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
501
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
502 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
503
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
504
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
505
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
506
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
507
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
508 #######################################################
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
509 # Main
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
510 #
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
511
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
512 # load filemaker xml dump
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
513 my ($input_doc, $input_root) = read_xml($infile);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
514 # set namespace prefix
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
515 my $fm_namespace = $input_root->namespaceURI();
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
516 $input_root->setNamespace($fm_namespace, 'fm', 1);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
517
16
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
518 # create digilib mapping file for digifiles mode
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
519 if ($digifiles_mode) {
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
520 $mapping_doc = XML::LibXML::Document->createDocument('1.0', 'UTF-8');
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
521 $mapping_root = $mapping_doc->createElementNS($namespace, 'digilib-aliases');
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
522 $mapping_doc->setDocumentElement($mapping_root);
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
523 #<mapping link="exp1/archimedes_image_repository/archimedes_large/achil_propo_087_la_1545" dir="permanent/archimedes_repository/large/achil_propo_087_la_1545"/>
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
524
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
525 }
8eee361fdec8 weiter arbeit am digifiles modus
casties
parents: 15
diff changeset
526
12
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
527 process_all_fm_entries($input_root);
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
528
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
529
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
530 logger("INFO", "$warncnt warnings");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
531 logger("INFO", "$errcnt errors");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
532 if ($errcnt > 0) {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
533 logger("ABORT", "there were errors!");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
534 exit 1;
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
535 } else {
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
536 logger("DONE", "done something successfully!");
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
537 }
620aad237f57 new tool makemeta-lib.pl to create index meta entries from the libraries online sources database
casties
parents:
diff changeset
538