Project

General

Profile

« Previous | Next » 

Revision 73129ab9

Added by Andreas Kohlbecker over 5 years ago

ref #6999 protecting type and name buttons

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.java
20 20
import com.vaadin.ui.themes.ValoTheme;
21 21

  
22 22
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
23
import eu.etaxonomy.cdm.model.name.TaxonName;
24
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
23 25
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
24
import eu.etaxonomy.cdm.remote.dto.tdwg.voc.TaxonName;
26
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
25 27
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference;
28
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
26 29
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet;
27 30
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType;
28 31
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO;
......
71 74
            nameIdButton = new IdButton<TaxonName>(TaxonName.class, regDto.getName().getId(), nameButton);
72 75
            Label nameLabel = new Label(regDto.getName().getLabel());
73 76
            nameLabel.setWidthUndefined();
74
            nameButton.setEnabled(!isRegistrationLocked);
75
            addComponents(nameIdButton.getButton(), nameLabel);
77
            nameButton.setEnabled(!isRegistrationLocked && UserHelper.fromSession().userHasPermission(TaxonName.class, regDto.getName().getId(), CRUD.UPDATE));
78

  
79
            addComponent(nameIdButton.getButton());
80
            // PermissionDebugUtils.fromSession().addGainPerEntityPermissionButton(this, TaxonName.class, regDto.getName().getId(), CRUD.UPDATE);
81
            addComponent(nameLabel);
76 82
        } else {
77 83
            // no name in the registration! we only show the typified name as label
78 84
            if(regDto.getTypifiedName() != null){
......
81 87
            }
82 88
        }
83 89
        if(regDto.getOrderdTypeDesignationWorkingSets() != null){
84
            for(TypedEntityReference baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) {
90
            for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) {
85 91
                TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef);
86 92
                String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
87 93
                Button tdButton = new Button(buttonLabel + ":");
88 94
                tdButton.setDescription("Edit the type designation working set");
89
                tdButton.setEnabled(!isRegistrationLocked);
95
                tdButton.setEnabled(!isRegistrationLocked && UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE));
90 96
                addComponent(tdButton);
91 97
//                Set<Integer> idSet = new HashSet<>();
92 98
//                typeDesignationWorkingSet.getTypeDesignations().forEach(td -> idSet.add(td.getId()));
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
15 15
import org.springframework.context.event.EventListener;
16 16
import org.springframework.security.core.Authentication;
17 17

  
18
import com.vaadin.server.SystemError;
19 18
import com.vaadin.spring.annotation.SpringComponent;
20 19
import com.vaadin.spring.annotation.ViewScope;
20
import com.vaadin.ui.Label;
21
import com.vaadin.ui.UI;
22
import com.vaadin.ui.VerticalLayout;
23
import com.vaadin.ui.Window;
21 24

  
22 25
import eu.etaxonomy.cdm.api.service.INameService;
23 26
import eu.etaxonomy.cdm.api.service.IRegistrationService;
......
160 163
        try {
161 164
            workingset = getWorkingSetService().loadWorkingSetByReferenceID(referenceID);
162 165
        } catch (RegistrationValidationException error) {
163
            getView().getWorkflow().setComponentError(new SystemError(error));
166
            logger.error(error);
167
            Window errorDialog = new Window("Validation Error");
168
            errorDialog.setModal(true);
169
            VerticalLayout subContent = new VerticalLayout();
170
            subContent.setMargin(true);
171
            errorDialog.setContent(subContent);
172
            subContent.addComponent(new Label(error.getMessage()));
173
            UI.getCurrent().addWindow(errorDialog);
164 174
        }
165 175
        if(workingset == null || workingset.getCitationId() == null){
166 176
            Reference citation = getRepo().getReferenceService().find(referenceID);
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
304 304
                    )
305 305
                );
306 306
            });
307
            editButtonGroup.getNameButton().getButton().addFocusListener(e -> System.out.println("###"));
307 308
        }
308 309

  
309 310
        for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){

Also available in: Unified diff