BrightSide Workbench Full Report + Source Code
RoleUtil.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.visual;
20 
21 import java.util.HashSet;
22 import org.turro.string.Strings;
23 import org.turro.dossier.entity.IDossierParticipant;
24 import org.turro.dossier.entity.IssueParticipant;
25 import org.turro.i18n.I_;
26 
31 public class RoleUtil {
32 
33  // Dossier
34 
35  public static HashSet<String> getStringRoles(IDossierParticipant dp) {
36  HashSet<String> set = new HashSet<>();
37  set.addAll(getAttributeStringRoles(dp));
38  if(!Strings.isBlank(dp.getDiscriminator())) {
39  set.add(dp.getDiscriminator());
40  }
41  set.add(dp.getRole().name());
42  return set;
43  }
44 
45  public static HashSet<String> getRoleLabels(IDossierParticipant dp) {
46  HashSet<String> set = new HashSet<>();
47  for(String label : getAttributeStringRoles(dp)) {
48  set.add(I_.get(label));
49  }
50  if(!Strings.isBlank(dp.getDiscriminator())) {
51  set.add(dp.getDiscriminator());
52  }
53  set.add(I_.byKey(dp.getRole().toString()));
54  return set;
55  }
56 
57  private static HashSet<String> getAttributeStringRoles(IDossierParticipant dp) {
58  HashSet<String> set = new HashSet<>();
59  if(dp.isAdmin()) {
60  set.add("Admin");
61  }
62  if(dp.isBeneficiary()) {
63  set.add("Beneficiary");
64  }
65  if(dp.isConsortium()) {
66  set.add("Consortium");
67  }
68  if(dp.isCoordinator()) {
69  set.add("Coordinator");
70  }
71  if(dp.isDriver()) {
72  set.add("Driver");
73  }
74  if(dp.isFunding()) {
75  set.add("Funding");
76  }
77  if(dp.isOfferer()) {
78  set.add("Offerer");
79  }
80  if(dp.isResearch()) {
81  set.add("Research");
82  }
83  if(dp.isSupport()) {
84  set.add("Support");
85  }
86  return set;
87  }
88 
89  // Issue
90 
91  public static HashSet<String> getStringRoles(IssueParticipant ip) {
92  HashSet<String> set = new HashSet<>();
93  set.add(ip.getRole().name());
94  return set;
95  }
96 
97 }
static String byKey(String key)
Definition: I_.java:83
static String get(String msg)
Definition: I_.java:41
static HashSet< String > getStringRoles(IDossierParticipant dp)
Definition: RoleUtil.java:35
static HashSet< String > getRoleLabels(IDossierParticipant dp)
Definition: RoleUtil.java:45
static HashSet< String > getStringRoles(IssueParticipant ip)
Definition: RoleUtil.java:91