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.kuali.core.document.Document;
19: import org.kuali.core.service.DocumentService;
20:
21: /**
22: * DocumentVersionMonitor
23: */
24: public class DocumentVersionMonitor extends ChangeMonitor {
25: private final DocumentService documentService;
26: private final String documentHeaderId;
27: private final Long startVersion;
28:
29: public DocumentVersionMonitor(DocumentService documentService,
30: String documentHeaderId, Long startVersion) {
31: this .documentService = documentService;
32: this .documentHeaderId = documentHeaderId;
33: this .startVersion = startVersion;
34: }
35:
36: /**
37: * Returns true if the version number of the given projectCode changes from startVersion.
38: *
39: * @see org.kuali.test.monitor.ChangeMonitor#valueChanged()
40: */
41: public boolean valueChanged() throws Exception {
42: boolean changed = false;
43:
44: Document hopefullyUpdatedDocument = documentService
45: .getByDocumentHeaderId(documentHeaderId.toString());
46: Long currentVersion = hopefullyUpdatedDocument
47: .getVersionNumber();
48:
49: changed = !currentVersion.equals(this.startVersion);
50:
51: return changed;
52:
53: }
54: }
|