Project

General

Profile

« Previous | Next » 

Revision 0844524a

Added by Andreas Kohlbecker about 6 years ago

switching vom id based to uuid based ui navigation and entity references

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemNameAndTypeButtons.java
11 11
import java.util.ArrayList;
12 12
import java.util.EnumSet;
13 13
import java.util.List;
14
import java.util.UUID;
14 15

  
15 16
import org.apache.log4j.Logger;
16 17

  
......
74 75
        if(regDto.getNameRef() != null){
75 76
            Button nameButton = new Button("Name:");
76 77
            nameButton.setDescription("Edit the Name");
77
            nameIdButton = new IdButton<TaxonName>(TaxonName.class, regDto.getNameRef().getId(), nameButton);
78
            nameIdButton = new IdButton<TaxonName>(TaxonName.class, regDto.getNameRef().getUuid(), nameButton);
78 79
            Label nameLabel = new Label(regDto.getNameRef().getLabel());
79 80
            nameLabel.setWidthUndefined();
80 81
            boolean userHasPermission = UserHelper.fromSession().userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
81 82
            nameButton.setReadOnly(isRegistrationLocked || ! userHasPermission);
82 83

  
83 84
            addComponent(nameIdButton.getButton());
84
            PermissionDebugUtils.addGainPerEntityPermissionButton(this, TaxonName.class, regDto.getNameRef().getId(),
85
            PermissionDebugUtils.addGainPerEntityPermissionButton(this, TaxonName.class, regDto.getNameRef().getUuid(),
85 86
                    EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
86 87
            addComponent(nameLabel);
87 88
        } else {
......
91 92
                addComponent(nameLabel);
92 93
            }
93 94
        }
94
        boolean userHasAddPermission = UserHelper.fromSession().userHasPermission(Registration.class, regDto.getId(), CRUD.UPDATE);
95
        boolean userHasAddPermission = UserHelper.fromSession().userHasPermission(Registration.class, regDto.getUuid(), CRUD.UPDATE);
95 96
        if(regDto.getOrderdTypeDesignationWorkingSets() != null){
96 97
            for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) {
97 98
                TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef);
......
99 100
                String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
100 101
                Button tdButton = new Button(buttonLabel + ":");
101 102
                tdButton.setDescription("Edit the type designation working set");
102
                boolean userHasUpdatePermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getId(), CRUD.UPDATE, CRUD.DELETE);
103
                boolean userHasUpdatePermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getUuid(), CRUD.UPDATE, CRUD.DELETE);
103 104
                tdButton.setReadOnly(isRegistrationLocked || !userHasUpdatePermission);
104 105
                addComponent(tdButton);
105 106

  
106 107
                PermissionDebugUtils.addGainPerEntityPermissionButton(this, SpecimenOrObservationBase.class,
107
                        baseEntityRef.getId(), EnumSet.of(CRUD.UPDATE, CRUD.DELETE), RegistrationStatus.PREPARATION.name());
108
                        baseEntityRef.getUuid(), EnumSet.of(CRUD.UPDATE, CRUD.DELETE), RegistrationStatus.PREPARATION.name());
108 109

  
109 110
                typeDesignationButtons.add(new TypeDesignationWorkingSetButton(
110 111
                        typeDesignationWorkingSet.getWorkingsetType(),
......
207 208
    }
208 209

  
209 210
    public class IdButton<T> {
210
        private Integer id;
211
        private UUID uuid;
211 212
        private Class<T> entityType;
212 213
        private Button button;
213 214

  
214
        public IdButton(Class<T> type, Integer id, Button button){
215
        public IdButton(Class<T> type, UUID uuid, Button button){
215 216
            this.entityType = type;
216
            this.id = id;
217
            this.uuid = uuid;
217 218
            this.button = button;
218 219
        }
219 220

  
220 221
        /**
221 222
         * @return the id
222 223
         */
223
        public Integer getId() {
224
            return id;
224
        public UUID getUuid() {
225
            return uuid;
225 226
        }
226 227

  
227 228
        /**

Also available in: Unified diff