Revision b3340748
Added by Andreas Müller about 5 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NaturalLanguageGenerator.java | ||
---|---|---|
22 | 22 |
import eu.etaxonomy.cdm.model.description.TextData; |
23 | 23 |
import eu.etaxonomy.cdm.model.description.TextFormat; |
24 | 24 |
import eu.etaxonomy.cdm.model.term.TermTreeNode; |
25 |
import eu.etaxonomy.cdm.model.term.FeatureTree;
|
|
25 |
import eu.etaxonomy.cdm.model.term.TermTree;
|
|
26 | 26 |
|
27 | 27 |
|
28 | 28 |
/** |
... | ... | |
158 | 158 |
* @return a list of TextData, each one being a basic element of the natural language description |
159 | 159 |
*/ |
160 | 160 |
@Override |
161 |
public List<TextData> generateNaturalLanguageDescription(FeatureTree featureTree,TaxonDescription description) {
|
|
161 |
public List<TextData> generateNaturalLanguageDescription(TermTree featureTree,TaxonDescription description) {
|
|
162 | 162 |
return generateNaturalLanguageDescription(featureTree,description,Language.DEFAULT()); |
163 | 163 |
} |
164 | 164 |
|
... | ... | |
174 | 174 |
* @return a list of TextData, each one being a basic element of the natural language description |
175 | 175 |
*/ |
176 | 176 |
@Override |
177 |
public List<TextData> generateNaturalLanguageDescription(FeatureTree featureTree, TaxonDescription description, Language language) {
|
|
177 |
public List<TextData> generateNaturalLanguageDescription(TermTree featureTree, TaxonDescription description, Language language) {
|
|
178 | 178 |
List<Language> languages = new ArrayList<Language>(); |
179 | 179 |
languages.add(language); |
180 | 180 |
initNaturalLanguageDescriptionElementProcessors(description.getAnnotations()); |
... | ... | |
191 | 191 |
* @return a list of TextData, each one being a basic element of the natural language description |
192 | 192 |
*/ |
193 | 193 |
@Override |
194 |
public List<TextData> generatePreferredNaturalLanguageDescription(FeatureTree featureTree,TaxonDescription description, List<Language> languages) {
|
|
194 |
public List<TextData> generatePreferredNaturalLanguageDescription(TermTree featureTree,TaxonDescription description, List<Language> languages) {
|
|
195 | 195 |
initNaturalLanguageDescriptionElementProcessors(description.getAnnotations()); |
196 | 196 |
return buildBranchesDescr(featureTree.getRootChildren(), featureTree.getRoot(), description, languages,0); |
197 | 197 |
} |
... | ... | |
205 | 205 |
* @return a TextData in the default language. |
206 | 206 |
*/ |
207 | 207 |
@Override |
208 |
public TextData generateSingleTextData(FeatureTree featureTree, TaxonDescription description) {
|
|
208 |
public TextData generateSingleTextData(TermTree featureTree, TaxonDescription description) {
|
|
209 | 209 |
return generateSingleTextData(featureTree,description,Language.DEFAULT()); |
210 | 210 |
} |
211 | 211 |
|
... | ... | |
219 | 219 |
* @return a TextData in the specified language. |
220 | 220 |
*/ |
221 | 221 |
@Override |
222 |
public TextData generateSingleTextData(FeatureTree featureTree, TaxonDescription description, Language language) {
|
|
222 |
public TextData generateSingleTextData(TermTree featureTree, TaxonDescription description, Language language) {
|
|
223 | 223 |
List<Language> languages = new ArrayList<Language>(); |
224 | 224 |
languages.add(language); |
225 | 225 |
return generatePreferredSingleTextData(featureTree,description,languages); |
... | ... | |
235 | 235 |
* @return a TextData using the languages (in the given order of preference) |
236 | 236 |
*/ |
237 | 237 |
@Override |
238 |
public TextData generatePreferredSingleTextData(FeatureTree featureTree, TaxonDescription description, List<Language> languages) {
|
|
238 |
public TextData generatePreferredSingleTextData(TermTree featureTree, TaxonDescription description, List<Language> languages) {
|
|
239 | 239 |
levels.clear(); // before the start, the table containing the levels of each node must be cleared |
240 | 240 |
// Note: this is not the most efficient way to keep track of the levels of the nodes but it allows some flexibility |
241 | 241 |
List<TextData> texts = generatePreferredNaturalLanguageDescription(featureTree,description, languages);// first get the description as a raw list of TextData |
Also available in: Unified diff
ref #6794 change FeatureTree to TermTree