001 package org.kuali.ole.describe.controller; 002 003 import java.util.HashMap; 004 import java.util.Map; 005 006 import org.kuali.ole.docstore.model.enums.DocCategory; 007 import org.kuali.ole.docstore.model.enums.DocFormat; 008 import 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 */ 015 public 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, WorkInstanceOlemlEditor.getInstance()); 034 035 key = DocCategory.WORK.getCode() + DocType.HOLDINGS.getCode() + DocFormat.OLEML.getCode(); 036 documentEditorMap.put(key, WorkInstanceOlemlEditor.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, WorkInstanceOlemlEditor.getInstance()); 043 } 044 045 public DocumentEditor getDocumentEditor(String docCategory, String docType, String docFormat) { 046 return documentEditorMap.get(docCategory + docType + docFormat); 047 } 048 049 }