01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.workflow.module.purap.attribute;
17:
18: import java.util.List;
19:
20: import org.kuali.core.service.DocumentService;
21: import org.kuali.core.util.ObjectUtils;
22: import org.kuali.kfs.context.SpringContext;
23: import org.kuali.module.purap.document.AccountsPayableDocument;
24:
25: import edu.iu.uis.eden.exception.WorkflowException;
26: import edu.iu.uis.eden.routeheader.DocumentContent;
27: import edu.iu.uis.eden.routetemplate.AbstractWorkflowAttribute;
28: import edu.iu.uis.eden.routetemplate.RuleExtension;
29:
30: /**
31: * This class... TODO delyea - documentation
32: */
33: public class KualiAccountsPayableReviewAttribute extends
34: AbstractWorkflowAttribute {
35: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
36: .getLogger(KualiAccountsPayableReviewAttribute.class);
37:
38: private AccountsPayableDocument getAccountsPayableDocument(
39: String documentNumber) {
40: try {
41: AccountsPayableDocument document = (AccountsPayableDocument) SpringContext
42: .getBean(DocumentService.class)
43: .getByDocumentHeaderId(documentNumber);
44: if (ObjectUtils.isNull(document)) {
45: String errorMsg = "Error trying to get document using doc id '"
46: + documentNumber + "'";
47: LOG.error("getAccountsPayableDocument() " + errorMsg);
48: throw new RuntimeException(errorMsg);
49: }
50: document.refreshNonUpdateableReferences();
51: return document;
52: } catch (WorkflowException e) {
53: String errorMsg = "Error trying to get document using doc id '"
54: + documentNumber + "'";
55: LOG.error("getAccountsPayableDocument() " + errorMsg, e);
56: throw new RuntimeException(errorMsg, e);
57: }
58: }
59:
60: /**
61: * @see edu.iu.uis.eden.plugin.attributes.WorkflowAttribute#isMatch(edu.iu.uis.eden.routeheader.DocumentContent, java.util.List)
62: */
63: public boolean isMatch(DocumentContent docContent,
64: List<RuleExtension> ruleExtensions) {
65: AccountsPayableDocument document = getAccountsPayableDocument(docContent
66: .getRouteContext().getDocument().getRouteHeaderId()
67: .toString());
68: return document.requiresAccountsPayableReviewRouting();
69: }
70:
71: }
|