1 /*
2 * Copyright 2003 - 2013 The eFaps Team
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 * Revision: $Rev$
17 * Last Changed: $Date$
18 * Last Changed By: $Author$
19 */
20
21 package org.efaps.bpm.process;
22
23 import java.util.List;
24
25 import org.jbpm.process.audit.JPAAuditLogService;
26 import org.jbpm.process.audit.NodeInstanceLog;
27 import org.jbpm.process.audit.ProcessInstanceLog;
28 import org.jbpm.process.audit.VariableInstanceLog;
29
30 /**
31 * TODO comment!
32 *
33 * @author The eFaps Team
34 * @version $Id$
35 */
36 public class ProcessAdmin
37 {
38 /**
39 * Underlying audit service used for administration.
40 */
41 private final JPAAuditLogService jpaAuditLogService;
42
43 /**
44 * @param _jpaAuditLogService audit service to be used
45 */
46 public ProcessAdmin(final JPAAuditLogService _jpaAuditLogService)
47 {
48 this.jpaAuditLogService = _jpaAuditLogService;
49 }
50
51 /**
52 * @param _processId processId
53 * @return list of all active processes for the given processId.
54 */
55 public List<ProcessInstanceLog> getActiveProcessInstances(final String _processId)
56 {
57 return this.jpaAuditLogService.findActiveProcessInstances(_processId);
58 }
59
60 /**
61 * @param _processInstanceId processInstanceId
62 * @return list of all NodeInstance logs for the given processInstanceId.
63 */
64 public List<NodeInstanceLog> getNodeInstances(final Long _processInstanceId)
65 {
66 return this.jpaAuditLogService.findNodeInstances(_processInstanceId);
67 }
68
69 /**
70 * @param _processInstanceId processInstanceId
71 * @param _nodeId NodeId
72 * @return list of all NodeInstance logs for the given processInstanceId and NodeId.
73 */
74 public List<NodeInstanceLog> getNodeInstances(final Long _processInstanceId,
75 final String _nodeId)
76 {
77 return this.jpaAuditLogService.findNodeInstances(_processInstanceId, _nodeId);
78 }
79
80 /**
81 * @param _processInstanceId processInstanceId
82 * @return processes for the given processId.
83 */
84 public ProcessInstanceLog getProcessInstance(final Long _processInstanceId)
85 {
86 return this.jpaAuditLogService .findProcessInstance(_processInstanceId);
87 }
88
89 /**
90 * @return list of all found process Instances.
91 */
92 public List<ProcessInstanceLog> getProcessInstances()
93 {
94 return this.jpaAuditLogService.findProcessInstances();
95 }
96
97 /**
98 * @param _processId processId
99 * @return list of all processes for the given processId.
100 */
101 public List<ProcessInstanceLog> getProcessInstances(final String _processId)
102 {
103 return this.jpaAuditLogService.findProcessInstances(_processId);
104 }
105
106 /**
107 * @param _processInstanceId processInstanceId
108 * @return list of all variable logs for the given processinstanceId.
109 */
110 public List<VariableInstanceLog> getVariableInstances(final Long _processInstanceId)
111 {
112 return this.jpaAuditLogService.findVariableInstances(_processInstanceId);
113 }
114
115 /**
116 * @param _processInstanceId processInstanceId
117 * @param _variableId variable id
118 * @return list of all variable logs for the given processinstanceId and variable id.
119 */
120 public List<VariableInstanceLog> getVariableInstances(final Long _processInstanceId,
121 final String _variableId)
122 {
123 return this.jpaAuditLogService.findVariableInstances(_processInstanceId, _variableId);
124 }
125 }