001 /* 002 * Copyright 2005-2008 The Kuali Foundation 003 * 004 * 005 * Licensed under the Educational Community License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.opensource.org/licenses/ecl2.php 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package mocks; 018 019 import java.io.InputStream; 020 import java.util.Collection; 021 import java.util.HashMap; 022 import java.util.List; 023 import java.util.Map; 024 025 import org.jdom.Element; 026 import org.kuali.rice.kew.doctype.bo.DocumentType; 027 import org.kuali.rice.kew.doctype.service.DocumentTypeService; 028 import org.kuali.rice.kew.dto.DocumentTypeDTO; 029 import org.kuali.rice.kew.export.ExportDataSet; 030 import org.kuali.rice.kew.postprocessor.PostProcessor; 031 import org.kuali.rice.kew.rule.bo.RuleAttribute; 032 033 034 public class MockDocumentTypeServiceImpl implements DocumentTypeService { 035 036 public DocumentType setDocumentTypeVersion(DocumentType documentType, boolean currentInd) { 037 return null; 038 } 039 public DocumentType getMostRecentDocType(String docTypeName) { 040 return null; 041 } 042 public boolean isLockedForRouting(DocumentType documentType) { 043 return false; 044 } 045 private Map documentsById = new HashMap(); 046 private Map documentsByName = new HashMap(); 047 private Map postProcessors = new HashMap(); 048 049 public void makeCurrent(List documentTypes) { 050 throw new UnsupportedOperationException("not yet implmeneted"); 051 } 052 053 public void addDocumentType(DocumentType documentType, PostProcessor postProcessor) { 054 documentsById.put(documentType.getDocumentTypeId(), documentType); 055 documentsByName.put(documentType.getName(), documentType); 056 postProcessors.put(documentType.getDocumentTypeId(), postProcessor); 057 } 058 059 public DocumentType findByDocumentId(Long documentId) { 060 throw new UnsupportedOperationException("not yet implemented"); 061 } 062 063 public Integer getMaxVersionNumber(String name){ 064 return new Integer(0); 065 } 066 public DocumentType findById(Long documentTypeId) { 067 return (DocumentType) documentsById.get(documentTypeId); 068 } 069 070 public DocumentType findByName(String name) { 071 return (DocumentType) documentsByName.get(name); 072 } 073 074 public DocumentType findByNameCaseInsensitive(String name) { 075 return (DocumentType) documentsByName.get(name); 076 } 077 078 public void versionAndSave(DocumentType documentType) { 079 addDocumentType(documentType, new MockPostProcessor(true)); 080 } 081 082 public PostProcessor getPostProcessor(Long documentTypeId) { 083 return (PostProcessor) postProcessors.get(documentTypeId); 084 } 085 086 public Collection findRouteLevels(Long documentTypeId) { 087 return (Collection) ((DocumentType)documentsById.get(documentTypeId)).getRouteLevels(); 088 } 089 090 public Collection find(DocumentType documentType, String docGroupName, boolean climbHiearchy) { 091 throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl"); 092 } 093 094 public void delete(DocumentType documentType) { 095 documentsById.remove(documentType.getDocumentTypeId()); 096 documentsByName.remove(documentType.getName()); 097 } 098 099 public List findByRouteHeaderId(Long routeHeaderId) { 100 throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl"); 101 } 102 public void makeCurrent(Long routeHeaderId) { 103 throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl"); 104 } 105 106 public List findAllCurrentRootDocuments() { 107 return null; 108 } 109 public DocumentType getMostRecentDocType(Long documentTypeId) { 110 return null; 111 } 112 /* (non-Javadoc) 113 * @see org.kuali.rice.kew.doctype.DocumentTypeService#getDocumentTypeVO(java.lang.Long) 114 */ 115 public DocumentTypeDTO getDocumentTypeVO(Long documentTypeId) { 116 return null; 117 } 118 /* (non-Javadoc) 119 * @see org.kuali.rice.kew.doctype.DocumentTypeService#getDocumentTypeVO(java.lang.String) 120 */ 121 public DocumentTypeDTO getDocumentTypeVO(String documentTypeName) { 122 return null; 123 } 124 /* (non-Javadoc) 125 * @see org.kuali.rice.kew.doctype.DocumentTypeService#getRootDocumentType(org.kuali.rice.kew.doctype.DocumentType) 126 */ 127 public DocumentType findRootDocumentType(DocumentType docType) { 128 return null; 129 } 130 public void loadXml(InputStream inputStream, String principalId) { 131 throw new UnsupportedOperationException("Mock document type service can't load xml"); 132 } 133 public Element export(ExportDataSet dataSet) { 134 return null; 135 } 136 public List findAllCurrent() { 137 return null; 138 } 139 public List getChildDocumentTypes(Long documentTypeId) { 140 return null; 141 } 142 public DocumentType findByNameIgnoreCache(Long documentTypeId) { 143 return null; 144 } 145 public void save(DocumentType documentType) { 146 147 } 148 public void save(DocumentType documentType, boolean flushCache) { 149 150 } 151 public void flushCache() { 152 153 } 154 public void clearCacheForAttributeUpdate(RuleAttribute ruleAttribute) { 155 156 } 157 public Integer getDocumentTypeCount() { 158 return null; 159 } 160 public List<DocumentType> findPreviousInstances(String documentTypeName) { 161 return null; 162 } 163 164 }