Project

General

Profile

« Previous | Next » 

Revision a735bbbf

Added by Andreas Kohlbecker about 7 years ago

  • ID a735bbbfccc284e24f355551d2496cd15e790243
  • Parent a1dac6b2

ref #5285 attempt to avoid using the CdmSpringContextHelper
using DI to get rid of CdmSpringContextHelper, but got stuck due to the complexity and variety of the 'design patterns' that have been used.

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/presenter/ConceptRelationshipPresenter.java
9 9
package eu.etaxonomy.cdm.vaadin.presenter;
10 10

  
11 11
import org.json.JSONException;
12
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.context.annotation.Scope;
12 14
import org.springframework.transaction.TransactionStatus;
13 15

  
14
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
15
import eu.etaxonomy.cdm.api.service.ITaxonService;
16
import com.vaadin.spring.annotation.SpringComponent;
17

  
18
import eu.etaxonomy.cdm.api.application.CdmRepository;
16 19
import eu.etaxonomy.cdm.model.common.CdmBase;
17 20
import eu.etaxonomy.cdm.model.taxon.Taxon;
18 21
import eu.etaxonomy.cdm.vaadin.container.IdUuidName;
19 22
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree;
20 23
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
21
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
22 24
import eu.etaxonomy.cdm.vaadin.view.IConceptRelationshipComponentListener;
23 25

  
24 26
/**
......
26 28
 * @date 9 Apr 2015
27 29
 *
28 30
 */
31
@SpringComponent
32
@Scope("prototype")
29 33
public class ConceptRelationshipPresenter implements IConceptRelationshipComponentListener {
30 34

  
35
    @Autowired
36
    private CdmRepository cdmRepo = null;
31 37

  
32
    private final D3ConceptRelationshipTree crTree;
33
    private final ITaxonService taxonService;
34

  
35
    private final ICdmApplicationConfiguration app;
38
    private D3ConceptRelationshipTree crTree = null;
36 39

  
40
    public ConceptRelationshipPresenter(){
41
    }
37 42

  
38
    public ConceptRelationshipPresenter(D3ConceptRelationshipTree crTree) {
43
    public void setTree(D3ConceptRelationshipTree crTree) {
39 44
        this.crTree = crTree;
40

  
41
        taxonService = CdmSpringContextHelper.getTaxonService();
42
        app = CdmSpringContextHelper.getApplicationConfiguration();
43 45
    }
44 46

  
45 47
    @Override
48
    //@Transactional // FIXME use this annotation instead of the explicit start commit below
46 49
    public void refreshRelationshipView(IdUuidName taxonIun, Direction direction) throws JSONException {
47
        TransactionStatus tx = app.startTransaction();
48
        Taxon taxon = CdmBase.deproxy(taxonService.load(taxonIun.getUuid()), Taxon.class);
50
        TransactionStatus tx = cdmRepo.startTransaction();
51
        Taxon taxon = CdmBase.deproxy(cdmRepo.getTaxonService().load(taxonIun.getUuid()), Taxon.class);
49 52
        crTree.update(taxon, direction);
50
        app.commitTransaction(tx);
53
        cdmRepo.commitTransaction(tx);
51 54
    }
52 55

  
53 56
    @Override

Also available in: Unified diff