Project

General

Profile

« Previous | Next » 

Revision 644a7b6e

Added by Andreas Kohlbecker over 5 years ago

fixing typeDesignation sort order

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.name.theme
112 112
  if (!empty($specimen_type_designations)) {
113 113
    // Sorting might be different for dataportals so this has to be
114 114
    // parameterized.
115
    usort($specimen_type_designations, "compare_specimenTypeDesignationStatus");
115
    usort($specimen_type_designations, "compare_specimen_type_designation");
116 116
    foreach ($specimen_type_designations as $type_designation) {
117 117
      $typeReference = '';
118 118

  
......
201 201
 * just didn't know where to put it right now.
202 202
 * Compares the status of two SpecimenTypeDesignations
203 203
 *
204
 * @param string $a
205
 *   A SpecimenTypeDesignations.
206
 * @param string $b
207
 *   SpecimenTypeDesignations.
204
 * @param object $a
205
 *   A SpecimenTypeDesignation.
206
 * @param object $b
207
 *   SpecimenTypeDesignation.
208 208
 */
209
function compare_specimenTypeDesignationStatus($a, $b) {
209
function compare_specimen_type_designation($a, $b) {
210 210
  /*
211 211
  This is the desired sort order as of now: Holotype Isotype Lectotype
212 212
  Isolectotype Syntype.
......
232 232
  }
233 233
  if ($aQuantifier == $bQuantifier) {
234 234
    // Sort alphabetically.
235
    return (isset($a->typeStatus->label) && isset($b->typeStatus->label) && $a->typeStatus->label < $b->typeStatus->label) ? -1 : 1;
235
    $a_text =  isset($a->typeSpecimen->titleCache) ? preg_replace('/[\[\]\"]/', '', $a->typeSpecimen->titleCache) : '';
236
    $b_text =  isset($b->typeSpecimen->titleCache) ? preg_replace('/[\[\]\"]/', '', $b->typeSpecimen->titleCache) : '';
237
    return strcasecmp($a_text, $b_text);
236 238
  }
237 239
  return ($aQuantifier < $bQuantifier) ? -1 : 1;
238 240
}
src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_TypeTest.java
70 70
        assertEquals("Expecting 7 Typedesignation", 7, typeDesignations.size());
71 71

  
72 72
        assertEquals(TypeDesignationType.specimenTypeDesignation, typeDesignations.get(0).getTypeDesignationType());
73
        assertEquals("Syntype: [Cameroon] \"Bamenda\", Ledermann 1889", typeDesignations.get(0).getText());
74
        assertEquals("Syntype: [Tanzania] \"Kilimandscharo\", Volkens 1238", typeDesignations.get(1).getText());
75
        assertEquals("Syntype: [Malawi] \"Kyimbila\", Stolz 306", typeDesignations.get(2).getText());
76
        assertEquals("Syntype: [Kenya] \"Mt. Aberdare: Ostseite\", 12 Mar 1922, R. E. Fries 2172", typeDesignations.get(3).getText());
77
        assertEquals("Syntype: [Kenya] \"Mt. Kenia: Nordostseite bei Meru\", 17 Feb 1922, R. E. Fries 1677", typeDesignations.get(4).getText());
78
        assertEquals("Syntype: [Tanzania] \"Karagwe\", Stuhlmann 1660", typeDesignations.get(5).getText());
79
        assertEquals("Syntype: \"Uganda\", Scott Elliot 7328", typeDesignations.get(6).getText());
73
        int i = 0;
74
        assertEquals("Syntype: [Cameroon] \"Bamenda\", Ledermann 1889", typeDesignations.get(i++).getText());
75
        assertEquals("Syntype: [Kenya] \"Mt. Aberdare: Ostseite\", 12 Mar 1922, R. E. Fries 2172", typeDesignations.get(i++).getText());
76
        assertEquals("Syntype: [Kenya] \"Mt. Kenia: Nordostseite bei Meru\", 17 Feb 1922, R. E. Fries 1677", typeDesignations.get(i++).getText());
77
        assertEquals("Syntype: [Malawi] \"Kyimbila\", Stolz 306", typeDesignations.get(i++).getText());
78
        assertEquals("Syntype: [Tanzania] \"Karagwe\", Stuhlmann 1660", typeDesignations.get(i++).getText());
79
        assertEquals("Syntype: [Tanzania] \"Kilimandscharo\", Volkens 1238", typeDesignations.get(i++).getText());
80
        assertEquals("Syntype: \"Uganda\", Scott Elliot 7328", typeDesignations.get(i++).getText());
80 81

  
81 82
        typeDesignations = p.getHeterotypicalGroupTypeDesignations(2);
82 83
        assertEquals("Expecting 3 Typedesignation", 3, typeDesignations.size());
83 84
        assertEquals(TypeDesignationType.specimenTypeDesignation, typeDesignations.get(0).getTypeDesignationType());
84
        assertEquals("Syntype: [Cameroon], Maitland 226", typeDesignations.get(0).getText());
85
        assertEquals("Syntype: [Cameroon], Mildbraed 10814", typeDesignations.get(1).getText());
86
        assertEquals("Syntype: [Cameroon] \"Cameroons Mt., 6,000 ft.\", Dunlap 47", typeDesignations.get(2).getText());
85
        i = 0;
86
        assertEquals("Syntype: [Cameroon] \"Cameroons Mt., 6,000 ft.\", Dunlap 47", typeDesignations.get(i++).getText());
87
        assertEquals("Syntype: [Cameroon], Maitland 226", typeDesignations.get(i++).getText());
88
        assertEquals("Syntype: [Cameroon], Mildbraed 10814", typeDesignations.get(i++).getText());
87 89
    }
88 90

  
89 91
    @Test

Also available in: Unified diff