Project

General

Profile

Revision 0a7237ca

ID0a7237cab905e6cc3d48596598e42c42dc6aa960
Parent a0e2b61c
Child c0babef0

Added by Katja Luther about 2 years ago

add condensed distribution string to cdm light export

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
20 20
import java.util.UUID;
21 21

  
22 22
import org.apache.commons.lang3.StringUtils;
23
import org.springframework.beans.factory.annotation.Autowired;
23 24
import org.springframework.stereotype.Component;
24 25

  
26
import eu.etaxonomy.cdm.api.service.dto.CondensedDistribution;
25 27
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager;
26 28
import eu.etaxonomy.cdm.common.CdmUtils;
27 29
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
30
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
28 31
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
29 32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
30 33
import eu.etaxonomy.cdm.io.common.CdmExportBase;
......
74 77
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
75 78
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
76 79
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
80
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
77 81
import eu.etaxonomy.cdm.model.reference.Reference;
78 82
import eu.etaxonomy.cdm.model.reference.ReferenceType;
79 83
import eu.etaxonomy.cdm.model.taxon.Classification;
......
109 113
    private static final String TROPICOS_NAME_IDENTIFIER = "Tropicos Name Identifier";
110 114
    private static final String WFO_NAME_IDENTIFIER = "WFO Name Identifier";
111 115

  
112

  
116
    @Autowired
117
    IEditGeoService geoService;
113 118

  
114 119
    public CdmLightClassificationExport() {
115 120
        super();
......
746 751
        Set<DescriptionElementSource> sources = element.getSources();
747 752

  
748 753
        for (DescriptionElementSource source: sources){
749

  
754
            if (!(source.getType().equals(OriginalSourceType.Import) && state.getConfig().isFilterImportSources())){
750 755
                String[] csvLine = new  String[table.getSize()];
751 756
                Reference ref = source.getCitation();
752 757
                if ((ref == null) && (source.getNameUsedInSource() == null)){
......
767 772
                    continue;
768 773
                }
769 774
                state.getProcessor().put(table, source, csvLine);
775
            }
770 776

  
771 777
        }
772 778
        } catch (Exception e) {
......
782 788
     */
783 789
    private void handleDistributionFacts(CdmLightExportState state, Taxon taxon, List<DescriptionElementBase> distributionFacts) {
784 790
        CdmLightExportTable table = CdmLightExportTable.GEOGRAPHIC_AREA_FACT;
785

  
791
        Set<Distribution>distributions = new HashSet();
786 792
        for (DescriptionElementBase element: distributionFacts){
787 793
            try {
788 794
                if (element instanceof Distribution){
789 795
                    String[] csvLine = new  String[table.getSize()];
790 796
                    Distribution distribution = (Distribution)element;
797
                    distributions.add(distribution);
791 798
                    csvLine[table.getIndex(CdmLightExportTable.FACT_ID)] = getId(state, element);
792 799
                    handleSource(state, element, table);
793 800
                    csvLine[table.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, taxon);
......
806 813
                        cdmBaseStr(element) + ": " + e.getMessage());
807 814
            }
808 815
        }
816
        if(state.getConfig().isCreateCondensedDistributionString()){
817
            List<Language> langs = new ArrayList<Language>();
818
            langs.add(Language.ENGLISH());
819

  
820
            CondensedDistribution conDis = geoService.getCondensedDistribution(distributions, true, null,null,state.getConfig().getCondensedDistributionRecipe(), langs );
821
            CdmLightExportTable tableCondensed = CdmLightExportTable.CONDENSED_DISTRIBUTION_FACT;
822
            String[] csvLine = new  String[table.getSize()];
823
            csvLine[tableCondensed.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, taxon);
824
            csvLine[tableCondensed.getIndex(CdmLightExportTable.FACT_TEXT)] = conDis.toString();
825
            state.getProcessor().put(tableCondensed, taxon, csvLine);
826
        }
827

  
809 828
    }
810 829

  
811 830
    /**
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportConfigurator.java
11 11
import java.io.File;
12 12
import java.util.Comparator;
13 13

  
14
import eu.etaxonomy.cdm.ext.geo.CondensedDistributionRecipe;
14 15
import eu.etaxonomy.cdm.io.common.CsvIOConfigurator;
15 16
import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
16 17
import eu.etaxonomy.cdm.io.common.ExportResultType;
......
40 41
    private boolean createZipFile = false;
41 42

  
42 43
    private boolean isFilterIntextReferences = true;
44
    private boolean isCreateCondensedDistributionString = true;
45
    private CondensedDistributionRecipe recipe = CondensedDistributionRecipe.EuroPlusMed;
46
    private boolean isFilterImportSources = true;
43 47

  
44 48
    private Comparator<TaxonNodeDto> comparator;
45 49

  
......
156 160
    }
157 161

  
158 162

  
163
    /**
164
     * @return
165
     */
166
    public boolean isCreateCondensedDistributionString() {
167
        return isCreateCondensedDistributionString;
168
    }
169

  
170
    public void setCreateCondensedDistributionString(boolean isCreateCondensedDistributionString) {
171
        this.isCreateCondensedDistributionString = isCreateCondensedDistributionString;
172
    }
173

  
174

  
175
    /**
176
     * @return
177
     */
178
    public CondensedDistributionRecipe getCondensedDistributionRecipe() {
179
        return recipe;
180
    }
181

  
182
    public void setCondensedDistributionRecipe(CondensedDistributionRecipe recipe) {
183
        this.recipe = recipe;
184
    }
185

  
186

  
187
    /**
188
     * @return
189
     */
190
    public boolean isFilterImportSources() {
191
        return isFilterImportSources;
192
    }
193

  
194
    public void setFilterImportSources(boolean isFilterImportSources) {
195
        this.isFilterImportSources = isFilterImportSources;
196
    }
197

  
159 198
//    public Set<UUID> getTaxonNodeUuids() {
160 199
//        return taxonNodeUuids;
161 200
//    }
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportTable.java
34 34
    FACT_SOURCES("FactSources", factSourcesColumns()),
35 35
    IDENTIFIER("NameIdentifier", identifierColumns()),
36 36
    MEDIA("MediaFact", mediaColumns()),
37
    CONDENSED_DISTRIBUTION_FACT("CondensedDistributionFact", compressedDistributionFactColumns()),
37 38
    NAME_FACT("NameFact", nameFactColumns())
38 39

  
39 40
    ;
......
234 235
    /**
235 236
     * @return
236 237
     */
238
    private static String[] compressedDistributionFactColumns() {
239
        return new String[]{FACT_ID, TAXON_FK, FACT_TEXT};
240
    }
241

  
242

  
243

  
244

  
245

  
246

  
247
    /**
248
     * @return
249
     */
237 250
    private Object usageFactColumns() {
238 251
        return new String[]{FACT_ID, TAXON_FK, FACT_TEXT, LANGUAGE, MEDIA_URI, FACT_CATEGORY};
239 252
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)