Project

General

Profile

Download (1.79 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.component.taxon;
10

    
11
import org.json.JSONException;
12
import org.springframework.transaction.TransactionStatus;
13

    
14
import eu.etaxonomy.cdm.api.application.ICdmRepository;
15
import eu.etaxonomy.cdm.api.service.ITaxonService;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.vaadin.container.IdUuidName;
19
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree;
20
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
21
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
22

    
23
/**
24
 * @author cmathew
25
 * @date 9 Apr 2015
26
 *
27
 */
28
public class ConceptRelationshipPresenter implements IConceptRelationshipComponentListener {
29

    
30

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

    
34
    private final ICdmRepository app;
35

    
36

    
37
    public ConceptRelationshipPresenter(D3ConceptRelationshipTree crTree) {
38
        this.crTree = crTree;
39

    
40
        taxonService = CdmSpringContextHelper.getTaxonService();
41
        app = CdmSpringContextHelper.getApplicationConfiguration();
42
    }
43

    
44
    @Override
45
    public void refreshRelationshipView(IdUuidName taxonIun, Direction direction) throws JSONException {
46
        TransactionStatus tx = app.startTransaction();
47
        Taxon taxon = CdmBase.deproxy(taxonService.load(taxonIun.getUuid()), Taxon.class);
48
        crTree.update(taxon, direction);
49
        app.commitTransaction(tx);
50
    }
51

    
52
    @Override
53
    public void clearRelationshipView() {
54
        crTree.clear();
55
    }
56

    
57

    
58

    
59
}
(2-2/12)