001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.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/ecl1.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:
027: import edu.iu.uis.eden.EdenConstants;
028: import edu.iu.uis.eden.clientapp.vo.DocumentTypeVO;
029: import edu.iu.uis.eden.doctype.DocumentType;
030: import edu.iu.uis.eden.doctype.DocumentTypeService;
031: import edu.iu.uis.eden.export.ExportDataSet;
032: import edu.iu.uis.eden.postprocessor.PostProcessor;
033: import edu.iu.uis.eden.routetemplate.RuleAttribute;
034: import edu.iu.uis.eden.user.WorkflowUser;
035:
036: public class MockDocumentTypeServiceImpl implements DocumentTypeService {
037:
038: public DocumentType setDocumentTypeVersion(
039: DocumentType documentType, boolean currentInd) {
040: return null;
041: }
042:
043: public DocumentType getMostRecentDocType(String docTypeName) {
044: return null;
045: }
046:
047: public boolean isLockedForRouting(DocumentType documentType) {
048: return false;
049: }
050:
051: private Map documentsById = new HashMap();
052: private Map documentsByName = new HashMap();
053: private Map postProcessors = new HashMap();
054:
055: public void makeCurrent(List documentTypes) {
056: throw new UnsupportedOperationException("not yet implmeneted");
057: }
058:
059: public void addDocumentType(DocumentType documentType,
060: PostProcessor postProcessor) {
061: documentsById.put(documentType.getDocumentTypeId(),
062: documentType);
063: documentsByName.put(documentType.getName(), documentType);
064: postProcessors.put(documentType.getDocumentTypeId(),
065: postProcessor);
066: }
067:
068: public DocumentType findByDocumentId(Long documentId) {
069: throw new UnsupportedOperationException("not yet implemented");
070: }
071:
072: public DocumentTypeVO getDocumentTypeVOById(Long documentTypeId) {
073: DocumentType docType = findById(documentTypeId);
074: DocumentTypeVO docTypeVO = new DocumentTypeVO();
075: docTypeVO.setDocTypeParentId(docType.getDocTypeParentId());
076: docTypeVO.setDocTypeDescription(docType.getDescription());
077: docTypeVO.setDocTypeHandlerUrl(docType.getDocHandlerUrl());
078: docTypeVO.setDocTypeId(docType.getDocumentTypeId());
079: docTypeVO.setDocTypeLabel(docType.getLabel());
080: docTypeVO.setName(docType.getName());
081: docTypeVO.setDocTypeVersion(docType.getVersion());
082: if (docType.getCurrentInd().booleanValue()) {
083: docTypeVO.setDocTypeCurrentInd(EdenConstants.ACTIVE_CD);
084: } else {
085: docTypeVO.setDocTypeCurrentInd(EdenConstants.INACTIVE_CD);
086: }
087: docTypeVO.setPostProcessorName(docType.getPostProcessorName());
088: docTypeVO.setDocTypeJndiFactoryClass(null);
089: docTypeVO.setDocTypeActiveInd(docType.getActiveInd()
090: .booleanValue());
091:
092: if (docType.getParentDocType() != null) {
093: docTypeVO.setDocTypeActiveInherited(true);
094: } else {
095: docTypeVO.setDocTypeActiveInherited(false);
096: }
097:
098: docTypeVO.setDocTypeDefaultApprovePolicy(docType
099: .getDefaultApprovePolicy().getPolicyValue()
100: .booleanValue());
101: docTypeVO.setDocTypePreApprovalPolicy(docType
102: .getPreApprovePolicy().getPolicyValue().booleanValue());
103: return docTypeVO;
104: }
105:
106: public Integer getMaxVersionNumber(String name) {
107: return new Integer(0);
108: }
109:
110: public DocumentType findById(Long documentTypeId) {
111: return (DocumentType) documentsById.get(documentTypeId);
112: }
113:
114: public DocumentType findByName(String name) {
115: return (DocumentType) documentsByName.get(name);
116: }
117:
118: public void versionAndSave(DocumentType documentType) {
119: addDocumentType(documentType, new MockPostProcessor(true));
120: }
121:
122: public PostProcessor getPostProcessor(Long documentTypeId) {
123: return (PostProcessor) postProcessors.get(documentTypeId);
124: }
125:
126: public Collection findRouteLevels(Long documentTypeId) {
127: return (Collection) ((DocumentType) documentsById
128: .get(documentTypeId)).getRouteLevels();
129: }
130:
131: public Collection find(DocumentType documentType,
132: String docGroupName, boolean climbHiearchy) {
133: throw new UnsupportedOperationException(
134: "not implemented in MockDocumentTypeServiceImpl");
135: }
136:
137: public void delete(DocumentType documentType) {
138: documentsById.remove(documentType.getDocumentTypeId());
139: documentsByName.remove(documentType.getName());
140: }
141:
142: public DocumentType route(DocumentType documentType,
143: WorkflowUser user, String annotation) {
144: return new DocumentType();
145: }
146:
147: public List findByRouteHeaderId(Long routeHeaderId) {
148: throw new UnsupportedOperationException(
149: "not implemented in MockDocumentTypeServiceImpl");
150: }
151:
152: public void makeCurrent(Long routeHeaderId) {
153: throw new UnsupportedOperationException(
154: "not implemented in MockDocumentTypeServiceImpl");
155: }
156:
157: public DocumentType blanketApprove(Long routeHeaderId,
158: DocumentType documentType, WorkflowUser user,
159: String annotation) throws Exception {
160: return null;
161: }
162:
163: public List findAllCurrentRootDocuments() {
164: return null;
165: }
166:
167: public DocumentType getMostRecentDocType(Long documentTypeId) {
168: return null;
169: }
170:
171: public DocumentType route(Long routeHeaderId,
172: DocumentType documentType, WorkflowUser user,
173: String annotation) throws Exception {
174:
175: return null;
176: }
177:
178: /* (non-Javadoc)
179: * @see edu.iu.uis.eden.doctype.DocumentTypeService#getDocumentTypeVO(java.lang.Long)
180: */
181: public DocumentTypeVO getDocumentTypeVO(Long documentTypeId) {
182: return null;
183: }
184:
185: /* (non-Javadoc)
186: * @see edu.iu.uis.eden.doctype.DocumentTypeService#getDocumentTypeVO(java.lang.String)
187: */
188: public DocumentTypeVO getDocumentTypeVO(String documentTypeName) {
189: return null;
190: }
191:
192: /* (non-Javadoc)
193: * @see edu.iu.uis.eden.doctype.DocumentTypeService#getRootDocumentType(edu.iu.uis.eden.doctype.DocumentType)
194: */
195: public DocumentType findRootDocumentType(DocumentType docType) {
196: return null;
197: }
198:
199: public void loadXml(InputStream inputStream, WorkflowUser user) {
200: throw new UnsupportedOperationException(
201: "Mock document type service can't load xml");
202: }
203:
204: public Element export(ExportDataSet dataSet) {
205: return null;
206: }
207:
208: public List findAllCurrent() {
209: return null;
210: }
211:
212: public List getChildDocumentTypes(DocumentType documentType) {
213: return null;
214: }
215:
216: public DocumentType findByNameIgnoreCache(Long documentTypeId) {
217: return null;
218: }
219:
220: public void save(DocumentType documentType) {
221:
222: }
223:
224: public void clearCacheForAttributeUpdate(RuleAttribute ruleAttribute) {
225:
226: }
227:
228: public Integer getDocumentTypeCount() {
229: return null;
230: }
231:
232: }
|