Project

General

Profile

Download (1.86 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.presenter;
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
import eu.etaxonomy.cdm.vaadin.view.IConceptRelationshipComponentListener;
23

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

    
31

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

    
35
    private final ICdmRepository app;
36

    
37

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

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

    
45
    @Override
46
    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);
49
        crTree.update(taxon, direction);
50
        app.commitTransaction(tx);
51
    }
52

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

    
58

    
59

    
60
}
(2-2/5)