1 package org.kuali.ole.docstore.document.jcr;
2
3 import org.junit.*;
4 import org.kuali.ole.BaseTestCase;
5 import org.kuali.ole.RepositoryBrowser;
6 import org.kuali.ole.RepositoryManager;
7 import org.kuali.ole.docstore.OleDocStoreException;
8 import org.kuali.ole.docstore.common.document.content.instance.*;
9 import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
10 import org.kuali.ole.docstore.common.document.content.instance.xstream.InstanceOlemlRecordProcessor;
11 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
12 import org.kuali.ole.docstore.document.DocumentManager;
13 import org.kuali.ole.docstore.model.enums.DocCategory;
14 import org.kuali.ole.docstore.model.enums.DocFormat;
15 import org.kuali.ole.docstore.model.enums.DocType;
16 import org.kuali.ole.docstore.model.xmlpojo.ingest.Content;
17 import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
18 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
19 import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument;
20 import org.kuali.ole.docstore.service.BeanLocator;
21 import org.kuali.ole.docstore.transaction.TransactionManager;
22 import org.kuali.ole.pojo.OleException;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import javax.jcr.*;
27 import java.io.FileNotFoundException;
28 import java.util.*;
29
30
31
32
33
34
35
36
37 @Ignore
38 @Deprecated
39 public class JcrWorkInstanceDocumentManager_UT extends BaseTestCase {
40 private static final Logger LOG = LoggerFactory
41 .getLogger(JcrWorkInstanceDocumentManager_UT.class);
42
43 Session session = null;
44 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
45
46
47 @Override
48 @Before
49 public void setUp() throws Exception {
50 if (null == session) {
51 session = RepositoryManager.getRepositoryManager().getSession("chuntley", "ingestDoc");
52 }
53 }
54
55 @After
56 public void tearDown() throws Exception {
57 if (session != null) {
58 session.logout();
59 session = null;
60 }
61
62
63 }
64
65 @Test
66 public void testHoldingsCallNumberValidations() throws Exception {
67 testHoldingsCreateCallNumberValidations();
68 testHoldingsUpdateCallNumberValidations();
69 }
70
71 @Test
72 public void testItemCallNumberValidations() throws Exception {
73 testItemCreateCallNumberValidations();
74 testItemUpdateCallNumberValidations();
75 }
76
77 @Test
78 public void testHoldingsShelvingOrderComputation() throws Exception {
79 holdingsCreateShelvingOrderComputation();
80 }
81
82 @Test
83 public void testHoldingsUpdateShelvingOrderComputation() throws Exception {
84 holdingsUpdateShelvingOrderComputation();
85 }
86
87 @Test
88 public void testItemShelvingOrderComputationWithHoldingsCallNumInfo() throws Exception {
89
90 ingestNUpdateItemWithHolCallNumberInfo("E461 .C58", "LCC");
91 ingestNUpdateItemWithHolCallNumberInfo("E461 .C59", "LCC");
92 ingestNUpdateItemWithHolCallNumberInfo("E461 .C60", "LCC");
93 ingestNUpdateItemWithHolCallNumberInfo("E461 .C61", "LCC");
94
95 ingestItemWithHoldingsCallNumberInfo("E461 .C62", "LCC", "v.1", "1996");
96 ingestItemWithHoldingsCallNumberInfo("E461 .C63", "LCC", "v.1", "1996");
97 ingestItemWithHoldingsCallNumberInfo("E461 .C64", "LCC", "v.1", "1996");
98 ingestItemWithHoldingsCallNumberInfo("E461 .C65", "LCC", "v.1", "1996");
99 }
100
101 private void ingestItemWithHoldingsCallNumberInfo(String callNum, String shelvingScheme, String eNum, String chronology) throws Exception {
102 RequestDocument requestDocument = buildInstanceRequestDocumentWithCallNumber(callNum, shelvingScheme, null, eNum, chronology);
103 ResponseDocument responseDocument = ingestTestData(requestDocument);
104
105 String instanceId = responseDocument.getUuid();
106 Instance instance = retriveInstanceData(instanceId);
107 OleHoldings holdings = instance.getOleHoldings();
108 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
109
110 verifyHoldingsNItemShelvingScheme(holdings, item);
111 Assert.assertNotSame("shelving order full value is same for both holdings and item ",
112 holdings.getCallNumber().getShelvingOrder().getFullValue(), item.getCallNumber().getShelvingOrder().getFullValue());
113
114 }
115
116 private void verifyHoldingsNItemShelvingScheme(OleHoldings holdings, org.kuali.ole.docstore.common.document.content.instance.Item item) throws OleDocStoreException {
117 Assert.assertNotNull(holdings.getCallNumber().getNumber());
118 Assert.assertNotNull(holdings.getCallNumber().getShelvingScheme().getCodeValue());
119 Assert.assertNotNull(holdings.getCallNumber().getShelvingOrder().getFullValue());
120 String holShelOrder = holdings.getCallNumber().getShelvingOrder().getFullValue();
121 LOG.debug("holShelOrder " + holShelOrder);
122
123 Assert.assertNull(item.getCallNumber().getNumber());
124 Assert.assertNull(item.getCallNumber().getShelvingScheme());
125 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
126 String itemShelOrder = item.getCallNumber().getShelvingOrder().getFullValue();
127 LOG.debug("itemShelOrder " + itemShelOrder);
128 }
129
130
131 private void ingestNUpdateItemWithHolCallNumberInfo(String callNum, String shelvingScheme) throws Exception {
132 cleanRepository("work", DocType.BIB.getDescription());
133 cleanRepository("work", DocType.INSTANCE.getDescription());
134 RequestDocument requestDocument = buildInstanceRequestDocumentWithCallNumber(callNum, shelvingScheme, null, null, null);
135 ResponseDocument responseDocument = ingestTestData(requestDocument);
136
137 String instanceId = responseDocument.getUuid();
138 Instance instance = retriveInstanceData(instanceId);
139 OleHoldings holdings = instance.getOleHoldings();
140 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
141 verifyHoldingsNItemShelvingScheme(holdings, item);
142 Assert.assertEquals("shelving order full value is same for both holdings and item ",
143 holdings.getCallNumber().getShelvingOrder().getFullValue(), item.getCallNumber().getShelvingOrder().getFullValue());
144
145
146 RequestDocument itemReq = buildItemCheckinDocumentWithCallNumber(item, null, null, null, "v.1", "1996", null);
147 org.kuali.ole.docstore.common.document.content.instance.Item updatedItem = updateItem(itemReq);
148 String updatedShelOrder = updatedItem.getCallNumber().getShelvingOrder().getFullValue();
149 Assert.assertNotNull(updatedShelOrder);
150 LOG.debug("updatedShelOrder" + updatedShelOrder);
151 }
152
153
154 @Test
155 public void testItemShelvingOrderComputation() throws Exception {
156
157 RequestDocument requestDocument = buildInstanceItemIngestDocumentWithCallNumber(null, null, null, null, null, null, null, null, null);
158 Instance instance = createInstance(requestDocument);
159
160 itemCreateWithInstanceShelvingOrderComputation();
161 itemCreateWithoutInstanceShelvingOrderComputation(instance.getInstanceIdentifier());
162 itemUpdateShelvingOrderComputation();
163
164
165 }
166
167 @Test
168 public void addMultipleItemsToInstanceNUpdateHoldings() throws Exception {
169
170 String callNumber = "DK602.3 .P44 1996";
171 String shelvingScheme = "LCC";
172
173 RequestDocument requestDocument = buildInstanceItemIngestDocumentWithCallNumber(callNumber, shelvingScheme, null, null, null, null, null, null, null);
174
175 Instance instance = createInstance(requestDocument);
176 String item1Uuid = instance.getItems().getItem().get(0).getItemIdentifier();
177 String so1 = instance.getItems().getItem().get(0).getCallNumber().getShelvingOrder().getFullValue();
178
179
180 RequestDocument itemReqDoc1 = buildAddItemToInstance(instance.getInstanceIdentifier(), "QS 11 c815a 1930", "NML", null, "v.5", "2013", "cp.5");
181 org.kuali.ole.docstore.common.document.content.instance.Item item = addItemToInstance(itemReqDoc1);
182 String item2Uuid = item.getItemIdentifier();
183 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
184 String so2 = item.getCallNumber().getShelvingOrder().getFullValue();
185
186
187 RequestDocument itemReqDoc2 = buildAddItemToInstance(instance.getInstanceIdentifier(), "P145.6.T5 S321 1981", "LCC", null, "v.6", "2013", "cp.6");
188 item = addItemToInstance(itemReqDoc2);
189 String item3Uuid = item.getItemIdentifier();
190 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
191 String so3 = item.getCallNumber().getShelvingOrder().getFullValue();
192
193 callNumber = "PQ145.6.T5 S4 1976";
194
195
196 RequestDocument holdingsReqDoc1 = buildHoldingsCheckinDocumentWithCallNumber(instance.getOleHoldings(), callNumber, shelvingScheme, null);
197 OleHoldings oleHoldings1 = updateHoldings(holdingsReqDoc1);
198
199
200 JcrWorkInstanceDocumentManager jcrWorkInstanceDocumentManager = (JcrWorkInstanceDocumentManager) BeanLocator.getDocumentManagerFactory().getDocumentManager(requestDocument);
201 org.kuali.ole.docstore.common.document.content.instance.Item item1 = checkOutItem(item1Uuid, jcrWorkInstanceDocumentManager);
202 Assert.assertNotNull(item1.getItemIdentifier());
203 Assert.assertNotNull(item1.getCallNumber().getShelvingOrder().getFullValue());
204 Assert.assertEquals("", item1.getCallNumber().getNumber());
205 Assert.assertEquals("", item1.getCallNumber().getShelvingScheme().getCodeValue());
206 Assert.assertNotSame(so1, item1.getCallNumber().getShelvingOrder().getFullValue());
207
208 org.kuali.ole.docstore.common.document.content.instance.Item item2 = checkOutItem(item2Uuid, jcrWorkInstanceDocumentManager);
209 Assert.assertNotNull(item2.getItemIdentifier());
210 Assert.assertNotNull(item2.getCallNumber().getShelvingOrder().getFullValue());
211 Assert.assertEquals("", item2.getCallNumber().getNumber());
212 Assert.assertEquals("", item2.getCallNumber().getShelvingScheme().getCodeValue());
213 Assert.assertNotSame(so2, item2.getCallNumber().getShelvingOrder().getFullValue());
214
215 org.kuali.ole.docstore.common.document.content.instance.Item item3 = checkOutItem(item3Uuid, jcrWorkInstanceDocumentManager);
216 Assert.assertNotNull(item3.getItemIdentifier());
217 Assert.assertNotNull(item3.getCallNumber().getShelvingOrder().getFullValue());
218 Assert.assertEquals("", item3.getCallNumber().getNumber());
219 Assert.assertEquals("", item3.getCallNumber().getShelvingScheme().getCodeValue());
220 Assert.assertNotSame(so3, item3.getCallNumber().getShelvingOrder().getFullValue());
221
222 }
223
224
225 private void testHoldingsCreateCallNumberValidations() throws Exception {
226
227
228 RequestDocument requestDocument = buildInstanceRequestDocumentWithCallNumber("DK602 .P44 1901", "LCC", "DK 0602.000000 P0.440000 ", null, null);
229 ResponseDocument responseDocument = new ResponseDocument();
230 responseDocument = ingestDocument(requestDocument);
231
232
233 Assert.assertNotNull(responseDocument.getStatusMessage());
234
235
236
237
238
239 RequestDocument requestDocument1 = buildInstanceRequestDocumentWithCallNumber(null, "LCC", "DK 0602.000000 P0.440000 001901", null, null);
240
241
242 ResponseDocument responseDocument1 = ingestDocument(requestDocument1);
243 Assert.assertNotNull(responseDocument1.getStatusMessage());
244
245
246
247
248 RequestDocument requestDocument2 = buildInstanceRequestDocumentWithCallNumber(null, null, "LCC", null, null);
249
250 ResponseDocument responseDocument2 = ingestDocument(requestDocument2);
251 Assert.assertNotNull(responseDocument2.getStatusMessage());
252
253
254
255
256 RequestDocument requestDocument3 = buildInstanceRequestDocumentWithCallNumber(null, null, null, null, null);
257 ResponseDocument responseDocument3 = ingestDocument(requestDocument3);
258 Assert.assertNotNull(responseDocument3.getStatusMessage());
259
260
261
262
263 RequestDocument requestDocument4 = buildInstanceRequestDocumentWithCallNumber(null, "LCC", null, null, null);
264
265 ResponseDocument responseDocument4 = ingestDocument(requestDocument4);
266 Assert.assertNotNull(responseDocument4.getStatusMessage());
267
268
269
270
271 RequestDocument requestDocument5 = buildInstanceRequestDocumentWithCallNumber("DK602 .P44 1901", null, null, null, null);
272
273 ResponseDocument responseDocument5 = ingestDocument(requestDocument5);
274 Assert.assertNotNull(responseDocument5.getStatusMessage());
275 Assert.assertEquals(responseDocument5.getStatusMessage(), "Please enter valid shelving scheme value in call number information ");
276
277
278
279
280 RequestDocument requestDocument6 = buildInstanceRequestDocumentWithCallNumber("DK602 .P44 1901", null, "shelvingOrderCode", null, null);
281
282 ResponseDocument responseDocument6 = ingestDocument(requestDocument6);
283 Assert.assertNotNull(responseDocument6.getStatusMessage());
284 Assert.assertEquals(responseDocument6.getStatusMessage(), "Please enter valid shelving scheme value in call number information ");
285
286
287
288
289 RequestDocument requestDocument7 = buildInstanceRequestDocumentWithCallNumber("DK602 .P44 1901", "LCC", null, null, null);
290
291 ResponseDocument responseDocument7 = ingestDocument(requestDocument7);
292 Assert.assertNotNull(responseDocument7.getStatusMessage());
293
294
295 }
296
297 private void testHoldingsUpdateCallNumberValidations() throws Exception {
298 RequestDocument instanceReqDoc = buildInstanceItemIngestDocumentWithCallNumber(null, null, null);
299 Instance instance = createInstance(instanceReqDoc);
300 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
301
302
303 RequestDocument holdingsReqDoc1 = buildHoldingsCheckinDocumentWithCallNumber(instance.getOleHoldings(), null, null, null);
304
305 OleHoldings oleHoldings1 = updateHoldings(holdingsReqDoc1);
306
307 Assert.assertNotNull(oleHoldings1.getCallNumber().getShelvingOrder());
308
309
310
311 RequestDocument holdingsReqDoc2 = buildHoldingsCheckinDocumentWithCallNumber(oleHoldings1, "P145.6.T5 S321 1981", "LCC", null);
312
313 OleHoldings oleHoldings2 = updateHoldings(holdingsReqDoc2);
314
315 Assert.assertNotNull(oleHoldings2.getCallNumber().getShelvingOrder());
316
317
318
319
320 RequestDocument holdingsReqDoc3 = buildHoldingsCheckinDocumentWithCallNumber(oleHoldings2, "P145.6.T5 S321 1981", "LCC", "so1");
321
322 OleHoldings oleHoldings3 = updateHoldings(holdingsReqDoc3);
323
324 Assert.assertNotSame(oleHoldings2.getCallNumber().getShelvingOrder(), oleHoldings3.getCallNumber().getShelvingOrder());
325
326
327 }
328
329
330 private void testItemCreateCallNumberValidations() throws Exception {
331
332
333
334 RequestDocument requestDocument = buildRequestDocumentWithCallNumberForItem("DK602 .P44 1901", "LCC", "DK 0602.300000 P0.440000 001996");
335
336
337 ResponseDocument responseDocument = ingestDocument(requestDocument);
338 Assert.assertNotNull(responseDocument.getStatusMessage());
339
340
341
342
343 RequestDocument requestDocument1 = buildRequestDocumentWithCallNumberForItem(null, "LCC", "DK 0602.300000 P0.440000 001996");
344
345
346 ResponseDocument responseDocument1 = ingestDocument(requestDocument1);
347 Assert.assertNotNull(responseDocument1.getStatusMessage());
348
349
350
351 RequestDocument requestDocument2 = buildRequestDocumentWithCallNumberForItem(null, null, "DK 0602.300000 P0.440000 001996");
352
353 ResponseDocument responseDocument2 = ingestDocument(requestDocument2);
354 Assert.assertNotNull(responseDocument2.getStatusMessage());
355
356
357
358
359 RequestDocument requestDocument3 = buildRequestDocumentWithCallNumberForItem(null, null, null);
360 ResponseDocument responseDocument3 = ingestDocument(requestDocument3);
361 Assert.assertNotNull(responseDocument3.getStatusMessage());
362
363
364
365
366 RequestDocument requestDocument4 = buildRequestDocumentWithCallNumberForItem(null, "LCC", null);
367
368 ResponseDocument responseDocument4 = ingestDocument(requestDocument4);
369 Assert.assertNotNull(responseDocument4.getStatusMessage());
370
371
372
373 RequestDocument requestDocument5 = buildRequestDocumentWithCallNumberForItem("DK602 .P44 1901", null, null);
374
375 ResponseDocument responseDocument5 = ingestDocument(requestDocument5);
376 Assert.assertNotNull(responseDocument5.getStatusMessage());
377 Assert.assertEquals(responseDocument5.getStatusMessage(), "Please enter valid shelving scheme value in call number information ");
378
379
380
381 RequestDocument requestDocument6 = buildRequestDocumentWithCallNumberForItem("DK602 .P44 1901", null, "DK 0602.300000 P0.440000 001996");
382
383 ResponseDocument responseDocument6 = ingestDocument(requestDocument6);
384 Assert.assertNotNull(responseDocument6.getStatusMessage());
385 Assert.assertEquals(responseDocument6.getStatusMessage(), "Please enter valid shelving scheme value in call number information ");
386
387
388
389
390 RequestDocument requestDocument7 = buildRequestDocumentWithCallNumberForItem("DK602 .P44 1901", "LCC", null);
391
392 ResponseDocument responseDocument7 = ingestDocument(requestDocument7);
393 Assert.assertNotNull(responseDocument7.getStatusMessage());
394
395
396 }
397
398
399 private void testItemUpdateCallNumberValidations() throws Exception {
400 RequestDocument instanceReqDoc = buildInstanceItemIngestDocumentWithCallNumber(null, null, null);
401 Instance instance = createInstance(instanceReqDoc);
402 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
403
404
405 RequestDocument itemReqDoc1 = buildItemCheckinDocumentWithCallNumber(item, null, null, null, null, null, null);
406
407 org.kuali.ole.docstore.common.document.content.instance.Item item1 = updateItem(itemReqDoc1);
408
409 Assert.assertNotNull(item1.getCallNumber().getShelvingOrder());
410
411
412
413 RequestDocument itemReqDoc2 = buildItemCheckinDocumentWithCallNumber(item1, "PQ145.T51 S4", "LCC", null, null, null, null);
414
415 org.kuali.ole.docstore.common.document.content.instance.Item item2 = updateItem(itemReqDoc2);
416
417 Assert.assertNotNull(item2.getCallNumber().getShelvingOrder().getFullValue());
418
419
420
421
422 RequestDocument itemReqDoc3 = buildItemCheckinDocumentWithCallNumber(item2, "PQ145.T51 S4", "LCC", "DK 0602.300000 P0.440000 001996", null, null, null);
423
424 org.kuali.ole.docstore.common.document.content.instance.Item item3 = updateItem(itemReqDoc3);
425
426 Assert.assertNotSame(item2.getCallNumber().getShelvingOrder(), item3.getCallNumber().getShelvingOrder());
427
428 }
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445 private RequestDocument buildInstanceRequestDocumentWithCallNumber(String callNumber, String shelvingScheme, String shelvingOrder, String eNum, String chronology) throws Exception {
446
447 List<Instance> instanceList = new ArrayList<Instance>();
448 OleHoldings oleHoldings = setHoldingCallNumberInformation(callNumber, shelvingScheme, shelvingOrder);
449
450 Instance instance = new Instance();
451 instance.setOleHoldings(oleHoldings);
452
453 org.kuali.ole.docstore.common.document.content.instance.Item item = new org.kuali.ole.docstore.common.document.content.instance.Item();
454 item.setEnumeration(eNum);
455 item.setChronology(chronology);
456 Items items = new Items();
457 items.setItem(Arrays.asList(item));
458 instance.setItems(items);
459 instanceList.add(instance);
460
461 InstanceCollection instanceCollection = new InstanceCollection();
462 instanceCollection.setInstance(instanceList);
463 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
464 String instanceContent = instProcessor.toXML(instanceCollection);
465 Content content = new Content();
466 content.setContent(instanceContent);
467 RequestDocument requestDocument = new RequestDocument();
468 requestDocument.setCategory(DocCategory.WORK.getCode());
469 requestDocument.setType(DocType.INSTANCE.getCode());
470 requestDocument.setFormat(DocFormat.OLEML.getCode());
471 requestDocument.setContent(content);
472 requestDocument.setUuid(UUID.randomUUID().toString());
473 return requestDocument;
474
475 }
476
477
478
479
480
481
482
483
484
485
486
487 private RequestDocument buildRequestDocumentWithCallNumberForItem(String callNumber, String shelvingScheme, String shelvingOrder) throws Exception {
488
489 List<Instance> instanceList = new ArrayList<Instance>();
490 org.kuali.ole.docstore.common.document.content.instance.Item item = new org.kuali.ole.docstore.common.document.content.instance.Item();
491 Items items = new Items();
492 List<org.kuali.ole.docstore.common.document.content.instance.Item> itemList = new ArrayList<org.kuali.ole.docstore.common.document.content.instance.Item>();
493
494 CallNumber callNumber1 = new CallNumber();
495 callNumber1.setNumber(callNumber);
496
497 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
498 shelvingScheme1.setCodeValue(shelvingScheme);
499
500 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
501 shelvingOrder1.setFullValue(shelvingOrder);
502
503 callNumber1.setShelvingScheme(shelvingScheme1);
504 callNumber1.setShelvingOrder(shelvingOrder1);
505 item.setCallNumber(callNumber1);
506
507 Instance instance = new Instance();
508 instance.setOleHoldings(setHoldingCallNumberInformation(null, null, null));
509 itemList.add(item);
510 items.setItem(itemList);
511 instance.setItems(items);
512 instanceList.add(instance);
513
514 InstanceCollection instanceCollection = new InstanceCollection();
515 instanceCollection.setInstance(instanceList);
516 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
517 String instanceContent = instProcessor.toXML(instanceCollection);
518 Content content = new Content();
519 content.setContent(instanceContent);
520 RequestDocument requestDocument = new RequestDocument();
521 requestDocument.setCategory(DocCategory.WORK.getCode());
522 requestDocument.setType(DocType.INSTANCE.getCode());
523 requestDocument.setFormat(DocFormat.OLEML.getCode());
524 requestDocument.setContent(content);
525
526
527 return requestDocument;
528
529 }
530
531
532
533
534
535
536
537
538
539 private ResponseDocument ingestDocument(RequestDocument requestDocument) throws Exception {
540
541 TransactionManager transactionManager = BeanLocator.getDocstoreFactory().getTransactionManager(requestDocument.getCategory(), requestDocument.getType(), requestDocument.getFormat());
542 List<RequestDocument> requestDocumentList = new ArrayList<RequestDocument>();
543 requestDocumentList.add(requestDocument);
544 transactionManager.startTransaction("testUser", "ingest");
545
546 ResponseDocument respDoc = new ResponseDocument();
547 try {
548 List<ResponseDocument> responseDocumentList = transactionManager.ingest(requestDocumentList);
549 transactionManager.commit();
550 respDoc = responseDocumentList.get(0);
551 } catch (Exception e) {
552 respDoc.setStatusMessage(e.getMessage());
553 }
554
555 return respDoc;
556 }
557
558
559
560
561
562
563
564
565 private OleHoldings updateHoldings(RequestDocument holdingsReqDoc) throws Exception {
566
567 JcrWorkInstanceDocumentManager jcrWorkInstanceDocumentManager = (JcrWorkInstanceDocumentManager) BeanLocator.getDocumentManagerFactory().getDocumentManager(holdingsReqDoc);
568
569 ResponseDocument checkInResponseDocument = checkInRequestDocument(holdingsReqDoc);
570
571 RequestDocument requestDocument = new RequestDocument();
572 requestDocument.setCategory(DocCategory.WORK.getCode());
573 requestDocument.setType(DocType.HOLDINGS.getCode());
574 requestDocument.setFormat(DocFormat.OLEML.getCode());
575 requestDocument.setUuid(checkInResponseDocument.getUuid());
576 ResponseDocument responseDocument = jcrWorkInstanceDocumentManager.checkout(requestDocument, session);
577 HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
578 OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(responseDocument.getContent().getContent());
579 return oleHoldings;
580 }
581
582 private ResponseDocument checkInRequestDocument(RequestDocument holdingsReqDoc) throws Exception {
583 TransactionManager transactionManager = BeanLocator.getDocstoreFactory().getTransactionManager(holdingsReqDoc.getCategory(), holdingsReqDoc.getType(), holdingsReqDoc.getFormat());
584 List<RequestDocument> requestDocumentList = new ArrayList<RequestDocument>();
585 requestDocumentList.add(holdingsReqDoc);
586 transactionManager.startTransaction("testUser", "checkIn");
587 List<ResponseDocument> responseDocumentList = transactionManager.checkIn(requestDocumentList);
588 transactionManager.commit();
589 return responseDocumentList.get(0);
590 }
591
592
593
594
595
596
597
598
599 private Instance createInstance(RequestDocument instanceReqDoc) throws Exception {
600 RepositoryBrowser repoBro = new RepositoryBrowser();
601 ResponseDocument respDoc = ingestDocument(instanceReqDoc);
602 Instance instance = retriveInstanceData(respDoc.getUuid());
603 return instance;
604 }
605
606 public void cleanRepository(String category, String type) throws OleException, RepositoryException {
607 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
608 Session session = repositoryManager.getSession("mockUser", "test");
609 Node rootNode = session.getRootNode();
610 Node catNode = rootNode.getNode(category);
611 Node typeNode = catNode.getNode(type);
612 for (Iterator<Node> typeiterator = typeNode.getNodes(); typeiterator.hasNext(); ) {
613 Node formatNode = typeiterator.next();
614 if (!formatNode.getName().equals("jcr:system")) {
615 formatNode.remove();
616 }
617 }
618 session.save();
619 repositoryManager.logout(session);
620 }
621
622
623
624
625
626
627
628
629
630
631 private RequestDocument buildInstanceItemIngestDocumentWithCallNumber(String callNumber, String shelvingScheme, String shelvingOrder) {
632 Items items = new Items();
633 List<org.kuali.ole.docstore.common.document.content.instance.Item> itemList = new ArrayList<org.kuali.ole.docstore.common.document.content.instance.Item>();
634
635 Instance instance = new Instance();
636 List<Instance> instanceList = new ArrayList<Instance>();
637 org.kuali.ole.docstore.common.document.content.instance.Item item = new org.kuali.ole.docstore.common.document.content.instance.Item();
638 CallNumber callNumber1 = new CallNumber();
639
640 callNumber1.setNumber(callNumber);
641
642 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
643 shelvingScheme1.setCodeValue(shelvingScheme);
644
645 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
646 shelvingOrder1.setFullValue(shelvingOrder);
647
648 callNumber1.setShelvingScheme(shelvingScheme1);
649 callNumber1.setShelvingOrder(shelvingOrder1);
650
651
652
653 item.setCallNumber(callNumber1);
654 itemList.add(item);
655 items.setItem(itemList);
656 instance.setItems(items);
657 instance.setOleHoldings(new OleHoldings());
658 instanceList.add(instance);
659
660 InstanceCollection instanceCollection = new InstanceCollection();
661 instanceCollection.setInstance(instanceList);
662 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
663 String instanceContent = instProcessor.toXML(instanceCollection);
664 Content content = new Content();
665 content.setContent(instanceContent);
666 RequestDocument requestDocument = new RequestDocument();
667 requestDocument.setCategory(DocCategory.WORK.getCode());
668 requestDocument.setType(DocType.INSTANCE.getCode());
669 requestDocument.setFormat(DocFormat.OLEML.getCode());
670 requestDocument.setContent(content);
671 return requestDocument;
672 }
673
674
675
676
677
678
679
680 private Instance retriveInstanceData(String instanceId) throws OleDocStoreException {
681
682 RequestDocument requestDocument = new RequestDocument();
683 requestDocument.setCategory(DocCategory.WORK.getCode());
684 requestDocument.setType(DocType.INSTANCE.getCode());
685 requestDocument.setFormat(DocFormat.OLEML.getCode());
686 requestDocument.setUuid(instanceId);
687
688 JcrWorkInstanceDocumentManager jcrWorkInstanceDocumentManager = (JcrWorkInstanceDocumentManager) BeanLocator.getDocumentManagerFactory().getDocumentManager(requestDocument);
689 ResponseDocument checkOutResponseDocument = jcrWorkInstanceDocumentManager.checkout(requestDocument, session);
690
691 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
692 InstanceCollection instanceCollection = instProcessor.fromXML(checkOutResponseDocument.getContent().getContent());
693 return instanceCollection.getInstance().get(0);
694 }
695
696
697
698
699
700
701
702
703
704
705
706
707 private RequestDocument buildHoldingsCheckinDocumentWithCallNumber(OleHoldings oleHoldings, String callNumber, String shelvingScheme, String shelvingOrderCode) throws OleDocStoreException {
708
709 RequestDocument requestDocument = new RequestDocument();
710 requestDocument.setId(oleHoldings.getHoldingsIdentifier());
711 requestDocument.setCategory(DocCategory.WORK.getCode());
712 requestDocument.setType(DocType.HOLDINGS.getCode());
713 requestDocument.setFormat(DocFormat.OLEML.getCode());
714
715 CallNumber cn = oleHoldings.getCallNumber();
716 if (cn == null) {
717 cn = new CallNumber();
718 cn.setNumber(callNumber);
719
720 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
721 shelvingScheme1.setCodeValue(shelvingScheme);
722
723 ShelvingOrder shelvingOrder = new ShelvingOrder();
724 shelvingOrder.setFullValue(shelvingOrderCode);
725
726 cn.setShelvingScheme(shelvingScheme1);
727 cn.setShelvingOrder(shelvingOrder);
728
729 oleHoldings.setCallNumber(cn);
730 } else {
731 oleHoldings.getCallNumber().setNumber(callNumber);
732 oleHoldings.getCallNumber().getShelvingScheme().setCodeValue(shelvingScheme);
733 oleHoldings.getCallNumber().getShelvingOrder().setFullValue(shelvingOrderCode);
734 }
735
736 Content content = new Content();
737 content.setContent(instProcessor.toXML(oleHoldings));
738 requestDocument.setContent(content);
739
740 return requestDocument;
741 }
742
743
744
745
746
747
748
749
750
751
752
753
754 private RequestDocument buildItemCheckinDocumentWithCallNumber(org.kuali.ole.docstore.common.document.content.instance.Item item, String callNumber, String shelvingScheme, String shelvingOrderCode, String enumeration, String chronology, String copyNumber) {
755 RequestDocument requestDocument = new RequestDocument();
756 requestDocument.setId(item.getItemIdentifier());
757 requestDocument.setUuid(item.getItemIdentifier());
758 requestDocument.setCategory(DocCategory.WORK.getCode());
759 requestDocument.setType(DocType.ITEM.getCode());
760 requestDocument.setFormat(DocFormat.OLEML.getCode());
761
762 CallNumber cn = item.getCallNumber();
763 if (cn == null) {
764 item.setCallNumber(new CallNumber());
765 }
766 if (item.getCallNumber().getShelvingScheme() == null) {
767 item.getCallNumber().setShelvingScheme(new ShelvingScheme());
768 }
769 if (item.getCallNumber().getShelvingOrder() == null) {
770 item.getCallNumber().setShelvingOrder(new ShelvingOrder());
771 }
772
773 item.getCallNumber().setNumber(callNumber);
774 item.getCallNumber().getShelvingScheme().setCodeValue(shelvingScheme);
775 item.getCallNumber().getShelvingOrder().setFullValue(shelvingOrderCode);
776
777 item.setChronology(chronology);
778 item.setCopyNumber(copyNumber);
779 item.setEnumeration(enumeration);
780
781 Content content = new Content();
782 content.setContent(instProcessor.toXML(item));
783 requestDocument.setContent(content);
784 requestDocument.setOperation(Request.Operation.checkIn.toString());
785 return requestDocument;
786 }
787
788
789
790
791
792
793 private org.kuali.ole.docstore.common.document.content.instance.Item updateItem(RequestDocument requestDocument) throws Exception {
794 JcrWorkInstanceDocumentManager jcrWorkInstanceDocumentManager = (JcrWorkInstanceDocumentManager) BeanLocator.getDocumentManagerFactory().getDocumentManager(requestDocument);
795
796 ResponseDocument checkInResponseDocument = checkInRequestDocument(requestDocument);
797
798 org.kuali.ole.docstore.common.document.content.instance.Item item = checkOutItem(checkInResponseDocument.getUuid(), jcrWorkInstanceDocumentManager);
799
800 return item;
801 }
802
803 private org.kuali.ole.docstore.common.document.content.instance.Item checkOutItem(String uuid, JcrWorkInstanceDocumentManager jcrWorkInstanceDocumentManager) throws OleDocStoreException {
804 RequestDocument requestDocument1 = new RequestDocument();
805 requestDocument1.setCategory(DocCategory.WORK.getCode());
806 requestDocument1.setType(DocType.ITEM.getCode());
807 requestDocument1.setFormat(DocFormat.OLEML.getCode());
808 requestDocument1.setUuid(uuid);
809 ResponseDocument responseDocument = jcrWorkInstanceDocumentManager.checkout(requestDocument1, session);
810 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
811 org.kuali.ole.docstore.common.document.content.instance.Item item = itemOlemlRecordProcessor.fromXML(responseDocument.getContent().getContent());
812 return item;
813 }
814
815
816 private void holdingsCreateShelvingOrderComputation() throws Exception {
817
818
819
820 RequestDocument requestDocument1 = buildInstanceRequestDocumentWithCallNumber(null, null, null, null, null);
821 ResponseDocument responseDocument1 = ingestTestData(requestDocument1);
822
823 String instanceId1 = responseDocument1.getUuid();
824
825 Instance instance = retriveInstanceData(instanceId1);
826 OleHoldings oleHoldings1 = instance.getOleHoldings();
827 String holdingsId1 = oleHoldings1.getHoldingsIdentifier();
828
829 CallNumber oleHoldings1CallNumber = oleHoldings1.getCallNumber();
830 ShelvingOrder shelvingOrder = null;
831 if (oleHoldings1CallNumber != null) {
832 shelvingOrder = oleHoldings1.getCallNumber().getShelvingOrder();
833 Assert.assertNull(shelvingOrder.getFullValue());
834 }
835
836
837
838 String callNumber = "DK602 .P44 1901";
839 String shelvingScheme = "LCC";
840 String shelvingOrderCode3 = "DK 0602.300000 P0.440000 001996";
841
842 RequestDocument requestDocument2 = buildInstanceRequestDocumentWithCallNumber(callNumber, shelvingScheme, null, null, null);
843 ResponseDocument responseDocument2 = ingestTestData(requestDocument2);
844 String instanceId2 = responseDocument2.getUuid();
845
846 instance = retriveInstanceData(instanceId2);
847
848 OleHoldings oleHoldings2 = instance.getOleHoldings();
849 String holdingsId2 = oleHoldings2.getHoldingsIdentifier();
850
851 CallNumber oleHoldings2CallNumber = oleHoldings2.getCallNumber();
852
853 Assert.assertNotNull(oleHoldings2CallNumber.getShelvingOrder());
854
855 Items items = instance.getItems();
856 Assert.assertNotNull(items);
857 Assert.assertEquals(items.getItem().size(), 1);
858 org.kuali.ole.docstore.common.document.content.instance.Item item = items.getItem().get(0);
859 Assert.assertNotNull(item.getItemIdentifier());
860 Assert.assertNull(item.getCallNumber().getNumber());
861 Assert.assertNull(item.getCallNumber().getShelvingScheme());
862 Assert.assertNotNull(item.getCallNumber().getShelvingOrder());
863
864
865
866 RequestDocument requestDocument3 = buildInstanceRequestDocumentWithCallNumber(callNumber, shelvingScheme, shelvingOrderCode3, null, null);
867 ResponseDocument responseDocument3 = ingestTestData(requestDocument3);
868 String instanceId3 = requestDocument3.getUuid();
869
870 instance = retriveInstanceData(instanceId3);
871
872 OleHoldings oleHoldings3 = instance.getOleHoldings();
873
874 String holdingsId3 = oleHoldings3.getHoldingsIdentifier();
875 CallNumber oleHoldings3CallNumber = oleHoldings3.getCallNumber();
876
877 ShelvingOrder shelvingOrder3 = oleHoldings3CallNumber.getShelvingOrder();
878
879 Assert.assertTrue(!shelvingOrderCode3.equalsIgnoreCase(shelvingOrder3.getFullValue()));
880
881 }
882
883 private void holdingsUpdateShelvingOrderComputation() throws Exception {
884
885 String callNumber = "PQ145.T51 S4";
886 String shelvingScheme = "LCC";
887 String shelvingOrder = "PQ 0000.000000";
888 RequestDocument instanceReqDoc = buildInstanceItemIngestDocumentWithCallNumber(null, null, null);
889 Instance instance = createInstance(instanceReqDoc);
890 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
891 String itemId = item.getItemIdentifier();
892 String itemShelvingOrder = item.getCallNumber().getShelvingOrder().getFullValue();
893
894
895 RequestDocument holdingsReqDoc1 = buildHoldingsCheckinDocumentWithCallNumber(instance.getOleHoldings(), null, null, null);
896
897 OleHoldings oleHoldings1 = updateHoldings(holdingsReqDoc1);
898
899 Assert.assertNotNull(oleHoldings1.getCallNumber().getShelvingOrder());
900
901
902
903 RequestDocument holdingsReqDoc2 = buildHoldingsCheckinDocumentWithCallNumber(oleHoldings1, callNumber, shelvingScheme, null);
904
905 OleHoldings oleHoldings2 = updateHoldings(holdingsReqDoc2);
906
907 Assert.assertNotNull(oleHoldings2.getCallNumber().getShelvingOrder());
908 Assert.assertNotSame(oleHoldings1.getCallNumber().getShelvingOrder(), oleHoldings2.getCallNumber().getShelvingOrder());
909
910 item = retriveItemData(itemId);
911 Assert.assertNotSame(itemShelvingOrder, item.getCallNumber().getShelvingOrder().getFullValue());
912
913
914
915 RequestDocument holdingsReqDoc3 = buildHoldingsCheckinDocumentWithCallNumber(oleHoldings2, callNumber, shelvingScheme, shelvingOrder);
916
917 OleHoldings oleHoldings3 = updateHoldings(holdingsReqDoc3);
918
919 Assert.assertNotSame(oleHoldings2.getCallNumber().getShelvingOrder(), oleHoldings3.getCallNumber().getShelvingOrder());
920
921
922 }
923
924 private org.kuali.ole.docstore.common.document.content.instance.Item retriveItemData(String itemId) throws OleDocStoreException {
925 RequestDocument requestDocument = new RequestDocument();
926 requestDocument.setCategory(DocCategory.WORK.getCode());
927 requestDocument.setType(DocType.ITEM.getCode());
928 requestDocument.setFormat(DocFormat.OLEML.getCode());
929 requestDocument.setUuid(itemId);
930
931 DocumentManager documentManager = BeanLocator.getDocumentManagerFactory().getDocumentManager(requestDocument);
932 ResponseDocument checkOutResponseDocument = documentManager.checkout(requestDocument, session);
933 ItemOlemlRecordProcessor itemOlemlRecordProcessor = new ItemOlemlRecordProcessor();
934 org.kuali.ole.docstore.common.document.content.instance.Item item = itemOlemlRecordProcessor.fromXML(checkOutResponseDocument.getContent().getContent());
935 return item;
936 }
937
938 private ResponseDocument ingestTestData(RequestDocument requestDocument) throws Exception {
939
940
941
942
943
944 ResponseDocument responseDocument = ingestDocument(requestDocument);
945
946 return responseDocument;
947 }
948
949
950 private void itemUpdateShelvingOrderComputation() throws Exception {
951 RequestDocument instanceReqDoc1 = buildInstanceItemIngestDocumentWithCallNumber(null, null, null, null, null, null, null, null, null);
952
953 Instance instance = createInstance(instanceReqDoc1);
954 org.kuali.ole.docstore.common.document.content.instance.Item item = instance.getItems().getItem().get(0);
955 String itemShelvingOrder = item.getCallNumber().getShelvingOrder().getFullValue();
956
957
958 String callNumber = "PQ145.T51 S4";
959 String shelvingScheme = "LCC";
960 String shelvingOrder = "PQ 0000.000000";
961
962 String enumeration = "v.1";
963 String chronology = "1984";
964 String copyNumber = "cp.2";
965
966
967 RequestDocument requestDocument = buildItemCheckinDocumentWithCallNumber(item, callNumber, shelvingScheme, null, null, null, null);
968 org.kuali.ole.docstore.common.document.content.instance.Item updateditem = updateItem(requestDocument);
969
970 Assert.assertNotNull(updateditem.getCallNumber().getShelvingOrder().getFullValue());
971
972
973 RequestDocument itemReq2 = buildItemCheckinDocumentWithCallNumber(updateditem, callNumber, shelvingScheme, shelvingOrder, null, null, null);
974 updateditem = updateItem(itemReq2);
975 Assert.assertNotNull(updateditem.getCallNumber().getShelvingOrder().getFullValue());
976 Assert.assertEquals(shelvingOrder, updateditem.getCallNumber().getShelvingOrder().getFullValue());
977
978
979
980
981 RequestDocument itemReq3 = buildItemCheckinDocumentWithCallNumber(updateditem, null, null, null, enumeration, chronology, copyNumber);
982 updateditem = updateItem(itemReq3);
983 Assert.assertNull(updateditem.getCallNumber().getShelvingOrder().getFullValue());
984 Assert.assertSame(itemShelvingOrder, updateditem.getCallNumber().getShelvingOrder().getFullValue());
985
986
987
988 RequestDocument itemReq4 = buildItemCheckinDocumentWithCallNumber(updateditem, callNumber, shelvingScheme, null, enumeration, chronology, copyNumber);
989 updateditem = updateItem(itemReq4);
990 Assert.assertNotNull(updateditem.getCallNumber().getShelvingOrder().getFullValue());
991 }
992
993
994 private void itemCreateWithoutInstanceShelvingOrderComputation(String instanceId) throws OleDocStoreException {
995
996 String callNumber = "PQ145.T51 S4";
997 String shelvingScheme = "LCC";
998 String shelvingOrder3 = "PQ 0000.000000";
999
1000 String enumeration = "v.1";
1001 String chronology = "1984";
1002 String copyNumber = "cp.2";
1003
1004
1005 RequestDocument itemReqDoc1 = buildAddItemToInstance(instanceId, null, null, null, null, null, null);
1006 org.kuali.ole.docstore.common.document.content.instance.Item item = addItemToInstance(itemReqDoc1);
1007 Assert.assertNull(item.getCallNumber().getShelvingOrder().getFullValue());
1008
1009
1010
1011 RequestDocument itemReqDoc2 = buildAddItemToInstance(instanceId, callNumber, shelvingScheme, null, null, null, null);
1012 item = addItemToInstance(itemReqDoc2);
1013 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
1014
1015
1016
1017 RequestDocument itemReqDoc3 = buildAddItemToInstance(instanceId, callNumber, shelvingScheme, shelvingOrder3, null, null, null);
1018 item = addItemToInstance(itemReqDoc3);
1019 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
1020 Assert.assertNotSame(shelvingOrder3, item.getCallNumber().getShelvingOrder().getFullValue());
1021
1022
1023
1024 RequestDocument itemReqDoc4 = buildAddItemToInstance(instanceId, callNumber, shelvingScheme, null, enumeration, null, null);
1025 item = addItemToInstance(itemReqDoc4);
1026 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
1027 Assert.assertNotSame(shelvingOrder3, item.getCallNumber().getShelvingOrder().getFullValue());
1028
1029
1030
1031 RequestDocument itemReqDoc5 = buildAddItemToInstance(instanceId, callNumber, shelvingScheme, shelvingOrder3, enumeration, chronology, null);
1032 item = addItemToInstance(itemReqDoc5);
1033 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
1034 Assert.assertNotSame(shelvingOrder3, item.getCallNumber().getShelvingOrder().getFullValue());
1035
1036
1037
1038 RequestDocument itemReqDoc6 = buildAddItemToInstance(instanceId, callNumber, shelvingScheme, null, enumeration, chronology, copyNumber);
1039 item = addItemToInstance(itemReqDoc6);
1040 Assert.assertNotNull(item.getCallNumber().getShelvingOrder().getFullValue());
1041 Assert.assertNotSame(shelvingOrder3, item.getCallNumber().getShelvingOrder().getFullValue());
1042
1043 }
1044
1045 private void itemCreateWithInstanceShelvingOrderComputation() throws Exception {
1046
1047 String callNumber = "PQ145.T51 S4";
1048 String shelvingScheme = "LCC";
1049 String shelvingOrder3 = "PQ 0000.000000";
1050
1051 String enumeration = "v.1";
1052 String chronology = "1984";
1053 String copyNumber = "cp.2";
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 RequestDocument instanceReqDoc4 = buildInstanceItemIngestDocumentWithCallNumber(null, null, null, callNumber, shelvingScheme, shelvingOrder3, enumeration, null, null);
1084
1085 Instance instance4 = createInstance(instanceReqDoc4);
1086 org.kuali.ole.docstore.common.document.content.instance.Item item4 = instance4.getItems().getItem().get(0);
1087 Assert.assertNotNull(item4.getCallNumber().getShelvingOrder().getFullValue());
1088 Assert.assertNotSame(shelvingOrder3, item4.getCallNumber().getShelvingOrder().getFullValue());
1089
1090
1091
1092
1093 RequestDocument instanceReqDoc5 = buildInstanceItemIngestDocumentWithCallNumber(null, null, null, callNumber, shelvingScheme, shelvingOrder3, enumeration, chronology, null);
1094
1095 Instance instance5 = createInstance(instanceReqDoc5);
1096 org.kuali.ole.docstore.common.document.content.instance.Item item5 = instance5.getItems().getItem().get(0);
1097 Assert.assertNotNull(item5.getCallNumber().getShelvingOrder().getFullValue());
1098 Assert.assertNotSame(shelvingOrder3, item5.getCallNumber().getShelvingOrder().getFullValue());
1099
1100
1101
1102 RequestDocument instanceReqDoc6 = buildInstanceItemIngestDocumentWithCallNumber(null, null, null, callNumber, shelvingScheme, null, enumeration, chronology, copyNumber);
1103
1104 Instance instance6 = createInstance(instanceReqDoc6);
1105 org.kuali.ole.docstore.common.document.content.instance.Item item6 = instance6.getItems().getItem().get(0);
1106 Assert.assertNotNull(item6.getCallNumber().getShelvingOrder().getFullValue());
1107 Assert.assertNotSame(shelvingOrder3, item6.getCallNumber().getShelvingOrder().getFullValue());
1108
1109 }
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123 private RequestDocument buildInstanceItemIngestDocumentWithCallNumber(String holdingsCallNumber, String holdingsShelvingScheme, String holdingsShelvingOrder,
1124 String itemCallNumber, String itemShelvingScheme, String itemShelvingOrder, String itemEnumeration,
1125 String itemChronology, String itemCopyNumber) {
1126
1127 InstanceCollection instanceCollection = new InstanceCollection();
1128 List<Instance> instanceList = new ArrayList<Instance>();
1129 Instance instance = new Instance();
1130
1131 OleHoldings oleHoldings = setHoldingCallNumberInformation(holdingsCallNumber, holdingsShelvingScheme, holdingsShelvingOrder);
1132 instance.setOleHoldings(oleHoldings);
1133
1134 org.kuali.ole.docstore.common.document.content.instance.Item item = setItemCallNumberInformation(itemCallNumber, itemShelvingScheme, itemShelvingOrder, itemEnumeration, itemChronology, itemCopyNumber);
1135
1136 List<org.kuali.ole.docstore.common.document.content.instance.Item> itemList = new ArrayList<org.kuali.ole.docstore.common.document.content.instance.Item>();
1137 itemList.add(item);
1138 Items items = new Items();
1139 items.setItem(itemList);
1140
1141 instance.setItems(items);
1142 instanceList.add(instance);
1143 instanceCollection.setInstance(instanceList);
1144
1145 InstanceOlemlRecordProcessor instProcessor = new InstanceOlemlRecordProcessor();
1146 String instanceContent = instProcessor.toXML(instanceCollection);
1147
1148 Content content = new Content();
1149 content.setContent(instanceContent);
1150 RequestDocument requestDocument = new RequestDocument();
1151 requestDocument.setCategory(DocCategory.WORK.getCode());
1152 requestDocument.setType(DocType.INSTANCE.getCode());
1153 requestDocument.setFormat(DocFormat.OLEML.getCode());
1154 requestDocument.setContent(content);
1155
1156 return requestDocument;
1157 }
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167 private OleHoldings setHoldingCallNumberInformation(String callNumber, String shelvingScheme, String shelvingOrder) {
1168
1169 OleHoldings oleHoldings = new OleHoldings();
1170
1171 CallNumber callNumber1 = new CallNumber();
1172 callNumber1.setNumber(callNumber);
1173
1174 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
1175 shelvingScheme1.setCodeValue(shelvingScheme);
1176
1177 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
1178 shelvingOrder1.setFullValue(shelvingOrder);
1179
1180 callNumber1.setShelvingScheme(shelvingScheme1);
1181 callNumber1.setShelvingOrder(shelvingOrder1);
1182
1183 oleHoldings.setCallNumber(callNumber1);
1184
1185 return oleHoldings;
1186 }
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196 private org.kuali.ole.docstore.common.document.content.instance.Item setItemCallNumberInformation(String callNumber, String shelvingScheme, String shelvingOrder,
1197 String enumeration, String chronology, String copyNumber) {
1198
1199 org.kuali.ole.docstore.common.document.content.instance.Item item = new org.kuali.ole.docstore.common.document.content.instance.Item();
1200
1201 CallNumber callNumber1 = new CallNumber();
1202 callNumber1.setNumber(callNumber);
1203
1204 ShelvingScheme shelvingScheme1 = new ShelvingScheme();
1205 shelvingScheme1.setCodeValue(shelvingScheme);
1206
1207 ShelvingOrder shelvingOrder1 = new ShelvingOrder();
1208 shelvingOrder1.setFullValue(shelvingOrder);
1209
1210 callNumber1.setShelvingScheme(shelvingScheme1);
1211 callNumber1.setShelvingOrder(shelvingOrder1);
1212
1213 item.setCallNumber(callNumber1);
1214 if (enumeration != null) {
1215 item.setEnumeration(enumeration);
1216 }
1217 if (chronology != null) {
1218 item.setChronology(chronology);
1219 }
1220 if (copyNumber != null) {
1221 item.setCopyNumber(copyNumber);
1222 }
1223
1224 return item;
1225 }
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236 private RequestDocument buildAddItemToInstance(String instanceId, String callNumber, String shelvingScheme, String shelvingOrder, String enumeration, String chronology, String copyNumber) {
1237
1238 RequestDocument requestDocument = new RequestDocument();
1239 requestDocument.setCategory(DocCategory.WORK.getCode());
1240 requestDocument.setType(DocType.INSTANCE.getCode());
1241 requestDocument.setFormat(DocFormat.OLEML.getCode());
1242 requestDocument.setId(instanceId);
1243
1244 List<RequestDocument> requestDocumentList = new ArrayList<RequestDocument>();
1245
1246 RequestDocument linkedRequestDocument = new RequestDocument();
1247 linkedRequestDocument.setCategory(DocCategory.WORK.getCode());
1248 linkedRequestDocument.setType(DocType.ITEM.getCode());
1249 linkedRequestDocument.setFormat(DocFormat.OLEML.getCode());
1250
1251 org.kuali.ole.docstore.common.document.content.instance.Item item = setItemCallNumberInformation(callNumber, shelvingScheme, shelvingOrder, enumeration, chronology, copyNumber);
1252 Content content = new Content();
1253 content.setContent(instProcessor.toXML(item));
1254 linkedRequestDocument.setContent(content);
1255
1256 requestDocumentList.add(linkedRequestDocument);
1257 requestDocument.setLinkedRequestDocuments(requestDocumentList);
1258 requestDocument.setOperation(Request.Operation.checkIn.toString());
1259
1260 Request request = new Request();
1261 List<RequestDocument> requestDocuments = new ArrayList<RequestDocument>();
1262 requestDocuments.add(requestDocument);
1263 request.setRequestDocuments(requestDocuments);
1264
1265 return requestDocument;
1266
1267 }
1268
1269
1270
1271
1272
1273
1274
1275
1276 private org.kuali.ole.docstore.common.document.content.instance.Item addItemToInstance(RequestDocument requestDocument) throws OleDocStoreException {
1277
1278 DocumentManager documentManager = JcrDocumentManagerFactory.getInstance().getDocumentManager(requestDocument);
1279 ResponseDocument responseDocument = new ResponseDocument();
1280 documentManager.checkin(requestDocument, session, responseDocument);
1281
1282 String itemId = responseDocument.getLinkedDocuments().get(0).getUuid();
1283
1284 org.kuali.ole.docstore.common.document.content.instance.Item item = retriveItemData(itemId);
1285
1286 return item;
1287 }
1288
1289
1290 }