9 |
9 |
package eu.etaxonomy.cdm.vaadin.component.registration;
|
10 |
10 |
|
11 |
11 |
import java.util.ArrayList;
|
|
12 |
import java.util.Collections;
|
12 |
13 |
import java.util.EnumSet;
|
13 |
14 |
import java.util.LinkedHashMap;
|
14 |
15 |
import java.util.List;
|
... | ... | |
41 |
42 |
import eu.etaxonomy.cdm.strategy.cache.TagEnum;
|
42 |
43 |
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
|
43 |
44 |
import eu.etaxonomy.cdm.vaadin.component.ButtonFactory;
|
|
45 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists.TypeDesignationStatusBaseComparator;
|
44 |
46 |
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
|
45 |
47 |
import eu.etaxonomy.vaadin.component.CompositeStyledComponent;
|
46 |
48 |
|
... | ... | |
114 |
116 |
}
|
115 |
117 |
boolean userHasAddPermission = !regDto.isPersisted() || userHelper.userHasPermission(regDto.registration(), CRUD.UPDATE);
|
116 |
118 |
LinkedHashMap<TypedEntityReference<? extends VersionableEntity>, TypeDesignationWorkingSet> typeDesignationworkingSets = regDto.getOrderedTypeDesignationWorkingSets();
|
|
119 |
|
|
120 |
|
117 |
121 |
if(typeDesignationworkingSets != null){
|
|
122 |
// order the typeDesignationworkingSet keys so that holotypes come first, etc
|
|
123 |
List<TypedEntityRefWithStatus> baseRefsByHighestStatus = new ArrayList<>();
|
118 |
124 |
for(TypedEntityReference<? extends VersionableEntity> baseEntityRef : typeDesignationworkingSets.keySet()) {
|
|
125 |
baseRefsByHighestStatus.add(new TypedEntityRefWithStatus(baseEntityRef, typeDesignationworkingSets.get(baseEntityRef).highestTypeStatus(new TypeDesignationStatusBaseComparator())));
|
|
126 |
}
|
|
127 |
|
|
128 |
Collections.sort(baseRefsByHighestStatus);
|
|
129 |
|
|
130 |
for(TypedEntityRefWithStatus typedEntityRefWithStatus : baseRefsByHighestStatus) {
|
|
131 |
TypedEntityReference<? extends VersionableEntity> baseEntityRef = typedEntityRefWithStatus.typedEntityRef;
|
119 |
132 |
TypeDesignationWorkingSet typeDesignationWorkingSet = typeDesignationworkingSets.get(baseEntityRef);
|
120 |
133 |
logger.debug("WorkingSet:" + typeDesignationWorkingSet.getWorkingsetType() + ">" + typeDesignationWorkingSet.getBaseEntityReference());
|
121 |
134 |
String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
|
... | ... | |
317 |
330 |
}
|
318 |
331 |
}
|
319 |
332 |
|
|
333 |
private class TypedEntityRefWithStatus implements Comparable<TypedEntityRefWithStatus> {
|
|
334 |
|
|
335 |
public TypedEntityReference<? extends VersionableEntity> typedEntityRef;
|
|
336 |
public TypeDesignationStatusBase<?> status;
|
|
337 |
private TypeDesignationStatusBaseComparator comparator = new TypeDesignationStatusBaseComparator();
|
|
338 |
|
|
339 |
|
|
340 |
public TypedEntityRefWithStatus(TypedEntityReference<? extends VersionableEntity> typedEntityRef,
|
|
341 |
TypeDesignationStatusBase<?> status) {
|
|
342 |
this.typedEntityRef = typedEntityRef;
|
|
343 |
this.status = status;
|
|
344 |
}
|
|
345 |
|
|
346 |
@Override
|
|
347 |
public int compareTo(TypedEntityRefWithStatus o) {
|
|
348 |
// TODO Auto-generated method stub
|
|
349 |
return comparator.compare(this.status, o.status);
|
|
350 |
}
|
|
351 |
|
|
352 |
|
|
353 |
}
|
|
354 |
|
320 |
355 |
}
|
ref #9701 defined order of typifications in registration workingset editors