Revision bb38665e
Added by Andreas Müller over 10 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/diptera/DipteraCollectionImport.java | ||
---|---|---|
18 | 18 |
import java.util.List; |
19 | 19 |
import java.util.Map; |
20 | 20 |
|
21 |
import org.apache.commons.lang.StringUtils; |
|
21 | 22 |
import org.apache.log4j.Logger; |
22 | 23 |
import org.springframework.transaction.TransactionStatus; |
23 | 24 |
|
... | ... | |
29 | 30 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
30 | 31 |
import eu.etaxonomy.cdm.model.agent.Institution; |
31 | 32 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
32 |
import eu.etaxonomy.cdm.model.occurrence.Specimen;
|
|
33 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
|
33 | 34 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
34 | 35 |
|
35 | 36 |
/** |
... | ... | |
66 | 67 |
* @param colletionMap |
67 | 68 |
*/ |
68 | 69 |
private void addCollectionsToSpecimen(CdmApplicationController cdmApp, Map<String, Collection> colletionMap) { |
69 |
List<SpecimenOrObservationBase> specimens = (cdmApp.getOccurrenceService().list(Specimen.class, null, null, null, null));
|
|
70 |
for (SpecimenOrObservationBase specOrObservBase : specimens){ |
|
71 |
if (specOrObservBase instanceof Specimen){
|
|
72 |
handleSingleSpecimen((Specimen)specOrObservBase, colletionMap);
|
|
70 |
List<SpecimenOrObservationBase> specimens = (cdmApp.getOccurrenceService().list(DerivedUnit.class, null, null, null, null));
|
|
71 |
for (SpecimenOrObservationBase<?> specOrObservBase : specimens){
|
|
72 |
if (specOrObservBase.getRecordBasis().isPreservedSpecimen()){
|
|
73 |
handleSingleSpecimen((DerivedUnit)specOrObservBase, colletionMap);
|
|
73 | 74 |
}else{ |
74 | 75 |
logger.warn("There are specimenOrObservationBase objects which are not of class Specimen. This is probably an error."); |
75 | 76 |
} |
... | ... | |
82 | 83 |
* @param specimen |
83 | 84 |
* @param colletionMap |
84 | 85 |
*/ |
85 |
private void handleSingleSpecimen(Specimen specimen, Map<String, Collection> collectionMap) {
|
|
86 |
private void handleSingleSpecimen(DerivedUnit specimen, Map<String, Collection> collectionMap) {
|
|
86 | 87 |
String titleCache = specimen.getTitleCache(); |
87 | 88 |
String collectionCode = getCollectionCode(titleCache); |
88 |
if (CdmUtils.isEmpty(collectionCode)){
|
|
89 |
if (StringUtils.isBlank(collectionCode)){
|
|
89 | 90 |
logger.warn("Collection code is empty for: " + titleCache); |
90 | 91 |
}else{ |
91 | 92 |
Collection collection = collectionMap.get(collectionCode); |
... | ... | |
215 | 216 |
|
216 | 217 |
institution.setName(instituteName); |
217 | 218 |
|
218 |
if (CdmUtils.isNotEmpty(lowerInstitutionName)){
|
|
219 |
if (StringUtils.isNotBlank(lowerInstitutionName)){
|
|
219 | 220 |
Institution lowerInstitution = Institution.NewInstance(); |
220 | 221 |
lowerInstitution.setName(lowerInstitutionName); |
221 | 222 |
lowerInstitution.setIsPartOf(institution); |
222 | 223 |
} |
223 | 224 |
|
224 |
if (CdmUtils.isNotEmpty(higherInstitutionName)){
|
|
225 |
if (StringUtils.isNotBlank(higherInstitutionName)){
|
|
225 | 226 |
Institution higherInstitution = Institution.NewInstance(); |
226 | 227 |
higherInstitution.setName(higherInstitutionName); |
227 | 228 |
institution.setIsPartOf(higherInstitution); |
Also available in: Unified diff
reintegrate cdmlib-app-3.3 branch into trunk