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
;
13 import java
.sql
.ResultSet
;
14 import java
.sql
.SQLException
;
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
.springframework
.stereotype
.Component
;
24 import org
.springframework
.transaction
.TransactionStatus
;
26 import eu
.etaxonomy
.cdm
.io
.algaterra
.validation
.AlgaTerraMorphologyImportValidator
;
27 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
28 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportState
;
29 import eu
.etaxonomy
.cdm
.io
.common
.IOValidator
;
30 import eu
.etaxonomy
.cdm
.io
.common
.ResultSetPartitioner
;
31 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
32 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.UndefinedTransformerMethodException
;
33 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
34 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
35 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceType
;
36 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
37 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
38 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
39 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
40 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
41 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
42 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
43 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
44 import eu
.etaxonomy
.cdm
.model
.description
.SpecimenDescription
;
45 import eu
.etaxonomy
.cdm
.model
.description
.State
;
46 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
47 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
48 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
49 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
50 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
51 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
59 public class AlgaTerraMorphologyImport
extends AlgaTerraSpecimenImportBase
{
60 private static final Logger logger
= Logger
.getLogger(AlgaTerraMorphologyImport
.class);
63 private static int modCount
= 5000;
64 private static final String pluralString
= "morpho facts";
65 private static final String dbTableName
= "MorphoFact";
68 public AlgaTerraMorphologyImport(){
69 super(dbTableName
, pluralString
);
74 protected String
getIdQuery(BerlinModelImportState state
) {
75 String result
= " SELECT MorphoFactId " +
77 " ORDER BY MorphoFact.MorphoFactId ";
83 protected String
getRecordQuery(BerlinModelImportConfigurator config
) {
85 " SELECT mf.*, mf.MorphoFactId as unitId, ecoFact.ecoFactId as ecoFactId, size.* " +
86 " FROM MorphoFact mf " +
87 " LEFT OUTER JOIN MorphoSizeRange size ON mf.SizeRangeFk = size.SizeRangeId " +
88 " LEFT OUTER JOIN MorphoValveDescription valve1Desc ON mf.Valve1DescriptionFk = valve1Desc.ValveDescriptionId " +
89 " LEFT OUTER JOIN MorphoValveDescription valve2Desc ON mf.Valve2DescriptionFk = valve2Desc.ValveDescriptionId " +
90 " LEFT OUTER JOIN EcoFact ecoFact ON ecoFact.CultureStrain = mf.CultureStrainNo " +
91 " WHERE (mf.MorphoFactId IN (" + ID_LIST_TOKEN
+ ") )"
92 + " ORDER BY mf.MorphoFactId "
98 private Map
<String
, TermVocabulary
<State
>> vocabularyMap
= new HashMap
<String
, TermVocabulary
<State
>>();
99 private Map
<String
, Feature
> featureMap
= new HashMap
<String
, Feature
>();
100 private Map
<String
, Map
<Integer
, State
>> algaTerraMorphoStates
= new HashMap
<String
, Map
<Integer
, State
>>();
101 private TermVocabulary
<Feature
> algaTerraMorphoFeatures
= TermVocabulary
102 .NewInstance(TermType
.Feature
, "Alga Terra Morphology Features", "AT Morphology Features", null, null);
104 private void doMorphoListen(AlgaTerraImportState state
) throws SQLException
{
106 TransactionStatus txStatus
= this.startTransaction();
108 getVocabularyService().save(algaTerraMorphoFeatures
);
110 //chloroplast position
111 String baseName
= "Chloroplast Position";
112 UUID uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocChloroplastPosition
;
113 boolean isOrdered
= false;
114 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
115 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
118 baseName
= "Chloroplast Shape";
119 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocChloroplastShape
;
121 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
122 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
125 baseName
= "Chloroplast Structure";
126 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocChloroplastStructure
;
128 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
129 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
132 baseName
= "Growth Form";
133 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocGrowthForm
;
135 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
136 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
139 baseName
= "Organisation Level";
140 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocOrganisationLevel
;
142 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
143 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
148 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocRaphe
;
150 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
151 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
155 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocShape
;
157 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
158 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
161 baseName
= "Symmetry";
162 uuidStateVocabulary
= AlgaTerraImportTransformer
.uuidVocSymmetry
;
164 makeFeatureAndVocabulary(state
, vocabularyMap
, featureMap
, algaTerraMorphoStates
,
165 algaTerraMorphoFeatures
, baseName
, uuidStateVocabulary
, isOrdered
);
167 getVocabularyService().saveOrUpdate(algaTerraMorphoFeatures
);
169 this.commitTransaction(txStatus
);
173 private void makeFeatureAndVocabulary(AlgaTerraImportState state
,
174 Map
<String
, TermVocabulary
<State
>> vocabularyMap
,
175 Map
<String
, Feature
> featureMap
, Map
<String
, Map
<Integer
, State
>> allMorphoStates
,
176 TermVocabulary
<Feature
> algaTerraMorphoFeatures
, String baseName
,
177 UUID uuidStateVocabulary
, boolean isOrdered
)
178 throws SQLException
{
180 Source source
= state
.getAlgaTerraConfigurator().getSource();
182 Map
<Integer
, State
> morphoStates
= new HashMap
<Integer
, State
>();
183 allMorphoStates
.put(baseName
, morphoStates
);
185 String baseNameCamel
= baseName
.replace(" ", "");
188 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
190 //make term vocabulary
191 String vocDescription
= "The vocabulary for the " + baseName
+ " in AlgaTerra";
192 String vocLabel
= baseName
;
193 String vocAbbrevLabel
= null;
194 URI termSourceUri
= null;
195 TermVocabulary
<State
> voc
= getVocabulary(TermType
.State
, uuidStateVocabulary
,vocDescription
, vocLabel
, vocAbbrevLabel
, termSourceUri
, isOrdered
, null);
196 vocabularyMap
.put(vocLabel
, voc
);
198 String idField
= baseNameCamel
+ "Id";
199 String sql
= "SELECT " + idField
+ "," + baseNameCamel
+ ", Description FROM Morpho" + baseNameCamel
;
200 ResultSet rs
= source
.getResultSet(sql
);
202 Integer id
= rs
.getInt(idField
);
203 String label
= rs
.getString(baseNameCamel
);
204 String description
= rs
.getString("Description");
205 State term
= State
.NewInstance(description
, label
, null);
207 term
.addSource(OriginalSourceType
.Import
, String
.valueOf(id
), baseNameCamel
, state
.getTransactionalSourceReference() , null);
208 morphoStates
.put(id
, term
);
210 getVocabularyService().saveOrUpdate(voc
);
214 private Feature
handleSingleFeature(AlgaTerraImportState state
,
215 Map
<String
, Feature
> featureMap
,
216 TermVocabulary
<Feature
> algaTerraMorphoFeatures
, String baseName
) {
218 String baseNameCamel
= baseName
.replace(" ", "");
220 UUID uuidFeature
= null;
222 uuidFeature
= AlgaTerraImportTransformer
.getFeatureUuid(baseName
);
223 } catch (UndefinedTransformerMethodException e
) {
224 throw new RuntimeException(e
);
226 Feature feature
= getFeature(state
, uuidFeature
, baseName
, baseName
, null, algaTerraMorphoFeatures
);
227 algaTerraMorphoFeatures
.addTerm(feature
);
228 featureMap
.put(baseNameCamel
, feature
);
232 private void doNonListenFeatures(AlgaTerraImportState state
) throws SQLException
{
233 String baseName
= "Apices";
234 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
236 baseName
= "Chloroplast Number";
237 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
239 baseName
= "Pyrenoid";
240 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
242 baseName
= "Cell Wall";
243 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
245 baseName
= "Reproductive Stages";
246 handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
248 makeValveFeatures(state
, featureMap
, algaTerraMorphoFeatures
);
255 private void makeValveFeatures(AlgaTerraImportState state
,
256 Map
<String
, Feature
> featureMap2
,
257 TermVocabulary
<Feature
> algaTerraMorphoFeatures2
) {
259 String baseName
= "Valve 1";
260 handleSingleValve(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
262 baseName
= "Valve 2";
263 handleSingleValve(state
, featureMap
, algaTerraMorphoFeatures
, baseName
);
268 private void handleSingleValve(AlgaTerraImportState state
,
269 Map
<String
, Feature
> featureMap2
,
270 TermVocabulary
<Feature
> algaTerraMorphoFeatures2
, String valveStr
) {
272 Feature featureValve
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, valveStr
);
274 String baseName
= "Striae Frequency";
275 Feature featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
276 //TODO is partOf correct here? see also below
277 featureSub
.setPartOf(featureValve
);
279 baseName
= "Striae Orientation Mid"; //Mid Valve
280 featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
281 featureSub
.setPartOf(featureValve
);
283 baseName
= "Striae Orientation Apices";
284 featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
285 featureSub
.setPartOf(featureValve
);
287 baseName
= "Central Area";
288 featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
289 featureSub
.setPartOf(featureValve
);
291 baseName
= "Axial Area";
292 featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
293 featureSub
.setPartOf(featureValve
);
295 baseName
= "has Raphe";
296 featureSub
= handleSingleFeature(state
, featureMap
, algaTerraMorphoFeatures
, baseName
+ " " + valveStr
);
297 featureSub
.setPartOf(featureValve
);
302 protected void doInvoke(BerlinModelImportState state
) {
303 AlgaTerraImportState atState
= (AlgaTerraImportState
)state
;
305 doMorphoListen(atState
);
306 doNonListenFeatures(atState
);
307 } catch (SQLException e
) {
308 throw new RuntimeException(e
);
310 super.doInvoke(state
);
315 public boolean doPartition(ResultSetPartitioner partitioner
, BerlinModelImportState bmState
) {
316 boolean success
= true;
318 AlgaTerraImportState state
= (AlgaTerraImportState
)bmState
;
319 Set
<SpecimenOrObservationBase
> objectsToSave
= new HashSet
<SpecimenOrObservationBase
>();
321 ResultSet rs
= partitioner
.getResultSet();
330 if ((i
++ % modCount
) == 0 && i
!= 1 ){ logger
.info(pluralString
+ " handled: " + (i
-1));}
332 int morphoFactId
= rs
.getInt("MorphoFactId");
333 String cultureStrainNo
= rs
.getString("CultureStrainNo");
338 Reference
<?
> sourceRef
= state
.getTransactionalSourceReference();
341 DerivedUnit ecoFact
= makeDerivationFromEcoFact(state
, rs
, morphoFactId
);
342 if (ecoFact
!= null){
343 SpecimenDescription desc
= SpecimenDescription
.NewInstance();
344 desc
.setTitleCache("Morphology for " + cultureStrainNo
, true);
346 ecoFact
.addDescription(desc
);
348 String baseLabel
= "Organisation Level";
349 handleStateTerm(state
, rs
, baseLabel
, desc
);
351 baseLabel
= "Growth Form";
352 handleStateTerm(state
, rs
, baseLabel
, desc
);
355 handleStateTerm(state
, rs
, baseLabel
, desc
);
357 baseLabel
= "Symmetry";
358 handleStateTerm(state
, rs
, baseLabel
, desc
);
361 handleStateTerm(state
, rs
, baseLabel
, desc
);
363 baseLabel
= "Chloroplast Shape";
364 handleStateTerm(state
, rs
, baseLabel
, desc
);
366 baseLabel
= "Chloroplast Structure";
367 handleStateTerm(state
, rs
, baseLabel
, desc
);
369 baseLabel
= "Chloroplast Position";
370 handleStateTerm(state
, rs
, baseLabel
, desc
);
372 baseLabel
= "Apices";
373 handleTextData(state
, rs
, baseLabel
, desc
);
375 baseLabel
= "Chloroplast Number";
376 handleTextData(state
, rs
, baseLabel
, desc
);
378 baseLabel
= "Pyrenoid";
379 handleTextData(state
, rs
, baseLabel
, desc
);
381 baseLabel
= "Cell Wall";
382 handleTextData(state
, rs
, baseLabel
, desc
);
384 baseLabel
= "Reproductive Stages";
385 handleTextData(state
, rs
, baseLabel
, desc
);
387 //TODO to which object to add this information
388 this.doId(state
, desc
, morphoFactId
, dbTableName
);
389 String notes
= rs
.getString("Notes");
390 this.doNotes(desc
, notes
);
392 objectsToSave
.add(ecoFact
);
393 }else if (cultureStrainNo
!= null) {
394 logger
.warn("cultureStrainNo (" + cultureStrainNo
+ ") exists but no ecoFact found for morphoFact " + morphoFactId
);
396 logger
.info("No cultureStrainNo defined for morphoFact " + morphoFactId
);
398 } catch (Exception e
) {
399 logger
.warn("Exception in morphoFact: morphoFactId " + morphoFactId
+ ". " + e
.getMessage());
406 //GrowthFormExplanation, ShapeExplanation, RapheExplanation, ChloroplastExplanation,
407 //SizeRangeFk, SizeRangeExplanation,
408 //Valve1RapheFlag, Valve1DescriptionFk,
409 //Valve2RapheFlag, Valve2DescriptionFk,
410 //StriaeFrequencyExplanation,
411 //PyrenoidExplanation,
413 //Not required: OrganisationLevelExplanation, ValveLinearShape, ValveShape, SymmetryExplanation,
414 //Rimoportula, Fultoportula, Description, CultureCollection
416 logger
.warn("Specimen to save: " + objectsToSave
.size());
417 getOccurrenceService().save(objectsToSave
);
420 } catch (SQLException e
) {
421 logger
.error("SQLException:" + e
);
426 private DerivedUnit
makeDerivationFromEcoFact(AlgaTerraImportState state
, ResultSet rs
, Integer morphoFactId
) throws SQLException
{
427 Integer ecoFactFk
= nullSafeInt(rs
, "ecoFactId");
428 if (ecoFactFk
!= null){
430 DerivedUnit ecoFact
= (DerivedUnit
)state
.getRelatedObject(ECO_FACT_DERIVED_UNIT_NAMESPACE
, ecoFactFk
.toString());
431 if (ecoFact
== null){
432 logger
.warn("EcoFact is null for ecoFactFk: " + ecoFactFk
+ ", morphoFactId: " + morphoFactId
);
442 private void handleTextData(AlgaTerraImportState state
, ResultSet rs
,
443 String baseLabel
, SpecimenDescription desc
) throws SQLException
{
444 String baseLabelCamel
= baseLabel
.replace(" ", "");
446 String value
= rs
.getString(baseLabelCamel
);
448 Feature feature
= this.featureMap
.get(baseLabelCamel
);
449 if (feature
== null){
450 logger
.warn("Feature is null");
452 TextData textData
= TextData
.NewInstance(feature
);
453 desc
.addElement(textData
);
458 private void handleStateTerm(AlgaTerraImportState algaTerraState
, ResultSet rs
,
459 String baseLabel
, SpecimenDescription desc
) throws SQLException
{
461 String baseLabelCamel
= baseLabel
.replace(" ", "");
462 Integer id
= nullSafeInt(rs
, baseLabelCamel
+ "Fk");
464 Feature feature
= this.featureMap
.get(baseLabelCamel
);
465 State state
= getState(baseLabel
, id
);
466 if (feature
== null || state
== null){
467 logger
.warn("Feature or state is null");
469 DescriptionElementBase deb
= CategoricalData
.NewInstance(state
, feature
);
470 desc
.addElement(deb
);
475 private State
getState(String baseLabel
, Integer id
) {
476 Map
<Integer
, State
> stateMap
= this.algaTerraMorphoStates
.get(baseLabel
);
477 return stateMap
.get(id
);
481 protected String
getDerivedUnitNameSpace(){
482 return ECO_FACT_DERIVED_UNIT_NAMESPACE
;
485 protected String
getFieldObservationNameSpace(){
486 return ECO_FACT_FIELD_OBSERVATION_NAMESPACE
;
491 private void makeParameter(AlgaTerraImportState state
, ResultSet rs
, DescriptionBase
<?
> descriptionBase
) throws SQLException
{
492 for (int i
= 1; i
<= 10; i
++){
493 String valueStr
= rs
.getString(String
.format("P%dValue", i
));
494 String unitStr
= rs
.getString(String
.format("P%dUnit", i
));
495 String parameter
= rs
.getString(String
.format("P%dParameter", i
));
496 String method
= rs
.getString(String
.format("P%dMethod", i
));
499 if (StringUtils
.isNotBlank(method
)){
500 logger
.warn("Methods not yet handled: " + method
);
503 TermVocabulary
<Feature
> vocParameter
= getVocabulary(TermType
.Feature
, uuidVocParameter
, "Feature vocabulary for AlgaTerra measurement parameters", "Parameters", null, null, false, Feature
.COMMON_NAME());
504 if (StringUtils
.isNotBlank(parameter
)){
505 UUID featureUuid
= getParameterFeatureUuid(state
, parameter
);
506 Feature feature
= getFeature(state
, featureUuid
, parameter
, parameter
, null, vocParameter
);
507 QuantitativeData quantData
= QuantitativeData
.NewInstance(feature
);
510 MeasurementUnit unit
= getMeasurementUnit(state
, unitStr
);
511 quantData
.setUnit(unit
);
514 Set
<DefinedTerm
> valueModifier
= new HashSet
<DefinedTerm
>();
515 valueStr
= normalizeAndModifyValue(state
, valueStr
, valueModifier
);
517 Float valueFlt
= Float
.valueOf(valueStr
); //TODO maybe change model to Double ??
519 StatisticalMeasure measureSingleValue
= getStatisticalMeasure(state
, uuidStatMeasureSingleValue
, "Value", "Single measurement value", null, null);
520 StatisticalMeasurementValue value
= StatisticalMeasurementValue
.NewInstance(measureSingleValue
, valueFlt
);
521 quantData
.addStatisticalValue(value
);
522 descriptionBase
.addElement(quantData
);
524 } catch (NumberFormatException e
) {
525 logger
.warn(String
.format("Value '%s' can't be converted to double. Parameter %s not imported.", valueStr
, parameter
));
527 }else if (isNotBlank(valueStr
) || isNotBlank(unitStr
) ){
528 logger
.warn("There is value or unit without parameter: " + i
);
536 private String
normalizeAndModifyValue(AlgaTerraImportState state
, String valueStr
, Set
<DefinedTerm
> valueModifier
) {
537 valueStr
= valueStr
.replace(",", ".");
538 if (valueStr
.startsWith("<")){
539 TermVocabulary
<DefinedTerm
> measurementValueModifierVocabulary
= getVocabulary(TermType
.Modifier
, uuidMeasurementValueModifier
, "Measurement value modifier", "Measurement value modifier", null, null, false, DefinedTerm
.NewModifierInstance(null, null, null));
540 DefinedTerm modifier
= getModifier(state
, uuidModifierLowerThan
, "Lower", "Lower than the given measurement value", "<", measurementValueModifierVocabulary
);
541 valueModifier
.add(modifier
);
542 valueStr
= valueStr
.replace("<", "");
544 if (valueStr
.startsWith(">")){
545 TermVocabulary
<DefinedTerm
> measurementValueModifierVocabulary
= getVocabulary(TermType
.Modifier
, uuidMeasurementValueModifier
, "Measurement value modifier", "Measurement value modifier", null, null, false, DefinedTerm
.NewModifierInstance(null, null, null));
546 DefinedTerm modifier
= getModifier(state
, uuidModifierGreaterThan
, "Lower", "Lower than the given measurement value", "<", measurementValueModifierVocabulary
);
547 valueModifier
.add(modifier
);
548 valueStr
= valueStr
.replace(">", "");
555 private UUID
getParameterFeatureUuid(AlgaTerraImportState state
, String key
) {
557 return AlgaTerraImportTransformer
.getFeatureUuid(key
);
558 } catch (UndefinedTransformerMethodException e
) {
559 throw new RuntimeException(e
);
566 * TODO move to InputTransformerBase
571 private MeasurementUnit
getMeasurementUnit(AlgaTerraImportState state
, String unitStr
) {
572 if (StringUtils
.isNotBlank(unitStr
)){
573 UUID uuid
= AlgaTerraImportTransformer
.getMeasurementUnitUuid(unitStr
);
575 return getMeasurementUnit(state
, uuid
, unitStr
, unitStr
, unitStr
, null);
577 logger
.warn("MeasurementUnit was not recognized");
587 public Map
<Object
, Map
<String
, ?
extends CdmBase
>> getRelatedObjectsForPartition(ResultSet rs
, BerlinModelImportState state
) {
591 Map
<Object
, Map
<String
, ?
extends CdmBase
>> result
= new HashMap
<Object
, Map
<String
, ?
extends CdmBase
>>();
594 Set
<String
> ecoFactFkSet
= new HashSet
<String
>();
597 handleForeignKey(rs
, ecoFactFkSet
, "ecoFactId");
600 //eco fact derived unit map
601 nameSpace
= AlgaTerraFactEcologyImport
.ECO_FACT_DERIVED_UNIT_NAMESPACE
;
602 cdmClass
= DerivedUnit
.class;
603 idSet
= ecoFactFkSet
;
604 Map
<String
, DerivedUnit
> derivedUnitMap
= (Map
<String
, DerivedUnit
>)getCommonService().getSourcedObjectsByIdInSource(cdmClass
, idSet
, nameSpace
);
605 result
.put(nameSpace
, derivedUnitMap
);
607 } catch (SQLException e
) {
608 throw new RuntimeException(e
);
614 protected boolean doCheck(BerlinModelImportState state
){
615 IOValidator
<BerlinModelImportState
> validator
= new AlgaTerraMorphologyImportValidator();
616 return validator
.validate(state
);
620 protected boolean isIgnore(BerlinModelImportState state
){
621 return ! ((AlgaTerraImportState
)state
).getAlgaTerraConfigurator().isDoMorphology();