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
|
import eu.etaxonomy.dataportal.elements.TypeDesignationElement;
|
37
|
|
38
|
/**
|
39
|
* TODO: subpages like /cdm_dataportal/taxon/{uuid}/images are not jet suported, implement means to handle page parts
|
40
|
*
|
41
|
* @author andreas
|
42
|
* @date Jul 1, 2011
|
43
|
*
|
44
|
*/
|
45
|
public class TaxonSynonymyPage extends PortalPage {
|
46
|
|
47
|
public static final Logger logger = Logger.getLogger(TaxonSynonymyPage.class);
|
48
|
|
49
|
private UUID taxonUuid;
|
50
|
|
51
|
protected static String drupalPagePathBase = "cdm_dataportal/taxon";
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
|
55
|
*/
|
56
|
@Override
|
57
|
protected String getDrupalPageBase() {
|
58
|
return drupalPagePathBase;
|
59
|
}
|
60
|
|
61
|
@FindBy(id = "synonymy")
|
62
|
@CacheLookup
|
63
|
private WebElement synonymy;
|
64
|
|
65
|
|
66
|
|
67
|
/**
|
68
|
* @param driver
|
69
|
* @param context
|
70
|
* @param taxonUuid
|
71
|
* @throws MalformedURLException
|
72
|
*/
|
73
|
public TaxonSynonymyPage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
|
74
|
|
75
|
super(driver, context, taxonUuid.toString() + "/synonymy");
|
76
|
|
77
|
this.taxonUuid = taxonUuid;
|
78
|
}
|
79
|
|
80
|
|
81
|
/**
|
82
|
* @param driver
|
83
|
* @param context
|
84
|
* @throws Exception
|
85
|
*/
|
86
|
public TaxonSynonymyPage(WebDriver driver, DataPortalContext context) throws Exception {
|
87
|
super(driver, context);
|
88
|
}
|
89
|
|
90
|
|
91
|
|
92
|
/**
|
93
|
* @return
|
94
|
*/
|
95
|
public String getAcceptedNameText() {
|
96
|
return getAcceptedName().getText();
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* @return
|
101
|
*/
|
102
|
public WebElement getAcceptedName() {
|
103
|
WebElement acceptedName = synonymy.findElement(
|
104
|
By.xpath("./span[contains(@class,'accepted-name')]")
|
105
|
);
|
106
|
return acceptedName;
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* @return
|
111
|
*/
|
112
|
public List<TypeDesignationElement> getAcceptedNameTypeDesignations() {
|
113
|
List<TypeDesignationElement> typeDesignations = new ArrayList<TypeDesignationElement>();
|
114
|
List<WebElement> typeDesignationElements = synonymy.findElements(
|
115
|
By.xpath("./span[contains(@class,'accepted-name')]/following-sibling::ul[contains(@class, 'typeDesignations')]/li")
|
116
|
);
|
117
|
for(WebElement el : typeDesignationElements){
|
118
|
typeDesignations.add(new TypeDesignationElement(el));
|
119
|
}
|
120
|
return typeDesignations;
|
121
|
}
|
122
|
|
123
|
/**
|
124
|
* @return
|
125
|
*/
|
126
|
public List<LinkElement> getAcceptedNameFootNoteKeys() {
|
127
|
List<WebElement> fnkListElements = synonymy.findElements(
|
128
|
By.xpath("./span[contains(@class,'accepted-name')]/following-sibling::span[contains(@class, 'footnote-key')]/a")
|
129
|
);
|
130
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* @param synonymIndex
|
135
|
* the 1-based position of the synonym in the list of homotypical
|
136
|
* synonyms
|
137
|
* @return the full text line of the synonym including the prepending symbol
|
138
|
* and all information rendered after the name. All whitespace is
|
139
|
* normalized to the SPACE character.
|
140
|
*/
|
141
|
public String getHomotypicalGroupSynonymName(Integer synonymIndex) {
|
142
|
WebElement synonym = getHomotypicalGroupSynonym(synonymIndex);
|
143
|
return synonym.getText().replaceAll("\\s", " ");
|
144
|
}
|
145
|
|
146
|
|
147
|
/**
|
148
|
* @param synonymIndex the 1-based index of the synonym in the group
|
149
|
* @return
|
150
|
*/
|
151
|
public WebElement getHomotypicalGroupSynonym(Integer synonymIndex) {
|
152
|
WebElement synonym = synonymy.findElement(
|
153
|
By.xpath("./ul[contains(@class,'homotypicSynonyms')]/li[" + synonymIndex + "]")
|
154
|
);
|
155
|
return synonym;
|
156
|
}
|
157
|
|
158
|
public List<LinkElement> getHomotypicalGroupFootNoteKeys() {
|
159
|
List<WebElement> fnkListElements = synonymy.findElements(
|
160
|
By.xpath("./ul[contains(@class,'homotypicSynonyms')]/*/span[contains(@class, 'footnote-key')]/a")
|
161
|
);
|
162
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
163
|
}
|
164
|
|
165
|
public List<BaseElement> getHomotypicalGroupFootNotes() {
|
166
|
List<WebElement> fnListElements = synonymy.findElements(
|
167
|
By.xpath("./ul[contains(@class,'homotypicSynonyms')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
|
168
|
);
|
169
|
return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
|
170
|
|
171
|
}
|
172
|
|
173
|
|
174
|
|
175
|
/**
|
176
|
* @param heterotypicalGroupIndex
|
177
|
* the 1-based index of the heterotypical group
|
178
|
* @param synonymIndex
|
179
|
* the 1-based position of the synonym in the list specified
|
180
|
* group of heterotypical synonyms
|
181
|
* @return the full text line of the synonym including the prepending symbol
|
182
|
* and all information rendered after the name. All whitespace is
|
183
|
* normalized to the SPACE character.
|
184
|
*/
|
185
|
public String getHeterotypicalGroupSynonymName(Integer heterotypicalGroupIndex, Integer synonymIndex) {
|
186
|
WebElement synonym = getHeterotypicalGroupSynonym(heterotypicalGroupIndex, synonymIndex);
|
187
|
return synonym.getText().replaceAll("\\s", " ");
|
188
|
}
|
189
|
|
190
|
|
191
|
/**
|
192
|
* @param heterotypicalGroupIndex
|
193
|
* the 1-based index of the heterotypical group
|
194
|
* @param synonymIndex
|
195
|
* the 1-based position of the synonym in the list specified
|
196
|
* group of heterotypical synonyms
|
197
|
* @return
|
198
|
*/
|
199
|
public WebElement getHeterotypicalGroupSynonym(Integer heterotypicalGroupIndex, Integer synonymIndex) {
|
200
|
WebElement synonym = synonymy.findElement(By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/li[" + synonymIndex + "]"));
|
201
|
return synonym;
|
202
|
}
|
203
|
|
204
|
/**
|
205
|
* @param heterotypicalGroupIndex
|
206
|
* the 1-based index of the heterotypical group
|
207
|
* @return
|
208
|
*/
|
209
|
public List<LinkElement> getHeterotypicalGroupFootNoteKeys(Integer heterotypicalGroupIndex) {
|
210
|
List<WebElement> fnkListElements = synonymy.findElements(
|
211
|
By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/*/*/span[contains(@class, 'footnote-key')]/a")
|
212
|
);
|
213
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
214
|
}
|
215
|
|
216
|
/**
|
217
|
* @param heterotypicalGroupIndex
|
218
|
* the 1-based index of the heterotypical group
|
219
|
* @return
|
220
|
*/
|
221
|
public List<BaseElement> getHeterotypicalGroupFootNotes(Integer heterotypicalGroupIndex) {
|
222
|
List<WebElement> fnListElements = synonymy.findElements(
|
223
|
By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')][" + heterotypicalGroupIndex + "]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
|
224
|
);
|
225
|
return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
|
226
|
}
|
227
|
|
228
|
}
|