Project

General

Profile

« Previous | Next » 

Revision 2242f8a9

Added by Patrick Plitzner almost 8 years ago

ref #5458 Revert SQL streamlining

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmQueryFactory.java
28 28

  
29 29
	public static final String RANK_COLUMN = "Rank";
30 30
	public static final String TAXON_COLUMN = "Taxon";
31
	
31

  
32 32
    public static final String ID = "id";
33 33
    public static final String UUID_ID = "uuid";
34 34

  
......
59 59
    	String idString = "";
60 60
    	Iterator<Integer> nodeIterator = taxonNodeIds.iterator();
61 61
    	while (nodeIterator.hasNext()) {
62
			Integer integer = (Integer) nodeIterator.next();
62
			Integer integer = nodeIterator.next();
63 63
			idString += String.valueOf(integer);
64 64
			if(nodeIterator.hasNext()){
65 65
				idString += ", ";
......
77 77
        		"LEFT OUTER JOIN DefinedTermBase dtb2 on tnb.rank_id = dtb2.id " +
78 78
        		"WHERE tn.id IN ("+ idString +") AND tb.DTYPE = 'Taxon'" ;
79 79

  
80
        String GROUP_BY = " GROUP BY tn.id ";
81

  
80 82
        String ORDER_BY = " ORDER BY tb.titleCache ";
81 83

  
82 84
        String SELECT_QUERY=
......
91 93
        for(String term : termList){
92 94
        	if(count == 1){
93 95
        		SELECT_QUERY= SELECT_QUERY +
94
            			"IF(dtb1.titleCache = '"+ term +"', dtb.titleCache, NULL) as '"+ term +"' " ;
96
            			"MAX( IF(dtb1.titleCache = '"+ term +"', dtb.titleCache, NULL) ) as '"+ term +"' " ;
95 97
        	}else{
96 98
        		SELECT_QUERY= SELECT_QUERY +
97
        				"IF(dtb1.titleCache = '"+ term +"', dtb.titleCache, NULL) as '"+ term +"'," ;
99
        				"MAX( IF(dtb1.titleCache = '"+ term +"', dtb.titleCache, NULL) ) as '"+ term +"'," ;
98 100
        	}
99 101
        	count--;
100 102
        }
101
        SELECT_QUERY= SELECT_QUERY + FROM_QUERY + ORDER_BY;
103
        SELECT_QUERY= SELECT_QUERY + FROM_QUERY + GROUP_BY + ORDER_BY;
102 104
        String COUNT_QUERY = "SELECT count(DISTINCT tb.id)" + FROM_QUERY;
103 105
//        String CONTAINS_QUERY = "SELECT * FROM TaxonNode tn WHERE tn.id = ?";
104 106
        String CONTAINS_QUERY = "SELECT * FROM TaxonBase tb WHERE tb.uuid = ?";

Also available in: Unified diff