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