Project

General

Profile

Download (6.92 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2

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

    
13
import static org.junit.Assert.assertEquals;
14
import static org.junit.Assert.assertTrue;
15

    
16
import java.net.MalformedURLException;
17
import java.util.ArrayList;
18
import java.util.List;
19
import java.util.UUID;
20

    
21
import org.apache.log4j.Logger;
22
import org.junit.Assert;
23
import org.openqa.selenium.By;
24
import org.openqa.selenium.NoSuchElementException;
25
import org.openqa.selenium.WebElement;
26
import org.openqa.selenium.WebDriver;
27
import org.openqa.selenium.support.CacheLookup;
28
import org.openqa.selenium.support.FindBy;
29

    
30
import eu.etaxonomy.dataportal.DataPortalContext;
31
import eu.etaxonomy.dataportal.ElementUtils;
32
import eu.etaxonomy.dataportal.elements.BaseElement;
33
import eu.etaxonomy.dataportal.elements.FeatureBlock;
34
import eu.etaxonomy.dataportal.elements.ImgElement;
35
import eu.etaxonomy.dataportal.elements.LinkElement;
36

    
37
/**
38
 * TODO: subpages like /cdm_dataportal/taxon/{uuid}/images are not jet suported, implement means to handle page parts
39
 *
40
 * @author andreas
41
 * @date Jul 1, 2011
42
 *
43
 */
44
public class TaxonSynonymyPage extends PortalPage {
45

    
46
    public static final Logger logger = Logger.getLogger(TaxonSynonymyPage.class);
47

    
48
    private UUID taxonUuid;
49

    
50
    protected static String drupalPagePathBase = "cdm_dataportal/taxon";
51

    
52
    /* (non-Javadoc)
53
     * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
54
     */
55
    @Override
56
    protected String getDrupalPageBase() {
57
        return drupalPagePathBase;
58
    }
59

    
60
    @FindBy(id = "synonymy")
61
    @CacheLookup
62
    private WebElement synonymy;
63

    
64

    
65

    
66
    /**
67
     * @param driver
68
     * @param context
69
     * @param taxonUuid
70
     * @throws MalformedURLException
71
     */
72
    public TaxonSynonymyPage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
73

    
74
        super(driver, context, taxonUuid.toString() + "/synonymy");
75

    
76
        this.taxonUuid = taxonUuid;
77
    }
78

    
79

    
80
    /**
81
     * @param driver
82
     * @param context
83
     * @throws Exception
84
     */
85
    public TaxonSynonymyPage(WebDriver driver, DataPortalContext context) throws Exception {
86
        super(driver, context);
87
    }
88

    
89

    
90
    /**
91
     * Returns the profile image of the taxon profile page. This image is
92
     * located at the top of the page. The Profile Image can be disabled in the
93
     * DataPortal settings.
94
     *
95
     * @return The Url of the profile image or null if the image is not visible.
96
     */
97
    public String getAcceptedName() {
98
        WebElement acceptedName = synonymy.findElement(
99
                By.xpath("./span[contains(@class,'accepted-name')]")
100
        );
101
        return acceptedName.getText();
102
    }
103

    
104
    public List<LinkElement> getAcceptedNameFootNoteKeys() {
105
        List<WebElement> fnkListElements = synonymy.findElements(
106
                By.xpath("./span[contains(@class,'accepted-name')]/following-sibling::span[contains(@class, 'footnote-key')]/a")
107
        );
108
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
109
    }
110

    
111
    /**
112
     * @param synonymIndex
113
     *            the 1-based position of the synonym in the list of homotypical
114
     *            synonyms
115
     * @return the full text line of the synonym including the prepending symbol
116
     *         and all information rendered after the name. All whitespace is
117
     *         normalized to the SPACE character.
118
     */
119
    public String getHomotypicalGroupSynonymName(Integer synonymIndex) {
120
        WebElement synonym = getHomotypicalGroupSynonym(synonymIndex);
121
        return synonym.getText().replaceAll("\\s", " ");
122
    }
123

    
124

    
125
    /**
126
     * @param synonymIndex
127
     * @return
128
     */
129
    public WebElement getHomotypicalGroupSynonym(Integer synonymIndex) {
130
        WebElement synonym = synonymy.findElement(
131
                By.xpath("./ul[contains(@class,'homotypicSynonyms')]/li[" + synonymIndex + "]")
132
        );
133
        return synonym;
134
    }
135

    
136
    public List<LinkElement> getHomotypicalGroupFootNoteKeys() {
137
        List<WebElement> fnkListElements = synonymy.findElements(
138
                By.xpath("./ul[contains(@class,'homotypicSynonyms')]/*/span[contains(@class, 'footnote-key')]/a")
139
        );
140
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
141
    }
142

    
143
    public List<BaseElement> getHomotypicalGroupFootNotes() {
144
        List<WebElement> fnListElements = synonymy.findElements(
145
                By.xpath("./ul[contains(@class,'homotypicSynonyms')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
146
        );
147
        return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
148

    
149
    }
150

    
151

    
152

    
153
    /**
154
     * @param heterotypicalGroupIndex
155
     *            the 1-based index of the heterotypical group
156
     * @param synonymIndex
157
     *            the 1-based position of the synonym in the list specified
158
     *            group of heterotypical synonyms
159
     * @return the full text line of the synonym including the prepending symbol
160
     *         and all information rendered after the name. All whitespace is
161
     *         normalized to the SPACE character.
162
     */
163
    public String getHeterotypicalGroupSynonymName(Integer heterotypicalGroupIndex, Integer synonymIndex) {
164
        WebElement synonym = getHeterotypicalGroupSynonym(heterotypicalGroupIndex, synonymIndex);
165
        return synonym.getText().replaceAll("\\s", " ");
166
    }
167

    
168

    
169
    /**
170
     * @param heterotypicalGroupIndex
171
     *            the 1-based index of the heterotypical group
172
     * @param synonymIndex
173
     *            the 1-based position of the synonym in the list specified
174
     *            group of heterotypical synonyms
175
     * @return
176
     */
177
    public WebElement getHeterotypicalGroupSynonym(Integer heterotypicalGroupIndex, Integer synonymIndex) {
178
        WebElement synonym = synonymy.findElement(By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/li[" + synonymIndex + "]"));
179
        return synonym;
180
    }
181

    
182
    public List<LinkElement> getHeterotypicalGroupFootNoteKeys(Integer heterotypicalGroupIndex) {
183
        List<WebElement> fnkListElements = synonymy.findElements(
184
                By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/*/span[contains(@class, 'footnote-key')]/a")
185
        );
186
        return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
187
    }
188

    
189
    public List<BaseElement> getHeterotypicalGroupFootNotes(Integer heterotypicalGroupIndex) {
190
        List<WebElement> fnListElements = synonymy.findElements(
191
                By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnotes')]")
192
        );
193
        return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
194
    }
195

    
196
}
(6-6/6)