1 package org.kuali.ole.docstore.repository;
2
3 import org.apache.commons.io.FileUtils;
4 import org.junit.Ignore;
5 import org.junit.Test;
6 import org.kuali.ole.BaseTestCase;
7 import org.kuali.ole.RepositoryManager;
8 import org.kuali.ole.docstore.model.xmlpojo.ingest.Request;
9 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
10 import org.kuali.ole.docstore.model.xstream.ingest.RequestHandler;
11 import org.kuali.ole.docstore.service.DocumentIndexer;
12 import org.kuali.ole.docstore.service.DocumentIngester;
13 import org.kuali.ole.docstore.service.IngestNIndexHandlerService;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 import javax.jcr.Node;
18 import javax.jcr.Session;
19 import java.io.File;
20
21
22
23
24
25
26
27
28 @Ignore
29 @Deprecated
30 public class WorkBibNodeManager_UT extends BaseTestCase {
31
32 private static final Logger LOG = LoggerFactory.getLogger(WorkBibNodeManager_UT.class);
33
34 @Test
35 public void testLinkNodes() throws Exception {
36 WorkBibNodeManager workBibNodeManager = WorkBibNodeManager.getInstance();
37 File inputDir = new File(this.getClass().getResource("/org/kuali/ole/repository/requestInstance.xml").toURI());
38 String input = FileUtils.readFileToString(inputDir);
39 RequestHandler requestHandler = new RequestHandler();
40 Request request = requestHandler.toObject(input);
41 IngestNIndexHandlerService ingestNIndexHandlerService = new IngestNIndexHandlerService();
42 ingestNIndexHandlerService.setRequestHandler(requestHandler);
43 ingestNIndexHandlerService.setDocumentIndexer(new DocumentIndexer());
44 ingestNIndexHandlerService.setDocumentIngester(new DocumentIngester());
45 ingestNIndexHandlerService.ingestNIndexRequestDocuments(request);
46 RequestDocument requestDocument = request.getRequestDocuments().get(0);
47 CustomNodeManager customNodeManager = CustomNodeManager.getInstance();
48 Session session = RepositoryManager.getRepositoryManager().getSession(requestDocument.getUser(), requestDocument.getOperation());
49 Node node = customNodeManager.getNodeByUUID(session, requestDocument.getUuid());
50 node.setProperty("bibIdentifier", requestDocument.getUuid());
51 node.getParent().setProperty("instanceIdentifier", node.getParent().getIdentifier());
52 workBibNodeManager.linkNodes(node.getParent(), node, session);
53 LOG.info("ParentNodePath :" + workBibNodeManager.getParentNodePath());
54 }
55 }