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.core.api.impex.ExportDataSet;
027    import org.kuali.rice.kew.doctype.bo.DocumentType;
028    import org.kuali.rice.kew.doctype.service.DocumentTypeService;
029    import org.kuali.rice.kew.postprocessor.PostProcessor;
030    import org.kuali.rice.kew.rule.bo.RuleAttribute;
031    
032    
033    public class MockDocumentTypeServiceImpl implements DocumentTypeService {
034    
035        public DocumentType setDocumentTypeVersion(DocumentType documentType, boolean currentInd) {
036            return null;
037        }
038        public DocumentType getMostRecentDocType(String docTypeName) {
039            return null;
040        }
041        public boolean isLockedForRouting(DocumentType documentType) {
042            return false;
043        }
044        private Map<String, DocumentType> documentsById = new HashMap<String, DocumentType>();
045        private Map<String, DocumentType> documentsByName = new HashMap<String, DocumentType>();
046        private Map<String, PostProcessor> postProcessors = new HashMap<String, PostProcessor>();
047    
048        public void makeCurrent(List documentTypes) {
049            throw new UnsupportedOperationException("not yet implmeneted");
050        }
051    
052        public void addDocumentType(DocumentType documentType, PostProcessor postProcessor) {
053            documentsById.put(documentType.getDocumentTypeId(), documentType);
054            documentsByName.put(documentType.getName(), documentType);
055            postProcessors.put(documentType.getDocumentTypeId(), postProcessor);
056        }
057    
058        public DocumentType findByDocumentId(String documentId) {
059                    throw new UnsupportedOperationException("not yet implemented");
060            }
061    
062        public Integer getMaxVersionNumber(String name){
063            return new Integer(0);
064        }
065        public DocumentType findById(String documentTypeId) {
066            return (DocumentType) documentsById.get(documentTypeId);
067        }
068    
069        public DocumentType findByName(String name) {
070            return (DocumentType) documentsByName.get(name);
071        }
072    
073        public DocumentType findByNameCaseInsensitive(String name) {
074            return (DocumentType) documentsByName.get(name);
075        }
076    
077        public void versionAndSave(DocumentType documentType) {
078            addDocumentType(documentType, new MockPostProcessor(true));
079        }
080    
081        public PostProcessor getPostProcessor(String documentTypeId) {
082            return (PostProcessor) postProcessors.get(documentTypeId);
083        }
084    
085        public Collection findRouteLevels(String documentTypeId) {
086            return (Collection) ((DocumentType)documentsById.get(documentTypeId)).getRouteLevels();
087        }
088    
089        public Collection find(DocumentType documentType, String docGroupName, boolean climbHiearchy) {
090            throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl");
091        }
092    
093        public void delete(DocumentType documentType) {
094            documentsById.remove(documentType.getDocumentTypeId());
095            documentsByName.remove(documentType.getName());
096        }
097    
098        public List findByRouteHeaderId (String documentId) {
099            throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl");
100        }
101        public void makeCurrent(String documentId) {
102            throw new UnsupportedOperationException("not implemented in MockDocumentTypeServiceImpl");
103        }
104    
105        public List findAllCurrentRootDocuments() {
106            return null;
107        }
108    
109        /* (non-Javadoc)
110         * @see org.kuali.rice.kew.doctype.DocumentTypeService#getRootDocumentType(org.kuali.rice.kew.doctype.DocumentType)
111         */
112        public DocumentType findRootDocumentType(DocumentType docType) {
113            return null;
114        }
115        public void loadXml(InputStream inputStream, String principalId) {
116            throw new UnsupportedOperationException("Mock document type service can't load xml");
117        }
118        public Element export(ExportDataSet dataSet) {
119            return null;
120        }
121            @Override
122            public boolean supportPrettyPrint() {
123                    return true;
124            }
125            public List findAllCurrent() {
126            return null;
127        }
128            public List getChildDocumentTypes(String documentTypeId) {
129                    return null;
130            }
131            public DocumentType findByNameIgnoreCache(String documentTypeId) {
132                    return null;
133            }
134            public void save(DocumentType documentType) {
135    
136            }
137        public void save(DocumentType documentType, boolean flushCache) {
138    
139        }
140        public void flushCache() {
141    
142        }
143            public void clearCacheForAttributeUpdate(RuleAttribute ruleAttribute) {
144    
145            }
146            public Integer getDocumentTypeCount() {
147                    return null;
148            }
149        public List<DocumentType> findPreviousInstances(String documentTypeName) {
150            return null;
151        }
152    
153    }