01: /*
02: * Copyright 2005-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.test.monitor;
17:
18: import org.apache.commons.lang.StringUtils;
19: import org.kuali.core.document.Document;
20: import org.kuali.core.service.DocumentService;
21:
22: /**
23: * DocumentStatusMonitor
24: */
25: public class DocumentStatusMonitor extends ChangeMonitor {
26: final DocumentService documentService;
27: final private String docHeaderId;
28: final private String desiredStatus;
29:
30: public DocumentStatusMonitor(DocumentService documentService,
31: String docHeaderId, String desiredStatus) {
32: this .documentService = documentService;
33: this .docHeaderId = docHeaderId;
34: this .desiredStatus = desiredStatus;
35: }
36:
37: public boolean valueChanged() throws Exception {
38: Document d = documentService.getByDocumentHeaderId(docHeaderId
39: .toString());
40:
41: String currentStatus = d.getDocumentHeader()
42: .getFinancialDocumentStatusCode();
43: return StringUtils.equals(desiredStatus, currentStatus);
44: }
45: }
|