Project

General

Profile

Revision e3f9b0ed

IDe3f9b0ed39c3a1c28c8b71067b78b61e4cc11ee0
Parent e0787689
Child 1e201891

Added by Patrick Plitzner over 4 years ago

Show list of taxon nodes in selection view #5458

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionSelectionPresenter.java
1 1
package eu.etaxonomy.cdm.vaadin.presenter.dbstatus;
2 2

  
3 3
import java.sql.SQLException;
4
import java.util.ArrayList;
4 5
import java.util.Arrays;
5 6
import java.util.List;
6 7

  
8
import org.apache.bcel.generic.ARRAYLENGTH;
9

  
7 10
import com.vaadin.server.VaadinSession;
8 11
import com.vaadin.ui.UI;
9 12

  
10 13
import eu.etaxonomy.cdm.api.service.IClassificationService;
14
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
11 15
import eu.etaxonomy.cdm.api.service.IVocabularyService;
12 16
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
13 17
import eu.etaxonomy.cdm.model.common.TermType;
14 18
import eu.etaxonomy.cdm.model.common.TermVocabulary;
15 19
import eu.etaxonomy.cdm.model.taxon.Classification;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
16 21
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
17 22
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionSelectionView;
18 23
import eu.etaxonomy.cdm.vaadin.view.dbstatus.DistributionTableView;
......
29 34
	}
30 35

  
31 36
	@Override
32
	public void buttonClick(Classification classification, TermVocabulary<DefinedTermBase> term) throws SQLException {
33
	    VaadinSession.getCurrent().setAttribute("classificationUUID", classification.getRootNode().getUuid());
37
	public void buttonClick(TaxonNode classification, TermVocabulary<DefinedTermBase> term) throws SQLException {
38
	    VaadinSession.getCurrent().setAttribute("classificationUUID", classification.getUuid());
34 39
	    VaadinSession.getCurrent().setAttribute("selectedTerm", term.getUuid());
35 40

  
36 41
	    DistributionTableView dtv = new DistributionTableView();
......
41 46
	}
42 47

  
43 48
	@Override
44
	public List<Classification> getClassificationList() {
49
	public List<TaxonNode> getClassificationList() {
45 50
		IClassificationService classificationService = CdmSpringContextHelper.getClassificationService();
51
		ITaxonNodeService taxonNodeService = CdmSpringContextHelper.getTaxonNodeService();
46 52
		List<Classification> classificationList = classificationService.listClassifications(null, null, null, NODE_INIT_STRATEGY());
47
		return classificationList;
53
		List<TaxonNode> nodes = new ArrayList<TaxonNode>();
54
		for (Classification classification : classificationList) {
55
			nodes.addAll(taxonNodeService.listAllNodesForClassification(classification, null, null));
56
		}
57
		return nodes;
48 58
	}
49 59

  
50 60
	@Override
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/dbstatus/DistributionTablePresenter.java
175 175

  
176 176
	@Override
177 177
	public List<TaxonNode> getAllNodes(int start, int end){
178
		Classification classification = getChosenClassification();
179
		TaxonNode taxonNode = classification.getRootNode();
178
		TaxonNode taxonNode = getChosenClassification();
180 179
		List<TaxonNode> nodes = new ArrayList<TaxonNode>();
181 180
		if(taxonNode.getTaxon()!=null){
182 181
			nodes.add(taxonNode);
......
187 186

  
188 187

  
189 188
	@Override
190
	public Classification getChosenClassification() {
189
	public TaxonNode getChosenClassification() {
191 190
		VaadinSession session = VaadinSession.getCurrent();
192 191
		UUID classificationUUID = (UUID) session.getAttribute("classificationUUID");
193 192
		TaxonNode classificationNode = taxonNodeService.load(classificationUUID);
194
		return classificationNode.getClassification();
193
		return classificationNode;
195 194
	}
196 195

  
197 196
	@Override
198 197
	public int getSizeOfClassification(){
199
		Classification classification = getChosenClassification();
200
		return taxonNodeService.countAllNodesForClassification(classification);
198
		TaxonNode taxonNode = getChosenClassification();
199
		return taxonNodeService.loadChildNodesOfTaxonNode(taxonNode, null, true, null).size();
201 200
	}
202 201

  
203 202

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/DistributionSelectionView.java
22 22
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
23 23
import eu.etaxonomy.cdm.model.common.TermVocabulary;
24 24
import eu.etaxonomy.cdm.model.taxon.Classification;
25
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
25 26

  
26 27
public class DistributionSelectionView extends CustomComponent implements IDistributionSelectionComponent, View, ClickListener{
27 28

  
......
70 71
	@Override
71 72
	public void buttonClick(ClickEvent event) {
72 73
		if(classificationBox != null && distributionAreaBox != null){
73
			Classification classification = (Classification) classificationBox.getValue();
74
			TaxonNode classification = (TaxonNode) classificationBox.getValue();
74 75
			TermVocabulary<DefinedTermBase> term = (TermVocabulary<DefinedTermBase>)distributionAreaBox.getValue();
75 76
			try {
76 77
				distListener.buttonClick(classification, term);
......
82 83
	}
83 84

  
84 85
	public void dataBinding(){
85
		List<Classification> classificationList = distListener.getClassificationList();
86
		List<TaxonNode> classificationList = distListener.getClassificationList();
86 87
		List<TermVocabulary<DefinedTermBase>> namedAreaList = distListener.getNamedAreaList();
87 88
		Container c = new IndexedContainer(classificationList);
88 89
		classificationBox.setContainerDataSource(c);
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionSelectionComponent.java
6 6
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
7 7
import eu.etaxonomy.cdm.model.common.TermVocabulary;
8 8
import eu.etaxonomy.cdm.model.taxon.Classification;
9
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
9 10

  
10 11
public interface IDistributionSelectionComponent {
11 12
	public interface DistributionSelectionComponentListener{
12
		void buttonClick(Classification classification, TermVocabulary<DefinedTermBase> term) throws SQLException;
13
		void buttonClick(TaxonNode classification, TermVocabulary<DefinedTermBase> term) throws SQLException;
13 14
		
14
		List<Classification> getClassificationList();
15
		List<TaxonNode> getClassificationList();
15 16
		
16 17
		List<TermVocabulary<DefinedTermBase>> getNamedAreaList();
17 18
		
src/main/java/eu/etaxonomy/cdm/vaadin/view/dbstatus/IDistributionTableComponent.java
54 54
		List<DescriptionElementBase> listDescriptionElementsForTaxon(
55 55
				Taxon taxon, Set<Feature> setFeature);
56 56

  
57
		Classification getChosenClassification();
57
		TaxonNode getChosenClassification();
58 58

  
59 59
		List<TaxonNode> getAllNodes(int start, int end);
60 60

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)