39 |
39 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
40 |
40 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
41 |
41 |
import eu.etaxonomy.cdm.model.reference.Reference;
|
|
42 |
import eu.etaxonomy.cdm.model.reference.ReferenceType;
|
42 |
43 |
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
|
43 |
44 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
|
44 |
45 |
|
... | ... | |
196 |
197 |
return dtoPager;
|
197 |
198 |
}
|
198 |
199 |
|
|
200 |
|
199 |
201 |
/**
|
200 |
202 |
* {@inheritDoc}
|
201 |
203 |
* @throws RegistrationValidationException
|
202 |
204 |
*/
|
203 |
205 |
@Override
|
204 |
|
public RegistrationWorkingSet loadWorkingSetByReferenceUuid(UUID referenceUuid) throws RegistrationValidationException {
|
|
206 |
public RegistrationWorkingSet loadWorkingSetByReferenceUuid(UUID referenceUuid, boolean resolveSections) throws RegistrationValidationException {
|
205 |
207 |
|
206 |
208 |
Reference reference = repo.getReferenceService().find(referenceUuid);
|
207 |
|
repo.getReferenceService().load(reference.getUuid()); // needed to avoid the problem described in #7331
|
|
209 |
if(resolveSections){
|
|
210 |
reference = resolveSection(reference);
|
|
211 |
}
|
208 |
212 |
|
209 |
213 |
Pager<Registration> pager = repo.getRegistrationService().page(Optional.of(reference), null, null, null, REGISTRATION_INIT_STRATEGY);
|
210 |
214 |
|
... | ... | |
213 |
217 |
return new RegistrationWorkingSet(makeDTOs(pager.getRecords()));
|
214 |
218 |
}
|
215 |
219 |
|
|
220 |
|
|
221 |
/**
|
|
222 |
* @param reference
|
|
223 |
* @return
|
|
224 |
*/
|
|
225 |
protected Reference resolveSection(Reference reference) {
|
|
226 |
repo.getReferenceService().load(reference.getUuid(), Arrays.asList(new String[]{"inReference"})); // needed to avoid the problem described in #7331
|
|
227 |
if(reference.isOfType(ReferenceType.Section) && reference.getInReference() != null) {
|
|
228 |
reference = reference.getInReference();
|
|
229 |
}
|
|
230 |
return reference;
|
|
231 |
}
|
|
232 |
|
216 |
233 |
/**
|
217 |
234 |
* {@inheritDoc}
|
218 |
235 |
* @throws RegistrationValidationException
|
219 |
236 |
*/
|
220 |
237 |
@Override
|
221 |
|
public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID) throws RegistrationValidationException {
|
|
238 |
public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID, boolean resolveSections) throws RegistrationValidationException {
|
222 |
239 |
|
223 |
240 |
Reference reference = repo.getReferenceService().find(referenceID);
|
|
241 |
if(resolveSections){
|
|
242 |
reference = resolveSection(reference);
|
|
243 |
}
|
224 |
244 |
repo.getReferenceService().load(reference.getUuid()); // needed to avoid the problem described in #7331
|
225 |
245 |
|
226 |
246 |
Pager<Registration> pager = repo.getRegistrationService().page(Optional.of(reference), null, null, null, REGISTRATION_INIT_STRATEGY);
|
... | ... | |
239 |
259 |
private void debugIssue7331(Pager<Registration> pager) {
|
240 |
260 |
for(Registration reg : pager.getRecords()){
|
241 |
261 |
if(reg.getName() != null && reg.getName().getNomenclaturalReference().getAuthorship() != null){
|
242 |
|
Reference ref = (Reference) reg.getName().getNomenclaturalReference();
|
|
262 |
Reference ref = reg.getName().getNomenclaturalReference();
|
243 |
263 |
if(!Hibernate.isInitialized(ref.getAuthorship())){
|
244 |
264 |
logger.error("UNINITIALIZED");
|
245 |
265 |
}
|
fix #7453 for sections resolve the inReference in the RegistrationWorkingSetService