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