Project

General

Profile

Revision 8f006e1e

ID8f006e1e7dd176b5249aee378757f573fb22f887
Parent e6bec461
Child 404c44e6

Added by Andreas Müller almost 3 years ago

fix #7180 fix #7175 refactor (CdmLight) and implementd (DwC-A) publish flag filtering

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
208 208
            state.getResult().setState(ExportResultState.INCOMPLETE_WITH_ERROR);
209 209
        }else{
210 210
            Taxon taxon = taxonNode.getTaxon();
211
            if (!state.getConfig().isIncludeUnpublishedTaxa() && !taxon.isPublish()){
212
                return;
213
            }
214 211

  
215 212
             try{
216 213
                TaxonName name = taxon.getName();
......
681 678

  
682 679
    /**
683 680
     * @param state
684
     * @param syn
681
     * @param synonym
685 682
     */
686
    private void handleSynonym(CdmLightExportState state, Synonym syn) {
683
    private void handleSynonym(CdmLightExportState state, Synonym synonym) {
687 684
       try {
688
           if (!syn.isPublish() && !state.getConfig().isIncludeUnpublishedTaxa()){
685
           if (isUnpublished(state.getConfig(), synonym)){
689 686
               return;
690 687
           }
691
           TaxonName name = syn.getName();
688
           TaxonName name = synonym.getName();
692 689
           handleName(state, name);
693 690

  
694 691
           CdmLightExportTable table = CdmLightExportTable.SYNONYM;
695 692
           String[] csvLine = new String[table.getSize()];
696 693

  
697
           csvLine[table.getIndex(CdmLightExportTable.SYNONYM_ID)] = getId(state, syn);
698
           csvLine[table.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, syn.getAcceptedTaxon());
694
           csvLine[table.getIndex(CdmLightExportTable.SYNONYM_ID)] = getId(state, synonym);
695
           csvLine[table.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, synonym.getAcceptedTaxon());
699 696
           csvLine[table.getIndex(CdmLightExportTable.NAME_FK)] = getId(state, name);
700
           csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE_FK)] = getId(state, syn.getSec());
701
           csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE)] = getTitleCache(syn.getSec());
702
           if (syn.isProParte()) {
697
           csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE_FK)] = getId(state, synonym.getSec());
698
           csvLine[table.getIndex(CdmLightExportTable.SEC_REFERENCE)] = getTitleCache(synonym.getSec());
699
           if (synonym.isProParte()) {
703 700
        	   csvLine[table.getIndex(CdmLightExportTable.IS_PRO_PARTE)] = "1";
704 701
           }else {
705 702
        	   csvLine[table.getIndex(CdmLightExportTable.IS_PRO_PARTE)] = "0";
706 703
           }
707 704

  
708
           state.getProcessor().put(table, syn, csvLine);
705
           state.getProcessor().put(table, synonym, csvLine);
709 706
        } catch (Exception e) {
710 707
            state.getResult().addException(e, "An unexpected error occurred when handling synonym " +
711
                    cdmBaseStr(syn) + ": " + e.getMessage());
708
                    cdmBaseStr(synonym) + ": " + e.getMessage());
712 709
        }
713 710
    }
714 711

  
712

  
715 713
    /**
716 714
     * @param state
717 715
     * @param name
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmExportBase.java
27 27
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportState;
28 28
import eu.etaxonomy.cdm.model.common.CdmBase;
29 29
import eu.etaxonomy.cdm.model.taxon.Classification;
30
import eu.etaxonomy.cdm.model.taxon.Synonym;
30 31
import eu.etaxonomy.cdm.model.taxon.Taxon;
31 32
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32 33
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
......
173 174
        return node.getUuid();
174 175
    }
175 176

  
177

  
178
    /**
179
     * <code>true</code> if neither synonym has state publish nor
180
     * taxon node filter includes unpublished taxa.
181
     */
182
    protected boolean isUnpublished(CONFIG config, Synonym synonym) {
183
        return ! (synonym.isPublish()
184
                || config.getTaxonNodeFilter().isIncludeUnpublished());
185
    }
186

  
176 187
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/ExportConfiguratorBase.java
35 35
	private ICdmDataSource source;
36 36
	private DEST destination;
37 37
	protected IDatabase sourceReference;
38
	protected boolean includeUnpublishedTaxa;
39 38

  
40 39
    protected Class<ICdmIO>[] ioClassList;
41 40

  
......
141 140
	}
142 141

  
143 142

  
144
    public boolean isIncludeUnpublishedTaxa() {
145
        return includeUnpublishedTaxa;
146
    }
147

  
148

  
149
    public void setIncludeUnpublishedTaxa(boolean includeUnpublished) {
150
        this.includeUnpublishedTaxa = includeUnpublished;
151
    }
152

  
153 143
	/**
154 144
	 * Returns a new instance of <code>CdmApplicationController</code> created by the values of this configuration.
155 145
	 * @return
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTaxonExport.java
110 110
	private void handleSynonyms(DwcaTaxExportState state, Taxon taxon, DwcaTaxExportFile file,
111 111
	        Classification classification, DwcaMetaDataRecord metaRecord) throws FileNotFoundException, UnsupportedEncodingException, IOException {
112 112
		for (Synonym synonym :taxon.getSynonyms() ){
113
			DwcaTaxonRecord record = new DwcaTaxonRecord(metaRecord, state.getConfig());
113
           if (isUnpublished(state.getConfig(), synonym)){
114
               return;
115
           }
116

  
117
		    DwcaTaxonRecord record = new DwcaTaxonRecord(metaRecord, state.getConfig());
114 118
			SynonymType type = synonym.getType();
115 119
			boolean isProParte = synonym.isProParte();
116 120
			boolean isPartial = synonym.isPartial();
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/checklist/DwcaExportController.java
278 278
                            TaxonNodeFilter taxonNodeFilter = TaxonNodeFilter.NewInstance(
279 279
                                    classificationUuids, subtreeUuids, taxonNodeUuids, taxonUuids,
280 280
                                    areaUuids, minRank, maxRank);
281
                            taxonNodeFilter.setIncludeUnpublished(includeUnpublished);
281 282
                            DwcaTaxExportConfigurator config = setDwcaTaxExportConfigurator(
282 283
                                    cacheFile, monitor, taxonNodeFilter, doSynonyms, doMisapplieds,
283 284
                                    doVernaculars, doDistributions, doDescriptions, doImages,
284 285
                                    doTypesAndSpecimen, doResourceRelations, doReferences,
285
                                    withHigherClassification, includeHeader, includeUnpublished );
286
                                    withHigherClassification, includeHeader);
286 287
                            performExport(cacheFile, monitor, config,
287 288
                                    downloadTokenValueId, origin, response);
288 289
                        }
......
381 382
            Boolean doDescriptions, Boolean doImages,
382 383
            Boolean doTypesAndSpecimen, Boolean doResourceRelations,
383 384
            Boolean doReferences, Boolean withHigherClassification,
384
            Boolean includeHeader,
385
            Boolean includeUnpublished) {
385
            Boolean includeHeader) {
386 386

  
387 387
        if(cacheFile == null){
388 388
            String destination = System.getProperty("java.io.tmpdir");
......
406 406
        config.setDoResourceRelations(doResourceRelations);
407 407
        config.setWithHigherClassification(withHigherClassification);
408 408
        config.setHasHeaderLines(includeHeader);
409
        config.setIncludeUnpublishedTaxa(includeUnpublished);
410 409

  
411 410
        config.setProgressMonitor(progressMonitor);
412 411

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)