script/ISO-t-dumper.pm untested

filter: Statementstmt 0.0% 0 / 359 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 87 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 447 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl
2 # Program: ISO-t-dumper.pm
3 # Purpose: create the types_ test case expected value files
4  
5 #---------------------------------------------------------------
6 # Mods:
7 # 0.3 - 2003.08.13 - added new types for:
8 # Forward-Notification
9 # Shipped
10 # Conditional-Reply
11 # Cancel
12 # Cancel-Reply
13 # Received
14 # Recall
15 # Returned
16 # Checked-In
17 # Overdue
18 # Renew
19 # Renew-Answer
20 # Lost
21 # Damaged
22 # Message
23 # Status-Query
24 # Status-Or-Error-Report
25 # Expired
26 # - note that this is NOT an exhaustive test!
27 # need to add more tests to excersise all types
28 # 0.2 - 2003.07.26 - added proper lib to @INC
29 # added Answer types
30 # 0.1 - 2003.07.15 - original version (Request types)
31 #---------------------------------------------------------------
32  
33 #BEGIN{push @INC, "./../lib/"}
34 #BEGIN{unshift @INC, "./../lib/"}
35 BEGIN{unshift @INC, "./lib/"}
36  
37 use Data::Dumper;
38  
39 use Biblio::ILL::ISO::ILLASNtype;
40  
41 use Biblio::ILL::ISO::AccountNumber;
42 use Biblio::ILL::ISO::AlreadyTriedListType;
43 use Biblio::ILL::ISO::Amount;
44 use Biblio::ILL::ISO::AmountString;
45 use Biblio::ILL::ISO::ClientId;
46 use Biblio::ILL::ISO::CostInfoType;
47 use Biblio::ILL::ISO::DateTime;
48 use Biblio::ILL::ISO::DeliveryAddress;
49 use Biblio::ILL::ISO::DeliveryService;
50 use Biblio::ILL::ISO::EDeliveryDetails;
51 use Biblio::ILL::ISO::ElectronicDeliveryService;
52 use Biblio::ILL::ISO::ElectronicDeliveryServiceSequence;
53 use Biblio::ILL::ISO::ENUMERATED;
54 use Biblio::ILL::ISO::ExpiryFlag;
55 use Biblio::ILL::ISO::Flag;
56 use Biblio::ILL::ISO::ILLServiceType;
57 use Biblio::ILL::ISO::ILLServiceTypeSequence;
58 use Biblio::ILL::ISO::ILLString;
59 use Biblio::ILL::ISO::ISODate;
60 use Biblio::ILL::ISO::ISOTime;
61 use Biblio::ILL::ISO::ItemId;
62 use Biblio::ILL::ISO::ItemType;
63 use Biblio::ILL::ISO::MediumType;
64 use Biblio::ILL::ISO::NameOfPersonOrInstitution;
65 use Biblio::ILL::ISO::PersonOrInstitutionSymbol;
66 use Biblio::ILL::ISO::PlaceOnHoldType;
67 use Biblio::ILL::ISO::PostalAddress;
68 use Biblio::ILL::ISO::Preference;
69 use Biblio::ILL::ISO::ProtocolVersionNum;
70 use Biblio::ILL::ISO::RequesterCHECKEDIN;
71 use Biblio::ILL::ISO::RequesterOptionalMessageType;
72 use Biblio::ILL::ISO::RequesterSHIPPED;
73 use Biblio::ILL::ISO::SearchType;
74 use Biblio::ILL::ISO::SendToListType;
75 use Biblio::ILL::ISO::SendToListTypeSequence;
76 use Biblio::ILL::ISO::SEQUENCE_OF;
77 use Biblio::ILL::ISO::ServiceDateTime;
78 use Biblio::ILL::ISO::SupplyMediumInfoType;
79 use Biblio::ILL::ISO::SupplyMediumInfoTypeSequence;
80 use Biblio::ILL::ISO::SupplyMediumType;
81 use Biblio::ILL::ISO::SystemAddress;
82 use Biblio::ILL::ISO::SystemId;
83 use Biblio::ILL::ISO::ThirdPartyInfoType;
84 use Biblio::ILL::ISO::TransactionId;
85 use Biblio::ILL::ISO::TransactionType;
86 use Biblio::ILL::ISO::TransportationMode;
87 # Extensions
88 use Biblio::ILL::ISO::Extension;
89 # Answer (new types)
90 use Biblio::ILL::ISO::ConditionalResults;
91 use Biblio::ILL::ISO::EstimateResults;
92 use Biblio::ILL::ISO::HoldPlacedResults;
93 use Biblio::ILL::ISO::LocationInfo;
94 use Biblio::ILL::ISO::LocationsResults;
95 use Biblio::ILL::ISO::ResponderOptionalMessageType;
96 use Biblio::ILL::ISO::ResponderRECEIVED;
97 use Biblio::ILL::ISO::ResponderRETURNED;
98 use Biblio::ILL::ISO::ResultsExplanation;
99 use Biblio::ILL::ISO::RetryResults;
100 use Biblio::ILL::ISO::TransactionResults;
101 use Biblio::ILL::ISO::UnfilledResults;
102 use Biblio::ILL::ISO::WillSupplyResults;
103  
104 # Forward-Notification (new types)
105 # -- none
106  
107 # Shipped (new types)
108 use Biblio::ILL::ISO::DateDue;
109 use Biblio::ILL::ISO::ShippedConditions;
110 use Biblio::ILL::ISO::ShippedServiceType;
111 use Biblio::ILL::ISO::ShippedVia;
112 use Biblio::ILL::ISO::SupplyDetails;
113 use Biblio::ILL::ISO::UnitsPerMediumType;
114 use Biblio::ILL::ISO::UnitsPerMediumTypeSequence;
115  
116 # Conditional-Reply (new types)
117 # -- none
118  
119 # Cancel (new types)
120 # -- none
121  
122 # Cancel-Reply (new types)
123 # -- none
124  
125 # Received (new types)
126 # External, so not defined:
127 # use Biblio::ILL::ISO::SupplementalItemDescription;
128  
129 # Recall (new types)
130 # -- none
131  
132 # Returned (new types)
133 # -- none
134  
135 # Checked-In (new types)
136 # -- none
137  
138 # Overdue (new types)
139 # -- none
140  
141 # Renew (new types)
142 # -- none
143  
144 # Renew-Answer (new types)
145 # -- none
146  
147 # Lost (new types)
148 # -- none
149  
150 # Damaged (new types)
151 # Currently unsupported:
152 # use Biblio::ILL::ISO::DamagedDetails;
153  
154 # Message (new types)
155 # -- none
156  
157 # Status-Query (new types)
158 # -- none
159  
160 # Status-Or-Error-Report (new types)
161 use Biblio::ILL::ISO::ReasonNoReport;
162 use Biblio::ILL::ISO::MostRecentService;
163 use Biblio::ILL::ISO::CurrentState;
164 use Biblio::ILL::ISO::HistoryReport;
165 use Biblio::ILL::ISO::StatusReport;
166 use Biblio::ILL::ISO::ErrorReport;
167 use Biblio::ILL::ISO::ReportSource;
168 use Biblio::ILL::ISO::AlreadyForwarded;
169 use Biblio::ILL::ISO::IntermediaryProblem;
170 use Biblio::ILL::ISO::SecurityProblem;
171 use Biblio::ILL::ISO::UnableToPerform;
172 use Biblio::ILL::ISO::UserErrorReport;
173 use Biblio::ILL::ISO::GeneralProblem;
174 use Biblio::ILL::ISO::TransactionIdProblem;
175 use Biblio::ILL::ISO::ILLAPDUtype;
176 use Biblio::ILL::ISO::StateTransitionProhibited;
177 use Biblio::ILL::ISO::ProviderErrorReport;
178  
179 # Expired (new types)
180 # -- none
181  
182  
183 my %hsh = ();
184 my $obj;
185 my $obj2;
186  
187 $hsh{"01.ILLString"} = new Biblio::ILL::ISO::ILLString("A string");
188 $hsh{"02.AccountNumber"} = new Biblio::ILL::ISO::AccountNumber("1234567890");
189 $hsh{"03.PersonOrInstitutionSymbol"} = new Biblio::ILL::ISO::PersonOrInstitutionSymbol("MWPL");
190 $hsh{"04.NameOfPersonOrInstitution"} = new Biblio::ILL::ISO::NameOfPersonOrInstitution("Manitoba Public Library Services");
191  
192 $hsh{"05.SystemId"} = new Biblio::ILL::ISO::SystemId();
193 $hsh{"05.SystemId"}->set_person_name("David A. Christensen");
194 $hsh{"05.SystemId"}->set_institution_symbol("MWPL");
195  
196 $hsh{"06.AlreadyTriedListType"} = new Biblio::ILL::ISO::AlreadyTriedListType( new Biblio::ILL::ISO::SystemId("BVAS") );
197 $obj = new Biblio::ILL::ISO::SystemId();
198 $obj->set_institution_name("Winnipeg Public Library");
199 $hsh{"06.AlreadyTriedListType"}->add($obj);
200 $obj = new Biblio::ILL::ISO::SystemId();
201 $obj->set_person_name("Frank Emil Urwald");
202 $hsh{"06.AlreadyTriedListType"}->add($obj);
203 $hsh{"06.AlreadyTriedListType"}->add( new Biblio::ILL::ISO::SystemId("MBOM"));
204  
205 $hsh{"07.AmountString"} = new Biblio::ILL::ISO::AmountString("\$123.45");
206 $hsh{"08.Amount"} = new Biblio::ILL::ISO::Amount("\$67.89","CAD");
207 $hsh{"09.ClientId"} = new Biblio::ILL::ISO::ClientId("David Christensen","Most excellent","007");
208  
209 $hsh{"10.CostInfoType"} = new Biblio::ILL::ISO::CostInfoType("","","","PLS001","\$40.00");
210 $hsh{"11.PostalAddress"} = new Biblio::ILL::ISO::PostalAddress("Manitoba Public Library Services",
211 "",
212 "Unit 200",
213 "1525 First Street South",
214 "",
215 "Brandon",
216 "MB",
217 "CANADA",
218 "R7A 7A1"
219 );
220 $hsh{"12.SystemAddress"} = new Biblio::ILL::ISO::SystemAddress("SMTP","DChristensen\@westman.wave.ca");
221  
222 $hsh{"13.DeliveryAddress"} = new Biblio::ILL::ISO::DeliveryAddress( new Biblio::ILL::ISO::SystemAddress("SMTP","DChristens\@gov.mb.ca"),
223 new Biblio::ILL::ISO::PostalAddress("Manitoba Public Library Services",
224 "",
225 "Unit 200",
226 "1525 First Street South",
227 "",
228 "Brandon",
229 "MB",
230 "CANADA",
231 "R7A 7A1"
232 )
233 );
234  
235 $obj = new Biblio::ILL::ISO::EDeliveryDetails( new Biblio::ILL::ISO::SystemAddress("SMTP","bob\@hope.com") );
236 $hsh{"14.ElectronicDeliveryService"} = new Biblio::ILL::ISO::ElectronicDeliveryService($obj);
237 $hsh{"14.ElectronicDeliveryService"}->set_description("Just a dummy");
238 $hsh{"14.ElectronicDeliveryService"}->set_name_or_code("MSG ID: 1001");
239 $hsh{"14.ElectronicDeliveryService"}->set_delivery_time("235959");
240  
241 $hsh{"15.ILLServiceTypeSequence"} = new Biblio::ILL::ISO::ILLServiceTypeSequence( new Biblio::ILL::ISO::ILLServiceType("loan"),
242 new Biblio::ILL::ISO::ILLServiceType("copy-non-returnable")
243 );
244 $hsh{"15.ILLServiceTypeSequence"}->add(new Biblio::ILL::ISO::ILLServiceType("locations"));
245  
246 $hsh{"16.ItemType"} = new Biblio::ILL::ISO::ItemType("monograph");
247 $hsh{"17.MediumType"} = new Biblio::ILL::ISO::MediumType("printed");
248  
249 $hsh{"18.ItemId"} = new Biblio::ILL::ISO::ItemId("My Book","David Christensen","CHR001.1");
250 $hsh{"18.ItemId"}->set_item_type("monograph");
251 $hsh{"18.ItemId"}->set_medium_type("printed");
252 $hsh{"18.ItemId"}->set_pagination("456");
253 $hsh{"18.ItemId"}->set_publication_date("2003");
254  
255 $hsh{"19.RequesterOptionalMessageType"} = new Biblio::ILL::ISO::RequesterOptionalMessageType(1,1,"desires","requires");
256 $hsh{"20.SearchType"} = new Biblio::ILL::ISO::SearchType("no-Expiry","1","","20030720");
257  
258 $hsh{"21.SendToListTypeSequence"} = new Biblio::ILL::ISO::SendToListTypeSequence( new Biblio::ILL::ISO::SendToListType( new Biblio::ILL::ISO::SystemId("MBOM") ));
259 $hsh{"21.SendToListTypeSequence"}->add(new Biblio::ILL::ISO::SendToListType( new Biblio::ILL::ISO::SystemId("MWPL"),
260 new Biblio::ILL::ISO::AccountNumber("PLS001"),
261 new Biblio::ILL::ISO::SystemAddress("SMTP","pls\@gov.mb.ca")
262 )
263 );
264  
265 $hsh{"22.ServiceDateTime.01"} = new Biblio::ILL::ISO::ServiceDateTime( new Biblio::ILL::ISO::DateTime("20030623") );
266 $hsh{"23.ServiceDateTime.02"} = new Biblio::ILL::ISO::ServiceDateTime( new Biblio::ILL::ISO::DateTime("20030623","114400"),
267 new Biblio::ILL::ISO::DateTime("20030623","114015")
268 );
269  
270 $hsh{"24.SupplyMediumInfoType"} = new Biblio::ILL::ISO::SupplyMediumInfoType("photocopy","legal-size paper");
271  
272 $hsh{"25.ThirdPartyInfoType.01"} = new Biblio::ILL::ISO::ThirdPartyInfoType();
273 $hsh{"26.ThirdPartyInfoType.02"} = new Biblio::ILL::ISO::ThirdPartyInfoType(1,1,1,1,"ordered",
274 new Biblio::ILL::ISO::SystemAddress("SMTP","David_A_Christensen\@hotmail.com"),
275 $hsh{"21.SendToListTypeSequence"},
276 $hsh{"06.AlreadyTriedListType"}
277 );
278  
279 $hsh{"27.TransactionId"} = new Biblio::ILL::ISO::TransactionId("PLS","001","", new Biblio::ILL::ISO::SystemId("MWPL"));
280  
281 $hsh{"28.DeliveryService.01"} = new Biblio::ILL::ISO::DeliveryService( new Biblio::ILL::ISO::TransportationMode("Canada Post") );
282 $hsh{"29.DeliveryService.02"} = new Biblio::ILL::ISO::ElectronicDeliveryServiceSequence( $hsh{"14.ElectronicDeliveryService"});
283 $obj = new Biblio::ILL::ISO::ElectronicDeliveryService( new Biblio::ILL::ISO::EDeliveryDetails( new Biblio::ILL::ISO::SystemAddress("SMTP","david\@alnitak.cxm")));
284 $obj->set_description("Another dummy");
285 $obj->set_name_or_code("MSG ID: 1002");
286 $obj->set_delivery_time("083000");
287 $hsh{"29.DeliveryService.02"}->add( $obj );
288  
289 # Answer types (those not covered by Request, anyway).
290  
291 $hsh{"30.TransactionResults"} = new Biblio::ILL::ISO::TransactionResults("will-supply");
292 $hsh{"31.ConditionalResultsCondition"} = new Biblio::ILL::ISO::ConditionalResultsCondition("library-use-only");
293  
294 $obj = new Biblio::ILL::ISO::SystemId();
295 $obj->set_person_name("David A. Christensen");
296 $obj->set_institution_symbol("MWPL");
297 $hsh{"32.LocationInfo"} = new Biblio::ILL::ISO::LocationInfo($obj,
298 new Biblio::ILL::ISO::SystemAddress("SMTP","DChristensen\@westman.wave.ca"),
299 new Biblio::ILL::ISO::ILLString("This is a location note.")
300 );
301  
302 $hsh{"33.LocationInfoSequence"} = new Biblio::ILL::ISO::LocationInfoSequence( $hsh{"32.LocationInfo"} );
303 $obj = new Biblio::ILL::ISO::SystemId();
304 $obj->set_institution_name("Brandon Public Library");
305 $obj2 = new Biblio::ILL::ISO::LocationInfo($obj, new Biblio::ILL::ISO::SystemAddress("SMTP","library\@brandon.mb.ca") );
306 $hsh{"33.LocationInfoSequence"}->add($obj2);
307  
308 $hsh{"34.ConditionalResults"} = new Biblio::ILL::ISO::ConditionalResults(new Biblio::ILL::ISO::ConditionalResultsCondition("charges"),
309 new Biblio::ILL::ISO::ISODate("20030727"),
310 $hsh{"33.LocationInfoSequence"},
311 new Biblio::ILL::ISO::DeliveryService( new Biblio::ILL::ISO::TransportationMode("Canada Post") )
312 );
313  
314  
315 $hsh{"35.RetryResults"} = new Biblio::ILL::ISO::RetryResults(new Biblio::ILL::ISO::ReasonNotAvailable("in-use-on-loan"),
316 new Biblio::ILL::ISO::ISODate("20030731"),
317 $hsh{"33.LocationInfoSequence"}
318 );
319 $hsh{"36.UnfilledResults"} = new Biblio::ILL::ISO::UnfilledResults(new Biblio::ILL::ISO::ReasonUnfilled("lost"),
320 $hsh{"33.LocationInfoSequence"}
321 );
322 $hsh{"37.LocationsResults"} = new Biblio::ILL::ISO::LocationsResults(new Biblio::ILL::ISO::ReasonLocsProvided("not-owned"),
323 $hsh{"33.LocationInfoSequence"}
324 );
325 $hsh{"38.WillSupplyResults"} = new Biblio::ILL::ISO::WillSupplyResults(new Biblio::ILL::ISO::ReasonWillSupply("at-bindery"),
326 new Biblio::ILL::ISO::ISODate("20030729"),
327 $hsh{"11.PostalAddress"},
328 $hsh{"33.LocationInfoSequence"}
329 );
330 $hsh{"39.HoldPlacedResults"} = new Biblio::ILL::ISO::HoldPlacedResults(new Biblio::ILL::ISO::ISODate("20030730"),
331 new Biblio::ILL::ISO::MediumType("printed"),
332 $hsh{"33.LocationInfoSequence"}
333 );
334 $hsh{"40.EstimateResults"} = new Biblio::ILL::ISO::EstimateResults(new Biblio::ILL::ISO::ILLString("56.78"),
335 $hsh{"33.LocationInfoSequence"}
336 );
337  
338 $hsh{"41.ResponderOptionalMessage"} = new Biblio::ILL::ISO::ResponderOptionalMessageType(1,1,"desires","requires");
339  
340 # Shipped types
341 $hsh{"42.DateDue"} = new Biblio::ILL::ISO::DateDue("20030813","false");
342 $hsh{"43.ShippedConditions"} = new Biblio::ILL::ISO::ShippedConditions("client-signature-required");
343 $hsh{"44.ShippedServiceType"} = new Biblio::ILL::ISO::ShippedServiceType("loan");
344 $hsh{"45.ShippedVia"} = new Biblio::ILL::ISO::ShippedVia( new Biblio::ILL::ISO::TransportationMode("Canada Post") );
345 $hsh{"46.UnitsPerMediumType"} = new Biblio::ILL::ISO::UnitsPerMediumType( new Biblio::ILL::ISO::SupplyMediumType("audio-recording"), 3);
346 $hsh{"47.SupplyDetails"} = new Biblio::ILL::ISO::SupplyDetails("20030813",
347 "20030920",
348 123,
349 "45.67",
350 new Biblio::ILL::ISO::ShippedConditions("no-reproduction"),
351 $hsh{"45.ShippedVia"},
352 new Biblio::ILL::ISO::Amount("50.00"),
353 "50.00",
354 new Biblio::ILL::ISO::UnitsPerMediumTypeSequence( $hsh{"46.UnitsPerMediumType"} )
355 );
356  
357 # Status-Or-Error-Report
358 $hsh{"48.ReasonNoReport"} = new Biblio::ILL::ISO::ReasonNoReport("permanent");
359 $hsh{"49.MostRecentService"} = new Biblio::ILL::ISO::MostRecentService("sTATUS-QUERY");
360 $hsh{"50.CurrentState"} = new Biblio::ILL::ISO::CurrentState("sHIPPED");
361 $hsh{"51.HistoryReport"} = new Biblio::ILL::ISO::HistoryReport("20030811",
362 "fORWARD",
363 "20030813",
364 $hsh{"05.SystemId"},
365 "20030815",
366 "Anne Author",
367 "A Title",
368 "",
369 "",
370 "loan",
371 $hsh{"30.TransactionResults"},
372 "This is a history report."
373 );
374 $hsh{"52.StatusReport"} = new Biblio::ILL::ISO::StatusReport($hsh{"51.HistoryReport"},
375 $hsh{"50.CurrentState"}
376 );
377 $hsh{"53.ProviderErrorReport"} = new Biblio::ILL::ISO::ProviderErrorReport( new Biblio::ILL::ISO::TransactionIdProblem("duplicate-transaction-id") );
378 $hsh{"54.ErrorReport"} = new Biblio::ILL::ISO::ErrorReport("Some correlation information",
379 "provider",
380 $hsh{"53.ProviderErrorReport"}
381 );
382 $hsh{"55.AlreadyForwarded"} = new Biblio::ILL::ISO::AlreadyForwarded($hsh{"05.SystemId"},
383 $hsh{"12.SystemAddress"}
384 );
385 $hsh{"56.IntermediaryProblem"} = new Biblio::ILL::ISO::IntermediaryProblem("cannot-send-onward");
386 $hsh{"57.SecurityProblem"} = new Biblio::ILL::ISO::SecurityProblem("This is a security problem.");
387 $hsh{"58.UnableToPerform"} = new Biblio::ILL::ISO::UnableToPerform("resource-limitation");
388 $hsh{"59.UserErrorReport"} = new Biblio::ILL::ISO::UserErrorReport($hsh{"57.SecurityProblem"});
389 $hsh{"60.GeneralProblem"} = new Biblio::ILL::ISO::GeneralProblem("protocol-version-not-supported");
390 $hsh{"61.ILLAPDUtype"} = new Biblio::ILL::ISO::ILLAPDUtype("eXPIRED");
391 $hsh{"62.StateTransitionProhibited"} = new Biblio::ILL::ISO::StateTransitionProhibited($hsh{"61.ILLAPDUtype"},
392 $hsh{"50.CurrentState"}
393 );
394  
395 #print "\n---------\n";
396 foreach my $key (sort keys %hsh) {
397 #print "\n[$key]\n" . $hsh{$key}->as_pretty_string();
398 open( OUT, ">t/types_$key" );
399 print OUT Dumper( $hsh{$key} );
400 close( OUT );
401 }
402  
403