View Javadoc

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   * User: tirumalesh.b
19   * Date: 31/8/12 Time: 5:31 PM
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      //protected NodeManager nodeManager;
29  
30      private WorkBibNodeManager() {
31          super();
32          numLevels = 3;
33          //nodeManager = CustomNodeManager.getInstance();
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              }
48              else {
49                  instanceNode.setProperty("bibIdentifier", bibNode.getIdentifier());
50              }
51              if (bibNode.hasProperty("instanceIdentifier")) {
52                  String instId = bibNode.getProperty("instanceIdentifier").getString();
53                  instId = instId + "," + instanceNode.getIdentifier();
54                  bibNode.setProperty("instanceIdentifier", instId);
55              }
56              else {
57                  bibNode.setProperty("instanceIdentifier", instanceNode.getIdentifier());
58              }
59  
60          }
61          catch (Exception e) {
62              throw new OleDocStoreException(e);
63          }
64      }
65  
66      public String getParentNodePath() {
67          return "/work/bib";
68      }
69  
70  
71  }