Project

General

Profile

« Previous | Next » 

Revision eda79691

Added by Patrick Plitzner almost 7 years ago

Refactor SQL query to work on a list of taxon nodes #5458

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java
10 10
package eu.etaxonomy.cdm.vaadin.util;
11 11

  
12 12
import java.sql.SQLException;
13
import java.util.Iterator;
13 14
import java.util.List;
14 15

  
15 16
import com.vaadin.data.util.sqlcontainer.query.FreeformQuery;
......
50 51
        return generateQueryDelegate(SELECT_QUERY, COUNT_QUERY, CONTAINS_QUERY);
51 52
    }
52 53

  
53
    public static QueryDelegate generateTaxonDistributionQuery(List<String> termList, int classificationID) throws SQLException {
54
    public static QueryDelegate generateTaxonDistributionQuery(List<String> termList, List<Integer> taxonNodeIds) throws SQLException {
55
    	String idString = "";
56
    	Iterator<Integer> nodeIterator = taxonNodeIds.iterator();
57
    	while (nodeIterator.hasNext()) {
58
			Integer integer = (Integer) nodeIterator.next();
59
			idString += String.valueOf(integer);
60
			if(nodeIterator.hasNext()){
61
				idString += ", ";
62
			}
63
		}
54 64
        String FROM_QUERY =
55 65
        		" FROM TaxonNode tn " +
56 66
        		"INNER JOIN TaxonBase tb on tn.taxon_id = tb.id " +
......
61 71
        		"LEFT OUTER JOIN DefinedTermBase dtb on deb.status_id=dtb.id " +
62 72
        		"LEFT OUTER JOIN DefinedTermBase dtb1 on deb.area_id=dtb1.id " +
63 73
        		"LEFT OUTER JOIN DefinedTermBase dtb2 on tnb.rank_id = dtb2.id " +
64
        		"WHERE tn.classification_id = "+ classificationID +" AND tb.DTYPE = 'Taxon'" ;
74
        		"WHERE tn.id IN ("+ idString +") AND tb.DTYPE = 'Taxon'" ;
65 75

  
66 76
        String GROUP_BY = " GROUP BY tb.id ";
67 77

  

Also available in: Unified diff