01: package org.emforge.jbpm.web.bean;
02:
03: import java.util.List;
04:
05: import org.emforge.BpmService;
06: import org.emforge.EmForgeException;
07: import org.emforge.projectmanager.ProjectService;
08: import org.emforge.xfer.StepTO;
09: import org.emforge.xfer.WorkflowTO;
10:
11: import ru.emdev.EmForge.security.UserSettingsService;
12: import ru.emdev.EmForge.web.bean.BaseControllerImpl;
13: import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
14: import ru.emdev.EmForge.wiki.web.bean.Crumb;
15:
16: /** Controller for processing main page
17: *
18: */
19: public class MainController extends BaseControllerImpl {
20: /** BPM Context */
21: BpmService m_bpmService;
22: ProjectService m_projectService;
23: UserSettingsService m_userSettingsService;
24:
25: public static final String TASKSMAINPAGE_NAME = "tasks";
26:
27: public static final String TITLE_SEPARATOR = ": ";
28:
29: public void setBpmService(BpmService i_bpmService) {
30: m_bpmService = i_bpmService;
31: }
32:
33: public void setUserSettingsService(
34: UserSettingsService i_userSettings) {
35: m_userSettingsService = i_userSettings;
36: }
37:
38: public void setProjectService(ProjectService i_projectService) {
39: m_projectService = i_projectService;
40: }
41:
42: @Override
43: public MainMenuItem getSelectionItemOnMainMenu() {
44: return MainMenuItem.TASKS;
45: }
46:
47: @Override
48: public Crumb getTrailCrumbInfo() {
49: return new Crumb(MainMenuItem.TASKS.getTitle(),
50: MainMenuItem.TASKS.getName());
51: }
52:
53: @Override
54: protected void init() {
55: }
56:
57: @Override
58: public String getTitleImpl() {
59: return MainMenuItem.TASKS.getTitle();
60: }
61:
62: /** Return list of workflows availale for user
63: *
64: * @return
65: * @throws EmForgeException
66: */
67: public WorkflowTO[] getWorkflowList() throws EmForgeException {
68: return m_bpmService.getWorkflows();
69: }
70:
71: /** Return list of steps, currently assigned to user
72: *
73: * @return
74: * @throws EmForgeException
75: */
76: public List<StepTO> getActiveStepList() throws EmForgeException {
77: if (m_userSettingsService.getDefaultProject() != null) {
78: return m_bpmService.getActiveSteps(m_userSettingsService
79: .getDefaultProject().getName());
80: } else {
81: return m_bpmService.getActiveSteps(null);
82: }
83:
84: }
85:
86: /** Canuser start new task?
87: *
88: * @return
89: * @throws EmForgeException
90: */
91: public boolean isCanStartNewTask() throws EmForgeException {
92: return !getCurrentUser().isAnonymous()
93: && getWorkflowList().length > 0
94: && m_projectService.getAllProjects().size() > 0;
95: }
96:
97: }
|