1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.api.service;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.stereotype.Service;
|
17
|
import org.springframework.transaction.annotation.Transactional;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
20
|
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
|
21
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
22
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
23
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
24
|
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionElementDao;
|
25
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @author a.kohlbecker
|
30
|
*
|
31
|
* @since 24.06.2008
|
32
|
*/
|
33
|
@Service
|
34
|
@Transactional(readOnly = true)
|
35
|
public class DescriptionElementServiceImpl
|
36
|
extends AnnotatableServiceBase<DescriptionElementBase,IDescriptionElementDao>
|
37
|
implements IDescriptionElementService {
|
38
|
|
39
|
private static final Logger logger = Logger.getLogger(DescriptionElementServiceImpl.class);
|
40
|
|
41
|
// protected IDescriptionElementDao descriptionElementDao;
|
42
|
// protected ITermTreeDao featureTreeDao;
|
43
|
// protected IDescriptiveDataSetDao descriptiveDataSetDao;
|
44
|
// protected ITermNodeDao termNodeDao;
|
45
|
// protected ITermVocabularyDao vocabularyDao;
|
46
|
// protected IDefinedTermDao definedTermDao;
|
47
|
// protected IStatisticalMeasurementValueDao statisticalMeasurementValueDao;
|
48
|
// protected ITaxonDao taxonDao;
|
49
|
// protected ITaxonNameDao nameDao;
|
50
|
// protected IOccurrenceDao occurrenceDao;
|
51
|
// protected ITaxonNodeDao taxonNodeDao;
|
52
|
// protected IDescriptiveDataSetDao dataSetDao;
|
53
|
// protected ITermService termService;
|
54
|
|
55
|
//TODO change to Interface
|
56
|
private NaturalLanguageGenerator naturalLanguageGenerator;
|
57
|
|
58
|
|
59
|
@Override
|
60
|
@Autowired
|
61
|
protected void setDao(IDescriptionElementDao dao) {
|
62
|
this.dao = dao;
|
63
|
}
|
64
|
//
|
65
|
// @Autowired
|
66
|
// protected void setFeatureTreeDao(ITermTreeDao featureTreeDao) {
|
67
|
// this.featureTreeDao = featureTreeDao;
|
68
|
// }
|
69
|
//
|
70
|
// @Autowired
|
71
|
// protected void setDescriptiveDataSetDao(IDescriptiveDataSetDao descriptiveDataSetDao) {
|
72
|
// this.descriptiveDataSetDao = descriptiveDataSetDao;
|
73
|
// }
|
74
|
//
|
75
|
// @Autowired
|
76
|
// protected void setTermNodeDao(ITermNodeDao featureNodeDao) {
|
77
|
// this.termNodeDao = featureNodeDao;
|
78
|
// }
|
79
|
//
|
80
|
// @Autowired
|
81
|
// protected void setVocabularyDao(ITermVocabularyDao vocabularyDao) {
|
82
|
// this.vocabularyDao = vocabularyDao;
|
83
|
// }
|
84
|
//
|
85
|
// @Autowired
|
86
|
// protected void setDefinedTermDao(IDefinedTermDao definedTermDao) {
|
87
|
// this.definedTermDao = definedTermDao;
|
88
|
// }
|
89
|
//
|
90
|
// @Autowired
|
91
|
// protected void setTermService(ITermService definedTermService) {
|
92
|
// this.termService = definedTermService;
|
93
|
// }
|
94
|
//
|
95
|
// @Autowired
|
96
|
// protected void statisticalMeasurementValueDao(IStatisticalMeasurementValueDao statisticalMeasurementValueDao) {
|
97
|
// this.statisticalMeasurementValueDao = statisticalMeasurementValueDao;
|
98
|
// }
|
99
|
//
|
100
|
// @Autowired
|
101
|
// protected void setDescriptionElementDao(IDescriptionElementDao descriptionElementDao) {
|
102
|
// this.descriptionElementDao = descriptionElementDao;
|
103
|
// }
|
104
|
|
105
|
@Autowired
|
106
|
protected void setNaturalLanguageGenerator(NaturalLanguageGenerator naturalLanguageGenerator) {
|
107
|
this.naturalLanguageGenerator = naturalLanguageGenerator;
|
108
|
}
|
109
|
|
110
|
// @Autowired
|
111
|
// protected void setTaxonDao(ITaxonDao taxonDao) {
|
112
|
// this.taxonDao = taxonDao;
|
113
|
// }
|
114
|
//
|
115
|
// @Autowired
|
116
|
// protected void setTaxonNodeDao(ITaxonNodeDao taxonNodeDao) {
|
117
|
// this.taxonNodeDao = taxonNodeDao;
|
118
|
// }
|
119
|
//
|
120
|
// @Autowired
|
121
|
// protected void setDataSetDao(IDescriptiveDataSetDao dataSetDao) {
|
122
|
// this.dataSetDao = dataSetDao;
|
123
|
// }
|
124
|
|
125
|
public DescriptionElementServiceImpl() {
|
126
|
if (logger.isDebugEnabled()){logger.debug("Load DescriptionElementService Bean");}
|
127
|
}
|
128
|
|
129
|
|
130
|
@Override
|
131
|
public Pager<Annotation> getDescriptionElementAnnotations(DescriptionElementBase annotatedObj, MarkerType status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths){
|
132
|
long numberOfResults = dao.countAnnotations(annotatedObj, status);
|
133
|
|
134
|
List<Annotation> results = new ArrayList<>();
|
135
|
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
|
136
|
results = dao.getAnnotations(annotatedObj, status, pageSize, pageNumber, orderHints, propertyPaths);
|
137
|
}
|
138
|
|
139
|
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results);
|
140
|
}
|
141
|
|
142
|
}
|