Project

General

Profile

Revision c0babef0

IDc0babef08efa6b57d6890a4a7839c55de0719ceb
Parent 0a7237ca
Child f9e8f532

Added by Katja Luther over 1 year ago

revert condensed distribution string and some performance issues in cdm light

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
23 23
import org.springframework.beans.factory.annotation.Autowired;
24 24
import org.springframework.stereotype.Component;
25 25

  
26
import eu.etaxonomy.cdm.api.service.dto.CondensedDistribution;
27 26
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager;
28 27
import eu.etaxonomy.cdm.common.CdmUtils;
29 28
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
......
344 343
                    csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE)] = getTitleCache(taxon.getSec());
345 344
                }
346 345
                if (taxon.getSec() != null){
347
                    if (state.getReferenceFromStore(taxon.getSec().getId()) == null){
346
                    if (!state.getReferenceStore().contains((taxon.getSec().getUuid()))){
348 347
                        handleReference(state, taxon.getSec());
349 348
                    }
350 349
                }
......
681 680
                        state.getResult().addWarning("There is an individual association with no specimen associated (Taxon "+ taxon.getTitleCache() + "(" + taxon.getUuid() +"). Could not be exported.");
682 681
                        continue;
683 682
                    }else{
684
                        if (state.getSpecimenFromStore(indAssociation.getAssociatedSpecimenOrObservation().getId()) == null){
683
                        if (!state.getSpecimenStore().contains((indAssociation.getAssociatedSpecimenOrObservation().getUuid())) ){
685 684
                            SpecimenOrObservationBase<?> specimenBase = HibernateProxyHelper.deproxy(indAssociation.getAssociatedSpecimenOrObservation(), SpecimenOrObservationBase.class);
686 685

  
687 686
                            handleSpecimen(state, specimenBase);
......
758 757
                    continue;
759 758
                }
760 759
                if (ref != null){
761
                    if (state.getReferenceFromStore(ref.getId()) == null){
760
                    if (!state.getReferenceStore().contains(ref.getUuid()) ){
762 761
                        handleReference(state, ref);
763 762

  
764 763
                    }
......
813 812
                        cdmBaseStr(element) + ": " + e.getMessage());
814 813
            }
815 814
        }
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
        }
815
//        if(state.getConfig().isCreateCondensedDistributionString()){
816
//            List<Language> langs = new ArrayList<Language>();
817
//            langs.add(Language.ENGLISH());
818
//
819
//            CondensedDistribution conDis = geoService.getCondensedDistribution(distributions, true, null,null,state.getConfig().getCondensedDistributionRecipe(), langs );
820
//            CdmLightExportTable tableCondensed = CdmLightExportTable.CONDENSED_DISTRIBUTION_FACT;
821
//            String[] csvLine = new  String[table.getSize()];
822
//            csvLine[tableCondensed.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, taxon);
823
//            csvLine[tableCondensed.getIndex(CdmLightExportTable.FACT_TEXT)] = conDis.toString();
824
//            state.getProcessor().put(tableCondensed, taxon, csvLine);
825
//        }
827 826

  
828 827
    }
829 828

  
......
1044 1043
            Reference nomRef = name.getNomenclaturalReference();
