Revision fe785c1e
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Arrays; |
|
11 | 13 |
import java.util.HashSet; |
12 | 14 |
import java.util.Iterator; |
15 |
import java.util.List; |
|
13 | 16 |
import java.util.Set; |
14 | 17 |
|
15 | 18 |
import org.hibernate.Session; |
... | ... | |
31 | 34 |
import eu.etaxonomy.cdm.model.reference.Reference; |
32 | 35 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
33 | 36 |
import eu.etaxonomy.cdm.service.CdmStore; |
34 |
import eu.etaxonomy.cdm.vaadin.component.SelectFieldFactory;
|
|
37 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
|
|
35 | 38 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
36 | 39 |
import eu.etaxonomy.cdm.vaadin.model.registration.DerivationEventTypes; |
37 | 40 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists; |
38 | 41 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
39 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
43 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet; |
|
40 | 44 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
41 | 45 |
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter; |
42 | 46 |
/** |
... | ... | |
52 | 56 |
|
53 | 57 |
private static final long serialVersionUID = 4255636253714476918L; |
54 | 58 |
|
59 |
private List<String> specimenTypeDesignationWorkingsetInitStrategy = Arrays.asList(new String[]{ |
|
60 |
"typeDesignations.typeStatus.representations", |
|
61 |
"typeDesignations.typeSpecimen.sources", |
|
62 |
"typeDesignations.typeSpecimen.mediaSpecimen.representations.parts", |
|
63 |
"typeDesignations.typeSpecimen.collection", |
|
64 |
"typeDesignations.typeSpecimen.derivedFrom.type", |
|
65 |
"typeDesignations.typeSpecimen.derivedFrom.derivatives", |
|
66 |
// Need to initialize all properties of the DerivedUnit to avoid LIEs while converting DerivedUnit with the DerivedUnitConverter: |
|
67 |
"typeDesignations.typeSpecimen.*", |
|
68 |
}); |
|
69 |
|
|
55 | 70 |
CdmStore<Registration, IRegistrationService> store ; |
56 | 71 |
|
57 | 72 |
protected CdmStore<Registration, IRegistrationService> getStore() { |
... | ... | |
62 | 77 |
} |
63 | 78 |
|
64 | 79 |
|
80 |
/** |
|
81 |
* {@inheritDoc} |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
protected SpecimenTypeDesignationWorkingSetDTO loadBeanById(Object identifier) { |
|
85 |
|
|
86 |
SpecimenTypeDesignationWorkingSetDTO workingSet; |
|
87 |
if(identifier != null){ |
|
88 |
RegistrationAndWorkingsetId registrationAndWorkingsetId = (RegistrationAndWorkingsetId)identifier; |
|
89 |
List<Integer> ids = new ArrayList<>(); |
|
90 |
ids.add(registrationAndWorkingsetId.registrationId); |
|
91 |
Registration reg = getRepo().getRegistrationService().loadByIds(ids, specimenTypeDesignationWorkingsetInitStrategy).get(0); |
|
92 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
93 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(registrationAndWorkingsetId.workingsetId); |
|
94 |
workingSet = regDTO.getSpecimenTypeDesignationWorkingSetDTO(typeDesignationWorkingSet.getBaseEntityReference()); |
|
95 |
} else { |
|
96 |
workingSet = null; |
|
97 |
} |
|
98 |
return workingSet; |
|
99 |
} |
|
100 |
|
|
101 |
|
|
65 | 102 |
/** |
66 | 103 |
* {@inheritDoc} |
67 | 104 |
*/ |
... | ... | |
69 | 106 |
@Override |
70 | 107 |
public void handleViewEntered() { |
71 | 108 |
|
72 |
SelectFieldFactory selectFactory = new SelectFieldFactory(getRepo());
|
|
109 |
CdmBeanItemContainerFactory selectFactory = new CdmBeanItemContainerFactory(getRepo());
|
|
73 | 110 |
getView().getCountrySelectField().setContainerDataSource(selectFactory.buildBeanItemContainer(Country.uuidCountryVocabulary)); |
74 | 111 |
|
75 | 112 |
getView().getTypeDesignationsCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<SpecimenTypeDesignationDTORow>() { |
76 | 113 |
|
77 |
CdmFilterablePagingProvider<Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection>(getRepo().getCollectionService()); |
|
114 |
CdmFilterablePagingProvider<Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection>(getRepo().getCollectionService(), SpecimenTypeDesignationWorkingsetEditorPresenter.this);
|
|
78 | 115 |
|
79 |
CdmFilterablePagingProvider<Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference>(getRepo().getReferenceService()); |
|
116 |
CdmFilterablePagingProvider<Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference>(getRepo().getReferenceService(), SpecimenTypeDesignationWorkingsetEditorPresenter.this);
|
|
80 | 117 |
|
81 | 118 |
@Override |
82 | 119 |
public SpecimenTypeDesignationDTORow create() { |
... | ... | |
104 | 141 |
collectionPagingProvider, |
105 | 142 |
collectionPagingProvider.getPageSize() |
106 | 143 |
); |
107 |
row.collection.getSelect().setCaptionGenerator( |
|
108 |
new CdmTitleCacheCaptionGenerator<Collection>() |
|
109 |
); |
|
144 |
row.collection.getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Collection>()); |
|
110 | 145 |
|
111 | 146 |
row.mediaSpecimenReference.loadFrom( |
112 | 147 |
referencePagingProvider, |
113 | 148 |
referencePagingProvider, |
114 | 149 |
collectionPagingProvider.getPageSize() |
115 | 150 |
); |
116 |
row.mediaSpecimenReference.getSelect().setCaptionGenerator( |
|
117 |
new CdmTitleCacheCaptionGenerator<Reference>() |
|
118 |
); |
|
151 |
row.mediaSpecimenReference.getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>()); |
|
119 | 152 |
|
120 | 153 |
getView().applyDefaultComponentStyle(row.components()); |
121 | 154 |
|
... | ... | |
191 | 224 |
@Override |
192 | 225 |
protected void saveBean(SpecimenTypeDesignationWorkingSetDTO dto) { |
193 | 226 |
|
194 |
getStore().startTransaction(false); |
|
195 | 227 |
Registration reg = (Registration) dto.getOwner(); |
196 | 228 |
|
197 | 229 |
// associate all type designations with the fieldUnit |
... | ... | |
238 | 270 |
* @throws Exception |
239 | 271 |
*/ |
240 | 272 |
private SpecimenOrObservationBase<?> findEarliestOriginal(DerivedUnit du) throws Exception { |
241 |
|
|
273 |
|
|
242 | 274 |
SpecimenOrObservationBase original = du; |
243 |
|
|
275 |
|
|
244 | 276 |
while(du != null && du.getDerivedFrom() != null && !du.getDerivedFrom().getOriginals().isEmpty()) { |
245 | 277 |
Iterator<SpecimenOrObservationBase> it = du.getDerivedFrom().getOriginals().iterator(); |
246 | 278 |
SpecimenOrObservationBase nextOriginal = it.next(); |
Also available in: Unified diff
fix #6687 per view implementation of the 'session-per-conversation' pattern