1 package org.kuali.ole.docstore.factory;
2
3 import org.kuali.ole.docstore.document.DocumentManager;
4 import org.kuali.ole.docstore.document.jcr.JcrDocumentManagerFactory;
5 import org.kuali.ole.docstore.document.rdbms.RdbmsDocumentManagerFactory;
6 import org.kuali.ole.docstore.model.enums.DocCategory;
7 import org.kuali.ole.docstore.model.enums.DocType;
8 import org.kuali.ole.docstore.transaction.JcrTransactionManager;
9 import org.kuali.ole.docstore.transaction.RdbmsTransactionManager;
10 import org.kuali.ole.docstore.transaction.TransactionManager;
11
12
13
14
15
16
17
18
19 public class RdbmsJcrDocstoreFactory extends AbstractDocstoreFactory {
20
21 @Override
22 public TransactionManager getTransactionManager(String docCategory, String docType, String docFormat) {
23
24 TransactionManager transactionManager = null;
25 if (isToStoreInRdbms(docCategory, docType, docFormat)) {
26 transactionManager = new RdbmsTransactionManager();
27 } else {
28 transactionManager = new JcrTransactionManager();
29 }
30
31 return transactionManager;
32 }
33
34 @Override
35 public DocumentManager getDocumentManager(String docCategory, String docType, String docFormat) {
36
37 DocumentManager documentManager = null;
38 if (isToStoreInRdbms(docCategory, docType, docFormat)) {
39 documentManager = RdbmsDocumentManagerFactory.getInstance().getDocumentManager(docCategory, docType, docFormat);
40 } else {
41 documentManager = JcrDocumentManagerFactory.getInstance().getDocumentManager(docCategory, docType, docFormat);
42 }
43
44 return documentManager;
45 }
46
47 private boolean isToStoreInRdbms(String docCategory, String docType, String docFormat) {
48
49 if (DocCategory.WORK.getCode().equals(docCategory)) {
50 if (DocType.BIB.getCode().equals(docType) || DocType.INSTANCE.getCode().equals(docType) ||
51 DocType.HOLDINGS.getCode().equals(docType) || DocType.ITEM.getCode().equals(docType) || DocType.EINSTANCE.getCode().equals(docType) || DocType.EHOLDINGS.getCode().equals(docType)) {
52 return true;
53 }
54 }
55 return false;
56 }
57
58 }