Revision fdf9eec2
Added by Andreas Müller almost 10 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/UnitsGatheringArea.java | ||
---|---|---|
79 | 79 |
*/ |
80 | 80 |
@SuppressWarnings("rawtypes") |
81 | 81 |
public void setAreaNames(List<String> namedAreas, ImportConfiguratorBase<?, ?> config, ITermService termService){ |
82 |
List<DefinedTermBase> termsList = termService.list(NamedArea.class,0,0,null,null);
|
|
82 |
List<NamedArea> termsList = termService.list(NamedArea.class,0,0,null,null);
|
|
83 | 83 |
termsList.addAll(termService.list(Country.class, 0, 0, null, null)); |
84 | 84 |
|
85 | 85 |
if (DEBUG) { |
... | ... | |
163 | 163 |
* @param fullName: the country's full name |
164 | 164 |
* @param app: the CDM application controller |
165 | 165 |
*/ |
166 |
@SuppressWarnings("rawtypes") |
|
167 | 166 |
public void setCountry(String iso, String fullName, ImportConfiguratorBase<?, ?> config, ITermService termService, |
168 | 167 |
IOccurrenceService occurrenceService){ |
169 |
List<DefinedTermBase> termsList = termService.list(NamedArea.class,0,0,null,null);
|
|
168 |
List<NamedArea> termsList = termService.list(NamedArea.class,0,0,null,null);
|
|
170 | 169 |
termsList.addAll(termService.list(Country.class, 0, 0, null, null)); |
171 | 170 |
|
172 | 171 |
HashMap<String, UUID> matchingTerms = new HashMap<String, UUID>(); |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java | ||
---|---|---|
414 | 414 |
} |
415 | 415 |
|
416 | 416 |
|
417 |
List<OriginalSourceBase> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
418 |
List<OriginalSourceBase> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
|
|
417 |
List<IdentifiableSource> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
418 |
List<DescriptionElementSource> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
|
|
419 | 419 |
|
420 | 420 |
Set<OriginalSourceBase> osbSet = new HashSet<OriginalSourceBase>(); |
421 | 421 |
if(issTmp2!=null) { |
... | ... | |
530 | 530 |
// for our new source. |
531 | 531 |
private IdentifiableSource getIdentifiableSource(Reference<?> reference, String citationDetail) { |
532 | 532 |
|
533 |
List<OriginalSourceBase> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
533 |
List<IdentifiableSource> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
534 | 534 |
|
535 | 535 |
|
536 | 536 |
if (reference != null){ |
... | ... | |
753 | 753 |
@SuppressWarnings("rawtypes") |
754 | 754 |
private Institution getInstitution(String institutionCode, Abcd206ImportState state) { |
755 | 755 |
Institution institution=null; |
756 |
List<AgentBase> institutions;
|
|
756 |
List<Institution> institutions;
|
|
757 | 757 |
try { |
758 | 758 |
institutions = getAgentService().list(Institution.class, null, null, null, null); |
759 | 759 |
} catch (Exception e) { |
760 |
institutions = new ArrayList<AgentBase>();
|
|
760 |
institutions = new ArrayList<Institution>();
|
|
761 | 761 |
logger.warn(e); |
762 | 762 |
} |
763 | 763 |
if (institutions.size() > 0 && state.getConfig().isReUseExistingMetadata()) { |
764 |
for (AgentBase inst:institutions){ |
|
765 |
Institution institut = (Institution)inst; |
|
764 |
for (Institution institut:institutions){ |
|
766 | 765 |
try{ |
767 | 766 |
if (institut.getCode().equalsIgnoreCase(institutionCode)) { |
768 | 767 |
institution=institut; |
... | ... | |
779 | 778 |
// create institution |
780 | 779 |
institution = Institution.NewInstance(); |
781 | 780 |
institution.setCode(institutionCode); |
782 |
institution.setTitleCache(institutionCode); |
|
781 |
institution.setTitleCache(institutionCode, true);
|
|
783 | 782 |
} |
784 | 783 |
save(institution, state); |
785 | 784 |
return institution; |
... | ... | |
957 | 956 |
|
958 | 957 |
Map<String,OriginalSourceBase<?>> sourceMap = new HashMap<String, OriginalSourceBase<?>>(); |
959 | 958 |
|
960 |
List<OriginalSourceBase> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
961 |
List<OriginalSourceBase> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
|
|
959 |
List<IdentifiableSource> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
|
|
960 |
List<DescriptionElementSource> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
|
|
962 | 961 |
|
963 | 962 |
Set<OriginalSourceBase> osbSet = new HashSet<OriginalSourceBase>(); |
964 | 963 |
if(issTmp2!=null) { |
... | ... | |
1426 | 1425 |
} |
1427 | 1426 |
|
1428 | 1427 |
private Feature getFeature(String featureName, Abcd206ImportState state){ |
1429 |
List<DefinedTermBase> features = getTermService().list(Feature.class, null,null,null,null);
|
|
1428 |
List<Feature> features = getTermService().list(Feature.class, null,null,null,null);
|
|
1430 | 1429 |
Feature currentFeature=null; |
1431 |
for (DefinedTermBase feature: features){
|
|
1432 |
String tmpF = ((Feature)feature).getTitleCache();
|
|
1430 |
for (Feature feature: features){
|
|
1431 |
String tmpF = feature.getTitleCache();
|
|
1433 | 1432 |
if (tmpF.equalsIgnoreCase(featureName)) { |
1434 | 1433 |
currentFeature=(Feature)feature; |
1435 | 1434 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx2013/TaxonXTreatmentExtractor.java | ||
---|---|---|
37 | 37 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
38 | 38 |
import eu.etaxonomy.cdm.model.agent.Person; |
39 | 39 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
40 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
41 | 40 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
42 | 41 |
import eu.etaxonomy.cdm.model.common.LSID; |
43 | 42 |
import eu.etaxonomy.cdm.model.common.Language; |
... | ... | |
1400 | 1399 |
@SuppressWarnings("rawtypes") |
1401 | 1400 |
private Feature getFeatureObjectFromString(String featureName) { |
1402 | 1401 |
logger.info("getFeatureObjectFromString"); |
1403 |
List<DefinedTermBase> features = importer.getTermService().list(Feature.class, null,null,null,null);
|
|
1402 |
List<Feature> features = importer.getTermService().list(Feature.class, null,null,null,null);
|
|
1404 | 1403 |
Feature currentFeature=null; |
1405 |
for (DefinedTermBase feature: features){
|
|
1406 |
String tmpF = ((Feature)feature).getTitleCache();
|
|
1404 |
for (Feature feature: features){
|
|
1405 |
String tmpF = feature.getTitleCache();
|
|
1407 | 1406 |
if (tmpF.equalsIgnoreCase(featureName)) { |
1408 |
currentFeature=(Feature)feature;
|
|
1407 |
currentFeature=feature; |
|
1409 | 1408 |
// System.out.println("currentFeatureFromList "+currentFeature.getUuid()); |
1410 | 1409 |
} |
1411 | 1410 |
} |
... | ... | |
1864 | 1863 |
@SuppressWarnings("rawtypes") |
1865 | 1864 |
private Feature getNotMarkedUpFeatureObject() { |
1866 | 1865 |
logger.info("getNotMarkedUpFeatureObject"); |
1867 |
List<DefinedTermBase> features = importer.getTermService().list(Feature.class, null,null,null,null);
|
|
1866 |
List<Feature> features = importer.getTermService().list(Feature.class, null,null,null,null);
|
|
1868 | 1867 |
Feature currentFeature =null; |
1869 |
for (DefinedTermBase feat: features){
|
|
1870 |
String tmpF = ((Feature)feat).getTitleCache();
|
|
1868 |
for (Feature feat: features){
|
|
1869 |
String tmpF = feat.getTitleCache();
|
|
1871 | 1870 |
if (tmpF.equalsIgnoreCase(notMarkedUp)) { |
1872 |
currentFeature=(Feature)feat;
|
|
1871 |
currentFeature=feat; |
|
1873 | 1872 |
} |
1874 | 1873 |
} |
1875 | 1874 |
if (currentFeature == null) { |
... | ... | |
4545 | 4544 |
} |
4546 | 4545 |
} |
4547 | 4546 |
if (lsid !=null){ |
4548 |
List<TaxonBase> taxons = importer.getTaxonService().list(Taxon.class, 0, 0, null, null);
|
|
4547 |
List<Taxon> taxa = importer.getTaxonService().list(Taxon.class, 0, 0, null, null);
|
|
4549 | 4548 |
LSID currentlsid=null; |
4550 |
for (TaxonBase t:taxons){
|
|
4549 |
for (Taxon t:taxa){
|
|
4551 | 4550 |
currentlsid = t.getLsid(); |
4552 | 4551 |
if (currentlsid !=null){ |
4553 | 4552 |
if (currentlsid.getLsid().equals(lsid.getLsid())){ |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/test/ValidateForeignKeys.java | ||
---|---|---|
71 | 71 |
|
72 | 72 |
|
73 | 73 |
private String sql(String thisTable, String thisField, String foreignTable){ |
74 |
String sql = "SELECT * FROM %s WHERE %s.%s NOT IN (SELECT id FROM %s)"; |
|
74 |
String sql = "SELECT * FROM %s WHERE %s.%s_id NOT IN (SELECT id FROM %s)";
|
|
75 | 75 |
sql = String.format(sql, thisTable, thisTable, thisField, foreignTable); |
76 | 76 |
return sql; |
77 | 77 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java | ||
---|---|---|
164 | 164 |
* @return |
165 | 165 |
* @throws DataAccessException |
166 | 166 |
*/ |
167 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
167 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
168 | 168 |
|
169 | 169 |
/** |
170 | 170 |
* Returns a sublist of CdmBase instances stored in the database. A maximum |
... | ... | |
198 | 198 |
* @return |
199 | 199 |
* @throws DataAccessException |
200 | 200 |
*/ |
201 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start) throws DataAccessException;
|
|
201 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start) throws DataAccessException;
|
|
202 | 202 |
|
203 | 203 |
/** |
204 | 204 |
* Returns a sublist of objects matching the grouping projections supplied using the groups parameter |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmEntityDaoBase.java | ||
---|---|---|
659 | 659 |
} |
660 | 660 |
|
661 | 661 |
@Override |
662 |
public List<T> list(Class<? extends T> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
|
662 |
public <S extends T> List<S> list(Class<S> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
|
663 | 663 |
Criteria criteria = null; |
664 | 664 |
if(clazz == null) { |
665 | 665 |
criteria = getSession().createCriteria(type); |
... | ... | |
678 | 678 |
|
679 | 679 |
addOrder(criteria,orderHints); |
680 | 680 |
|
681 |
List<T> results = criteria.list();
|
|
681 |
List<S> results = criteria.list();
|
|
682 | 682 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
683 | 683 |
return results; |
684 | 684 |
} |
685 | 685 |
|
686 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start, List<OrderHint> orderHints) {
|
|
686 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start, List<OrderHint> orderHints) {
|
|
687 | 687 |
return list(type,limit,start,orderHints,null); |
688 | 688 |
} |
689 | 689 |
|
690 | 690 |
@Override |
691 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start) {
|
|
691 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start) {
|
|
692 | 692 |
return list(type,limit,start,null,null); |
693 | 693 |
} |
694 | 694 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/VersionableDaoBase.java | ||
---|---|---|
164 | 164 |
} |
165 | 165 |
|
166 | 166 |
@Override |
167 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start) {
|
|
167 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start) {
|
|
168 | 168 |
AuditEvent auditEvent = getAuditEventFromContext(); |
169 | 169 |
if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) { |
170 | 170 |
return super.list(type,limit, start); |
... | ... | |
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
@Override |
177 |
public List<T> list(Class<? extends T> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
|
177 |
public <S extends T> List<S> list(Class<S> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
|
178 | 178 |
AuditEvent auditEvent = getAuditEventFromContext(); |
179 | 179 |
if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) { |
180 | 180 |
return super.list(clazz, limit, start, orderHints, propertyPaths); |
... | ... | |
194 | 194 |
query.setFirstResult(start); |
195 | 195 |
} |
196 | 196 |
|
197 |
List<T> result = (List<T>)query.getResultList();
|
|
197 |
List<S> result = query.getResultList();
|
|
198 | 198 |
defaultBeanInitializer.initializeAll(result, propertyPaths); |
199 | 199 |
return result; |
200 | 200 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImpl.java | ||
---|---|---|
737 | 737 |
return persistentObject.getUuid(); |
738 | 738 |
} |
739 | 739 |
|
740 |
/* (non-Javadoc) |
|
741 |
* @see eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao#getZoologicalNames(java.lang.Integer, java.lang.Integer) |
|
742 |
*/ |
|
743 |
//TODO candidate for harmonization |
|
744 |
@Override |
|
745 |
public List<ZoologicalName> getZoologicalNames(Integer limit, Integer start){ |
|
746 |
List <TaxonNameBase> names = new ArrayList<TaxonNameBase>(); |
|
747 |
List <ZoologicalName> zooNames = new ArrayList<ZoologicalName>(); |
|
748 |
names = super.list(ZoologicalName.class, limit, start); |
|
749 |
for (TaxonNameBase name: names){ |
|
750 |
zooNames.add((ZoologicalName)name); |
|
751 |
} |
|
752 |
return zooNames; |
|
753 |
} |
|
754 | 740 |
|
755 | 741 |
@Override |
756 | 742 |
public ZoologicalName findZoologicalNameByUUID(UUID uuid){ |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/name/ITaxonNameDao.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
import org.hibernate.criterion.Criterion; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
17 | 16 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
18 | 17 |
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache; |
19 | 18 |
import eu.etaxonomy.cdm.model.name.HybridRelationship; |
... | ... | |
317 | 316 |
*/ |
318 | 317 |
public Integer countByName(Class<? extends TaxonNameBase> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria); |
319 | 318 |
|
320 |
public List<ZoologicalName> getZoologicalNames(Integer limit, Integer start); |
|
321 |
|
|
322 | 319 |
public ZoologicalName findZoologicalNameByUUID(UUID uuid); |
323 | 320 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImplTest.java | ||
---|---|---|
239 | 239 |
@Test |
240 | 240 |
@DataSet("AgentDaoImplTest.testExists.xml") |
241 | 241 |
public void testListPeople() { |
242 |
List<AgentBase> result = agentDao.list(Person.class,null,null);
|
|
242 |
List<Person> result = agentDao.list(Person.class,null,null);
|
|
243 | 243 |
Assert.assertNotNull("list() should return a list",result); |
244 | 244 |
Assert.assertEquals("list() should return four agents in the current view", result.size(),4); |
245 | 245 |
} |
... | ... | |
248 | 248 |
@DataSet("AgentDaoImplTest.testExists.xml") |
249 | 249 |
public void testListPeopleInPreviousView() { |
250 | 250 |
AuditEventContextHolder.getContext().setAuditEvent(previousAuditEvent); |
251 |
List<AgentBase> result = agentDao.list(Person.class,null, null);
|
|
251 |
List<Person> result = agentDao.list(Person.class,null, null);
|
|
252 | 252 |
Assert.assertNotNull("list() should return a list",result); |
253 | 253 |
Assert.assertEquals("list() should return five agents in the current view",result.size(),5); |
254 | 254 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.java | ||
---|---|---|
204 | 204 |
List<String> propertyPaths = new ArrayList<String>(); |
205 | 205 |
propertyPaths.add("representations"); |
206 | 206 |
propertyPaths.add("representations.language"); |
207 |
List<DefinedTermBase> extensionTypes = dao.list(ExtensionType.class,null, null, orderHints, propertyPaths);
|
|
207 |
List<ExtensionType> extensionTypes = dao.list(ExtensionType.class,null, null, orderHints, propertyPaths);
|
|
208 | 208 |
|
209 | 209 |
|
210 | 210 |
assertTrue(Hibernate.isInitialized(extensionTypes.get(0).getRepresentations())); |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java | ||
---|---|---|
740 | 740 |
@Test |
741 | 741 |
@DataSet |
742 | 742 |
public void testListAllTaxa() { |
743 |
List<TaxonBase> taxa = taxonDao.list(Taxon.class,100, 0);
|
|
743 |
List<Taxon> taxa = taxonDao.list(Taxon.class,100, 0); |
|
744 | 744 |
assertNotNull("list should return a List",taxa); |
745 | 745 |
assertEquals("list should return 33 taxa",33, taxa.size()); |
746 | 746 |
} |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/DemoTaxonTable.java | ||
---|---|---|
65 | 65 |
|
66 | 66 |
final BeanItemContainer<RedlistDTO> redListContainer = new BeanItemContainer<RedlistDTO>(RedlistDTO.class); |
67 | 67 |
//TODO: Make use of paging |
68 |
Collection<TaxonBase> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY);
|
|
68 |
Collection<Taxon> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY); |
|
69 | 69 |
|
70 |
for(TaxonBase taxonBase:listTaxon){
|
|
70 |
for(Taxon taxonBase:listTaxon){ |
|
71 | 71 |
|
72 |
if(taxonBase instanceof Taxon){ |
|
73 |
Taxon taxon = (Taxon) taxonBase; |
|
74 |
List<PresenceAbsenceTermBase> termList = termService.listByTermClass(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
75 |
List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
76 |
RedlistDTO redlistDTO = new RedlistDTO(taxon, listTaxonDescription, termList); |
|
77 |
redListContainer.addBean(redlistDTO); |
|
78 |
} |
|
72 |
Taxon taxon = (Taxon) taxonBase; |
|
73 |
List<PresenceAbsenceTermBase> termList = termService.listByTermClass(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
74 |
List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
75 |
RedlistDTO redlistDTO = new RedlistDTO(taxon, listTaxonDescription, termList); |
|
76 |
redListContainer.addBean(redlistDTO); |
|
79 | 77 |
} |
80 | 78 |
|
81 | 79 |
setContainerDataSource(redListContainer); |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/components/TaxonTableDTO.java | ||
---|---|---|
84 | 84 |
// conversationHolder.bind(); |
85 | 85 |
final BeanItemContainer<RedlistDTO> redListContainer = new BeanItemContainer<RedlistDTO>(RedlistDTO.class); |
86 | 86 |
//TODO: Make use of paging |
87 |
Collection<TaxonBase> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY);
|
|
87 |
Collection<Taxon> listTaxon = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY); |
|
88 | 88 |
|
89 |
for(TaxonBase taxonBase:listTaxon){
|
|
89 |
for(Taxon taxonBase:listTaxon){ |
|
90 | 90 |
|
91 |
if(taxonBase instanceof Taxon){ |
|
92 |
Taxon taxon = (Taxon) taxonBase; |
|
93 |
List<PresenceAbsenceTermBase> termList = termService.listByTermClass(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
94 |
List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
95 |
RedlistDTO redlistDTO = new RedlistDTO(taxon, listTaxonDescription, termList); |
|
96 |
redListContainer.addBean(redlistDTO); |
|
97 |
} |
|
91 |
Taxon taxon = (Taxon) taxonBase; |
|
92 |
List<PresenceAbsenceTermBase> termList = termService.listByTermClass(PresenceAbsenceTermBase.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
93 |
List<DescriptionElementBase> listTaxonDescription = descriptionService.listDescriptionElementsForTaxon(taxon, null, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
94 |
RedlistDTO redlistDTO = new RedlistDTO(taxon, listTaxonDescription, termList); |
|
95 |
redListContainer.addBean(redlistDTO); |
|
98 | 96 |
} |
99 | 97 |
|
100 | 98 |
|
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/vaadin/uiset/redlist/views/DashBoardView.java | ||
---|---|---|
62 | 62 |
import eu.etaxonomy.cdm.model.description.TextData; |
63 | 63 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
64 | 64 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
65 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
66 | 65 |
import eu.etaxonomy.cdm.remote.dto.redlist.RedlistDTO; |
67 | 66 |
import eu.etaxonomy.cdm.remote.vaadin.components.HorizontalToolbar; |
68 | 67 |
import eu.etaxonomy.cdm.remote.vaadin.components.TaxonTableDTO; |
... | ... | |
462 | 461 |
//------------------------------------Example Data Creation------------------------------------------// |
463 | 462 |
//---------------------------------------------------------------------------------------------------// |
464 | 463 |
private void createExampleData(){ |
465 |
List<TaxonBase> listTaxa = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY); |
|
466 |
for(TaxonBase taxonBase : listTaxa){ |
|
467 |
Taxon taxon = (Taxon) taxonBase; |
|
464 |
List<Taxon> listTaxa = taxonService.list(Taxon.class, null, null, null, NODE_INIT_STRATEGY); |
|
465 |
for(Taxon taxon : listTaxa){ |
|
468 | 466 |
TaxonDescription td = getTaxonDescription(taxon, false, true); |
469 | 467 |
NamedArea na = NamedArea.NewInstance();//0a9727d2-8d1f-4a88-ad4c-d6ef4ebc112a |
470 | 468 |
na = (NamedArea) termService.load(UUID.fromString("cbe7ce69-2952-4309-85dd-0d7d4a4830a1")); |
... | ... | |
478 | 476 |
} |
479 | 477 |
|
480 | 478 |
private void deleteExampleData(){ |
481 |
List<TaxonBase> listTaxa = taxonService.list(Taxon.class, null, null, null, DESCRIPTION_INIT_STRATEGY);
|
|
482 |
Iterator<TaxonBase> taxonIterator = listTaxa.iterator();
|
|
479 |
List<Taxon> listTaxa = taxonService.list(Taxon.class, null, null, null, DESCRIPTION_INIT_STRATEGY); |
|
480 |
Iterator<Taxon> taxonIterator = listTaxa.iterator(); |
|
483 | 481 |
while(taxonIterator.hasNext()){ |
484 |
TaxonBase taxonBase = taxonIterator.next(); |
|
485 |
Taxon taxon = (Taxon) taxonBase; |
|
482 |
Taxon taxon = taxonIterator.next(); |
|
486 | 483 |
TaxonDescription td = getTaxonDescription(taxon, false, false); |
487 | 484 |
Iterator<DescriptionElementBase> descriptionIterator = td.getElements().iterator(); |
488 | 485 |
while(descriptionIterator.hasNext()){ |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AgentServiceImpl.java | ||
---|---|---|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
import org.springframework.beans.factory.annotation.Autowired; |
18 | 18 |
import org.springframework.stereotype.Service; |
19 |
import org.springframework.transaction.annotation.Propagation; |
|
20 | 19 |
import org.springframework.transaction.annotation.Transactional; |
21 | 20 |
|
22 | 21 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
23 |
import eu.etaxonomy.cdm.api.service.pager.impl.AbstractPagerImpl; |
|
24 | 22 |
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl; |
25 | 23 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
26 | 24 |
import eu.etaxonomy.cdm.model.agent.Address; |
... | ... | |
30 | 28 |
import eu.etaxonomy.cdm.model.agent.Person; |
31 | 29 |
import eu.etaxonomy.cdm.model.agent.Team; |
32 | 30 |
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache; |
33 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
|
34 | 31 |
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao; |
35 | 32 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
36 | 33 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IService.java | ||
---|---|---|
167 | 167 |
* @return |
168 | 168 |
*/ |
169 | 169 |
//TODO refactor to public <S extends T> List<T> list(Class<S> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths); |
170 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
170 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
171 | 171 |
|
172 | 172 |
/** |
173 | 173 |
* Finds the cdm entity specified by the <code>uuid</code> parameter and |
... | ... | |
214 | 214 |
* @param propertyPaths properties to be initialized |
215 | 215 |
* @return a pager of objects of type <T> |
216 | 216 |
*/ |
217 |
public Pager<T> page(Class<? extends T> type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
217 |
public <S extends T> Pager<S> page(Class<S> type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
|
218 | 218 |
|
219 | 219 |
/** |
220 | 220 |
* Re-read the state of the given instance from the underlying database. |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java | ||
---|---|---|
60 | 60 |
|
61 | 61 |
public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{ |
62 | 62 |
|
63 |
/** |
|
64 |
* Computes all taxon bases. |
|
65 |
* @param limit |
|
66 |
* @param start |
|
67 |
* @return |
|
68 |
* |
|
69 |
* FIXME could substitute with list(Synonym.class, limit, start) |
|
70 |
*/ |
|
71 |
public List<Synonym> getAllSynonyms(int limit, int start); |
|
72 |
|
|
73 |
/** |
|
74 |
* Computes all taxon bases. |
|
75 |
* @param limit |
|
76 |
* @param start |
|
77 |
* @return |
|
78 |
* |
|
79 |
* FIXME could substitute with list(Taxon.class, limit,start) |
|
80 |
*/ |
|
81 |
public List<Taxon> getAllTaxa(int limit, int start); |
|
82 |
|
|
83 | 63 |
/** |
84 | 64 |
* Computes all Taxon instances that do not have a taxonomic parent. |
85 | 65 |
* @param sec The concept reference that the taxon belongs to |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IdentifiableServiceBase.java | ||
---|---|---|
222 | 222 |
} |
223 | 223 |
|
224 | 224 |
@Transactional(readOnly = false) //TODO check transactional behaviour, e.g. what happens with the session if count is very large |
225 |
protected void updateTitleCacheImpl(Class<? extends T> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<T> cacheStrategy, IProgressMonitor monitor) {
|
|
225 |
protected <S extends T > void updateTitleCacheImpl(Class<S> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<T> cacheStrategy, IProgressMonitor monitor) {
|
|
226 | 226 |
if (stepSize == null){ |
227 | 227 |
stepSize = UPDATE_TITLE_CACHE_DEFAULT_STEP_SIZE; |
228 | 228 |
} |
... | ... | |
240 | 240 |
|
241 | 241 |
|
242 | 242 |
Map<Class<? extends CdmBase>, AutoPropertyInitializer<CdmBase>> oldAutoInit = switchOfAutoinitializer(); |
243 |
List<T> list = this.list(clazz, stepSize, i, orderHints, null);
|
|
243 |
List<S> list = this.list(clazz, stepSize, i, orderHints, null);
|
|
244 | 244 |
switchOnOldAutoInitializer(oldAutoInit); |
245 | 245 |
|
246 | 246 |
List<T> entitiesToUpdate = new ArrayList<T>(); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java | ||
---|---|---|
18 | 18 |
import org.apache.log4j.Logger; |
19 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
20 | 20 |
import org.springframework.stereotype.Service; |
21 |
import org.springframework.transaction.annotation.Propagation; |
|
22 | 21 |
import org.springframework.transaction.annotation.Transactional; |
23 | 22 |
|
24 | 23 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ServiceBase.java | ||
---|---|---|
116 | 116 |
|
117 | 117 |
@Override |
118 | 118 |
@Transactional(readOnly = true) |
119 |
public List<T> list(Class<? extends T> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths){
|
|
119 |
public <S extends T> List<S> list(Class<S> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths){
|
|
120 | 120 |
return dao.list(type,limit, start, orderHints,propertyPaths); |
121 | 121 |
} |
122 | 122 |
|
... | ... | |
140 | 140 |
|
141 | 141 |
@Override |
142 | 142 |
@Transactional(readOnly = true) |
143 |
public Pager<T> page(Class<? extends T> type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths){
|
|
143 |
public <S extends T> Pager<S> page(Class<S> type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths){
|
|
144 | 144 |
Integer numberOfResults = dao.count(type); |
145 |
List<T> results = new ArrayList<T>();
|
|
145 |
List<S> results = new ArrayList<S>();
|
|
146 | 146 |
pageNumber = pageNumber == null ? 0 : pageNumber; |
147 | 147 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
148 | 148 |
Integer start = pageSize == null ? 0 : pageSize * pageNumber; |
149 | 149 |
results = dao.list(type, pageSize, start, orderHints,propertyPaths); |
150 | 150 |
} |
151 |
return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
|
|
151 |
return new DefaultPagerImpl<S>(pageNumber, numberOfResults, pageSize, results);
|
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
@Override |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java | ||
---|---|---|
189 | 189 |
return dao.getTaxaByName(name, sec); |
190 | 190 |
} |
191 | 191 |
|
192 |
/** |
|
193 |
* FIXME Candidate for harmonization |
|
194 |
* list(Synonym.class, ...) |
|
195 |
* (non-Javadoc) |
|
196 |
* @see eu.etaxonomy.cdm.api.service.ITaxonService#getAllSynonyms(int, int) |
|
197 |
*/ |
|
198 |
@Override |
|
199 |
public List<Synonym> getAllSynonyms(int limit, int start) { |
|
200 |
return dao.getAllSynonyms(limit, start); |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* FIXME Candidate for harmonization |
|
205 |
* list(Taxon.class, ...) |
|
206 |
* (non-Javadoc) |
|
207 |
* @see eu.etaxonomy.cdm.api.service.ITaxonService#getAllTaxa(int, int) |
|
208 |
*/ |
|
209 |
@Override |
|
210 |
public List<Taxon> getAllTaxa(int limit, int start) { |
|
211 |
return dao.getAllTaxa(limit, start); |
|
212 |
} |
|
213 |
|
|
214 | 192 |
/** |
215 | 193 |
* FIXME Candidate for harmonization |
216 | 194 |
* merge with getRootTaxa(Reference sec, ..., ...) |
... | ... | |
225 | 203 |
return dao.getRootTaxa(sec, cdmFetch, onlyWithChildren, false); |
226 | 204 |
} |
227 | 205 |
|
228 |
|
|
229 |
/* (non-Javadoc) |
|
230 |
* @see eu.etaxonomy.cdm.api.service.ITaxonService#getRootTaxa(eu.etaxonomy.cdm.model.name.Rank, eu.etaxonomy.cdm.model.reference.Reference, boolean, boolean) |
|
231 |
*/ |
|
232 | 206 |
@Override |
233 | 207 |
public List<Taxon> getRootTaxa(Rank rank, Reference sec, boolean onlyWithChildren,boolean withMisapplications, List<String> propertyPaths) { |
234 | 208 |
return dao.getRootTaxa(rank, sec, null, onlyWithChildren, withMisapplications, propertyPaths); |
235 | 209 |
} |
236 | 210 |
|
237 |
/* (non-Javadoc) |
|
238 |
* @see eu.etaxonomy.cdm.api.service.ITaxonService#getAllRelationships(int, int) |
|
239 |
*/ |
|
240 | 211 |
@Override |
241 | 212 |
public List<RelationshipBase> getAllRelationships(int limit, int start){ |
242 | 213 |
return dao.getAllRelationships(limit, start); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/TransmissionEngineDistribution.java | ||
---|---|---|
56 | 56 |
import eu.etaxonomy.cdm.model.name.Rank; |
57 | 57 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
58 | 58 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
59 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
60 | 59 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
61 | 60 |
|
62 | 61 |
/** |
... | ... | |
376 | 375 |
List<DefinedTermBase> superAreaList = termService.find(superAreaUuids); |
377 | 376 |
|
378 | 377 |
// visit all accepted taxa |
379 |
Pager<TaxonBase> taxonPager = null;
|
|
378 |
Pager<Taxon> taxonPager = null; |
|
380 | 379 |
int pageIndex = 0; |
381 | 380 |
boolean isLastPage = false; |
382 | 381 |
while (!isLastPage) { |
... | ... | |
401 | 400 |
isLastPage = taxonPager.getRecords().size() < batchSize; |
402 | 401 |
|
403 | 402 |
// iterate over the taxa and accumulate areas |
404 |
for(TaxonBase taxonBase : taxonPager.getRecords()) {
|
|
403 |
for(Taxon taxon : taxonPager.getRecords()) {
|
|
405 | 404 |
if(logger.isDebugEnabled()){ |
406 |
logger.debug("accumulateByArea() - taxon :" + taxonBase.getTitleCache());
|
|
405 |
logger.debug("accumulateByArea() - taxon :" + taxon.getTitleCache()); |
|
407 | 406 |
} |
408 | 407 |
|
409 |
Taxon taxon = (Taxon)taxonBase; |
|
410 | 408 |
TaxonDescription description = findComputedDescription(taxon, doClearDescriptions); |
411 | 409 |
List<Distribution> distributions = distributionsFor(taxon); |
412 | 410 |
|
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java | ||
---|---|---|
21 | 21 |
import java.util.UUID; |
22 | 22 |
|
23 | 23 |
import org.apache.log4j.Logger; |
24 |
import org.hibernate.ObjectDeletedException; |
|
25 | 24 |
import org.junit.Assert; |
26 | 25 |
import org.junit.Test; |
27 | 26 |
import org.unitils.dbunit.annotation.DataSet; |
... | ... | |
31 | 30 |
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator; |
32 | 31 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
33 | 32 |
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling; |
34 |
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException; |
|
35 | 33 |
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException; |
36 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
|
37 | 34 |
import eu.etaxonomy.cdm.datagenerator.TaxonGenerator; |
38 | 35 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
39 | 36 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
... | ... | |
1009 | 1006 |
Classification tree = classificationService.find(classificationUuid); |
1010 | 1007 |
UUID taxonUuid = UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"); |
1011 | 1008 |
TaxonBase<?> taxonBase = service.find(taxonUuid); |
1012 |
List <TaxonBase> synonyms = service.list(Synonym.class, null, null, null, null);
|
|
1009 |
List <Synonym> synonyms = service.list(Synonym.class, null, null, null, null);
|
|
1013 | 1010 |
assertEquals("Number of synonyms should be 2",2,synonyms.size()); |
1014 | 1011 |
Taxon taxon = (Taxon)taxonBase; |
1015 | 1012 |
|
cdmlib-services/src/test/java/eu/etaxonomy/cdm/scripts/FixMultipleTextDataInImageGalleries.java | ||
---|---|---|
25 | 25 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
26 | 26 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
27 | 27 |
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException; |
28 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
29 | 28 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
30 | 29 |
import eu.etaxonomy.cdm.model.description.Feature; |
31 | 30 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
... | ... | |
83 | 82 |
IDescriptionService service = applicationController.getDescriptionService(); |
84 | 83 |
|
85 | 84 |
// get all taxon descriptions |
86 |
List<DescriptionBase> result = service.list(TaxonDescription.class, null, null, null, null);
|
|
85 |
List<TaxonDescription> result = service.list(TaxonDescription.class, null, null, null, null);
|
|
87 | 86 |
|
88 | 87 |
int countTaxonDescriptions = 0; |
89 | 88 |
|
90 |
for (DescriptionBase description : result){
|
|
89 |
for (TaxonDescription description : result){
|
|
91 | 90 |
// filter image galleries with more than one element |
92 | 91 |
if(description.isImageGallery() && description.getElements().size() > 1){ |
93 | 92 |
countTaxonDescriptions++; |
94 | 93 |
|
95 | 94 |
logger.warn("Found image gallery with mulitple TextData: " + description.getElements().size()); |
96 |
TaxonDescription taxonDescription = (TaxonDescription) description; |
|
97 | 95 |
|
98 | 96 |
TextData newDescriptionElement = TextData.NewInstance(Feature.IMAGE()); |
99 | 97 |
|
100 | 98 |
Set<DescriptionElementBase> elementsToRemove = new HashSet<DescriptionElementBase>(); |
101 | 99 |
|
102 | 100 |
// consolidate media from all elements into a new element |
103 |
for(DescriptionElementBase element : taxonDescription.getElements()){
|
|
101 |
for(DescriptionElementBase element : description.getElements()){
|
|
104 | 102 |
List<Media> medias = element.getMedia(); |
105 | 103 |
|
106 | 104 |
for(Media media : medias){ |
... | ... | |
112 | 110 |
|
113 | 111 |
// remove old elements |
114 | 112 |
for(DescriptionElementBase element : elementsToRemove){ |
115 |
taxonDescription.removeElement(element);
|
|
113 |
description.removeElement(element);
|
|
116 | 114 |
} |
117 | 115 |
|
118 | 116 |
// add the new element |
119 |
taxonDescription.addElement(newDescriptionElement);
|
|
117 |
description.addElement(newDescriptionElement);
|
|
120 | 118 |
|
121 | 119 |
} |
122 | 120 |
} |
Also available in: Unified diff
better use of generics in service layer and persistence list methods