Revision f756340a
Added by Andreas Kohlbecker about 3 years ago
src/main/java/eu/etaxonomy/cdm/service/CdmBeanItemContainerFactory.java | ||
---|---|---|
122 | 122 |
return termItemContainer; |
123 | 123 |
} |
124 | 124 |
|
125 |
public BeanItemContainer<TypeDesignationStatusBase> buildTypeDesignationStatusBaseItemItemContainer(Class<TypeDesignationStatusBase> type, |
|
126 |
List<OrderHint> orderHints, Optional<Boolean> withHasDesignationSource) { |
|
127 |
|
|
128 |
BeanItemContainer<TypeDesignationStatusBase> container = buildBeanItemContainer(type, null); |
|
129 |
List<TypeDesignationStatusBase> filteredItems = container.getItemIds().stream().filter(tsb -> |
|
130 |
!withHasDesignationSource.isPresent() |
|
131 |
|| withHasDesignationSource.get().equals(false) |
|
132 |
|| tsb.hasDesignationSource() == true |
|
133 |
) |
|
134 |
.collect(Collectors.toList()); |
|
135 |
container.removeAllItems(); |
|
136 |
container.addAll(filteredItems); |
|
137 |
return container; |
|
138 |
} |
|
139 |
|
|
140 |
|
|
125 | 141 |
@Transactional(readOnly=true) |
126 | 142 |
public <T extends CdmBase> BeanItemContainer<T> buildBeanItemContainer(Class<T> type, List<OrderHint> orderHints) { |
127 | 143 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
13 | 13 |
import java.util.EnumSet; |
14 | 14 |
import java.util.HashSet; |
15 | 15 |
import java.util.List; |
16 |
import java.util.Optional; |
|
16 | 17 |
import java.util.UUID; |
18 |
import java.util.stream.Collectors; |
|
17 | 19 |
|
18 | 20 |
import org.apache.log4j.Logger; |
19 | 21 |
import org.hibernate.criterion.Restrictions; |
... | ... | |
21 | 23 |
import org.springframework.context.annotation.Scope; |
22 | 24 |
import org.vaadin.spring.events.annotation.EventBusListenerMethod; |
23 | 25 |
|
26 |
import com.vaadin.data.util.BeanItemContainer; |
|
24 | 27 |
import com.vaadin.spring.annotation.SpringComponent; |
25 | 28 |
|
26 | 29 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
... | ... | |
36 | 39 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
37 | 40 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus; |
38 | 41 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
42 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
|
39 | 43 |
import eu.etaxonomy.cdm.model.permission.CRUD; |
40 | 44 |
import eu.etaxonomy.cdm.model.reference.Reference; |
41 | 45 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
... | ... | |
90 | 94 |
*/ |
91 | 95 |
private DescriptionElementSource publishedUnit; |
92 | 96 |
|
97 |
/** |
|
98 |
* possible values: |
|
99 |
* |
|
100 |
* <ul> |
|
101 |
* <li>NULL: undecided, should be treaded like <code>false</code></li> |
|
102 |
* <li>false: the typification is published in an nomenclatural act in which no new name or new combination is being published. |
|
103 |
* The available {@link TypeDesignationStatusBase} should be limited to those with |
|
104 |
* <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</code></li> |
|
105 |
* <li>true: only status with <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</li> |
|
106 |
* </ul> |
|
107 |
*/ |
|
108 |
private Optional<Boolean> isInTypedesignationOnlyAct = Optional.empty(); |
|
109 |
|
|
110 |
|
|
93 | 111 |
protected static BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator = new BeanInstantiator<NameTypeDesignation>() { |
94 | 112 |
|
95 | 113 |
@Override |
... | ... | |
114 | 132 |
@Override |
115 | 133 |
protected NameTypeDesignation loadBeanById(Object identifier) { |
116 | 134 |
NameTypeDesignation bean; |
117 |
if(identifier instanceof Integer || identifier == null){ |
|
118 |
bean = super.loadBeanById(identifier); |
|
119 |
} else { |
|
120 |
TypeDesignationWorkingsetIds idset = (TypeDesignationWorkingsetIds)identifier; |
|
121 |
RegistrationDTO regDTO = registrationWorkingSetService.loadDtoByUuid(idset.registrationUuid); |
|
122 |
typifiedNameInContext = regDTO.typifiedName(); |
|
123 |
// find the working set |
|
135 |
|
|
136 |
NameTypeDesignationWorkingsetIds idset = (NameTypeDesignationWorkingsetIds)identifier; |
|
137 |
RegistrationDTO regDTO = registrationWorkingSetService.loadDtoByUuid(idset.registrationUuid); |
|
138 |
typifiedNameInContext = regDTO.typifiedName(); |
|
139 |
// find the working set |
|
140 |
if(idset.baseEntityRef != null) { |
|
124 | 141 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(idset.baseEntityRef); |
125 | 142 |
if(!typeDesignationWorkingSet.getBaseEntityReference().getType().equals(NameTypeDesignation.class)){ |
126 | 143 |
throw new RuntimeException("TypeDesignationWorkingsetEditorIdSet references not a NameTypeDesignation"); |
... | ... | |
129 | 146 |
UUID nameTypeDesignationUuid = typeDesignationWorkingSet.getTypeDesignations().get(0).getUuid(); |
130 | 147 |
bean = super.loadBeanById(nameTypeDesignationUuid); |
131 | 148 |
} |
149 |
} else { |
|
150 |
bean = super.loadBeanById(null); |
|
132 | 151 |
} |
152 |
isInTypedesignationOnlyAct = Optional.of(Boolean.valueOf(regDTO.getNameRef() == null)); |
|
133 | 153 |
|
134 | 154 |
try { |
135 | 155 |
setPublishedUnit(bean.getTypifiedNames().iterator().next().getNomenclaturalSource()); |
... | ... | |
160 | 180 |
}; |
161 | 181 |
} |
162 | 182 |
|
183 |
getView().getTypeStatusSelect().setContainerDataSource(provideTypeStatusTermItemContainer()); |
|
184 |
|
|
163 | 185 |
return bean; |
164 | 186 |
} |
165 | 187 |
|
... | ... | |
195 | 217 |
return typeDesignation; |
196 | 218 |
} |
197 | 219 |
|
220 |
protected BeanItemContainer<NameTypeDesignationStatus> provideTypeStatusTermItemContainer() { |
|
221 |
|
|
222 |
BeanItemContainer<NameTypeDesignationStatus> container = cdmBeanItemContainerFactory.buildBeanItemContainer(NameTypeDesignationStatus.class); |
|
223 |
List<NameTypeDesignationStatus> filteredItems = container.getItemIds().stream().filter(tsb -> |
|
224 |
!isInTypedesignationOnlyAct.isPresent() |
|
225 |
|| isInTypedesignationOnlyAct.get().equals(false) |
|
226 |
|| tsb.hasDesignationSource() == true |
|
227 |
) |
|
228 |
.collect(Collectors.toList()); |
|
229 |
container.removeAllItems(); |
|
230 |
container.addAll(filteredItems); |
|
231 |
return container; |
|
232 |
|
|
233 |
} |
|
198 | 234 |
|
199 | 235 |
/** |
200 | 236 |
* {@inheritDoc} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
17 | 17 |
import java.util.Optional; |
18 | 18 |
import java.util.Set; |
19 | 19 |
import java.util.Stack; |
20 |
import java.util.stream.Collectors; |
|
20 | 21 |
|
21 | 22 |
import org.apache.log4j.Logger; |
22 | 23 |
import org.hibernate.criterion.Restrictions; |
... | ... | |
42 | 43 |
import eu.etaxonomy.cdm.model.location.Country; |
43 | 44 |
import eu.etaxonomy.cdm.model.name.Registration; |
44 | 45 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
46 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; |
|
45 | 47 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
46 | 48 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
47 | 49 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
... | ... | |
49 | 51 |
import eu.etaxonomy.cdm.model.reference.Reference; |
50 | 52 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
51 | 53 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
54 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
52 | 55 |
import eu.etaxonomy.cdm.model.term.TermType; |
53 | 56 |
import eu.etaxonomy.cdm.persistence.dao.common.Restriction; |
54 | 57 |
import eu.etaxonomy.cdm.persistence.dao.common.Restriction.Operator; |
... | ... | |
331 | 334 |
|
332 | 335 |
} |
333 | 336 |
|
334 |
protected BeanItemContainer<TypeDesignationStatusBase> provideTypeStatusTermItemContainer() { |
|
335 |
return cdmBeanItemContainerFactory.buildTypeDesignationStatusBaseItemContainer( |
|
336 |
RegistrationTermLists.SPECIMEN_TYPE_DESIGNATION_STATUS_UUIDS(), |
|
337 |
isInTypedesignationOnlyAct |
|
338 |
); |
|
337 |
protected BeanItemContainer<DefinedTermBase> provideTypeStatusTermItemContainer() { |
|
338 |
BeanItemContainer<DefinedTermBase> container = cdmBeanItemContainerFactory.buildTermItemContainer( |
|
339 |
RegistrationTermLists.SPECIMEN_TYPE_DESIGNATION_STATUS_UUIDS()); |
|
340 |
List<TypeDesignationStatusBase> filteredItems = container.getItemIds().stream() |
|
341 |
.filter(t -> t instanceof SpecimenTypeDesignationStatus) |
|
342 |
.map(t -> (SpecimenTypeDesignationStatus)t) |
|
343 |
.filter(tsb -> |
|
344 |
!isInTypedesignationOnlyAct.isPresent() |
|
345 |
|| isInTypedesignationOnlyAct.get().equals(false) |
|
346 |
|| tsb.hasDesignationSource() == true |
|
347 |
) |
|
348 |
.collect(Collectors.toList()); |
|
349 |
container.removeAllItems(); |
|
350 |
container.addAll(filteredItems); |
|
351 |
return container; |
|
339 | 352 |
} |
340 | 353 |
|
341 | 354 |
/** |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
637 | 637 |
} |
638 | 638 |
}); |
639 | 639 |
popup.withDeleteButton(false); |
640 |
popup.loadInEditor(null); |
|
640 |
popup.loadInEditor(new NameTypeDesignationWorkingsetIds( |
|
641 |
event.getRegistrationUuid(), |
|
642 |
event.getTypifiedNameUuid() |
|
643 |
) |
|
644 |
); |
|
641 | 645 |
popup.getTypifiedNamesComboboxSelect().setEnabled(false); |
642 | 646 |
if(event.hasSource()){ |
643 | 647 |
// propagate readonly state from source component to popup |
Also available in: Unified diff
ref #9290 limiting available designation status types for nom acts without a name - NameTypeDesignationEditor & improving previous code