Revision c2f87993
Added by Andreas Kohlbecker over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityLabelTextProvider.java | ||
---|---|---|
9 | 9 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
10 | 10 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
11 | 11 |
import eu.etaxonomy.cdm.api.service.INameService; |
12 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
12 | 13 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
14 |
import eu.etaxonomy.cdm.api.service.IRegistrationService; |
|
13 | 15 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
14 | 16 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
15 | 17 |
import eu.etaxonomy.cdm.api.service.IUserService; |
... | ... | |
18 | 20 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
19 | 21 |
|
20 | 22 |
public class GrantedAuthorityLabelTextProvider { |
21 |
|
|
23 |
|
|
22 | 24 |
public static final Logger logger = Logger.getLogger(CdmAuthority.class); |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
25 | 27 |
public static String getText(GrantedAuthority grantedAuthority){ |
26 | 28 |
String labelText = grantedAuthority.getAuthority(); |
27 | 29 |
try { |
... | ... | |
30 | 32 |
if(targetLabelText.length() > 0){ |
31 | 33 |
labelText = grantedAuthority.getAuthority().replace(cdmAuthority.getTargetUUID().toString(), targetLabelText); |
32 | 34 |
} |
33 |
} catch (Exception e) {
|
|
34 |
/* will in most cases catch a ParsingException
|
|
35 |
} catch (Exception e) { |
|
36 |
/* will in most cases catch a ParsingException |
|
35 | 37 |
* this is ignored |
36 | 38 |
*/ |
37 | 39 |
if(!e.getClass().getSimpleName().equals("ParsingException")){ |
... | ... | |
42 | 44 |
} |
43 | 45 |
return labelText; |
44 | 46 |
} |
45 |
|
|
47 |
|
|
46 | 48 |
public static String getTargetText(GrantedAuthority grantedAuthority){ |
47 | 49 |
if(grantedAuthority instanceof CdmAuthority){ |
48 | 50 |
return getCdmAuthorityTargetText((CdmAuthority)grantedAuthority); |
49 |
|
|
51 |
|
|
50 | 52 |
} |
51 | 53 |
return ""; |
52 | 54 |
} |
53 | 55 |
|
54 | 56 |
private static String getCdmAuthorityTargetText(CdmAuthority cdmAuthority) { |
55 |
|
|
57 |
|
|
56 | 58 |
UUID uuid = cdmAuthority.getTargetUUID(); |
57 | 59 |
String targetText = ""; |
58 |
|
|
60 |
|
|
59 | 61 |
if(uuid != null){ |
60 | 62 |
targetText = uuid.toString(); |
61 | 63 |
if(cdmAuthority.getPermissionClass() != null){ |
... | ... | |
91 | 93 |
case CLASSIFICATION: |
92 | 94 |
targetText = CdmStore.getService(IClassificationService.class).load(uuid).getTitleCache(); |
93 | 95 |
break; |
94 |
case REFERENCE:
|
|
96 |
case REFERENCE: |
|
95 | 97 |
targetText = CdmStore.getService(IReferenceService.class).load(uuid).getTitleCache(); |
96 | 98 |
break; |
97 | 99 |
case TAXONNAME: |
... | ... | |
100 | 102 |
case TEAMORPERSONBASE: |
101 | 103 |
targetText = CdmStore.getService(IAgentService.class).load(uuid).getTitleCache(); |
102 | 104 |
break; |
103 |
|
|
105 |
case REGISTRATION: |
|
106 |
targetText = CdmStore.getService(IRegistrationService.class).load(uuid).getIdentifier(); |
|
107 |
break; |
|
108 |
case SPECIMENOROBSERVATIONBASE: |
|
109 |
targetText = CdmStore.getService(IOccurrenceService.class).load(uuid).getTitleCache(); |
|
110 |
break; |
|
111 |
default: |
|
112 |
break; |
|
113 |
|
|
104 | 114 |
} |
105 | 115 |
} catch (NullPointerException e){ |
106 | 116 |
logger.warn("Either no service found for " + cdmAuthority.getPermissionClass() + " or entitiy not found" , e); |
107 | 117 |
} |
108 | 118 |
} |
109 | 119 |
} |
110 |
|
|
120 |
|
|
111 | 121 |
return targetText; |
112 | 122 |
} |
113 |
|
|
123 |
|
|
114 | 124 |
|
115 | 125 |
} |
Also available in: Unified diff
ref #7018 adapting taxeditor to changes in cdm permission classes