View Javadoc

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   * Created with IntelliJ IDEA.
14   * User: sambasivam
15   * Date: 6/20/13
16   * Time: 3:13 PM
17   * To change this template use File | Settings | File Templates.
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.getDescription().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  }