Revision 60ad1ed0
Added by Andreas Müller almost 10 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraTypeImport.java | ||
---|---|---|
16 | 16 |
import java.util.HashSet; |
17 | 17 |
import java.util.Map; |
18 | 18 |
import java.util.Set; |
19 |
import java.util.UUID; |
|
19 | 20 |
|
20 | 21 |
import org.apache.commons.lang.StringUtils; |
21 | 22 |
import org.apache.log4j.Logger; |
... | ... | |
38 | 39 |
import eu.etaxonomy.cdm.model.common.Annotation; |
39 | 40 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
40 | 41 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
42 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
41 | 43 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
42 | 44 |
import eu.etaxonomy.cdm.model.common.Language; |
43 | 45 |
import eu.etaxonomy.cdm.model.common.User; |
... | ... | |
86 | 88 |
protected String getRecordQuery(BerlinModelImportConfigurator config) { |
87 | 89 |
String strQuery = |
88 | 90 |
|
89 |
" SELECT ts.*, ts.TypeSpecimenId as unitId, td.*, gz.ID as GazetteerId, gz.L2Code, gz.L3Code, gz.L4Code, gz.ISOCountry, gz.Country, ts.WaterBody, " +
|
|
90 |
" ts.RefFk as tsRefFk, ts.RefDetailFk as tsRefDetailFk, td.RefFk as tdRefFk, td.RefDetailFk as tdRefDetailFk, " + |
|
91 |
" SELECT ts.*, ts.TypeSpecimenId as unitId, td.*, gz.ID as GazetteerId, gz.L1Code, gz.L2Code, gz.L3Code, gz.L4Code, gz.ISOCountry, gz.Country, gz.subL4, ts.WaterBody, " +
|
|
92 |
" ts.RefFk as tsRefFk, ts.RefDetailFk as tsRefDetailFk, ts.MaterialCategoryFK as tsMaterialCategoryFK, td.RefFk as tdRefFk, td.RefDetailFk as tdRefDetailFk, " +
|
|
91 | 93 |
" RefDet.Details as tdRefDetails, " + |
92 | 94 |
" td.created_When as tdCreated_When, tsd.created_When as tsdCreated_When, td.updated_when as tdUpdated_when, " + |
93 |
" td.created_who as tdCreated_who, tsd.created_who as tsdCreated_who, td.updated_who tdUpdated_who " + |
|
95 |
" td.created_who as tdCreated_who, tsd.created_who as tsdCreated_who, td.updated_who tdUpdated_who, " + |
|
96 |
" mc.* " + |
|
94 | 97 |
" FROM TypeSpecimenDesignation tsd " |
95 | 98 |
+ " LEFT OUTER JOIN TypeSpecimen AS ts ON tsd.TypeSpecimenFk = ts.TypeSpecimenId " |
96 | 99 |
+ " FULL OUTER JOIN TypeDesignation td ON td.TypeDesignationId = tsd.TypeDesignationFk " |
97 | 100 |
+ " LEFT OUTER JOIN TDWGGazetteer gz ON ts.TDWGGazetteerFk = gz.ID " |
98 | 101 |
+ " LEFT OUTER JOIN RefDetail refDet ON td.RefDetailFk = refDet.RefDetailId AND td.RefFk = refDet.RefFk " |
102 |
+ " LEFT OUTER JOIN MaterialCategory mc ON mc.MaterialCategoryId = ts.MaterialCategoryFK " |
|
99 | 103 |
+ " WHERE (td.TypeDesignationId IN (" + ID_LIST_TOKEN + ") )" |
100 | 104 |
+ " ORDER BY NameFk " |
101 | 105 |
; |
... | ... | |
150 | 154 |
Boolean restrictedFlag = nullSafeBoolean(rs, "RestrictedFlag"); |
151 | 155 |
|
152 | 156 |
String typeSpecimenPhrase = rs.getString("TypeSpecimenPhrase"); |
157 |
Integer tsMaterialCategoryFK = nullSafeInt(rs, "MaterialCategoryFK"); |
|
153 | 158 |
|
154 | 159 |
boolean isIcon = typeSpecimenPhrase != null && typeSpecimenPhrase.toLowerCase().startsWith("\u005bicon"); |
155 | 160 |
|
... | ... | |
165 | 170 |
type = SpecimenOrObservationType.StillImage; |
166 | 171 |
}else if (typeStatusFk != null && typeStatusFk.equals(39)){ |
167 | 172 |
type = SpecimenOrObservationType.LivingSpecimen; |
173 |
}else if (tsMaterialCategoryFK != null && tsMaterialCategoryFK.equals(4)){ |
|
174 |
type = SpecimenOrObservationType.Fossil; |
|
168 | 175 |
} |
169 | 176 |
|
177 |
|
|
178 |
if (tsMaterialCategoryFK != null && typeStatusFk != null && |
|
179 |
( typeStatusFk.equals(39) && !tsMaterialCategoryFK.equals(14) || ! typeStatusFk.equals(39) && tsMaterialCategoryFK.equals(14) )){ |
|
180 |
logger.warn("Living Specimen type status should be 39 and materialCategoryFk 14 but one of them wasn't"); |
|
181 |
} |
|
182 |
|
|
183 |
|
|
170 | 184 |
DerivedUnitFacade facade = getDerivedUnit(state, typeSpecimenId, typeSpecimenMap, type, ecoFactMap, ecoFactId, sourceRef); |
171 | 185 |
|
172 | 186 |
//field observation |
173 | 187 |
handleFieldObservationSpecimen(rs, facade, state, partitioner); |
174 | 188 |
|
189 |
// handleTypeSpecimenSpecificFieldObservation(rs,facade, state); |
|
190 |
|
|
175 | 191 |
//TODO divide like in EcoFact (if necessary) |
176 | 192 |
handleTypeSpecimenSpecificSpecimen(rs,facade, state, refMap, typeSpecimenId); |
177 | 193 |
|
... | ... | |
335 | 351 |
|
336 | 352 |
DerivedUnit derivedUnit = facade.innerDerivedUnit(); |
337 | 353 |
|
354 |
Integer tsMaterialCategoryFK = nullSafeInt(rs, "tsMaterialCategoryFK"); |
|
355 |
String matCat = rs.getString("MaterialCategory"); |
|
356 |
if (tsMaterialCategoryFK != null){ |
|
357 |
if (tsMaterialCategoryFK.equals(16)){ |
|
358 |
tsMaterialCategoryFK = 9; |
|
359 |
} |
|
360 |
UUID uuid = materialCategoryMapping.get(tsMaterialCategoryFK); |
|
361 |
if (uuid == null){ |
|
362 |
logger.warn("Uuid was null. This should not happen."); |
|
363 |
} |
|
364 |
DefinedTerm kindOfUnit = getKindOfUnit(state, uuid, matCat, null, null, null); //all terms should exist already |
|
365 |
facade.setKindOfUnit(kindOfUnit); |
|
366 |
}else{ |
|
367 |
logger.warn("Material Category was null. This is not expected"); |
|
368 |
} |
|
369 |
|
|
370 |
|
|
338 | 371 |
//collection |
339 | 372 |
String barcode = rs.getString("Barcode"); |
340 | 373 |
if (StringUtils.isNotBlank(barcode)){ |
... | ... | |
359 | 392 |
logger.warn("TypeSpecimen.RefDetailFk should always be NULL but wasn't: " + typeSpecimenId); |
360 | 393 |
} |
361 | 394 |
|
362 |
|
|
363 |
|
|
364 | 395 |
} |
365 | 396 |
|
366 | 397 |
/** |
... | ... | |
396 | 427 |
|
397 | 428 |
|
398 | 429 |
private SpecimenTypeDesignationStatus getSpecimenTypeDesignationStatusByKey(Integer typeStatusFk) { |
399 |
if (typeStatusFk == null){ return null;
|
|
430 |
if (typeStatusFk == null){ return SpecimenTypeDesignationStatus.TYPE();
|
|
400 | 431 |
}else if (typeStatusFk == 1) { return SpecimenTypeDesignationStatus.HOLOTYPE(); |
401 | 432 |
}else if (typeStatusFk == 2) { return SpecimenTypeDesignationStatus.LECTOTYPE(); |
402 | 433 |
}else if (typeStatusFk == 3) { return SpecimenTypeDesignationStatus.NEOTYPE(); |
Also available in: Unified diff
latest changes to AT