View Javadoc
1   package org.kuali.ole.describe.controller;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import org.kuali.ole.docstore.model.enums.DocCategory;
7   import org.kuali.ole.docstore.model.enums.DocFormat;
8   import org.kuali.ole.docstore.model.enums.DocType;
9   
10  /**
11   * Creates a singleton instance of an editor based on the given parameters.
12   * User: tirumalesh.b
13   * Date: 28/12/12 Time: 12:51 PM
14   */
15  public class DocumentEditorFactory {
16      private static DocumentEditorFactory documentEditorFactory = new DocumentEditorFactory();
17  
18      private Map<String, DocumentEditor> documentEditorMap = new HashMap<String, DocumentEditor>();
19  
20      public static DocumentEditorFactory getInstance() {
21          return documentEditorFactory;
22      }
23  
24      private DocumentEditorFactory() {
25          initDocumentEditorMap();
26      }
27  
28      private void initDocumentEditorMap() {
29          String key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.MARC.getCode();
30          documentEditorMap.put(key, WorkBibMarcEditor.getInstance());
31  
32          key = DocCategory.WORK.getCode() + DocType.INSTANCE.getCode() + DocFormat.OLEML.getCode();
33          documentEditorMap.put(key, WorkHoldingsOlemlEditor.getInstance());
34  
35          key = DocCategory.WORK.getCode() + DocType.HOLDINGS.getCode() + DocFormat.OLEML.getCode();
36          documentEditorMap.put(key, WorkHoldingsOlemlEditor.getInstance());
37  
38  //        key = DocCategory.WORK.getCode() + DocType.SOURCEHOLDINGS.getCode() + DocFormat.OLEML.getCode();
39  //        documentEditorMap.put(key, WorkInstanceOlemlEditor.getInstance());
40  
41          key = DocCategory.WORK.getCode() + DocType.ITEM.getCode() + DocFormat.OLEML.getCode();
42          documentEditorMap.put(key, WorkItemOlemlEditor.getInstance());
43  
44          key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_CORE.getCode();
45          documentEditorMap.put(key, WorkBibDublinEditor.getInstance());
46  
47          key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_UNQUALIFIED.getCode();
48          documentEditorMap.put(key, WorkBibDublinEditor.getInstance());
49  
50          key = DocCategory.WORK.getCode() + DocType.EINSTANCE.getCode() + DocFormat.OLEML.getCode();
51          documentEditorMap.put(key, WorkEInstanceOlemlEditor.getInstance());
52  
53          key = DocCategory.WORK.getCode() + DocType.EHOLDINGS.getCode() + DocFormat.OLEML.getCode();
54          documentEditorMap.put(key, WorkEInstanceOlemlEditor.getInstance());
55      }
56  
57      public DocumentEditor getDocumentEditor(String docCategory, String docType, String docFormat) {
58          return documentEditorMap.get(docCategory + docType + docFormat);
59      }
60  
61  }