Project

General

Profile

Revision 85bac62c

ID85bac62c9215c70ef40c60c3063af74a056afb23
Parent fec3f60f
Child 9ee84720

Added by Katja Luther almost 3 years ago

sort also taxon node uuid for rank and name for getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNodeByRankAndNameComparator.java
26 26
	@Override
27 27
    public int compare(TaxonNode node1, TaxonNode node2) {
28 28

  
29
	    boolean node1Excluded = node1.isExcluded();
30
	    boolean node2Excluded = node2.isExcluded();
31
	    boolean node1Unplaced = node1.isUnplaced();
32
	    boolean node2Unplaced = node2.isUnplaced();
33

  
29 34

  
30 35
		if (node1.getUuid().equals(node2.getUuid())){
31 36
			return 0;
32 37
		}
38
		//They should both be put to the end (first unplaced then excluded)
39
		if (node2Excluded && !node1Excluded){
40
		    return -1;
41
		}
42
		if (node2Unplaced && !(node1Unplaced || node1Excluded)){
43
		    return -1;
44
		}
45

  
46
		if (node1Excluded && !node2Excluded){
47
            return 1;
48
        }
49
        if (node1Unplaced && !(node2Unplaced || node2Excluded)){
50
            return 1;
51
        }
52

  
53
        if (node1Unplaced && node2Excluded){
54
            return -1;
55
        }
56
        if (node2Unplaced && node1Excluded){
57
            return 1;
58
        }
59

  
60

  
33 61
		TaxonBase<?> taxon1 = node1.getTaxon();
34 62
		TaxonBase<?> taxon2 = node2.getTaxon();
35 63

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
1206 1206
        int classificationId = classification.getId();
1207 1207
        // StringBuffer excludeUuids = new StringBuffer();
1208 1208

  
1209
         String queryString = "SELECT nodes.uuid, nodes.id, taxon.titleCache FROM TaxonNode AS nodes JOIN nodes.taxon as taxon WHERE nodes.classification.id = " + classificationId ;
1209
         String queryString = "SELECT nodes.uuid, nodes.id, taxon.titleCache, taxon.name.rank FROM TaxonNode AS nodes JOIN nodes.taxon as taxon WHERE nodes.classification.id = " + classificationId ;
1210 1210
         if (pattern != null){
1211 1211
             if (pattern.equals("?")){
1212 1212
                 limit = null;
......
1239 1239
             return null;
1240 1240
         }else{
1241 1241
             List<UuidAndTitleCache<TaxonNode>> list = new ArrayList<UuidAndTitleCache<TaxonNode>>(result.size());
1242

  
1242
             if (result != null && !result.isEmpty()){
1243
                 if (result.iterator().next().length == 4){
1244
                     Collections.sort(result, new UuidAndTitleCacheTaxonComparator());
1245
                 }
1246
             }
1243 1247
             for (Object object : result){
1244 1248

  
1245 1249
                 Object[] objectArray = (Object[]) object;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)