1 package org.kuali.ole.docstore.repository;
2
3 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.BibRecord;
4 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.HoldingsRecord;
5 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.InstanceRecord;
6 import org.kuali.ole.docstore.engine.service.storage.rdbms.pojo.ItemRecord;
7 import org.kuali.ole.pojo.OleException;
8 import org.kuali.rice.krad.service.BusinessObjectService;
9 import org.kuali.rice.krad.service.KRADServiceLocator;
10
11 import javax.jcr.RepositoryException;
12 import java.util.*;
13
14
15
16
17
18
19
20
21 public class RdbmsNodeCountManager {
22
23 private static RdbmsNodeCountManager nodeCountManager;
24 private Map<String, Long> nodeCountMap = null;
25 private BusinessObjectService businessObjectService;
26
27 private BusinessObjectService getBusinessObjectService() {
28 if (null == businessObjectService) {
29 businessObjectService = KRADServiceLocator.getBusinessObjectService();
30 }
31 return businessObjectService;
32 }
33
34 private RdbmsNodeCountManager() {
35 }
36
37 public static RdbmsNodeCountManager getNodeCountManager() {
38 if (null == nodeCountManager) {
39 nodeCountManager = new RdbmsNodeCountManager();
40 }
41 return nodeCountManager;
42 }
43
44 public Map generateNodeCountMap() throws OleException, RepositoryException {
45 Map<String, Long> bibMap = new TreeMap<String, Long>();
46
47 Map countMap = new HashMap();
48 countMap.put("uniqueIdPrefix" , "wbm");
49 long bibSize = getBusinessObjectService().countMatching(BibRecord.class,countMap);
50 countMap.clear();
51 countMap.put("uniqueIdPrefix" , "who");
52 long holdingsSize = getBusinessObjectService().countMatching(HoldingsRecord.class,countMap);
53 countMap.clear();
54 countMap.put("uniqueIdPrefix" , "wio");
55 long itemSize = getBusinessObjectService().countMatching(ItemRecord.class,countMap);
56
57
58 StringBuffer temp = new StringBuffer();
59 temp.append("work").append("/").append("").append("/").append("");
60 String temp1 = new String();
61
62 bibMap.put("work", bibSize + holdingsSize);
63 bibMap.put("bibliographic", bibSize);
64
65
66
67 bibMap.put("holdings", holdingsSize);
68 bibMap.put("items", itemSize);
69
70
71 return bibMap;
72 }
73 }