Project

General

Profile

Revision f37e7436

IDf37e7436b7a5e7315fea12bf11bddfd41952a254
Parent c0f42391
Child 8ea0f81f

Added by Andreas Kohlbecker over 2 years ago

fix #7834 findInTaxonGraph implemented for Registrations with RegistrationDTOController endpoint

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxonGraph/AbstractHibernateTaxonGraphProcessor.java
206 206
    abstract public Session getSession();
207 207

  
208 208
    public Taxon assureSingleTaxon(TaxonName taxonName) throws TaxonGraphException {
209
        return assureSingleTaxon(taxonName, true);
210
    }
211

  
212
    public Taxon assureSingleTaxon(TaxonName taxonName, boolean createMissing) throws TaxonGraphException {
209 213

  
210 214
        UUID secRefUuid = getSecReferenceUUID();
211 215
        Session session = getSession();
212 216
        TaxonName taxonNamePersisted = session.load(TaxonName.class, taxonName.getId());
213 217

  
214 218
        // filter by secRefUuid
215
        Taxon taxon;
219
        Taxon taxon = null;
216 220
        Set<Taxon> taxa = new HashSet<>();
217 221
        for(Taxon t : taxonName.getTaxa()){
218 222
            if(t.getSec().getUuid().equals(secRefUuid)){
......
221 225
        }
222 226

  
223 227
        if(taxa.size() == 0){
224
            if(taxonNamePersisted != null){
225
                Reference secRef = secReference();
226
                taxon = Taxon.NewInstance(taxonNamePersisted, secRef);
227
                session.saveOrUpdate(taxon);
228
            if(createMissing){
229
                if(taxonNamePersisted != null){
230
                    Reference secRef = secReference();
231
                    taxon = Taxon.NewInstance(taxonNamePersisted, secRef);
232
                    session.saveOrUpdate(taxon);
233
                } else {
234
                    throw new TaxonGraphException("Can't create taxon for deleted name: " + taxonName);
235
                }
228 236
            } else {
229
                throw new TaxonGraphException("Can't create taxon for deleted name: " + taxonName);
237
                if(logger.isDebugEnabled()){
238
                    logger.debug("No taxon found for " + taxonName);
239
                }
230 240
            }
231 241
        } else if(taxa.size() == 1){
232 242
            taxon = taxa.iterator().next();
233 243
        } else {
234 244
            throw new TaxonGraphException("A name to be used in a taxon graph must only have one taxon with the default sec reference [secRef uuid: "+ secRefUuid.toString() +"]");
235 245
        }
236
        return session.load(Taxon.class, taxon.getId());
246
        return taxon != null ? session.load(Taxon.class, taxon.getId()) : null;
237 247
    }
238 248

  
239 249
    protected Reference conceptReference(Reference nomenclaturalReference) {
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxonGraph/TaxonGraphDaoHibernateImpl.java
183 183
        return taxonDao.getSession();
184 184
    }
185 185

  
186

  
187 186
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxonGraph/ITaxonGraphDao.java
12 12
import java.util.UUID;
13 13

  
14 14
import eu.etaxonomy.cdm.model.name.TaxonName;
15
import eu.etaxonomy.cdm.model.taxon.Taxon;
15 16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
16 17
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
17 18

  
......
32 33
    * @param includeUnpublished
33 34
    * @return
34 35
    */
35
   List<TaxonGraphEdgeDTO> listTaxonGraphEdgeDTOs(UUID fromTaxonUuid, UUID toTaxonUuid, TaxonRelationshipType type,
36
    public List<TaxonGraphEdgeDTO> listTaxonGraphEdgeDTOs(UUID fromTaxonUuid, UUID toTaxonUuid, TaxonRelationshipType type,
36 37
           boolean includeUnpublished, Integer pageSize, Integer pageIndex);
37 38

  
38 39
   /**
......
44 45
    * @param includeUnpublished
45 46
    * @return
46 47
    */
47
   long countTaxonGraphEdgeDTOs(UUID fromTaxonUuid, UUID toTaxonUuid, TaxonRelationshipType type,
48
    public long countTaxonGraphEdgeDTOs(UUID fromTaxonUuid, UUID toTaxonUuid, TaxonRelationshipType type,
48 49
           boolean includeUnpublished);
49 50

  
50
    List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException;
51
    public List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException;
51 52

  
52
    List<TaxonGraphEdgeDTO> edges(TaxonName fromName, TaxonName toName, boolean includeUnpublished) throws TaxonGraphException;
53
    public List<TaxonGraphEdgeDTO> edges(TaxonName fromName, TaxonName toName, boolean includeUnpublished) throws TaxonGraphException;
54

  
55
    public Taxon assureSingleTaxon(TaxonName taxonName) throws TaxonGraphException;
56

  
57
    public Taxon assureSingleTaxon(TaxonName taxonName, boolean createMissing) throws TaxonGraphException;
53 58

  
54 59
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/RegistrationController.java
131 131
    }
132 132

  
133 133

  
134

  
135

  
136

  
137 134
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/RegistrationDTOController.java
12 12
import java.io.IOException;
13 13
import java.util.Arrays;
14 14
import java.util.Collection;
15
import java.util.List;
15 16
import java.util.UUID;
16 17

  
17 18
import javax.servlet.http.HttpServletRequest;
......
35 36
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
36 37
import eu.etaxonomy.cdm.model.name.Registration;
37 38
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
39
import eu.etaxonomy.cdm.persistence.query.MatchMode;
38 40
import eu.etaxonomy.cdm.persistence.query.OrderHint;
39 41
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
40 42
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
......
58 60
public class RegistrationDTOController extends AbstractController<Registration, IRegistrationService>
59 61
{
60 62

  
63

  
64
    private static final List<OrderHint> ORDER_BY_IDENTIFIER = Arrays.asList(new OrderHint("specificIdentifier", SortOrder.ASCENDING));
65

  
66
    private static final List<OrderHint> ORDER_BY_SUMMARY = Arrays.asList(new OrderHint("summary", SortOrder.ASCENDING));
67

  
61 68
    public static final Logger logger = Logger.getLogger(RegistrationDTOController.class);
62 69

  
63 70
    public RegistrationDTOController(){
......
156 163
        }
157 164
        Pager<RegistrationDTO> pager = registrationWorkingSetService.pageDTOs(submitterUuid, statusSet,
158 165
                identifierFilterPattern, taxonNameFilterPattern, typeDesignationStatusUuids,
159
                pageSize, pageIndex, Arrays.asList(new OrderHint("specificIdentifier", SortOrder.ASCENDING)));
166
                pageSize, pageIndex, ORDER_BY_IDENTIFIER);
160 167
        return pager;
161 168
    }
162 169

  
......
173 180

  
174 181
        return workingset;
175 182
    }
183

  
184

  
185
    @RequestMapping(value="/registrationDTO/findInTaxonGraph", method = RequestMethod.GET)
186
    public Pager<RegistrationDTO> doPageByTaxomicInclusion(
187
            @RequestParam(value = "taxonNameFilter", required = true) String taxonNameFilterPattern,
188
            @RequestParam(value = "matchMode", required = false) MatchMode matchMode,
189
            @RequestParam(value = "pageNumber", required = false, defaultValue="0") Integer pageIndex,
190
            @RequestParam(value = "pageSize", required = false, defaultValue="30" /*AbstractController.DEFAULT_PAGE_SIZE_VALUE*/ ) Integer pageSize,
191
            HttpServletRequest request,
192
            HttpServletResponse response) {
193

  
194
        logger.info("findInTaxonGraph() " + requestPathAndQuery(request));
195

  
196
        Collection<RegistrationStatus> includedStatus = Arrays.asList(RegistrationStatus.PUBLISHED);
197

  
198
        Pager<RegistrationDTO> regPager = registrationWorkingSetService.findInTaxonGraph(null, includedStatus,
199
                taxonNameFilterPattern, matchMode,
200
                pageSize, pageIndex, ORDER_BY_IDENTIFIER);
201

  
202
        return regPager;
203
    }
176 204
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java
132 132
	 * using the given match mode and initialization strategy
133 133
	 *
134 134
	 * @param name
135
	 * @param matchMode
135
	 * @param matchMode must not be <code>NULL</code>
136 136
	 * @param propertyPaths
137 137
	 * @return
138 138
	 */
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IRegistrationService.java
22 22
import eu.etaxonomy.cdm.model.name.TaxonName;
23 23
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
24 24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.persistence.query.MatchMode;
25 26
import eu.etaxonomy.cdm.persistence.query.OrderHint;
26 27

  
27 28
/**
......
134 135
            String taxonNameFilterPattern, Collection<UUID> typeDesignationStatusUuids, Integer pageSize,
135 136
            Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths);
136 137

  
138
    public Pager<Registration> page(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
139
            Collection<UUID> taxonNameUUIDs,
140
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths);
141

  
142
    public Pager<Registration> pageTaxomicInclusion(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
143
            String taxonNameFilterPattern, MatchMode matchMode,
144
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths);
145

  
137 146
    // ============= functionality to be moved into a "RegistrationManagerBean" ==================
138 147

  
139 148
    public Registration newRegistration();
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/RegistrationServiceImpl.java
18 18
import java.util.Optional;
19 19
import java.util.Set;
20 20
import java.util.UUID;
21
import java.util.stream.Collectors;
21 22

  
22 23
import org.springframework.beans.factory.annotation.Autowired;
23 24
import org.springframework.security.core.Authentication;
......
29 30
import eu.etaxonomy.cdm.api.service.pager.Pager;
30 31
import eu.etaxonomy.cdm.api.service.pager.impl.AbstractPagerImpl;
31 32
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
33
import eu.etaxonomy.cdm.api.service.taxonGraph.ITaxonGraphService;
32 34
import eu.etaxonomy.cdm.api.utility.UserHelper;
33 35
import eu.etaxonomy.cdm.model.common.User;
34 36
import eu.etaxonomy.cdm.model.name.Registration;
......
50 52
 */
51 53
@Service
52 54
@Transactional(readOnly = true)
53
public class RegistrationServiceImpl extends AnnotatableServiceBase<Registration, IRegistrationDao> implements IRegistrationService {
55
public class RegistrationServiceImpl extends AnnotatableServiceBase<Registration, IRegistrationDao>
56
    implements IRegistrationService {
54 57

  
55 58
    /**
56 59
     * {@inheritDoc}
......
67 70
    @Autowired
68 71
    private UserHelper userHelper;
69 72

  
70

  
71 73
    @Autowired
72 74
    private INameService nameService;
73 75

  
76
    @Autowired
77
    private ITaxonGraphService taxonGraphService;
78

  
74 79

  
75 80

  
76 81

  
......
181 186
        return new DefaultPagerImpl<>(pageIndex, numberOfResults, pageSize, results);
182 187
    }
183 188

  
189
    @Override
190
    @Transactional(readOnly = true)
191
    public Pager<Registration> pageTaxomicInclusion(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
192
            String taxonNameFilterPattern, MatchMode matchMode,
193
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths) {
194

  
195
        List<TaxonName> includedNames = taxonGraphService.listIncludedNames(taxonNameFilterPattern, matchMode);
196
        Set<UUID> includedNamesUuids = includedNames.stream().map(TaxonName::getUuid).collect(Collectors.toSet());
197

  
198
        return page(submitterUuid, includedStatus, includedNamesUuids, pageSize, pageIndex, orderHints, propertyPaths);
199
    }
200

  
201
    @Override
202
    @Transactional(readOnly = true)
203
    public Pager<Registration> page(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
204
            Collection<UUID> taxonNameUUIDs,
205
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths) {
206

  
207
        List<Restriction<? extends Object>> restrictions = new ArrayList<>();
208

  
209
        if( !userHelper.userIsAutheticated() || userHelper.userIsAnnonymous() ) {
210
            includedStatus = Arrays.asList(RegistrationStatus.PUBLISHED);
211
        }
212

  
213
        if(submitterUuid != null){
214
            restrictions.add(new Restriction<>("submitter.uuid", null, submitterUuid));
215
        }
216
        if(includedStatus != null && !includedStatus.isEmpty()){
217
            restrictions.add(new Restriction<>("status", null, includedStatus.toArray(new RegistrationStatus[includedStatus.size()])));
218
        }
219

  
220
        if(taxonNameUUIDs != null){
221
            restrictions.add(new Restriction<>("name.uuid", null , taxonNameUUIDs.toArray(new UUID[taxonNameUUIDs.size()])));
222
        }
223

  
224
        long numberOfResults = dao.count(Registration.class, restrictions);
225

  
226
        List<Registration> results = new ArrayList<>();
227
        if(pageIndex == null){
228
            pageIndex = 0;
229
        }
230
        Integer [] limitStart = AbstractPagerImpl.limitStartforRange(numberOfResults, pageIndex, pageSize);
231
        if(limitStart != null) {
232
            results = dao.list(Registration.class, restrictions, limitStart[0], limitStart[1], orderHints, propertyPaths);
233
        }
234

  
235
        return new DefaultPagerImpl<>(pageIndex, numberOfResults, pageSize, results);
236
    }
237

  
184 238
    /**
185 239
     * @param identifier
186 240
     * @param validateUniqueness
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
2992 2992
    }
2993 2993

  
2994 2994
    /**
2995
     * Computes all children and conceptually congruent and included taxa and adds them to the existingTaxa
2996
     * data structure.
2997
     * @return the set of conceptually related taxa for further use
2998
     */
2999
    /**
3000 2995
     * @param uncheckedTaxa
3001 2996
     * @param existingTaxa
3002 2997
     * @param config
3003
     * @return
2998
     *
2999
     * Computes all children and conceptually congruent and included taxa and adds them to the existingTaxa
3000
     * data structure.
3001
     * @return the set of conceptually related taxa for further use
3004 3002
     */
3005 3003
    private Set<Taxon> makeRelatedIncluded(Set<Taxon> uncheckedTaxa, IncludedTaxaDTO existingTaxa, IncludedTaxonConfiguration config) {
3006 3004

  
......
3057 3055
                if (config.includeDoubtful == false && fromRel.isDoubtful()){
3058 3056
                    continue;
3059 3057
                }
3060
                if (fromRel.getType().equals(TaxonRelationshipType.CONGRUENT_TO()) ||
3061
                        !config.onlyCongruent && fromRel.getType().equals(TaxonRelationshipType.INCLUDES()) ||
3062
                        !config.onlyCongruent && fromRel.getType().equals(TaxonRelationshipType.CONGRUENT_OR_INCLUDES())
3063
                        ){
3058
                TaxonRelationshipType fromRelType = fromRel.getType();
3059
                if (fromRelType.equals(TaxonRelationshipType.CONGRUENT_TO()) ||
3060
                        !config.onlyCongruent && (
3061
                            fromRelType.equals(TaxonRelationshipType.INCLUDES()) ||
3062
                            fromRelType.equals(TaxonRelationshipType.CONGRUENT_OR_INCLUDES())
3063
                        )
3064
                    ){
3064 3065
                    result.add(fromRel.getToTaxon());
3065 3066
                }
3066 3067
            }
......
3069 3070
                if (config.includeDoubtful == false && toRel.isDoubtful()){
3070 3071
                    continue;
3071 3072
                }
3072
                if (toRel.getType().equals(TaxonRelationshipType.CONGRUENT_TO())){
3073
                TaxonRelationshipType fromRelType = toRel.getType();
3074
                if (fromRelType.equals(TaxonRelationshipType.CONGRUENT_TO()) ||
3075
                        !config.includeDoubtful && fromRelType.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())){
3073 3076
                    result.add(toRel.getFromTaxon());
3074 3077
                }
3075 3078
            }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/registration/IRegistrationWorkingSetService.java
22 22
import eu.etaxonomy.cdm.model.name.Registration;
23 23
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
24 24
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
25
import eu.etaxonomy.cdm.persistence.query.MatchMode;
25 26
import eu.etaxonomy.cdm.persistence.query.OrderHint;
26 27

  
27 28
/**
......
71 72
    Pager<RegistrationDTO> pageDTOs(UUID submitterUuid, Collection<RegistrationStatus> includedStatus, String identifierFilterPattern, String taxonNameFilterPattern, Collection<UUID> typeDesignationStatusUuids, Integer pageSize, Integer pageIndex,
72 73
            List<OrderHint> orderHints);
73 74

  
75
    /**
76
     * @param submitterUuid
77
     * @param includedStatus
78
     * @param taxonNameFilterPattern
79
     * @param matchMode
80
     * @param pageSize
81
     * @param pageIndex
82
     * @param orderHints
83
     * @param propertyPaths
84
     * @return
85
     */
86
    Pager<RegistrationDTO> findInTaxonGraph(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
87
            String taxonNameFilterPattern, MatchMode matchMode, Integer pageSize, Integer pageIndex,
88
            List<OrderHint> orderHints);
89

  
90

  
91

  
74 92
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/registration/RegistrationWorkingSetService.java
44 44
import eu.etaxonomy.cdm.model.reference.Reference;
45 45
import eu.etaxonomy.cdm.model.reference.ReferenceType;
46 46
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
47
import eu.etaxonomy.cdm.persistence.query.MatchMode;
47 48
import eu.etaxonomy.cdm.persistence.query.OrderHint;
48 49
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
49 50

  
......
256 257

  
257 258
    }
258 259

  
260
    @Override
261
    @Transactional(readOnly = true)
262
    public Pager<RegistrationDTO> findInTaxonGraph(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
263
            String taxonNameFilterPattern, MatchMode matchMode,
264
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints) {
265

  
266
        Pager<Registration> regPager = repo.getRegistrationService().pageTaxomicInclusion(null, includedStatus,
267
            taxonNameFilterPattern, matchMode,
268
            pageSize, pageIndex, orderHints, REGISTRATION_DTO_INIT_STRATEGY);
269

  
270
        return convertToDTOPager(regPager);
271
    }
272

  
259 273

  
260 274
    /**
261 275
     * {@inheritDoc}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/taxonGraph/ITaxonGraphService.java
11 11
import java.util.List;
12 12
import java.util.UUID;
13 13

  
14
import eu.etaxonomy.cdm.model.name.TaxonName;
14 15
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
15 16
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
17
import eu.etaxonomy.cdm.persistence.query.MatchMode;
16 18

  
17 19
/**
18 20
 * @author a.kohlbecker
......
21 23
 */
22 24
public interface ITaxonGraphService {
23 25

  
24
    List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException;
26
    public List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException;
27

  
28
    public List<TaxonName> listIncludedNames(String queryString, MatchMode matchMode);
25 29

  
26 30
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/taxonGraph/TaxonGraphServiceImpl.java
8 8
*/
9 9
package eu.etaxonomy.cdm.api.service.taxonGraph;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.List;
12 13
import java.util.UUID;
14
import java.util.stream.Collectors;
13 15

  
16
import org.apache.log4j.Logger;
14 17
import org.springframework.beans.factory.annotation.Autowired;
15 18
import org.springframework.stereotype.Service;
16 19
import org.springframework.transaction.annotation.Transactional;
17 20

  
21
import eu.etaxonomy.cdm.api.service.INameService;
22
import eu.etaxonomy.cdm.api.service.ITaxonService;
23
import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;
24
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
25
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO.IncludedTaxon;
26
import eu.etaxonomy.cdm.model.name.TaxonName;
27
import eu.etaxonomy.cdm.model.taxon.Taxon;
28
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
18 29
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.ITaxonGraphDao;
19 30
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
20 31
import eu.etaxonomy.cdm.persistence.dto.TaxonGraphEdgeDTO;
32
import eu.etaxonomy.cdm.persistence.query.MatchMode;
21 33

  
22 34
/**
23 35
 * @author a.kohlbecker
......
28 40
@Transactional(readOnly = true)
29 41
public class TaxonGraphServiceImpl implements ITaxonGraphService {
30 42

  
43
    static private final Logger logger = Logger.getLogger(TaxonGraphServiceImpl.class);
44

  
45

  
31 46
    @Autowired
32 47
    private ITaxonGraphDao taxonGraphDao;
33 48

  
49
    @Autowired
50
    private INameService nameService;
51

  
52
    @Autowired
53
    private ITaxonService taxonService;
54

  
34 55

  
35 56
    @Override
36 57
    public List<TaxonGraphEdgeDTO> edges(UUID fromtaxonUuid, UUID toTaxonUuid, boolean includeUnpublished) throws TaxonGraphException{
37 58
        return taxonGraphDao.edges(fromtaxonUuid, toTaxonUuid, includeUnpublished);
38 59
    }
60

  
61
    @Override
62
    public List<TaxonName> listIncludedNames(String queryString, MatchMode matchMode) {
63

  
64
        if(matchMode == null){
65
            matchMode = MatchMode.BEGINNING;
66
        }
67

  
68
        List<TaxonName> includedNames = new ArrayList<>();
69

  
70
        IncludedTaxonConfiguration configuration = new IncludedTaxonConfiguration(null, false, false, false);
71

  
72
        List<TaxonName> matchingNames = nameService.findNamesByTitleCache(queryString, matchMode, null);
73
        for(TaxonName name : matchingNames){
74
            if(logger.isDebugEnabled()){
75
                logger.debug("pageIncludedNames() - matching name: " + name.getTitleCache());
76
            }
77
            try {
78
                Taxon graphTaxon = taxonGraphDao.assureSingleTaxon(name, false);
79
                IncludedTaxaDTO includedTaxaDTO = taxonService.listIncludedTaxa(graphTaxon.getUuid(), configuration);
80
                List<UUID> includedTaxaUUIDs = includedTaxaDTO.getIncludedTaxa().stream().map(IncludedTaxon::getTaxonUuid).collect(Collectors.toList());
81
                List<TaxonBase> includedTaxa = taxonService.load(includedTaxaUUIDs, null);
82
                List<TaxonName> iclNames = includedTaxa.stream().map(TaxonBase::getName).collect(Collectors.toList());
83
                includedNames.addAll(iclNames);
84

  
85
            } catch(TaxonGraphException e){
86
                logger.error(e.getMessage());
87
            }
88
        }
89
        return includedNames;
90

  
91
    }
39 92
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)