Project

General

Profile

Revision e867c225

IDe867c225e7bcfe76841819fc1a33a84bfa6a53cd
Parent de671fe5
Child 98df38b9

Added by Andreas Müller about 2 months ago

ref #7450 implement interfaces and signatures for setPublishForSubtree for misapplications and ppSyns (not yet implemented)

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
713 713
        queryStr += " AND syn.publish != :publish ";
714 714
        return setPublish(publish, queryStr, monitor);
715 715
    }
716
    @Override
717
    public int countPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish, boolean includeSharedTaxa) {
718
        return 0;
719
    }
720
    @Override
721
    public Set<TaxonBase> setPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish,
722
            boolean includeSharedTaxa, IProgressMonitor monitor) {
723
        return new HashSet<>();
724
    }
725

  
716 726

  
717 727
    private static final int DEFAULT_PARTITION_SIZE = 100;
718 728
    /**
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonNodeDao.java
186 186
            boolean includeSharedTaxa, IProgressMonitor monitor);
187 187

  
188 188
    /**
189
     * @param subTreeIndex
190
     * @param publish
191
     * @param includeSharedTaxa
192
     * @return
193
     */
194
    public int countPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish, boolean includeSharedTaxa);
195
    public Set<TaxonBase> setPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish,
196
            boolean includeSharedTaxa, IProgressMonitor monitor);
197

  
198
    /**
189 199
     * @param parent
190 200
     * @return
191 201
     */
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonNodeService.java
275 275

  
276 276
    /**
277 277
     * Sets the publish flag for all taxa and/or synonyms of the subtree.
278
     * @param subtreeUuid
279
     * @param publish
280
     * @param includeAcceptedTaxa
281
     * @param includeSynonyms
282
     * @param overwriteExistingAccepted
283
     * @param overwriteExistingSynonyms
284
     * @param includeSharedTaxa
285
     * @param progressMonitor
286
     * @return
287
     * @deprecated use {@link #setPublishForSubtree(PublishForSubtreeConfigurator)} instead
288
     */
289
    @Deprecated
290
    public UpdateResult setPublishForSubtree(UUID subtreeUuid, boolean publish, boolean includeAcceptedTaxa,
291
            boolean includeSynonyms, boolean includeSharedTaxa, IProgressMonitor progressMonitor);
292

  
293
    /**
294
     * Sets the publish flag for all taxa and/or synonyms of the subtree.
295 278
     * @param configurator
296 279
     * @return
297 280
     */
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
1048 1048
            subTreeIndex = TreeIndex.NewInstance(subTree.treeIndex());
1049 1049
            int count = includeAcceptedTaxa ? dao.countPublishForSubtreeAcceptedTaxa(subTreeIndex, publish, includeSharedTaxa):0;
1050 1050
            count += includeSynonyms ? dao.countPublishForSubtreeSynonyms(subTreeIndex, publish, includeSharedTaxa):0;
1051
            count += includeSynonyms ? dao.countPublishForSubtreeRelatedTaxa(subTreeIndex, publish, includeSharedTaxa):0;
1051 1052
            monitor.beginTask("Update publish flag", count);
1052 1053
        }
1053 1054

  
......
1062 1063
            Set<TaxonBase> updatedSynonyms = dao.setPublishForSubtreeSynonyms(subTreeIndex, publish, includeSharedTaxa, monitor);
1063 1064
            result.addUpdatedObjects(updatedSynonyms);
1064 1065
        }
1065

  
1066
        if (includeAcceptedTaxa){
1067
            monitor.subTask("Update Related Taxa");
1068
            Set<TaxonBase> updatedTaxa = dao.setPublishForSubtreeRelatedTaxa(subTreeIndex, publish, includeSharedTaxa, monitor);
1069
            result.addUpdatedObjects(updatedTaxa);
1070
        }
1066 1071

  
1067 1072
        monitor.done();
1068 1073
        return result;
1069 1074
    }
1070 1075

  
1071 1076
    @Override
1072
    @Transactional(readOnly=false)
1073
    @Deprecated
1074
    public UpdateResult setPublishForSubtree(UUID subtreeUuid, boolean publish, boolean includeAcceptedTaxa,
1075
            boolean includeSynonyms, boolean includeSharedTaxa, IProgressMonitor monitor) {
1076
        PublishForSubtreeConfigurator configurator = new PublishForSubtreeConfigurator(subtreeUuid, publish, monitor);
1077
        return setPublishForSubtree(configurator);
1078
    }
1079

  
1080
    @Override
1081 1077
    public long count(TaxonNodeFilter filter){
1082 1078
        return nodeFilterDao.count(filter);
1083 1079
    }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/PublishForSubtreeConfigurator.java
