Revision 32a4157a
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemNameAndTypeButtons.java | ||
---|---|---|
24 | 24 |
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO; |
25 | 25 |
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSet; |
26 | 26 |
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType; |
27 |
import eu.etaxonomy.cdm.api.utility.UserHelper; |
|
28 |
import eu.etaxonomy.cdm.model.ICdmEntityUuidCacher; |
|
27 | 29 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
28 | 30 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
29 | 31 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
... | ... | |
63 | 65 |
|
64 | 66 |
private Link identifierLink; |
65 | 67 |
|
66 |
public RegistrationItemNameAndTypeButtons(RegistrationDTO regDto) { |
|
68 |
public RegistrationItemNameAndTypeButtons(RegistrationDTO regDto, ICdmEntityUuidCacher entitiyCacher) {
|
|
67 | 69 |
|
68 | 70 |
boolean isRegistrationLocked = EnumSet.of( |
69 | 71 |
RegistrationStatus.PUBLISHED, RegistrationStatus.REJECTED) |
... | ... | |
71 | 73 |
|
72 | 74 |
setWidth(100, Unit.PERCENTAGE); |
73 | 75 |
|
76 |
UserHelper userHelper; |
|
77 |
if(entitiyCacher != null){ |
|
78 |
userHelper = UserHelperAccess.userHelper().withCache(entitiyCacher); |
|
79 |
} else { |
|
80 |
userHelper = UserHelperAccess.userHelper(); |
|
81 |
} |
|
82 |
|
|
74 | 83 |
if(regDto.getNameRef() != null){ |
75 | 84 |
Button nameButton = new Button("Name:"); |
76 | 85 |
nameButton.setDescription("Edit the Name"); |
77 | 86 |
nameIdButton = new IdButton<TaxonName>(TaxonName.class, regDto.getNameRef().getUuid(), nameButton); |
78 | 87 |
Label nameLabel = new Label(regDto.getNameRef().getLabel()); |
79 | 88 |
nameLabel.setWidthUndefined(); |
80 |
boolean userHasPermission = UserHelperAccess.userHelper().userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
|
|
89 |
boolean userHasPermission = userHelper.userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
|
|
81 | 90 |
nameButton.setReadOnly(isRegistrationLocked || ! userHasPermission); |
82 | 91 |
|
83 | 92 |
addComponent(nameIdButton.getButton()); |
... | ... | |
91 | 100 |
addComponent(nameLabel); |
92 | 101 |
} |
93 | 102 |
} |
94 |
boolean userHasAddPermission = !regDto.isPersisted() || UserHelperAccess.userHelper().userHasPermission(regDto.registration(), CRUD.UPDATE);
|
|
103 |
boolean userHasAddPermission = !regDto.isPersisted() || userHelper.userHasPermission(regDto.registration(), CRUD.UPDATE);
|
|
95 | 104 |
if(regDto.getOrderdTypeDesignationWorkingSets() != null){ |
96 | 105 |
for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) { |
97 | 106 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef); |
... | ... | |
99 | 108 |
String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType"; |
100 | 109 |
Button tdButton = new Button(buttonLabel + ":"); |
101 | 110 |
tdButton.setDescription("Edit the type designation working set"); |
102 |
boolean userHasUpdatePermission = UserHelperAccess.userHelper().userHasPermission(baseEntityRef.getType(), baseEntityRef.getUuid(), CRUD.UPDATE, CRUD.DELETE);
|
|
111 |
boolean userHasUpdatePermission = userHelper.userHasPermission(baseEntityRef.getType(), baseEntityRef.getUuid(), CRUD.UPDATE, CRUD.DELETE);
|
|
103 | 112 |
tdButton.setReadOnly(isRegistrationLocked || !userHasUpdatePermission); |
104 | 113 |
addComponent(tdButton); |
105 | 114 |
|
Also available in: Unified diff
using CachingUserHelper also with RegistrationItemNameAndTypeButtons to speed up registration workingsets