Project

General

Profile

Revision 0e601fdc

ID0e601fdcc9380911b9074d67645747547392ba57
Parent 744bd412
Child f859201a

Added by Andreas Müller 10 months ago

ref #8509 fix sourceFk handling in PESI taxon export

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
1872 1872
	}
1873 1873

  
1874 1874
	/**
1875
     * Returns the <code>sourceFk</code> attribute which is
1876
     * a link to a reference.
1877
     * @see #8796
1878
     * @return The <code>sourceFk</code> attribute.
1879
     * @see MethodMapper
1880
     */
1881
    @SuppressWarnings("unused")  //used by methodmapper
1882
    private static Integer getSourceFk(TaxonBase<?> taxonBase, PesiExportState state) {
1883
        if (taxonBase.getSec() != null){
1884
            return state.getDbId(taxonBase.getSec());
1885
        }else{
1886
            Set<IdentifiableSource> sources = getPesiSources(taxonBase);
1887
            for (IdentifiableSource source : sources){
1888
                Reference ref = source.getCitation();
1889
                if (ref != null){
1890
                    return state.getDbId(ref);
1891
                }
1892
            }
1893
        }
1894
        logger.warn("No source found for " + taxonBase.getTitleCache());
1895
        return null;
1896
    }
1897

  
1898
    /**
1899
     * Returns the <code>sourceFk</code> attribute which is
1900
     * a link to a reference.
1901
     *
1902
     * @return The <code>sourceFk</code> attribute.
1903
     * @see MethodMapper
1904
     * @see #8796
1905
     */
1906
    @SuppressWarnings("unused")  //used by methodmapper
1907
    private static Integer getSourceFk(TaxonName taxonName) {
1908
        //for now pure names (only coming from E+M) have no source
1909
        //according to SQL scripts (#8796)
1910
        return null;
1911
    }
1912

  
1913
	/**
1875 1914
	 * Returns the <code>IdInSource</code> attribute.
1876 1915
	 * @param taxonName The {@link TaxonNameBase TaxonName}.
1877 1916
	 * @return The <code>IdInSource</code> attribute.
......
2230 2269
		PesiExportMapping mapping = new PesiExportMapping(dbTableName);
2231 2270

  
2232 2271
		mapping.addMapper(IdMapper.NewInstance("TaxonId"));
2233
		mapping.addMapper(DbObjectMapper.NewInstance("sec", "sourceFk")); //OLD:mapping.addMapper(MethodMapper.NewInstance("SourceFK", this.getClass(), "getSourceFk", standardMethodParameter, PesiExportState.class));
2272
		mapping.addMapper(MethodMapper.NewInstance("SourceFk", this.getClass(), "getSourceFk", standardMethodParameter, PesiExportState.class));
2234 2273
		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusFk", this.getClass(), "getTaxonStatusFk", standardMethodParameter, PesiExportState.class));
2235 2274
		mapping.addMapper(MethodMapper.NewInstance("TaxonStatusCache", this.getClass(), "getTaxonStatusCache", standardMethodParameter, PesiExportState.class));
2236 2275

  
......
2279 2318

  
2280 2319
		mapping.addMapper(IdMapper.NewInstance("TaxonId"));
2281 2320

  
2282
		mapping.addMapper(MethodMapper.NewInstance("KingdomFk", this, TaxonName.class));
2321
		mapping.addMapper(MethodMapper.NewInstance("SourceFk", this, TaxonName.class, PesiExportState.class));  //for now is only null
2322
        mapping.addMapper(MethodMapper.NewInstance("KingdomFk", this, TaxonName.class));
2283 2323
		mapping.addMapper(MethodMapper.NewInstance("RankFk", this, TaxonName.class));
2284 2324
		mapping.addMapper(MethodMapper.NewInstance("RankCache", this, TaxonName.class, PesiExportState.class));
2285 2325
		mapping.addMapper(DbConstantMapper.NewInstance("TaxonStatusFk", Types.INTEGER, PesiTransformer.T_STATUS_UNACCEPTED));

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)