View Javadoc

1   package org.kuali.ole.docstore.document;
2   
3   import org.kuali.ole.docstore.model.enums.DocCategory;
4   import org.kuali.ole.docstore.model.enums.DocFormat;
5   import org.kuali.ole.docstore.model.enums.DocType;
6   import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
7   
8   import java.util.HashMap;
9   import java.util.Map;
10  
11  /**
12   * Creates the suitable implementation of DocumentManager for the given document category, type and format.
13   *
14   * @author tirumalesh.b
15   * @version %I%, %G%
16   *          Date: 28/8/12 Time: 12:52 PM
17   */
18  public class DocumentManagerFactory {
19      private static DocumentManagerFactory       documentManagerFactory = new DocumentManagerFactory();
20      private        Map<String, DocumentManager> documentManagerMap     = new HashMap<String, DocumentManager>();
21  
22      public static DocumentManagerFactory getInstance() {
23          return documentManagerFactory;
24      }
25  
26      private DocumentManagerFactory() {
27          initDocumentManagerMap();
28      }
29  
30      private void initDocumentManagerMap() {
31          String key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.MARC.getCode();
32          documentManagerMap.put(key, WorkBibMarcDocumentManager.getInstance());
33  
34          key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_CORE.getCode();
35          documentManagerMap.put(key, WorkBibDocumentManager.getInstance());
36  
37          key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_UNQUALIFIED.getCode();
38          documentManagerMap.put(key, WorkBibDocumentManager.getInstance());
39  
40          key = DocCategory.WORK.getCode() + DocType.INSTANCE.getCode() + DocFormat.OLEML.getCode();
41          documentManagerMap.put(key, WorkInstanceDocumentManager.getInstance());
42  
43          key = DocCategory.WORK.getCode() + DocType.HOLDINGS.getCode() + DocFormat.OLEML.getCode();
44          documentManagerMap.put(key, WorkInstanceDocumentManager.getInstance());
45  
46          key = DocCategory.WORK.getCode() + DocType.ITEM.getCode() + DocFormat.OLEML.getCode();
47          documentManagerMap.put(key, WorkItemDocumentManager.getInstance());
48  
49          key = DocCategory.WORK.getCode() + DocType.SOURCEHOLDINGS.getCode() + DocFormat.OLEML.getCode();
50          documentManagerMap.put(key, WorkInstanceDocumentManager.getInstance());
51  
52          key = DocCategory.WORK.getCode() + DocType.LICENSE.getCode() + DocFormat.ONIXPL.getCode();
53          documentManagerMap.put(key, WorkLicenseDocumentManager.getInstance());
54  
55          key = DocCategory.WORK.getCode() + DocType.LICENSE.getCode() + DocFormat.PDF.getCode();
56          documentManagerMap.put(key, WorkLicenseDocumentManager.getInstance());
57  
58          key = DocCategory.WORK.getCode() + DocType.LICENSE.getCode() + DocFormat.DOC.getCode();
59          documentManagerMap.put(key, WorkLicenseDocumentManager.getInstance());
60  
61          key = DocCategory.WORK.getCode() + DocType.LICENSE.getCode() + DocFormat.XSLT.getCode();
62          documentManagerMap.put(key, WorkLicenseDocumentManager.getInstance());
63  
64      }
65  
66      public DocumentManager getDocumentManager(String docCategory, String docType, String docFormat) {
67          return documentManagerMap.get(docCategory + docType + docFormat);
68      }
69  
70      public DocumentManager getDocumentManager(RequestDocument requestDocument) {
71          return documentManagerMap
72                  .get(requestDocument.getCategory() + requestDocument.getType() + requestDocument.getFormat());
73      }
74  }