1 package org.kuali.ole.docstore.repository;
2
3 import javax.jcr.Node;
4 import javax.jcr.Property;
5 import javax.jcr.Session;
6
7 import org.kuali.ole.docstore.OleDocStoreException;
8 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12 import static org.kuali.ole.docstore.process.ProcessParameters.FILE;
13 import static org.kuali.ole.docstore.process.ProcessParameters.NODE_LEVEL1;
14 import static org.kuali.ole.docstore.process.ProcessParameters.NODE_LEVEL2;
15 import static org.kuali.ole.docstore.process.ProcessParameters.NODE_LEVEL3;
16
17
18
19
20
21 public class WorkBibNodeManager
22 extends CustomNodeManager
23 implements NodeManager {
24 private static WorkBibNodeManager ourInstance = new WorkBibNodeManager();
25 private static final Logger LOG = LoggerFactory.getLogger(WorkBibNodeManager.class);
26
27
28
29
30 private WorkBibNodeManager() {
31 super();
32 numLevels = 3;
33
34 }
35
36 public static WorkBibNodeManager getInstance() {
37 return ourInstance;
38 }
39
40 @Override
41 public void linkNodes(Node bibNode, Node instanceNode, Session session) throws OleDocStoreException {
42 try {
43 if (instanceNode.hasProperty("bibIdentifier")) {
44 String bibId = instanceNode.getProperty("bibIdentifier").getString();
45 bibId = bibId + "," + bibNode.getIdentifier();
46 instanceNode.setProperty("bibIdentifier", bibId);
47 } else {
48 instanceNode.setProperty("bibIdentifier", bibNode.getIdentifier());
49 }
50 if (bibNode.hasProperty("instanceIdentifier")) {
51 String instId = bibNode.getProperty("instanceIdentifier").getString();
52 instId = instId + "," + instanceNode.getIdentifier();
53 bibNode.setProperty("instanceIdentifier", instId);
54 } else {
55 bibNode.setProperty("instanceIdentifier", instanceNode.getIdentifier());
56 }
57
58 } catch (Exception e) {
59 throw new OleDocStoreException(e);
60 }
61 }
62
63 public String getParentNodePath() {
64 return "/work/bib";
65 }
66
67
68 }