BrightSide Workbench Full Report + Source Code
FinancialsUserMenu.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2019 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.financials.user.menu;
20 
21 import org.turro.action.UserSummaries;
22 import org.turro.elephant.context.Application;
23 import org.turro.elephant.user.menu.DefaultUserMenu;
24 import org.turro.elephant.user.menu.UserMenu;
25 
30 @UserMenu
31 public class FinancialsUserMenu extends DefaultUserMenu {
32 
33  public FinancialsUserMenu() {
34  super("Billing", null, null, 3);
35  }
36 
37  @Override
38  public void initMenu() {
39  addChild(new DefaultUserMenu("Contracts", null, "/user/contracts") {
40  @Override
41  public boolean isInRole() {
42  return UserSummaries.isNotZero("contractCount");
43  }
44  @Override
45  public Object getDetail() {
46  return UserSummaries.getAttribute("contractCount");
47  }
48  });
49  addChild(new DefaultUserMenu("Documents", null, "/user/documents") {
50  @Override
51  public boolean isInRole() {
52  return UserSummaries.isNotZero("contractCount");
53  }
54  @Override
55  public Object getDetail() {
56  return null;
57  }
58  });
59  addChild(new DefaultUserMenu("Logistic", null, "/user/logistic") {
60  @Override
61  public boolean isInRole() {
62  return UserSummaries.isNotZero("notPreparedCount") ||
63  UserSummaries.isNotZero("notDeliveredCount");
64  }
65  @Override
66  public Object getDetail() {
67  return ((Long) UserSummaries.getAttribute("notPreparedCount", 0)) +
68  ((Long) UserSummaries.getAttribute("notDeliveredCount", 0));
69  }
70  });
71  }
72 
73  @Override
74  public boolean isInRole() {
76  UserSummaries.isNotZero("contractCount") ||
77  UserSummaries.isNotZero("notPreparedCount") ||
78  UserSummaries.isNotZero("notDeliveredCount"));
79  }
80 
81  @Override
82  public Object getDetail() {
83  return null;
84  }
85 
86 }
static boolean isNotZero(String attribute)
static Object getAttribute(String attribute)