2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.algaterra
;
12 import java
.sql
.ResultSet
;
13 import java
.sql
.SQLException
;
14 import java
.sql
.Timestamp
;
15 import java
.util
.HashMap
;
16 import java
.util
.HashSet
;
19 import java
.util
.UUID
;
21 import org
.apache
.commons
.lang
.StringUtils
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.joda
.time
.DateTime
;
24 import org
.springframework
.stereotype
.Component
;
26 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
27 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
28 import eu
.etaxonomy
.cdm
.io
.algaterra
.validation
.AlgaTerraTypeImportValidator
;
29 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportBase
;
30 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
31 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportState
;
32 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelRefDetailImport
;
33 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelReferenceImport
;
34 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelTaxonNameImport
;
35 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.EDITOR
;
36 import eu
.etaxonomy
.cdm
.io
.common
.IOValidator
;
37 import eu
.etaxonomy
.cdm
.io
.common
.ResultSetPartitioner
;
38 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
39 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
40 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
41 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
42 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
43 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
44 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
45 import eu
.etaxonomy
.cdm
.model
.common
.User
;
46 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
47 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
48 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
49 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
50 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
51 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
52 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
53 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
54 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
55 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
62 public class AlgaTerraTypeImport
extends AlgaTerraSpecimenImportBase
{
63 private static final Logger logger
= Logger
.getLogger(AlgaTerraTypeImport
.class);
66 private static int modCount
= 5000;
67 private static final String pluralString
= "types";
68 private static final String dbTableName
= "TypeDesignation"; //??
70 protected String
getLocalityString(){
71 return "TypeLocality";
74 public AlgaTerraTypeImport(){
75 super(dbTableName
, pluralString
);
80 protected String
getIdQuery(BerlinModelImportState state
) {
81 String result
= " SELECT TypeDesignationId "
82 + " FROM TypeDesignation "
83 + " ORDER BY NameFk ";
88 protected String
getRecordQuery(BerlinModelImportConfigurator config
) {
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, " +
93 " RefDet.Details as tdRefDetails, " +
94 " td.created_When as tdCreated_When, tsd.created_When as tsdCreated_When, td.updated_when as tdUpdated_when, " +
95 " td.created_who as tdCreated_who, tsd.created_who as tsdCreated_who, td.updated_who tdUpdated_who, " +
97 " FROM TypeSpecimenDesignation tsd "
98 + " LEFT OUTER JOIN TypeSpecimen AS ts ON tsd.TypeSpecimenFk = ts.TypeSpecimenId "
99 + " FULL OUTER JOIN TypeDesignation td ON td.TypeDesignationId = tsd.TypeDesignationFk "
100 + " LEFT OUTER JOIN TDWGGazetteer gz ON ts.TDWGGazetteerFk = gz.ID "
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 "
103 + " WHERE (td.TypeDesignationId IN (" + ID_LIST_TOKEN
+ ") )"
104 + " ORDER BY NameFk "
110 public boolean doPartition(ResultSetPartitioner partitioner
, BerlinModelImportState bmState
) {
111 boolean success
= true;
113 AlgaTerraImportState state
= (AlgaTerraImportState
)bmState
;
115 //TODO check that no duplicate vocabularies will be created, also remove redundant code here
116 // and in Specimen importer
118 makeVocabulariesAndFeatures(state
);
119 } catch (SQLException e1
) {
120 logger
.warn("Exception occurred when trying to create Type specimen vocabularies: " + e1
.getMessage());
121 e1
.printStackTrace();
126 Set
<TaxonNameBase
> namesToSave
= new HashSet
<TaxonNameBase
>();
128 Map
<String
, TaxonNameBase
> taxonNameMap
= (Map
<String
, TaxonNameBase
>) partitioner
.getObjectMap(BerlinModelTaxonNameImport
.NAMESPACE
);
129 Map
<String
, DerivedUnit
> ecoFactMap
= (Map
<String
, DerivedUnit
>) partitioner
.getObjectMap(AlgaTerraEcoFactImport
.ECO_FACT_FIELD_OBSERVATION_NAMESPACE
);
130 Map
<String
, DerivedUnit
> typeSpecimenMap
= (Map
<String
, DerivedUnit
>) partitioner
.getObjectMap(TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE
);
131 Map
<String
, Reference
> refMap
= (Map
<String
, Reference
>) partitioner
.getObjectMap(BerlinModelReferenceImport
.REFERENCE_NAMESPACE
);
132 Map
<String
, Reference
> refDetailMap
= partitioner
.getObjectMap(BerlinModelRefDetailImport
.REFDETAIL_NAMESPACE
);
135 ResultSet rs
= partitioner
.getResultSet();
144 if ((i
++ % modCount
) == 0 && i
!= 1 ){ logger
.info("Type designations handled: " + (i
-1));}
146 int nameId
= rs
.getInt("nameFk");
147 int typeSpecimenId
= rs
.getInt("TypeSpecimenId");
148 int typeDesignationId
= rs
.getInt("TypeDesignationId");
149 Integer typeStatusFk
= nullSafeInt(rs
, "typeStatusFk");
150 Integer ecoFactId
= nullSafeInt(rs
, "ecoFactFk");
151 Integer tdRefFk
= nullSafeInt(rs
, "tdRefFk");
152 Integer tdRefDetailFk
= nullSafeInt(rs
, "tdRefDetailFk");
153 String tdRefDetails
= rs
.getString("tdRefDetails");
154 Boolean restrictedFlag
= nullSafeBoolean(rs
, "RestrictedFlag");
156 String typeSpecimenPhrase
= rs
.getString("TypeSpecimenPhrase");
157 Integer tsMaterialCategoryFK
= nullSafeInt(rs
, "MaterialCategoryFK");
159 boolean isIcon
= typeSpecimenPhrase
!= null && typeSpecimenPhrase
.toLowerCase().startsWith("\u005bicon");
164 Reference
<?
> sourceRef
= state
.getTransactionalSourceReference();
167 SpecimenOrObservationType type
= SpecimenOrObservationType
.PreservedSpecimen
;
169 //TODO handle images correctly for these specimen
170 type
= SpecimenOrObservationType
.StillImage
;
171 }else if (typeStatusFk
!= null && typeStatusFk
.equals(39)){
172 type
= SpecimenOrObservationType
.LivingSpecimen
;
173 }else if (tsMaterialCategoryFK
!= null && tsMaterialCategoryFK
.equals(4)){
174 type
= SpecimenOrObservationType
.Fossil
;
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");
184 DerivedUnitFacade facade
= getDerivedUnit(state
, typeSpecimenId
, typeSpecimenMap
, type
, ecoFactMap
, ecoFactId
, sourceRef
);
187 handleFieldObservationSpecimen(rs
, facade
, state
, partitioner
);
189 // handleTypeSpecimenSpecificFieldObservation(rs,facade, state);
191 //TODO divide like in EcoFact (if necessary)
192 handleTypeSpecimenSpecificSpecimen(rs
,facade
, state
, refMap
, typeSpecimenId
);
194 handleFirstDerivedSpecimen(rs
, facade
, state
, partitioner
);
198 TaxonNameBase
<?
,?
> name
= getTaxonName(state
, taxonNameMap
, nameId
);
199 SpecimenTypeDesignation designation
= SpecimenTypeDesignation
.NewInstance();
200 SpecimenTypeDesignationStatus status
= getSpecimenTypeDesignationStatusByKey(typeStatusFk
);
201 if (typeStatusFk
!= null && typeStatusFk
.equals(39)){
202 designation
.addAnnotation(Annotation
.NewInstance("Type status: Authentic strain", AnnotationType
.EDITORIAL(), Language
.DEFAULT()));
205 designation
.setTypeSpecimen(facade
.innerDerivedUnit());
206 designation
.setTypeStatus(status
);
207 if (tdRefFk
!= null){
208 Reference
<?
> typeDesigRef
= getReferenceFromMaps(refDetailMap
, refMap
, String
.valueOf(tdRefDetailFk
), String
.valueOf(tdRefFk
));
209 if (typeDesigRef
== null){
210 logger
.warn("Type designation reference not found in maps: " + tdRefFk
);
212 designation
.setCitation(typeDesigRef
);
215 if (isNotBlank(tdRefDetails
)){
216 designation
.setCitationMicroReference(tdRefDetails
);
219 //ID: Type designations do not allow OriginalSources
220 designation
.addAnnotation(Annotation
.NewInstance("Id in BerlinModel-TypeDesignation: " + String
.valueOf(typeDesignationId
), AnnotationType
.TECHNICAL(), Language
.UNDETERMINED()));
222 if (restrictedFlag
!= null &&restrictedFlag
.equals(true)){
223 logger
.warn("Restricted Flag is expected to be null or 0. TypeDesignationId" + typeDesignationId
);
227 this.doCreatedUpdated(state
, designation
, rs
);
230 name
.addTypeDesignation(designation
, true); //TODO check if true is correct
232 logger
.warn("Name could not be found for type designation " + typeDesignationId
);
234 namesToSave
.add(name
);
237 } catch (Exception e
) {
238 logger
.warn("Exception in TypeDesignation: TypeDesignationId " + typeDesignationId
+ ". " + e
.getMessage());
244 // logger.warn("Specimen: " + countSpecimen + ", Descriptions: " + countDescriptions );
246 logger
.warn("Names to save: " + namesToSave
.size());
247 getNameService().save(namesToSave
);
250 } catch (SQLException e
) {
251 logger
.error("SQLException:" + e
);
257 * same as {@link BerlinModelImportBase#doCreatedUpdatedNotes}, but handles multiple similar fields
258 * @throws SQLException
260 private void doCreatedUpdated(BerlinModelImportState state
, AnnotatableEntity annotatableEntity
, ResultSet rs
) throws SQLException
{
261 BerlinModelImportConfigurator config
= state
.getConfig();
262 Object createdWhen
= rs
.getObject("tsdCreated_When");
263 Object tdCreatedWhen
= rs
.getObject("tdCreated_When");
264 if (tdCreatedWhen
!= null){
265 createdWhen
= tdCreatedWhen
;
268 String createdWho
= rs
.getString("tsdCreated_Who");
269 String tdCreatedWho
= rs
.getString("tdCreated_Who");
270 if (tdCreatedWho
!= null){
271 createdWho
= tdCreatedWho
;
274 Object updatedWhen
= rs
.getObject("tdUpdated_When");
275 String updatedWho
= rs
.getString("tdUpdated_who");
277 //Created When, Who, Updated When Who
278 if (config
.getEditor() == null || config
.getEditor().equals(EDITOR
.NO_EDITORS
)){
280 }else if (config
.getEditor().equals(EDITOR
.EDITOR_AS_ANNOTATION
)){
281 String createdAnnotationString
= "Berlin Model record was created By: " + String
.valueOf(createdWho
) + " (" + String
.valueOf(createdWhen
) + ") ";
282 if (updatedWhen
!= null && updatedWho
!= null){
283 createdAnnotationString
+= " and updated By: " + String
.valueOf(updatedWho
) + " (" + String
.valueOf(updatedWhen
) + ")";
285 Annotation annotation
= Annotation
.NewInstance(createdAnnotationString
, Language
.DEFAULT());
286 annotation
.setCommentator(config
.getCommentator());
287 annotation
.setAnnotationType(AnnotationType
.TECHNICAL());
288 annotatableEntity
.addAnnotation(annotation
);
289 }else if (config
.getEditor().equals(EDITOR
.EDITOR_AS_EDITOR
)){
290 User creator
= getUser(state
, createdWho
);
291 User updator
= getUser(state
, updatedWho
);
292 DateTime created
= getDateTime(createdWhen
);
293 DateTime updated
= getDateTime(updatedWhen
);
294 annotatableEntity
.setCreatedBy(creator
);
295 annotatableEntity
.setUpdatedBy(updator
);
296 annotatableEntity
.setCreated(created
);
297 annotatableEntity
.setUpdated(updated
);
299 logger
.warn("Editor type not yet implemented: " + config
.getEditor());
304 private DateTime
getDateTime(Object timeString
){
305 if (timeString
== null){
308 DateTime dateTime
= null;
309 if (timeString
instanceof Timestamp
){
310 Timestamp timestamp
= (Timestamp
)timeString
;
311 dateTime
= new DateTime(timestamp
);
313 logger
.warn("time ("+timeString
+") is not a timestamp. Datetime set to current date. ");
314 dateTime
= new DateTime();
320 protected String
getDerivedUnitNameSpace(){
321 return TYPE_SPECIMEN_DERIVED_UNIT_NAMESPACE
;
324 protected String
getFieldObservationNameSpace(){
325 return TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE
;
330 * @param taxonNameMap
334 private TaxonNameBase
<?
,?
> getTaxonName(AlgaTerraImportState state
, Map
<String
, TaxonNameBase
> taxonNameMap
, int nameId
) {
335 TaxonNameBase
<?
,?
> result
;
336 if (state
.getConfig().isDoTaxonNames()){
337 result
= taxonNameMap
.get(String
.valueOf(nameId
));
340 result
= BotanicalName
.NewInstance(Rank
.SPECIES());
345 private void handleTypeSpecimenSpecificSpecimen(ResultSet rs
, DerivedUnitFacade facade
, AlgaTerraImportState state
, Map
<String
, Reference
> refMap
, int typeSpecimenId
) throws SQLException
{
352 DerivedUnit derivedUnit
= facade
.innerDerivedUnit();
354 Integer tsMaterialCategoryFK
= nullSafeInt(rs
, "tsMaterialCategoryFK");
355 String matCat
= rs
.getString("MaterialCategory");
356 if (tsMaterialCategoryFK
!= null){
357 if (tsMaterialCategoryFK
.equals(16)){
358 tsMaterialCategoryFK
= 9;
360 UUID uuid
= materialCategoryMapping
.get(tsMaterialCategoryFK
);
362 logger
.warn("Uuid was null. This should not happen.");
364 DefinedTerm kindOfUnit
= getKindOfUnit(state
, uuid
, matCat
, null, null, null); //all terms should exist already
365 facade
.setKindOfUnit(kindOfUnit
);
367 logger
.warn("Material Category was null. This is not expected");
372 String barcode
= rs
.getString("Barcode");
373 if (StringUtils
.isNotBlank(barcode
)){
374 facade
.setBarcode(barcode
);
377 //RefFk + RefDetailFk
378 Integer refFk
= nullSafeInt(rs
, "tsRefFk");
381 Reference
<?
> ref
= refMap
.get(String
.valueOf(refFk
));
383 logger
.warn("TypeSpecimen reference (" + refFk
+ ")not found in biblioRef. TypeSpecimenId: " + typeSpecimenId
);
385 IdentifiableSource source
= IdentifiableSource
.NewPrimarySourceInstance(ref
, null);
386 derivedUnit
.addSource(source
);
390 Integer refDetailFk
= nullSafeInt(rs
, "tsRefDetailFk");
391 if (refDetailFk
!= null){
392 logger
.warn("TypeSpecimen.RefDetailFk should always be NULL but wasn't: " + typeSpecimenId
);
400 * @param derivedUnitMap
407 private DerivedUnitFacade
getDerivedUnit(AlgaTerraImportState state
, int typeSpecimenId
, Map
<String
, DerivedUnit
> typeSpecimenMap
, SpecimenOrObservationType type
, Map
<String
, DerivedUnit
> ecoFactMap
, Integer ecoFactId2
, Reference
<?
> sourceRef
) {
408 //TODO implement ecoFact map - if not all null anymore
409 String typeKey
= String
.valueOf(typeSpecimenId
);
410 DerivedUnit derivedUnit
= typeSpecimenMap
.get(typeKey
);
411 DerivedUnitFacade facade
;
412 if (derivedUnit
== null){
413 facade
= DerivedUnitFacade
.NewInstance(type
);
414 typeSpecimenMap
.put(typeKey
, derivedUnit
);
417 facade
= DerivedUnitFacade
.NewInstance(derivedUnit
);
418 facade
.addSource(IdentifiableSource
.NewDataImportInstance(typeKey
, "TypeSpecimen", sourceRef
));
419 } catch (DerivedUnitFacadeNotSupportedException e
) {
420 logger
.error(e
.getMessage());
421 facade
= DerivedUnitFacade
.NewInstance(type
);
429 private SpecimenTypeDesignationStatus
getSpecimenTypeDesignationStatusByKey(Integer typeStatusFk
) {
430 if (typeStatusFk
== null){ return SpecimenTypeDesignationStatus
.TYPE();
431 }else if (typeStatusFk
== 1) { return SpecimenTypeDesignationStatus
.HOLOTYPE();
432 }else if (typeStatusFk
== 2) { return SpecimenTypeDesignationStatus
.LECTOTYPE();
433 }else if (typeStatusFk
== 3) { return SpecimenTypeDesignationStatus
.NEOTYPE();
434 }else if (typeStatusFk
== 4) { return SpecimenTypeDesignationStatus
.EPITYPE();
435 }else if (typeStatusFk
== 5) { return SpecimenTypeDesignationStatus
.ISOLECTOTYPE();
436 }else if (typeStatusFk
== 6) { return SpecimenTypeDesignationStatus
.ISONEOTYPE();
437 }else if (typeStatusFk
== 7) { return SpecimenTypeDesignationStatus
.ISOTYPE();
438 }else if (typeStatusFk
== 8) { return SpecimenTypeDesignationStatus
.PARANEOTYPE();
439 }else if (typeStatusFk
== 9) { return SpecimenTypeDesignationStatus
.PARATYPE();
440 }else if (typeStatusFk
== 10) { return SpecimenTypeDesignationStatus
.SECOND_STEP_LECTOTYPE();
441 }else if (typeStatusFk
== 11) { return SpecimenTypeDesignationStatus
.SECOND_STEP_NEOTYPE();
442 }else if (typeStatusFk
== 12) { return SpecimenTypeDesignationStatus
.SYNTYPE();
443 }else if (typeStatusFk
== 13) { return SpecimenTypeDesignationStatus
.PARALECTOTYPE();
444 }else if (typeStatusFk
== 14) { return SpecimenTypeDesignationStatus
.ISOEPITYPE();
445 }else if (typeStatusFk
== 21) { return SpecimenTypeDesignationStatus
.ICONOTYPE();
446 }else if (typeStatusFk
== 22) { return SpecimenTypeDesignationStatus
.PHOTOTYPE();
447 }else if (typeStatusFk
== 30) { return SpecimenTypeDesignationStatus
.TYPE();
448 }else if (typeStatusFk
== 38) { return SpecimenTypeDesignationStatus
.ISOEPITYPE();
449 }else if (typeStatusFk
== 39) { return SpecimenTypeDesignationStatus
.ORIGINAL_MATERIAL(); //but add annotation
450 }else if (typeStatusFk
== 40) { return SpecimenTypeDesignationStatus
.ORIGINAL_MATERIAL();
452 logger
.warn("typeStatusFk undefined for " + typeStatusFk
);
453 return SpecimenTypeDesignationStatus
.TYPE();
460 public Map
<Object
, Map
<String
, ?
extends CdmBase
>> getRelatedObjectsForPartition(ResultSet rs
, BerlinModelImportState state
) {
464 Map
<Object
, Map
<String
, ?
extends CdmBase
>> result
= new HashMap
<Object
, Map
<String
, ?
extends CdmBase
>>();
467 Set
<String
> nameIdSet
= new HashSet
<String
>();
468 Set
<String
> ecoFieldObservationIdSet
= new HashSet
<String
>();
469 Set
<String
> typeSpecimenIdSet
= new HashSet
<String
>();
470 // Set<String> termsIdSet = new HashSet<String>();
471 Set
<String
> collectionIdSet
= new HashSet
<String
>();
472 Set
<String
> referenceIdSet
= new HashSet
<String
>();
473 Set
<String
> refDetailIdSet
= new HashSet
<String
>();
476 handleForeignKey(rs
, nameIdSet
, "nameFk");
477 handleForeignKey(rs
, ecoFieldObservationIdSet
, "ecoFactFk");
478 handleForeignKey(rs
, typeSpecimenIdSet
, "TypeSpecimenId");
479 handleForeignKey(rs
, collectionIdSet
, "CollectionFk");
480 handleForeignKey(rs
, referenceIdSet
, "tsRefFk");
481 handleForeignKey(rs
, referenceIdSet
, "tdRefFk");
482 handleForeignKey(rs
, refDetailIdSet
, "tdRefDetailFk");
486 nameSpace
= BerlinModelTaxonNameImport
.NAMESPACE
;
487 cdmClass
= TaxonNameBase
.class;
489 Map
<String
, TaxonNameBase
> objectMap
= (Map
<String
, TaxonNameBase
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
490 result
.put(nameSpace
, objectMap
);
492 //eco fact field observation map
493 nameSpace
= AlgaTerraTypeImport
.ECO_FACT_FIELD_OBSERVATION_NAMESPACE
;
494 cdmClass
= FieldUnit
.class;
495 idSet
= ecoFieldObservationIdSet
;
496 Map
<String
, FieldUnit
> fieldObservationMap
= (Map
<String
, FieldUnit
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
497 result
.put(nameSpace
, fieldObservationMap
);
500 nameSpace
= AlgaTerraTypeImport
.TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE
;
501 cdmClass
= FieldUnit
.class;
502 idSet
= typeSpecimenIdSet
;
503 Map
<String
, FieldUnit
> typeSpecimenMap
= (Map
<String
, FieldUnit
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
504 result
.put(nameSpace
, typeSpecimenMap
);
508 nameSpace
= AlgaTerraCollectionImport
.NAMESPACE_COLLECTION
;
509 cdmClass
= Collection
.class;
510 idSet
= collectionIdSet
;
511 Map
<String
, Collection
> collectionMap
= (Map
<String
, Collection
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
512 result
.put(nameSpace
, collectionMap
);
515 nameSpace
= AlgaTerraCollectionImport
.NAMESPACE_SUBCOLLECTION
;
516 cdmClass
= Collection
.class;
517 idSet
= collectionIdSet
;
518 Map
<String
, Collection
> subCollectionMap
= (Map
<String
, Collection
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
519 result
.put(nameSpace
, subCollectionMap
);
522 nameSpace
= BerlinModelReferenceImport
.REFERENCE_NAMESPACE
;
523 cdmClass
= Reference
.class;
524 idSet
= referenceIdSet
;
525 Map
<String
, Reference
> referenceMap
= (Map
<String
, Reference
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
526 result
.put(nameSpace
, referenceMap
);
529 nameSpace
= BerlinModelRefDetailImport
.REFDETAIL_NAMESPACE
;
530 cdmClass
= Reference
.class;
531 idSet
= refDetailIdSet
;
532 Map
<String
, Reference
> refDetailMap
= (Map
<String
, Reference
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
533 result
.put(nameSpace
, refDetailMap
);
537 } catch (SQLException e
) {
538 throw new RuntimeException(e
);
544 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
547 protected boolean doCheck(BerlinModelImportState state
){
548 IOValidator
<BerlinModelImportState
> validator
= new AlgaTerraTypeImportValidator();
549 return validator
.validate(state
);
554 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
556 protected boolean isIgnore(BerlinModelImportState state
){
557 return ! state
.getConfig().isDoTypes();