01: /*
02: * Copyright 2006-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.bo.user.AuthenticationUserId;
19: import org.kuali.core.service.UniversalUserService;
20: import org.kuali.core.workflow.service.KualiWorkflowDocument;
21: import org.kuali.core.workflow.service.WorkflowDocumentService;
22: import org.kuali.kfs.context.SpringContext;
23:
24: import edu.iu.uis.eden.exception.WorkflowException;
25:
26: /**
27: * Watches the workflow document and indicates valueChanged when either the status or the current node changes.
28: */
29: public class DocumentWorkflowNodeMonitor extends ChangeMonitor {
30:
31: private Long docHeaderId;
32: private String networkId;
33: private String desiredNodeName;
34:
35: public DocumentWorkflowNodeMonitor(KualiWorkflowDocument document,
36: String desiredNodeName) throws WorkflowException {
37: this .docHeaderId = document.getRouteHeaderId();
38: this .networkId = document.getInitiatorNetworkId();
39: this .desiredNodeName = desiredNodeName;
40: }
41:
42: public boolean valueChanged() throws Exception {
43: KualiWorkflowDocument document = SpringContext.getBean(
44: WorkflowDocumentService.class).createWorkflowDocument(
45: docHeaderId,
46: SpringContext.getBean(UniversalUserService.class)
47: .getUniversalUser(
48: new AuthenticationUserId(networkId)));
49: String currentNodeName = null;
50: if (document.getNodeNames().length > 0) {
51: currentNodeName = document.getNodeNames()[0];
52: }
53: // currently in Kuali there is no parallel branching so we can only ever be at one node
54: return desiredNodeName.equals(currentNodeName);
55: }
56:
57: }
|