Project

General

Profile

Download (10.3 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.dataportal.pages;
11

    
12
import java.net.MalformedURLException;
13
import java.util.ArrayList;
14
import java.util.List;
15
import java.util.UUID;
16

    
17
import org.apache.log4j.Logger;
18
import org.openqa.selenium.By;
19
import org.openqa.selenium.WebDriver;
20
import org.openqa.selenium.WebElement;
21
import org.openqa.selenium.support.CacheLookup;
22
import org.openqa.selenium.support.FindBy;
23

    
24
import eu.etaxonomy.dataportal.DataPortalContext;
25
import eu.etaxonomy.dataportal.ElementUtils;
26
import eu.etaxonomy.dataportal.elements.BaseElement;
27
import eu.etaxonomy.dataportal.elements.LinkElement;
28
import eu.etaxonomy.dataportal.elements.TypeDesignationElement;
29

    
30
/**
31
 * TODO: subpages like /cdm_dataportal/taxon/{uuid}/images are not jet suported, implement means to handle page parts
32
 *
33
 * @author andreas
34
 * @date Jul 1, 2011
35
 *
36
 */
37
public class TaxonSynonymyPage extends PortalPage {
38

    
39
    public static final Logger logger = Logger.getLogger(TaxonSynonymyPage.class);
40

    
41
    private UUID taxonUuid;
42

    
43
    protected static String drupalPagePathBase = "cdm_dataportal/taxon";
44

    
45
    /* (non-Javadoc)
46
     * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
47
     */
48
    @Override
49
    protected String getDrupalPageBase() {
50
        return drupalPagePathBase;
51
    }
52

    
53
    @FindBy(id = "synonymy")
54
    @CacheLookup
55
    private WebElement synonymy;
56

    
57

    
58

    
59
    /**
60
     * @param driver
61
     * @param context
62
     * @param taxonUuid
63
     * @throws MalformedURLException
64
     */
65
    public TaxonSynonymyPage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
66

    
67
        super(driver, context, taxonUuid.toString() + "/synonymy");
68

    
69
        this.taxonUuid = taxonUuid;
70
    }
71

    
72

    
73
    /**
74
     * @param driver
75
     * @param context
76
     * @throws Exception
77
     */
78
    public TaxonSynonymyPage(WebDriver driver, DataPortalContext context) throws Exception {
79
        super(driver, context);
80
    }
81

    
82

    
83

    
84
    /**
85
     * @return
86
     */
87
    public String getAcceptedNameText() {
88
        return getAcceptedName().getText();
89
    }
90

    
91
    /**
92
     * @return
93
     */
94
    public WebElement getAcceptedName() {
95
        WebElement acceptedName = synonymy.findElement(
96
                By.xpath("./div[contains(@class,'accepted-name')]")
97
        );
98
        return acceptedName;
99
    }
100

    
101
    /**
102
     * TypeDesignation of the accepted name are found in the HomotypicalGroup block element
103
     * thus this method will delegate to {@link #getHomotypicalGroupTypeDesignations()}
104
     * @return
105
     * @deprecated use {@link #getHomotypicalGroupTypeDesignations()} instead
106
     */
107
    @Deprecated
108
    public List<TypeDesignationElement> getAcceptedNameTypeDesignations() {
109
        return getHomotypicalGroupTypeDesignations();
110
    }
111

    
112
    /**
113
     * @return the getHomotypicalGroupFootNoteKeys()
114
     */
115
    public List<LinkElement> getAcceptedNameFootNoteKeys() {
116
        List<WebElement> fnkListElements = synonymy.findElements(
117
                By.xpath("./div[contains(@class,'accepted-name')]/span[contains(@class, 'footnote-key')]/a")
118
        );
119
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
120
    }
121

    
122
    /**
123
     * Footnotes of the accepted name are found in the HomotypicalGroup block element
124
     * thus this method will delegate to {@link #getHomotypicalGroupFootNotes()}
125
     *
126
     * @return
127
     * @deprecated
128
     */
129
    @Deprecated
130
    public List<BaseElement> getAcceptedNameFootNotes() {
131
//        List<WebElement> fnListElements = synonymy.findElements(
132
//                By.xpath("./div[contains(@class,'accepted-name')]/following-sibling::ul[contains(@class, 'footnotes')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
133
//        );
134
//        return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
135
        return getHomotypicalGroupFootNotes();
136
    }
137

    
138
    /**
139
     * @param synonymIndex
140
     *            the 1-based position of the synonym in the list of homotypical
141
     *            synonyms
142
     * @return the full text line of the synonym including the prepending symbol
143
     *         and all information rendered after the name. All whitespace is
144
     *         normalized to the SPACE character.
145
     */
146
    public String getHomotypicalGroupSynonymName(Integer synonymIndex) {
147
        WebElement synonym = getHomotypicalGroupSynonym(synonymIndex);
148
        return synonym.getText().replaceAll("\\s", " ");
149
    }
150

    
151

    
152
    /**
153
     * @param synonymIndex the 1-based index of the synonym in the group
154
     * @return
155
     */
156
    public WebElement getHomotypicalGroupSynonym(Integer synonymIndex) {
157
        WebElement synonym = synonymy.findElement(
158
                By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/li[" + synonymIndex + "]")
159
        );
160
        return synonym;
161
    }
162

    
163
    /**
164
     * @return
165
     */
166
    public List<TypeDesignationElement> getHomotypicalGroupTypeDesignations() {
167
        List<WebElement> typeDesignationElements = synonymy.findElements(By
168
                .xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/ul[contains(@class,'typeDesignations')]/li"));
169
        List<TypeDesignationElement> typeDesignations = new ArrayList<TypeDesignationElement>();
170
        for (WebElement el : typeDesignationElements) {
171
            typeDesignations.add(new TypeDesignationElement(el));
172
        }
173
        return typeDesignations;
174
    }
175

    
176
    public List<LinkElement> getHomotypicalGroupFootNoteKeys() {
177
        List<WebElement> fnkListElements = synonymy.findElements(
178
                By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/*/span[contains(@class, 'footnote-key')]/a")
179
        );
180
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
181
    }
182

    
183
    public List<BaseElement> getHomotypicalGroupFootNotes() {
184
        List<WebElement> fnListElements = synonymy.findElements(
185
                By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'footnotes')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
186
        );
187
        return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
188

    
189
    }
190

    
191

    
192

    
193
    /**
194
     * @param heterotypicalGroupIndex
195
     *            the 1-based index of the heterotypical group
196
     * @param synonymIndex
197
     *            the 1-based position of the synonym in the list specified
198
     *            group of heterotypical synonyms
199
     * @return the full text line of the synonym including the prepending symbol
200
     *         and all information rendered after the name. All whitespace is
201
     *         normalized to the SPACE character.
202
     */
203
    public String getHeterotypicalGroupSynonymName(Integer heterotypicalGroupIndex, Integer synonymIndex) {
204
        WebElement synonym = getHeterotypicalGroupSynonym(heterotypicalGroupIndex, synonymIndex);
205
        return synonym.getText().replaceAll("\\s", " ");
206
    }
207

    
208

    
209
    /**
210
     * @param heterotypicalGroupIndex
211
     *            the 1-based index of the heterotypical group
212
     * @param synonymIndex
213
     *            the 1-based position of the synonym in the list specified
214
     *            group of heterotypical synonyms
215
     * @return
216
     */
217
    public WebElement getHeterotypicalGroupSynonym(Integer heterotypicalGroupIndex, Integer synonymIndex) {
218
        WebElement synonym = synonymy.findElement(By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul[contains(@class,'heterotypicSynonymyGroup')]/li[" + synonymIndex + "]"));
219
        return synonym;
220
    }
221

    
222
    /**
223
     * @param heterotypicalGroupIndex
224
     *            the 1-based index of the heterotypical group
225
     * @return
226
     */
227
    public List<TypeDesignationElement> getHeterotypicalGroupTypeDesignations(Integer heterotypicalGroupIndex) {
228
        List<WebElement> typeDesignationElements = synonymy.findElements(By
229
                .xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex
230
                        + "]/ul[contains(@class,'heterotypicSynonymyGroup')]/ul[contains(@class,'typeDesignations')]/li"));
231
        List<TypeDesignationElement> typeDesignations = new ArrayList<TypeDesignationElement>();
232
        for (WebElement el : typeDesignationElements) {
233
            typeDesignations.add(new TypeDesignationElement(el));
234
        }
235
        return typeDesignations;
236
    }
237

    
238
    /**
239
     * @param heterotypicalGroupIndex
240
     * 				the 1-based index of the heterotypical group
241
     * @return
242
     */
243
    public List<LinkElement> getHeterotypicalGroupFootNoteKeys(Integer heterotypicalGroupIndex) {
244
        List<WebElement> fnkListElements = synonymy.findElements(
245
                By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul/*/*/span[contains(@class, 'footnote-key')]/a")
246
         );
247
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
248
    }
249

    
250
    /**
251
     * @param heterotypicalGroupIndex
252
     * 				the 1-based index of the heterotypical group
253
     * @return
254
     */
255
    public List<BaseElement> getHeterotypicalGroupFootNotes(Integer heterotypicalGroupIndex) {
256
        List<WebElement> fnListElements = synonymy.findElements(
257
                By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
258
        );
259
        return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
260
    }
261

    
262
    public WebElement getTaxonRelationships() {
263
        WebElement taxonRelationships = synonymy.findElement(
264
                By.xpath("./div[contains(@class,'taxon-relationships')]")
265
        );
266
        return taxonRelationships;
267
    }
268

    
269
    /**
270
     * @param heterotypicalGroupIndex
271
     *              the 1-based index of the misapplied names
272
     * @return
273
     */
274
    public WebElement getMisappliedName(Integer misappliedNameIndex) {
275
        WebElement misappliedName = getTaxonRelationships().findElement(
276
                By.xpath("./ul[contains(@class,'misapplied')]/li[" + misappliedNameIndex + "]")
277
        );
278
        return misappliedName;
279
    }
280

    
281
}
(6-6/6)