Revision bb38665e
Added by Andreas Müller over 10 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraTypeImport.java | ||
---|---|---|
21 | 21 |
import org.springframework.stereotype.Component; |
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
24 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType; |
|
25 | 24 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; |
26 | 25 |
import eu.etaxonomy.cdm.io.algaterra.validation.AlgaTerraTypeImportValidator; |
27 | 26 |
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator; |
... | ... | |
32 | 31 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
33 | 32 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
34 | 33 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
34 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
35 | 35 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
36 | 36 |
import eu.etaxonomy.cdm.model.name.Rank; |
37 | 37 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
39 | 39 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
40 | 40 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
41 | 41 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
42 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
|
|
43 |
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
|
|
42 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
|
43 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
|
44 | 44 |
import eu.etaxonomy.cdm.model.reference.Reference; |
45 | 45 |
|
46 | 46 |
|
... | ... | |
155 | 155 |
//facade |
156 | 156 |
//FIXME - depends on material category |
157 | 157 |
// DerivedUnitType type = makeDerivedUnitType(recordBasis); |
158 |
DerivedUnitType type = DerivedUnitType.Specimen; |
|
158 |
if (i<=2){logger.warn("RecordBasis not yet implemented in TypeImport");} |
|
159 |
|
|
160 |
SpecimenOrObservationType type = SpecimenOrObservationType.PreservedSpecimen; |
|
159 | 161 |
DerivedUnitFacade facade = getDerivedUnit(state, typeSpecimenId, typeSpecimenMap, type, ecoFactMap, ecoFactId); |
160 | 162 |
|
161 | 163 |
//field observation |
... | ... | |
246 | 248 |
|
247 | 249 |
|
248 | 250 |
|
249 |
DerivedUnitBase<?> derivedUnit = facade.innerDerivedUnit();
|
|
251 |
DerivedUnit derivedUnit = facade.innerDerivedUnit(); |
|
250 | 252 |
|
251 | 253 |
//collection |
252 | 254 |
String barcode = rs.getString("Barcode"); |
... | ... | |
262 | 264 |
if (ref == null){ |
263 | 265 |
logger.warn("TypeSpecimen reference (" + refFk + ")not found in biblioRef. TypeSpecimenId: " + typeSpecimenId); |
264 | 266 |
}else{ |
265 |
IdentifiableSource source = IdentifiableSource.NewInstance(ref, null); |
|
267 |
IdentifiableSource source = IdentifiableSource.NewPrimarySourceInstance(ref, null);
|
|
266 | 268 |
derivedUnit.addSource(source); |
267 | 269 |
} |
268 | 270 |
} |
... | ... | |
285 | 287 |
* @param ecoFactMap |
286 | 288 |
* @return |
287 | 289 |
*/ |
288 |
private DerivedUnitFacade getDerivedUnit(AlgaTerraImportState state, int typeSpecimenId, Map<String, DerivedUnit> typeSpecimenMap, DerivedUnitType type, Map<String, DerivedUnit> ecoFactMap, Integer ecoFactId2) {
|
|
290 |
private DerivedUnitFacade getDerivedUnit(AlgaTerraImportState state, int typeSpecimenId, Map<String, DerivedUnit> typeSpecimenMap, SpecimenOrObservationType type, Map<String, DerivedUnit> ecoFactMap, Integer ecoFactId2) {
|
|
289 | 291 |
//TODO implement ecoFact map - if not all null anymore |
290 | 292 |
String typeKey = String.valueOf(typeSpecimenId); |
291 | 293 |
DerivedUnit derivedUnit = typeSpecimenMap.get(typeKey); |
... | ... | |
304 | 306 |
|
305 | 307 |
return facade; |
306 | 308 |
} |
307 |
private DerivedUnitType makeDerivedUnitType(String recordBasis) { |
|
308 |
DerivedUnitType result = null; |
|
309 |
if (StringUtils.isBlank(recordBasis)){ |
|
310 |
result = DerivedUnitType.DerivedUnit; |
|
311 |
} else if (recordBasis.equalsIgnoreCase("FossileSpecimen")){ |
|
312 |
result = DerivedUnitType.Fossil; |
|
313 |
}else if (recordBasis.equalsIgnoreCase("HumanObservation")){ |
|
314 |
result = DerivedUnitType.Observation; |
|
315 |
}else if (recordBasis.equalsIgnoreCase("Literature")){ |
|
316 |
logger.warn("Literature record basis not yet supported"); |
|
317 |
result = DerivedUnitType.DerivedUnit; |
|
318 |
}else if (recordBasis.equalsIgnoreCase("LivingSpecimen")){ |
|
319 |
result = DerivedUnitType.LivingBeing; |
|
320 |
}else if (recordBasis.equalsIgnoreCase("MachineObservation")){ |
|
321 |
logger.warn("MachineObservation record basis not yet supported"); |
|
322 |
result = DerivedUnitType.Observation; |
|
323 |
}else if (recordBasis.equalsIgnoreCase("PreservedSpecimen")){ |
|
324 |
result = DerivedUnitType.Specimen; |
|
325 |
} |
|
326 |
return result; |
|
327 |
} |
|
309 |
// private DerivedUnitType makeDerivedUnitType(String recordBasis) {
|
|
310 |
// DerivedUnitType result = null;
|
|
311 |
// if (StringUtils.isBlank(recordBasis)){
|
|
312 |
// result = DerivedUnitType.DerivedUnit;
|
|
313 |
// } else if (recordBasis.equalsIgnoreCase("FossileSpecimen")){
|
|
314 |
// result = DerivedUnitType.Fossil;
|
|
315 |
// }else if (recordBasis.equalsIgnoreCase("HumanObservation")){
|
|
316 |
// result = DerivedUnitType.Observation;
|
|
317 |
// }else if (recordBasis.equalsIgnoreCase("Literature")){
|
|
318 |
// logger.warn("Literature record basis not yet supported");
|
|
319 |
// result = DerivedUnitType.DerivedUnit;
|
|
320 |
// }else if (recordBasis.equalsIgnoreCase("LivingSpecimen")){
|
|
321 |
// result = DerivedUnitType.LivingBeing;
|
|
322 |
// }else if (recordBasis.equalsIgnoreCase("MachineObservation")){
|
|
323 |
// logger.warn("MachineObservation record basis not yet supported");
|
|
324 |
// result = DerivedUnitType.Observation;
|
|
325 |
// }else if (recordBasis.equalsIgnoreCase("PreservedSpecimen")){
|
|
326 |
// result = DerivedUnitType.Specimen;
|
|
327 |
// }
|
|
328 |
// return result;
|
|
329 |
// }
|
|
328 | 330 |
|
329 | 331 |
|
330 | 332 |
private SpecimenTypeDesignationStatus getSpecimenTypeDesignationStatusByKey(Integer typeStatusFk) { |
... | ... | |
392 | 394 |
|
393 | 395 |
//eco fact field observation map |
394 | 396 |
nameSpace = AlgaTerraTypeImport.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
395 |
cdmClass = FieldObservation.class;
|
|
397 |
cdmClass = FieldUnit.class;
|
|
396 | 398 |
idSet = ecoFieldObservationIdSet; |
397 |
Map<String, FieldObservation> fieldObservationMap = (Map<String, FieldObservation>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
399 |
Map<String, FieldUnit> fieldObservationMap = (Map<String, FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
398 | 400 |
result.put(nameSpace, fieldObservationMap); |
399 | 401 |
|
400 | 402 |
//type specimen map |
401 | 403 |
nameSpace = AlgaTerraTypeImport.TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE; |
402 |
cdmClass = FieldObservation.class;
|
|
404 |
cdmClass = FieldUnit.class;
|
|
403 | 405 |
idSet = typeSpecimenIdSet; |
404 |
Map<String, FieldObservation> typeSpecimenMap = (Map<String, FieldObservation>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
406 |
Map<String, FieldUnit> typeSpecimenMap = (Map<String, FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
405 | 407 |
result.put(nameSpace, typeSpecimenMap); |
406 | 408 |
|
407 | 409 |
|
Also available in: Unified diff
reintegrate cdmlib-app-3.3 branch into trunk