}
}
+ protected String getValue(STATE state, String key){
+ return getValue(state.getOriginalRecord(), key);
+ }
/**
* Returns the taxon for the given CDM uuid. If no taxon exists for the given id
String colNameCache, String colNameTitleCache, String colTaxonTitleCache,
Class<T> clazz, String line) {
- Map<String, String> record = state.getOriginalRecord();
+ Map<String, String> record = getRecord(state);
String strUuidTaxon = record.get(colTaxonUuid);
if (strUuidTaxon != null){
UUID uuidTaxon;
}
}
+ protected Map<String, String> getRecord(STATE state) {
+ Map<String, String> record = state.getOriginalRecord();
+ return record;
+ }
+
/**
* @see #getTaxonByCdmId(ExcelImportState, String, String, String, String, Class, String)
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.altitude.in;
+
+import java.math.BigDecimal;
+import java.util.UUID;
+
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase;
+import eu.etaxonomy.cdm.io.fact.in.FactExcelImportBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ *
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+@Component
+public class AltitudeExcelImport
+ extends FactExcelImportBase<AltitudeExcelImportState, AltitudeExcelImportConfigurator, ExcelRowBase>{
+
+ private static final long serialVersionUID = 8264900898340386516L;
+
+ private static final String COL_ALTITUDE_MIN = "Altitude min";
+ private static final String COL_ALTITUDE_MAX = "Altitude max";
+
+
+ @Override
+ protected void doFirstPass(AltitudeExcelImportState state, Taxon taxon,
+ String line, String linePure){
+
+ if (taxon == null){
+ return;
+ }
+
+ UUID uuid = Feature.uuidAltitude;
+ String featureLabel = "Altitude";
+ Feature feature = getFeature(state, uuid, featureLabel, featureLabel, null, null);
+
+ String minStr = getValue(state, COL_ALTITUDE_MIN);
+ String maxStr = getValue(state, COL_ALTITUDE_MAX);
+
+ BigDecimal min = new BigDecimal(minStr);
+ BigDecimal max = new BigDecimal(maxStr);
+
+ //source
+ String id = null;
+ String idNamespace = null;
+ Reference reference = getSourceReference(state);
+
+
+ QuantitativeData qd = QuantitativeData.NewMinMaxInstance(feature, min, max);
+
+ TaxonDescription taxonDescription = this.getTaxonDescription(taxon, reference, !IMAGE_GALLERY, true);
+ taxonDescription.addElement(qd);
+ qd.addImportSource(id, idNamespace, reference, linePure);
+
+ }
+
+ @Override
+ protected boolean isIgnore(AltitudeExcelImportState state) {
+ return false;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.altitude.in;
+
+import java.net.URI;
+import java.util.UUID;
+
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+import eu.etaxonomy.cdm.io.fact.in.FactExcelImportConfiguratorBase;
+
+/**
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public class AltitudeExcelImportConfigurator
+ extends FactExcelImportConfiguratorBase{
+
+ private static final long serialVersionUID = -6403743396163163359L;
+
+ private UUID featureUuid;
+
+ public static AltitudeExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
+ return new AltitudeExcelImportConfigurator(uri, destination, null);
+ }
+
+ /**
+ * How to fill the media title if not explicit value is given.
+ */
+ public enum MediaTitleEnum{
+ NONE,
+ NAME_CACHE, //use name cache
+ NAME_TITLE_CACHE, //use name title cache
+ TAXON_TITLE_CACHE, //use taxon title
+ FILE_NAME //use file name
+ }
+
+ private AltitudeExcelImportConfigurator(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
+ super(uri, destination, transformer);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public AltitudeExcelImportState getNewState() {
+ return new AltitudeExcelImportState(this);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void makeIoClassList() {
+ ioClassList = new Class[]{
+ AltitudeExcelImport.class,
+ };
+ }
+
+ public UUID getFeatureUuid() {
+ return featureUuid;
+ }
+
+ public void setFeatureUuid(UUID featureUuid) {
+ this.featureUuid = featureUuid;
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.altitude.in;
+
+import java.util.UUID;
+
+/**
+ * Data holder class for altitude import for taxa.
+ *
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public class AltitudeExcelImportRow {
+ private UUID taxonUuid;
+ private String fullTaxonName;
+ private String fileName;
+ private String copyright;
+ private String artist;
+
+}
--- /dev/null
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.altitude.in;
+
+import eu.etaxonomy.cdm.io.fact.in.FactExcelImportStateBase;
+
+/**
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public class AltitudeExcelImportState
+ extends FactExcelImportStateBase<AltitudeExcelImportConfigurator>{
+
+ public AltitudeExcelImportState(AltitudeExcelImportConfigurator config) {
+ super(config);
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2020 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.in;
+
+import java.util.Map;
+
+import eu.etaxonomy.cdm.io.excel.common.ExcelImportBase;
+import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public abstract class FactExcelImportBase<STATE extends FactExcelImportStateBase<CONFIG>, CONFIG extends FactExcelImportConfiguratorBase, ROW extends ExcelRowBase>
+ extends ExcelImportBase<STATE, CONFIG, ExcelRowBase>{
+
+ private static final long serialVersionUID = 2233954525898978414L;
+
+ protected static final String COL_TAXON_UUID = "taxonUuid";
+ protected static final String COL_NAME_CACHE = "nameCache";
+ protected static final String COL_NAME_TITLE = "nameTitle";
+ protected static final String COL_TAXON_TITLE = "taxonTitle";
+
+ @Override
+ protected void analyzeRecord(Map<String, String> record, STATE state) {
+ // do nothing
+ }
+
+ @Override
+ protected void firstPass(STATE state) {
+ Map<String, String> record = state.getOriginalRecord();
+ String line = "row " + state.getCurrentLine() + ": ";
+ String linePure = "row " + state.getCurrentLine();
+ System.out.println(linePure);
+
+ //taxon
+ Taxon taxon = getTaxonByCdmId(state, COL_TAXON_UUID,
+ COL_NAME_CACHE, COL_NAME_TITLE, COL_TAXON_TITLE,
+ Taxon.class, linePure);
+
+ doFirstPass(state, taxon, line, linePure);
+ }
+
+ protected abstract void doFirstPass(STATE state, Taxon taxon, String line, String linePure);
+
+ @Override
+ protected void secondPass(STATE state) {
+ //override if necessary
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2020 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.in;
+
+import java.net.URI;
+
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
+import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
+
+/**
+ * Configurator base class for taxon fact excel imports.
+ *
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public abstract class FactExcelImportConfiguratorBase
+ extends ExcelImportConfiguratorBase{
+
+ private static final long serialVersionUID = 1649010514975388511L;
+
+ protected FactExcelImportConfiguratorBase(URI uri, ICdmDataSource destination, IInputTransformer transformer) {
+ super(uri, destination, transformer);
+ }
+
+}
--- /dev/null
+/**
+* Copyright (C) 2020 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.io.fact.in;
+
+import eu.etaxonomy.cdm.io.excel.common.ExcelImportState;
+import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase;
+
+/**
+ * @author a.mueller
+ * @since 28.05.2020
+ */
+public abstract class FactExcelImportStateBase<CONFIG extends FactExcelImportConfiguratorBase>
+ extends ExcelImportState<CONFIG, ExcelRowBase>{
+
+ public FactExcelImportStateBase(CONFIG config) {
+ super(config);
+ }
+}