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
|
* @since 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
|
*/
|
64
|
public TaxonSynonymyPage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
|
65
|
|
66
|
super(driver, context, taxonUuid.toString() + "/synonymy");
|
67
|
|
68
|
this.taxonUuid = taxonUuid;
|
69
|
}
|
70
|
|
71
|
|
72
|
/**
|
73
|
* @param driver
|
74
|
* @param context
|
75
|
*/
|
76
|
public TaxonSynonymyPage(WebDriver driver, DataPortalContext context) throws Exception {
|
77
|
super(driver, context);
|
78
|
}
|
79
|
|
80
|
public String getAcceptedNameText() {
|
81
|
return getAcceptedName().getText();
|
82
|
}
|
83
|
|
84
|
public WebElement getAcceptedName() {
|
85
|
WebElement acceptedName = synonymy.findElement(
|
86
|
By.xpath("./div[contains(@class,'accepted-name')]")
|
87
|
);
|
88
|
return acceptedName;
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* TypeDesignation of the accepted name are found in the HomotypicalGroup block element
|
93
|
* thus this method will delegate to {@link #getHomotypicalGroupTypeDesignations()}
|
94
|
* @deprecated use {@link #getHomotypicalGroupTypeDesignations()} instead
|
95
|
*/
|
96
|
@Deprecated
|
97
|
public List<TypeDesignationElement> getAcceptedNameTypeDesignations() {
|
98
|
return getHomotypicalGroupTypeDesignations();
|
99
|
}
|
100
|
|
101
|
/**
|
102
|
* @return the getHomotypicalGroupFootNoteKeys()
|
103
|
*/
|
104
|
public List<LinkElement> getAcceptedNameFootNoteKeys() {
|
105
|
List<WebElement> fnkListElements = synonymy.findElements(
|
106
|
By.xpath("./div[contains(@class,'accepted-name')]/span[contains(@class, 'footnote-key')]/a")
|
107
|
);
|
108
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Footnotes of the accepted name are found in the HomotypicalGroup block element
|
113
|
* thus this method will delegate to {@link #getHomotypicalGroupFootNotes()}
|
114
|
*
|
115
|
*/
|
116
|
@Deprecated
|
117
|
public List<BaseElement> getAcceptedNameFootNotes() {
|
118
|
// List<WebElement> fnListElements = synonymy.findElements(
|
119
|
// By.xpath("./div[contains(@class,'accepted-name')]/following-sibling::ul[contains(@class, 'footnotes')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
|
120
|
// );
|
121
|
// return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
|
122
|
return getHomotypicalGroupFootNotes();
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* @param synonymIndex
|
127
|
* the 1-based position of the synonym in the list of homotypical
|
128
|
* synonyms
|
129
|
* @return the full text line of the synonym including the prepending symbol
|
130
|
* and all information rendered after the name. All whitespace is
|
131
|
* normalized to the SPACE character.
|
132
|
*/
|
133
|
public String getHomotypicalGroupSynonymName(Integer synonymIndex) {
|
134
|
WebElement synonym = getHomotypicalGroupSynonym(synonymIndex);
|
135
|
return synonym.getText().replaceAll("\\s", " ");
|
136
|
}
|
137
|
|
138
|
|
139
|
/**
|
140
|
* @param synonymIndex the 1-based index of the synonym in the group
|
141
|
*/
|
142
|
public WebElement getHomotypicalGroupSynonym(Integer synonymIndex) {
|
143
|
WebElement synonym = synonymy.findElement(
|
144
|
By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/li[" + synonymIndex + "]")
|
145
|
);
|
146
|
return synonym;
|
147
|
}
|
148
|
|
149
|
public List<TypeDesignationElement> getHomotypicalGroupTypeDesignations() {
|
150
|
List<WebElement> typeDesignationElements = synonymy.findElements(By
|
151
|
.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/ul[contains(@class,'typeDesignations')]/li"));
|
152
|
List<TypeDesignationElement> typeDesignations = new ArrayList<TypeDesignationElement>();
|
153
|
for (WebElement el : typeDesignationElements) {
|
154
|
typeDesignations.add(new TypeDesignationElement(el));
|
155
|
}
|
156
|
return typeDesignations;
|
157
|
}
|
158
|
|
159
|
public List<LinkElement> getHomotypicalGroupFootNoteKeys() {
|
160
|
List<WebElement> fnkListElements = synonymy.findElements(
|
161
|
By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'homotypicSynonyms')]/*/span[contains(@class, 'footnote-key')]/a")
|
162
|
);
|
163
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
164
|
}
|
165
|
|
166
|
public List<BaseElement> getHomotypicalGroupFootNotes() {
|
167
|
List<WebElement> fnListElements = synonymy.findElements(
|
168
|
By.xpath("./div[contains(@class,'homotypic-synonymy-group')]/ul[contains(@class,'footnotes')]/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
|
169
|
);
|
170
|
return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
|
171
|
|
172
|
}
|
173
|
|
174
|
|
175
|
|
176
|
/**
|
177
|
* @param heterotypicalGroupIndex
|
178
|
* the 1-based index of the heterotypical group
|
179
|
* @param synonymIndex
|
180
|
* the 1-based position of the synonym in the list specified
|
181
|
* group of heterotypical synonyms
|
182
|
* @return the full text line of the synonym including the prepending symbol
|
183
|
* and all information rendered after the name. All whitespace is
|
184
|
* normalized to the SPACE character.
|
185
|
*/
|
186
|
public String getHeterotypicalGroupSynonymName(Integer heterotypicalGroupIndex, Integer synonymIndex) {
|
187
|
WebElement synonym = getHeterotypicalGroupSynonym(heterotypicalGroupIndex, synonymIndex);
|
188
|
return synonym.getText().replaceAll("\\s", " ");
|
189
|
}
|
190
|
|
191
|
|
192
|
/**
|
193
|
* @param heterotypicalGroupIndex
|
194
|
* the 1-based index of the heterotypical group
|
195
|
* @param synonymIndex
|
196
|
* the 1-based position of the synonym in the list specified
|
197
|
* group of heterotypical synonyms
|
198
|
*/
|
199
|
public WebElement getHeterotypicalGroupSynonym(Integer heterotypicalGroupIndex, Integer synonymIndex) {
|
200
|
WebElement synonym = synonymy.findElement(By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul[contains(@class,'heterotypicSynonymyGroup')]/li[" + synonymIndex + "]"));
|
201
|
return synonym;
|
202
|
}
|
203
|
|
204
|
/**
|
205
|
* @param heterotypicalGroupIndex
|
206
|
* the 1-based index of the heterotypical group
|
207
|
*/
|
208
|
public List<TypeDesignationElement> getHeterotypicalGroupTypeDesignations(Integer heterotypicalGroupIndex) {
|
209
|
List<WebElement> typeDesignationElements = synonymy.findElements(By
|
210
|
.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex
|
211
|
+ "]/ul[contains(@class,'heterotypicSynonymyGroup')]/ul[contains(@class,'typeDesignations')]/li"));
|
212
|
List<TypeDesignationElement> typeDesignations = new ArrayList<TypeDesignationElement>();
|
213
|
for (WebElement el : typeDesignationElements) {
|
214
|
typeDesignations.add(new TypeDesignationElement(el));
|
215
|
}
|
216
|
return typeDesignations;
|
217
|
}
|
218
|
|
219
|
/**
|
220
|
* @param heterotypicalGroupIndex
|
221
|
* the 1-based index of the heterotypical group
|
222
|
*/
|
223
|
public List<LinkElement> getHeterotypicalGroupFootNoteKeys(Integer heterotypicalGroupIndex) {
|
224
|
List<WebElement> fnkListElements = synonymy.findElements(
|
225
|
By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul/*/*/span[contains(@class, 'footnote-key')]/a")
|
226
|
);
|
227
|
return ElementUtils.linkElementsFromFootNoteKeyListElements(fnkListElements);
|
228
|
}
|
229
|
|
230
|
/**
|
231
|
* @param heterotypicalGroupIndex
|
232
|
* the 1-based index of the heterotypical group
|
233
|
*/
|
234
|
public List<BaseElement> getHeterotypicalGroupFootNotes(Integer heterotypicalGroupIndex) {
|
235
|
List<WebElement> fnListElements = synonymy.findElements(
|
236
|
By.xpath("./div[contains(@class,'heterotypic-synonymy-group')][" + heterotypicalGroupIndex + "]/ul/li[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]")
|
237
|
);
|
238
|
return ElementUtils.baseElementsFromFootNoteListElements(fnListElements);
|
239
|
}
|
240
|
|
241
|
public WebElement getTaxonRelationships() {
|
242
|
WebElement taxonRelationships = synonymy.findElement(
|
243
|
By.xpath("./div[contains(@class,'taxon-relationships')]")
|
244
|
);
|
245
|
return taxonRelationships;
|
246
|
}
|
247
|
|
248
|
public WebElement getMisappliedName(Integer misappliedNameIndex) {
|
249
|
WebElement misappliedName = getTaxonRelationships().findElement(
|
250
|
By.xpath("./ul[contains(@class,'misapplied')]/li[" + misappliedNameIndex + "]")
|
251
|
);
|
252
|
return misappliedName;
|
253
|
}
|
254
|
|
255
|
}
|