1045 1044

  
1046 1045
            if (nomRef != null){
1047
                if (state.getReferenceFromStore(nomRef.getId()) == null){
1046
                if (!state.getReferenceStore().contains(nomRef.getUuid())){
1048 1047
                    handleReference(state, nomRef);
1049 1048
                }
1050 1049
                csvLine[table.getIndex(CdmLightExportTable.REFERENCE_FK)] = getId(state, nomRef);
......
1152 1151

  
1153 1152
            HomotypicalGroup group =name.getHomotypicalGroup();
1154 1153

  
1155
            if (state.getHomotypicalGroupFromStore(group.getId()) == null){
1154
            if (state.containsHomotypicalGroupFromStore(group.getUuid())){
1156 1155
                handleHomotypicalGroup(state, HibernateProxyHelper.deproxy(group, HomotypicalGroup.class));
1157 1156
            }
1158 1157
            csvLine[table.getIndex(CdmLightExportTable.HOMOTYPIC_GROUP_FK)] = getId(state, group);
......
1732 1731
            }
1733 1732

  
1734 1733
            csvLine[table.getIndex(CdmLightExportTable.IN_REFERENCE)] = getId(state, reference.getInReference());
1735
            if (reference.getInReference() != null && state.getReferenceFromStore(reference.getInReference().getId()) == null){
1734
            if (reference.getInReference() != null && !state.getReferenceStore().contains(reference.getInReference().getUuid())){
1736 1735
                handleReference(state, reference.getInReference());
1737 1736
            }
1738 1737
            if ( reference.getInstitution() != null){ csvLine[table.getIndex(CdmLightExportTable.INSTITUTION)] = reference.getInstitution().getTitleCache();}
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;
15 14
import eu.etaxonomy.cdm.io.common.CsvIOConfigurator;
16 15
import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
17 16
import eu.etaxonomy.cdm.io.common.ExportResultType;
......
41 40
    private boolean createZipFile = false;
42 41

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

  
48 47
    private Comparator<TaxonNodeDto> comparator;
......
163 162
    /**
164 163
     * @return
165 164
     */
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
    }
165
//    public boolean isCreateCondensedDistributionString() {
166
//        return isCreateCondensedDistributionString;
167
//    }
168
//
169
//    public void setCreateCondensedDistributionString(boolean isCreateCondensedDistributionString) {
170
//        this.isCreateCondensedDistributionString = isCreateCondensedDistributionString;
171
//    }
172
//
173
//
174
//    /**
175
//     * @return
176
//     */
177
//    public CondensedDistributionRecipe getCondensedDistributionRecipe() {
178
//        return recipe;
179
//    }
180
//
181
//    public void setCondensedDistributionRecipe(CondensedDistributionRecipe recipe) {
182
//        this.recipe = recipe;
183
//    }
185 184

  
186 185

  
187 186
    /**
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportResultProcessor.java
114 114

  
115 115
        if (!result.isEmpty() ){
116 116
            state.setAuthorStore(new HashMap<>());
117
            state.setHomotypicalGroupStore(new HashMap<>());
118
            state.setReferenceStore(new HashMap<>());
119
            state.setSpecimenStore(new HashMap<>());
117
            state.setHomotypicalGroupStore(new ArrayList<>());
118
            state.setReferenceStore(new ArrayList());
119
            state.setSpecimenStore(new ArrayList());
120 120
            state.setNodeChildrenMap(new HashMap<>());
121 121
            //Replace quotes by double quotes
122 122
            for (CdmLightExportTable table: result.keySet()){
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportState.java
9 9
package eu.etaxonomy.cdm.io.cdmLight;
10 10

  
11 11
import java.io.File;
12
import java.util.ArrayList;
12 13
import java.util.HashMap;
13 14
import java.util.List;
14 15
import java.util.Map;
......
40 41

  
41 42
    private TaxonBase<?> actualTaxonBase;
42 43

  
43
    private Map<Integer, HomotypicalGroup> homotypicalGroupStore = new HashMap<>();
44
    private ArrayList<UUID> homotypicalGroupStore = new ArrayList();
44 45
    private Map<Integer, TeamOrPersonBase<?>> authorStore = new HashMap<>();
45 46

  
46
    private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
47
    private Map<Integer, Reference> referenceStore = new HashMap<>();
47
    private List<UUID> specimenStore = new ArrayList();
48
    //private Map<Integer, SpecimenOrObservationBase> specimenStore = new HashMap<>();
49
    private List<UUID> referenceStore = new ArrayList();
48 50
    private Map<Integer, UUID> nameStore = new HashMap<>();
49 51
    private Map<UUID,List<TaxonNodeDto>> nodeChildrenMap = new HashMap<>();
50 52
    private Map<UUID, OrderHelper> orderHelperMap = new HashMap();
......
101 103
    /**
102 104
     * @return the homotypicalGroupStore
103 105
     */
104
    public Map<Integer, HomotypicalGroup> getHomotypicalGroupStore() {
106
    public ArrayList<UUID> getHomotypicalGroupStore() {
105 107
        return homotypicalGroupStore;
106 108
    }
107 109

  
......
109 111
     * @param homotypicalGroupStore the homotypicalGroupStore to set
110 112
     */
111 113
    public void addHomotypicalGroupToStore(HomotypicalGroup homotypicalGroup) {
112
        this.homotypicalGroupStore.put(homotypicalGroup.getId(), homotypicalGroup);
114
        this.homotypicalGroupStore.add(homotypicalGroup.getUuid());
113 115
    }
114 116

  
115
    public HomotypicalGroup getHomotypicalGroupFromStore(Integer id){
116
        return homotypicalGroupStore.get(id);
117
    public boolean containsHomotypicalGroupFromStore(UUID id){
118
        return homotypicalGroupStore.contains(id);
117 119
    }
118 120

  
119 121
    /**
120 122
     * @return the specimenStore
121 123
     */
122
    public Map<Integer, SpecimenOrObservationBase> getSpecimenStore() {
124
    public List<UUID> getSpecimenStore() {
123 125
        return specimenStore;
124 126
    }
125 127

  
......
128 130
    /**
129 131
     * @param specimenStore the specimenStore to set
130 132
     */
131
    public void setSpecimenStore(Map<Integer, SpecimenOrObservationBase> specimenStore) {
133
    public void setSpecimenStore(List<UUID> specimenStore) {
132 134
        this.specimenStore = specimenStore;
133 135
    }
134 136

  
......
139 141
    /**
140 142
     * @param homotypicalGroupStore the homotypicalGroupStore to set
141 143
     */
142
    public void setHomotypicalGroupStore(Map<Integer, HomotypicalGroup> homotypicalGroupStore) {
144
    public void setHomotypicalGroupStore(ArrayList<UUID> homotypicalGroupStore) {
143 145
        this.homotypicalGroupStore = homotypicalGroupStore;
144 146
    }
145 147

  
......
171 173

  
172 174

  
173 175
    public void addSpecimenToStore(SpecimenOrObservationBase specimen) {
174
        this.specimenStore.put(specimen.getId(), specimen);
176
        this.specimenStore.add(specimen.getUuid());
175 177

  
176 178
    }
177 179

  
178 180

  
179
    public SpecimenOrObservationBase getSpecimenFromStore(Integer id){
180
        return specimenStore.get(id);
181
    }
182

  
183
    public Reference getReferenceFromStore(Integer id){
184
        return referenceStore.get(id);
185
    }
186 181
    public void addReferenceToStore(Reference ref) {
187
        this.referenceStore.put(ref.getId(), ref);
182
        this.referenceStore.add(ref.getUuid());
188 183

  
189 184
    }
190 185
    /**
191 186
     * @param referenceStore the referenceStore to set
192 187
     */
193
    public void setReferenceStore(Map<Integer, Reference> referenceStore) {
188
    public void setReferenceStore(List<UUID> referenceStore) {
194 189
        this.referenceStore = referenceStore;
195 190
    }
196 191
    /**
197 192
     * @return the referenceStore
198 193
     */
199
    public Map<Integer, Reference> getReferenceStore() {
194
    public List<UUID> getReferenceStore() {
200 195
        return referenceStore;
201 196
    }
202 197

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)