001package org.kuali.ole.describe.controller; 002 003import java.util.HashMap; 004import java.util.Map; 005 006import org.kuali.ole.docstore.model.enums.DocCategory; 007import org.kuali.ole.docstore.model.enums.DocFormat; 008import org.kuali.ole.docstore.model.enums.DocType; 009 010/** 011 * Creates a singleton instance of an editor based on the given parameters. 012 * User: tirumalesh.b 013 * Date: 28/12/12 Time: 12:51 PM 014 */ 015public class DocumentEditorFactory { 016 private static DocumentEditorFactory documentEditorFactory = new DocumentEditorFactory(); 017 018 private Map<String, DocumentEditor> documentEditorMap = new HashMap<String, DocumentEditor>(); 019 020 public static DocumentEditorFactory getInstance() { 021 return documentEditorFactory; 022 } 023 024 private DocumentEditorFactory() { 025 initDocumentEditorMap(); 026 } 027 028 private void initDocumentEditorMap() { 029 String key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.MARC.getCode(); 030 documentEditorMap.put(key, WorkBibMarcEditor.getInstance()); 031 032 key = DocCategory.WORK.getCode() + DocType.INSTANCE.getCode() + DocFormat.OLEML.getCode(); 033 documentEditorMap.put(key, WorkHoldingsOlemlEditor.getInstance()); 034 035 key = DocCategory.WORK.getCode() + DocType.HOLDINGS.getCode() + DocFormat.OLEML.getCode(); 036 documentEditorMap.put(key, WorkHoldingsOlemlEditor.getInstance()); 037 038// key = DocCategory.WORK.getCode() + DocType.SOURCEHOLDINGS.getCode() + DocFormat.OLEML.getCode(); 039// documentEditorMap.put(key, WorkInstanceOlemlEditor.getInstance()); 040 041 key = DocCategory.WORK.getCode() + DocType.ITEM.getCode() + DocFormat.OLEML.getCode(); 042 documentEditorMap.put(key, WorkItemOlemlEditor.getInstance()); 043 044 key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_CORE.getCode(); 045 documentEditorMap.put(key, WorkBibDublinEditor.getInstance()); 046 047 key = DocCategory.WORK.getCode() + DocType.BIB.getDescription() + DocFormat.DUBLIN_UNQUALIFIED.getCode(); 048 documentEditorMap.put(key, WorkBibDublinEditor.getInstance()); 049 050 key = DocCategory.WORK.getCode() + DocType.EINSTANCE.getCode() + DocFormat.OLEML.getCode(); 051 documentEditorMap.put(key, WorkEInstanceOlemlEditor.getInstance()); 052 053 key = DocCategory.WORK.getCode() + DocType.EHOLDINGS.getCode() + DocFormat.OLEML.getCode(); 054 documentEditorMap.put(key, WorkEInstanceOlemlEditor.getInstance()); 055 } 056 057 public DocumentEditor getDocumentEditor(String docCategory, String docType, String docFormat) { 058 return documentEditorMap.get(docCategory + docType + docFormat); 059 } 060 061}