Revision c1a8faa1
Added by Andreas Müller about 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/reference/OriginalSourceDaoImpl.java | ||
---|---|---|
18 | 18 |
import org.hibernate.Query; |
19 | 19 |
import org.hibernate.Session; |
20 | 20 |
import org.hibernate.criterion.Order; |
21 |
import org.hibernate.criterion.Projections; |
|
21 | 22 |
import org.hibernate.criterion.Restrictions; |
22 | 23 |
import org.springframework.stereotype.Repository; |
23 | 24 |
|
24 | 25 |
import eu.etaxonomy.cdm.common.CdmUtils; |
26 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
27 |
import eu.etaxonomy.cdm.model.name.HybridRelationship; |
|
25 | 28 |
import eu.etaxonomy.cdm.model.reference.ISourceable; |
26 | 29 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
27 | 30 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase; |
28 | 31 |
import eu.etaxonomy.cdm.persistence.dao.reference.IOriginalSourceDao; |
32 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
29 | 33 |
|
30 | 34 |
/** |
31 | 35 |
* @author a.mueller |
... | ... | |
108 | 112 |
|
109 | 113 |
return results; |
110 | 114 |
} |
115 |
|
|
116 |
@Override |
|
117 |
public <T extends DescriptionElementSource> Long countWithNameUsedInSource(Class<T> clazz){ |
|
118 |
Criteria criteria = getSession().createCriteria(HybridRelationship.class); |
|
119 |
|
|
120 |
clazz = clazz != null? clazz : (Class<T>) DescriptionElementSource.class; |
|
121 |
Criteria crit = getSession().createCriteria(clazz); |
|
122 |
//count |
|
123 |
criteria.setProjection(Projections.rowCount()); |
|
124 |
long result = (Long)criteria.uniqueResult(); |
|
125 |
|
|
126 |
return result; |
|
127 |
} |
|
128 |
|
|
129 |
|
|
130 |
@Override |
|
131 |
public <T extends DescriptionElementSource> List<T> listWithNameUsedInSource(Class<T> clazz, |
|
132 |
Integer pageSize, Integer pageNumber,List<OrderHint> orderHints, List<String> propertyPaths){ |
|
133 |
clazz = clazz != null? clazz : (Class<T>) DescriptionElementSource.class; |
|
134 |
Criteria crit = getSession().createCriteria(clazz); |
|
135 |
crit.add(Restrictions.isNotNull("nameUsedInSource")); |
|
136 |
|
|
137 |
crit.addOrder(Order.desc("created")); |
|
138 |
@SuppressWarnings({ "unchecked" }) |
|
139 |
List<T> results = crit.list(); |
|
140 |
|
|
141 |
return results; |
|
142 |
} |
|
111 | 143 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/reference/IOriginalSourceDao.java | ||
---|---|---|
12 | 12 |
import java.util.Map; |
13 | 13 |
import java.util.Set; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
15 | 16 |
import eu.etaxonomy.cdm.model.reference.ISourceable; |
16 | 17 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase; |
17 | 18 |
import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao; |
18 |
|
|
19 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
19 | 20 |
|
20 | 21 |
public interface IOriginalSourceDao extends ICdmEntityDao<OriginalSourceBase>{ |
21 | 22 |
|
... | ... | |
37 | 38 |
*/ |
38 | 39 |
public List<OriginalSourceBase> findOriginalSourceByIdInSource(String idInSource, String idNamespace); |
39 | 40 |
|
41 |
public <T extends DescriptionElementSource> List<T> listWithNameUsedInSource(Class<T> clazz, Integer pageSize, Integer pageNumber, |
|
42 |
List<OrderHint> orderHints, List<String> propertyPaths); |
|
43 |
|
|
44 |
public <T extends DescriptionElementSource> Long countWithNameUsedInSource(Class<T> clazz); |
|
40 | 45 |
|
41 | 46 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java | ||
---|---|---|
35 | 35 |
import eu.etaxonomy.cdm.model.name.NameRelationship; |
36 | 36 |
import eu.etaxonomy.cdm.model.name.NameRelationshipType; |
37 | 37 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
38 |
import eu.etaxonomy.cdm.model.name.NomenclaturalSource; |
|
38 | 39 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
39 | 40 |
import eu.etaxonomy.cdm.model.name.Rank; |
40 | 41 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
305 | 306 |
|
306 | 307 |
public List<HomotypicalGroup> getAllHomotypicalGroups(int limit, int start); |
307 | 308 |
|
309 |
/** |
|
310 |
* Returns all or a page of all original spellings in the database. |
|
311 |
* As original spellings are |
|
312 |
* |
|
313 |
* @param pageSize the page size |
|
314 |
* @param pageStart the number of the page |
|
315 |
* @param orderHints the order hints |
|
316 |
* @param propertyPaths the property path to initialize the resulting objects |
|
317 |
* @return list of nomenclatural the filter criteria |
|
318 |
*/ |
|
319 |
public List<NomenclaturalSource> listOriginalSpellings(Integer pageSize, |
|
320 |
Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths); |
|
321 |
|
|
308 | 322 |
/** |
309 | 323 |
* Returns all or a page of all taxon name relationships in the database. |
310 | 324 |
* The result can be filtered by relationship types. |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java | ||
---|---|---|
70 | 70 |
import eu.etaxonomy.cdm.model.name.NameRelationshipType; |
71 | 71 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
72 | 72 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
73 |
import eu.etaxonomy.cdm.model.name.NomenclaturalSource; |
|
73 | 74 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
74 | 75 |
import eu.etaxonomy.cdm.model.name.Rank; |
75 | 76 |
import eu.etaxonomy.cdm.model.name.Registration; |
... | ... | |
95 | 96 |
import eu.etaxonomy.cdm.persistence.dao.name.INomenclaturalStatusDao; |
96 | 97 |
import eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao; |
97 | 98 |
import eu.etaxonomy.cdm.persistence.dao.name.ITypeDesignationDao; |
98 |
import eu.etaxonomy.cdm.persistence.dao.term.IOrderedTermVocabularyDao; |
|
99 |
import eu.etaxonomy.cdm.persistence.dao.term.ITermVocabularyDao; |
|
99 |
import eu.etaxonomy.cdm.persistence.dao.reference.IOriginalSourceDao; |
|
100 | 100 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNameParts; |
101 | 101 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
102 | 102 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
... | ... | |
120 | 120 |
static private final Logger logger = Logger.getLogger(NameServiceImpl.class); |
121 | 121 |
|
122 | 122 |
@Autowired |
123 |
protected ITermVocabularyDao vocabularyDao;
|
|
123 |
private IOccurrenceService occurrenceService;
|
|
124 | 124 |
@Autowired |
125 |
protected IOrderedTermVocabularyDao orderedVocabularyDao;
|
|
125 |
private ICollectionService collectionService;
|
|
126 | 126 |
@Autowired |
127 |
protected IOccurrenceService occurrenceService;
|
|
127 |
private ITaxonService taxonService;
|
|
128 | 128 |
@Autowired |
129 |
protected ICollectionService collectionService; |
|
130 |
@Autowired |
|
131 |
protected ITaxonService taxonService; |
|
129 |
private ICommonService commonService; |
|
132 | 130 |
@Autowired |
133 | 131 |
@Qualifier("sourcedEntityDao") |
134 |
protected ISourcedEntityDao<SourcedEntityBase<?>> sourcedEntityDao;
|
|
132 |
private ISourcedEntityDao<SourcedEntityBase<?>> sourcedEntityDao;
|
|
135 | 133 |
@Autowired |
136 | 134 |
private INomenclaturalStatusDao nomStatusDao; |
137 | 135 |
@Autowired |
... | ... | |
143 | 141 |
@Autowired |
144 | 142 |
private ILuceneIndexToolProvider luceneIndexToolProvider; |
145 | 143 |
@Autowired |
146 |
protected ICommonService commonService;
|
|
144 |
private IOriginalSourceDao sourcedDao;
|
|
147 | 145 |
|
148 | 146 |
@Autowired |
149 | 147 |
// @Qualifier("defaultBeanInitializer") |
... | ... | |
532 | 530 |
return homotypicalGroupDao.list(limit, start); |
533 | 531 |
} |
534 | 532 |
|
533 |
|
|
534 |
@Override |
|
535 |
public List<NomenclaturalSource> listOriginalSpellings(Integer pageSize, Integer pageNumber, |
|
536 |
List<OrderHint> orderHints, List<String> propertyPaths) { |
|
537 |
|
|
538 |
Long numberOfResults = sourcedDao.countWithNameUsedInSource(NomenclaturalSource.class); |
|
539 |
List<NomenclaturalSource> results = new ArrayList<>(); |
|
540 |
if(numberOfResults > 0) { |
|
541 |
results = sourcedDao.listWithNameUsedInSource(NomenclaturalSource.class, pageSize, pageNumber, orderHints, propertyPaths); |
|
542 |
} |
|
543 |
return results; |
|
544 |
} |
|
545 |
|
|
535 | 546 |
@Override |
536 | 547 |
public List<NameRelationship> listNameRelationships(Set<NameRelationshipType> types, |
537 | 548 |
Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) { |
Also available in: Unified diff
ref #6591 adapt PESI import to new original spellings handling