Project

General

Profile

Revision a433cf9e

IDa433cf9e6bc18b10bf621cc69a42bf8517998311
Parent caf42d50
Child e5d7b47f

Added by Andreas Kohlbecker almost 2 years ago

fix #7453 for sections resolve the inReference in the RegistrationWorkingSetService

View differences:

src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java
42 42

  
43 43
    /**
44 44
     * @param referenceID
45
     * @param resolveSections resolve the higher publication unit and build the RegistrationWorkingSet for that reference. E.e. For journal sections the
46
     *  use the inReference which is the journal article.
47
     *
45 48
     * @return
46 49
     */
47
    public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID) throws RegistrationValidationException;
50
    public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID, boolean resolveSections) throws RegistrationValidationException;
48 51

  
49 52
    /**
50 53
     * @param referenceID
54
     * @param resolveSections resolve the higher publication unit and build the RegistrationWorkingSet for that reference. E.e. For journal sections the
55
     *  use the inReference which is the journal article.
51 56
     * @return
52 57
     */
53
    public RegistrationWorkingSet loadWorkingSetByReferenceUuid(UUID referenceUuid) throws RegistrationValidationException;
58
    public RegistrationWorkingSet loadWorkingSetByReferenceUuid(UUID referenceUuid, boolean resolveSections) throws RegistrationValidationException;
54 59

  
55 60
    public Set<RegistrationDTO> loadBlockingRegistrations(UUID blockedRegistrationUuid);
56 61

  
src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java
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
                }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
264 264
     */
265 265
    protected void loadWorkingSet(UUID referenceUuid) {
266 266
        try {
267
            workingset = getWorkingSetService().loadWorkingSetByReferenceUuid(referenceUuid);
267
            workingset = getWorkingSetService().loadWorkingSetByReferenceUuid(referenceUuid, true);
268 268
        } catch (RegistrationValidationException error) {
269 269
            logger.error(error);
270 270
            Window errorDialog = new Window("Validation Error");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)