8 8
*/
9 9
package eu.etaxonomy.cdm.api.service.config;
10 10

  
11
import java.util.HashSet;
12
import java.util.Set;
11 13
import java.util.UUID;
12 14

  
13 15
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
14 17

  
15 18
/**
16 19
 * Configurator for the setPublishForSubtree operation.
......
25 28

  
26 29
    private boolean publish = false;
27 30

  
31

  
32
    //TODO UUIDs ??
33
    private Set<TaxonRelationshipType> includedRelationTypes = new HashSet<>();
34

  
35

  
36
    public static PublishForSubtreeConfigurator NewInstance(UUID subtreeUuid, boolean publish,
37
            IProgressMonitor monitor) {
38
        PublishForSubtreeConfigurator result = new PublishForSubtreeConfigurator(subtreeUuid, publish, monitor);
39
        return result;
40
    }
41

  
42
    public static PublishForSubtreeConfigurator NewInstance(UUID subtreeUuid, boolean publish,
43
            boolean includeAcceptedTaxa, boolean includeSynonyms,
44
            boolean includeSharedTaxa, IProgressMonitor monitor) {
45
        PublishForSubtreeConfigurator result = new PublishForSubtreeConfigurator(subtreeUuid, publish, includeAcceptedTaxa,
46
                includeSynonyms, includeSharedTaxa, monitor);
47
        return result;
48
    }
49

  
50
// ****************************** CONSTRUCTOR ******************************/
51

  
28 52
    /**
29 53
     * @param subtreeUuid
30 54
     * @param newSecundum
31 55
     */
32
    public PublishForSubtreeConfigurator(UUID subtreeUuid, boolean publish, IProgressMonitor monitor) {
56
    private PublishForSubtreeConfigurator(UUID subtreeUuid, boolean publish, IProgressMonitor monitor) {
33 57
        super(subtreeUuid, monitor);
34 58
        this.publish = publish;
35 59
    }
36 60

  
37
    private PublishForSubtreeConfigurator(UUID subtreeUuid, boolean includeAcceptedTaxa, boolean includeSynonyms,
38
            boolean includeSharedTaxa, IProgressMonitor monitor, boolean publish) {
61
    private PublishForSubtreeConfigurator(UUID subtreeUuid, boolean publish, boolean includeAcceptedTaxa, boolean includeSynonyms,
62
            boolean includeSharedTaxa, IProgressMonitor monitor) {
39 63
        super(subtreeUuid, includeAcceptedTaxa, includeSynonyms, includeSharedTaxa, monitor);
40 64
        this.publish = publish;
41 65
    }
......
50 74
        this.publish = publish;
51 75
    }
52 76

  
77
    public Set<TaxonRelationshipType> getIncludedRelationTypes() {
78
        return includedRelationTypes;
79
    }
80
    public void setIncludedRelationTypes(Set<TaxonRelationshipType> includedRelationTypes) {
81
        this.includedRelationTypes = includedRelationTypes;
82
    }
83

  
53 84

  
54 85

  
55 86
}
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImplTest.java
29 29
import org.unitils.dbunit.annotation.DataSet;
30 30
import org.unitils.spring.annotation.SpringBeanByType;
31 31

  
32
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
32 33
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
33 34
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
34 35
import eu.etaxonomy.cdm.model.common.CdmBase;
......
891 892
//        SecundumForSubtreeConfigurator config = new SetPublishForSubtreeConfigurator(subTreeUuid);
892 893
//        config.setNewSecundum(newSec);
893 894
        boolean publish = false;
894
        taxonNodeService.setPublishForSubtree(subTreeUuid,  publish, true, true, true, null);
895
        taxonNodeService.setPublishForSubtree(PublishForSubtreeConfigurator.NewInstance(subTreeUuid,  publish, true, true, true, null));
895 896

  
896 897
        commitAndStartNewTransaction(new String[]{});
897 898
        Assert.assertEquals(publish, taxonService.find(1).isPublish());
......
917 918
//        SecundumForSubtreeConfigurator config = new SetPublishForSubtreeConfigurator(subTreeUuid, newSec, null);
918 919
//        config.setIncludeSynonyms(false);
919 920
        boolean publish = false;
920
        taxonNodeService.setPublishForSubtree(subTreeUuid,  publish, true, false, true, null);
921
        taxonNodeService.setPublishForSubtree(PublishForSubtreeConfigurator.NewInstance(subTreeUuid,  publish, true, false, true, null));
921 922

  
922 923
        commitAndStartNewTransaction();
923 924
        Assert.assertEquals(publish, taxonService.find(1).isPublish());
......
943 944
//        SecundumForSubtreeConfigurator config = new SetPublishForSubtreeConfigurator(subTreeUuid, newSec, null);
944 945
//        config.setIncludeAcceptedTaxa(false);
945 946
        boolean publish = false;
946
        taxonNodeService.setPublishForSubtree(subTreeUuid, publish, false, true, true, null);
947
        taxonNodeService.setPublishForSubtree(PublishForSubtreeConfigurator.NewInstance(subTreeUuid, publish, false, true, true, null));
947 948

  
948 949
        commitAndStartNewTransaction(new String[]{});
949 950
        Assert.assertEquals(true, taxonService.find(1).isPublish());
......
970 971
     //   SecundumForSubtreeConfigurator config = new SetPublishForSubtreeConfigurator(subTreeUuid, newSec, null);
971 972
   //     config.setIncludeSharedTaxa(false);
972 973
        boolean publish = false;
973
        taxonNodeService.setPublishForSubtree(subTreeUuid, publish, true, true, false, null);
974
        taxonNodeService.setPublishForSubtree(PublishForSubtreeConfigurator.NewInstance(subTreeUuid, publish, true, true, false, null));
974 975

  
975 976
        commitAndStartNewTransaction(new String[]{});
976 977
        Assert.assertEquals("Shared taxon must not be set", true, taxonService.find(1).isPublish());

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)