Project

General

Profile

Revision bca2429d

IDbca2429dcfc44c9e930a1ca08832325643395c42
Parent 727a2e1a
Child 6eb9a868

Added by Andreas Kohlbecker over 3 years ago

ref #7348 implementing find service for registrations with user, typeDesignationStatus, registrationStatus, identifier and taxonname filters

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/RegistrationController.java
10 10
package eu.etaxonomy.cdm.remote.controller;
11 11

  
12 12
import java.io.IOException;
13
import java.util.ArrayList;
14 13
import java.util.Arrays;
15
import java.util.List;
16 14
import java.util.UUID;
17 15

  
18 16
import javax.servlet.http.HttpServletRequest;
......
30 28
import eu.etaxonomy.cdm.api.service.pager.Pager;
31 29
import eu.etaxonomy.cdm.model.name.Registration;
32 30
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
33
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
34
import eu.etaxonomy.cdm.persistence.query.MatchMode;
35 31
import io.swagger.annotations.Api;
36 32

  
37 33
/**
......
91 87

  
92 88
        String identifier = readPathParameter(request, "/registration/identifier/");
93 89

  
94
        Pager<Registration> regPager = pageByIdentifier(identifier, 0, 2, response);
90
        Pager<Registration> regPager = service.pageByIdentifier(identifier, 0, 2, getInitializationStrategy());
95 91

  
96 92
        if(regPager.getCount() == 1){
97 93
            return regPager.getRecords().get(0);
......
115 111

  
116 112
        String identifier = readPathParameter(request, "/registration/identifier/");
117 113

  
118
        Pager<Registration> regPager = pageByIdentifier(identifier, pageIndex, pageSize, response);
119

  
114
        Pager<Registration> regPager = service.pageByIdentifier(identifier, pageIndex, pageSize, getInitializationStrategy());
120 115
        return regPager;
121 116
    }
122 117

  
123
    /**
124
     * @param identifier
125
     * @param validateUniqueness
126
     * @param response
127
     * @return
128
     * @throws IOException
129
     */
130
    protected Pager<Registration> pageByIdentifier(String identifier, Integer pageIndex,  Integer pageSize,
131
            HttpServletResponse response) throws IOException {
132 118

  
133
        List<Restriction<?>> restrictions = new ArrayList<>();
134
        if( !userHelper.userIsAutheticated() || userHelper.userIsAnnonymous() ) {
135
            restrictions.add(new Restriction<>("status", null, RegistrationStatus.PUBLISHED));
136
        }
137 119

  
138
        Pager<Registration> regPager = service.pageByRestrictions(Registration.class, "identifier", identifier, MatchMode.EXACT,
139
                restrictions, pageSize, pageIndex, null, getInitializationStrategy());
140 120

  
141 121

  
142
        return regPager;
143
    }
144

  
145 122
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/RegistrationDTOController.java
10 10
package eu.etaxonomy.cdm.remote.controller;
11 11

  
12 12
import java.io.IOException;
13
import java.util.ArrayList;
14 13
import java.util.Arrays;
15
import java.util.List;
14
import java.util.Collection;
15
import java.util.UUID;
16 16

  
17 17
import javax.servlet.http.HttpServletRequest;
18 18
import javax.servlet.http.HttpServletResponse;
......
20 20
import org.apache.log4j.Logger;
21 21
import org.springframework.beans.factory.annotation.Autowired;
22 22
import org.springframework.stereotype.Controller;
23
import org.springframework.web.bind.WebDataBinder;
24
import org.springframework.web.bind.annotation.InitBinder;
23 25
import org.springframework.web.bind.annotation.RequestMapping;
24 26
import org.springframework.web.bind.annotation.RequestMethod;
25 27
import org.springframework.web.bind.annotation.RequestParam;
......
30 32
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
31 33
import eu.etaxonomy.cdm.model.name.Registration;
32 34
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
33
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
34
import eu.etaxonomy.cdm.persistence.query.MatchMode;
35
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
36
import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;
37
import eu.etaxonomy.cdm.remote.editor.UuidList;
38
import eu.etaxonomy.cdm.remote.editor.term.RegistrationStatusList;
35 39
import io.swagger.annotations.Api;
36 40

  
37 41
/**
......
72 76
    @Autowired
73 77
    RegistrationController registrationController;
74 78

  
79
    @InitBinder
80
    public void initBinder(WebDataBinder binder) {
81
        binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());
82
        binder.registerCustomEditor(RegistrationStatusList.class, new RegistrationStatusList().propertyEditor());
83
        binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor());
84
    }
75 85

  
76 86
    @RequestMapping(value="identifier/**", method = RequestMethod.GET)
77 87
    public RegistrationDTO doGetByIdentifier(
......
107 117
        return regDTOPager;
108 118
    }
109 119

  
110
    /**
111
     * @param identifier
112
     * @param validateUniqueness
113
     * @param response
114
     * @return
115
     * @throws IOException
116
     */
117
    protected Pager<Registration> pageByIdentifier(String identifier, boolean validateUniqueness,
120

  
121
    @RequestMapping(value="find", method = RequestMethod.GET)
122
    public Pager<RegistrationDTO> doFind(
123
            @RequestParam(value = "submitterUuid", required=false) UUID submitterUuid,
124
            @RequestParam(value = "status", required=false) RegistrationStatusList status,
125
            @RequestParam(value = "typeDesignationStatusUuids", required=false) UuidList typeDesignationStatusUuids,
126
            @RequestParam(value = "identifierFilterPattern", required=false) String identifierFilterPattern,
127
            @RequestParam(value = "taxonNameFilterPattern", required=false) String taxonNameFilterPattern,
128
            @RequestParam(value = "pageNumber", required=false) Integer pageIndex,
129
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
130
            HttpServletRequest request,
118 131
            HttpServletResponse response) throws IOException {
119
        List<Restriction<?>> restrictions = new ArrayList<>();
120
        if( !userHelper.userIsAutheticated() || userHelper.userIsAnnonymous() ) {
121
            restrictions.add(new Restriction<>("status", null, RegistrationStatus.PUBLISHED));
122
        }
123 132

  
124
        Pager<Registration> regPager = service.pageByRestrictions(Registration.class, "identifier", identifier, MatchMode.EXACT, restrictions, 2, 0, null, getInitializationStrategy());
133
        logger.info("doFind() " + requestPathAndQuery(request));
125 134

  
126
        if(validateUniqueness && regPager.getCount() > 1){
127
            HttpStatusMessage.create("The identifier " + identifier + " refrences multiple registrations", HttpServletResponse.SC_PRECONDITION_FAILED).send(response);
135
        Collection<RegistrationStatus> statusSet = null;
136
        if(status != null){
137
            statusSet = status.asSet();
128 138
        }
129
        return regPager;
139
        Pager<RegistrationDTO> pager = registrationWorkingSetService.pageDTOs(submitterUuid, statusSet,
140
                identifierFilterPattern, taxonNameFilterPattern, typeDesignationStatusUuids,
141
                pageSize, pageIndex, null);
142
        return pager;
130 143
    }
131 144

  
132 145
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/term/EnumTermList.java
1
package eu.etaxonomy.cdm.remote.editor.term;
2

  
3
import java.util.ArrayList;
4
import java.util.HashSet;
5
import java.util.Iterator;
6
import java.util.Set;
7

  
8
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
9
import eu.etaxonomy.cdm.model.common.IEnumTerm;
10

  
11

  
12
/**
13
 * @author a.kohlbecker
14
 * @since Jun 25, 2013
15
 *
16
 */
17
abstract public class EnumTermList<T extends IEnumTerm<T>> extends ArrayList<T> {
18

  
19
    private static final long serialVersionUID = 1L;
20

  
21
    Class<T> enumTermClass;
22

  
23
    protected EnumTermList(Class<T> enumTermClass) {
24
        this.enumTermClass = enumTermClass;
25
    }
26

  
27
    public Set<T> asSet() {
28
        HashSet<T> tmpSet = new HashSet<T>(this.size());
29

  
30
        Iterator<T> e = iterator();
31
        while (e.hasNext()) {
32
            tmpSet.add(e.next());
33
        }
34
        return tmpSet;
35
    }
36

  
37
    public EnumTermListPropertyEditor<T> propertyEditor() {
38
        return new EnumTermListPropertyEditor<T>(
39
                EnumeratedTermVoc.getVoc(enumTermClass));
40
    }
41

  
42
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/term/EnumTermListPropertyEditor.java
1
/**
2
 * Copyright (C) 2013 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.cdm.remote.editor.term;
10

  
11
import java.util.ArrayList;
12
import java.util.List;
13

  
14
import org.apache.commons.lang.StringUtils;
15

  
16
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
17
import eu.etaxonomy.cdm.model.common.IEnumTerm;
18

  
19
/**
20
 * This PropertyEditor translates concatenated lists string identifiers into
21
 * {@link eu.etaxonomy.cdm.model.common.IEnumTerm} instances. The instances can be identified by the value of the
22
 * {@link eu.etaxonomy.cdm.model.common.IKeyTerm#getKey() key} property. The separator for concatenations is the colon: ','
23
 *
24
 * @author a.kohlbecker
25
 * @since Jun 25, 2013
26
 *
27
 */
28
public class EnumTermListPropertyEditor<T extends IEnumTerm<T>> extends EnumTermPropertyEditor<T> {
29

  
30
    public EnumTermListPropertyEditor(EnumeratedTermVoc<T> delegateVoc){
31
        super(delegateVoc);
32
    }
33

  
34
    @Override
35
    public void setAsText(String text) {
36

  
37
        List<T> termList = null;
38

  
39
        String[] tokens = StringUtils.split(text, ',');
40
        if(tokens != null && tokens.length > 0){
41
            termList = new ArrayList<>(tokens.length);
42
            for(String key : tokens){
43
                termList.add(super.textToTerm(key));
44
            }
45
        }
46
        setValue(termList);
47
    }
48

  
49
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/term/EnumTermPropertyEditor.java
1
/**
2
 * Copyright (C) 2013 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.cdm.remote.editor.term;
10

  
11
import java.beans.PropertyEditorSupport;
12

  
13
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
14
import eu.etaxonomy.cdm.model.common.IEnumTerm;
15

  
16
/**
17
 * This PropertyEditor translates a single string into a {@link eu.etaxonomy.cdm.model.common.IEnumTerm} instance.
18
 * The instance can be identified by the value of the
19
 * {@link eu.etaxonomy.cdm.model.common.IKeyTerm#getKey() key} property.
20
 *
21
 * @author a.kohlbecker
22
 * @since Jun 25, 2013
23
 *
24
 */
25
public class EnumTermPropertyEditor<T extends IEnumTerm<T>> extends PropertyEditorSupport {
26

  
27
    protected final EnumeratedTermVoc<T> delegateVoc;
28

  
29
    public EnumTermPropertyEditor(EnumeratedTermVoc<T> delegateVoc){
30
        super();
31
        this.delegateVoc = delegateVoc;
32
    }
33

  
34
    @Override
35
    public void setAsText(String text) {
36
        setValue(textToTerm(text));
37
    }
38

  
39
    /**
40
     * @param text
41
     * @return
42
     */
43
    protected T textToTerm(String text) {
44
        T term = delegateVoc.getByKey(text);
45
        if(term == null){
46
            throw new java.lang.IllegalArgumentException("No EnumTerm instance in " + delegateVoc.toString() + " found for the key: " + text);
47
        }
48
        return term;
49
    }
50
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/editor/term/RegistrationStatusList.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.editor.term;
10

  
11
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
12

  
13
/**
14
 * @author a.kohlbecker
15
 * @since Jul 13, 2018
16
 *
17
 */
18
public class RegistrationStatusList extends EnumTermList<RegistrationStatus> {
19

  
20
    /**
21
     *
22
     */
23
    public RegistrationStatusList() {
24
        super(RegistrationStatus.class);
25
    }
26

  
27
    private static final long serialVersionUID = 8936508095351613591L;
28

  
29
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/json/processor/value/MapJSONValueProcessor.java
9 9
package eu.etaxonomy.cdm.remote.json.processor.value;
10 10

  
11 11
import java.util.Map;
12
import java.util.Objects;
12 13

  
13 14
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager;
14 15
import eu.etaxonomy.cdm.model.common.LanguageString;
......
35 36
	        JSONObject json = new JSONObject();
36 37
            for(TypeDesignationStatusBase<?> key : map.keySet()){
37 38
                TermRepresentation_L10n term_L10n = new TermRepresentation_L10n(key, false);
38
                json.element(term_L10n.getLabel(), map.get(key), jsonConfig);
39
                String label = Objects.toString(term_L10n.getLabel(), "NULL");
40
                json.element(label, map.get(key), jsonConfig);
39 41
            }
40 42
            return json;
41 43
	    } else if(value instanceof Map){
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IRegistrationService.java
9 9
package eu.etaxonomy.cdm.api.service;
10 10

  
11 11
import java.io.IOException;
12
import java.util.ArrayList;
13 12
import java.util.Collection;
14 13
import java.util.List;
15 14
import java.util.Optional;
16 15
import java.util.Set;
16
import java.util.UUID;
17 17

  
18 18
import eu.etaxonomy.cdm.api.service.pager.Pager;
19 19
import eu.etaxonomy.cdm.model.common.User;
......
21 21
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
22 22
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
23 23
import eu.etaxonomy.cdm.model.reference.Reference;
24
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
25
import eu.etaxonomy.cdm.persistence.query.MatchMode;
26 24
import eu.etaxonomy.cdm.persistence.query.OrderHint;
27 25

  
28 26
/**
......
119 117

  
120 118
    Pager<Registration> pageByIdentifier(String identifier, Integer pageIndex, Integer pageSize, List<String> propertyPaths) throws IOException;
121 119

  
120
    /**
121
     * @param submitterUuid
122
     * @param includedStatusUuids
123
     * @param identifierFilterPattern
124
     * @param taxonNameFilterPattern
125
     * @param typeDesignationStatusUuids
126
     * @param pageSize
127
     * @param pageIndex
128
     * @param orderHints
129
     * @param propertyPaths
130
     * @return
131
     */
132
    Pager<Registration> page(UUID submitterUuid, Collection<RegistrationStatus> includedStatus, String identifierFilterPattern,
133
            String taxonNameFilterPattern, Collection<UUID> typeDesignationStatusUuids, Integer pageSize,
134
            Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths);
135

  
122 136
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/RegistrationServiceImpl.java
10 10

  
11 11
import java.io.IOException;
12 12
import java.util.ArrayList;
13
import java.util.Arrays;
13 14
import java.util.Collection;
14 15
import java.util.List;
15 16
import java.util.Optional;
16 17
import java.util.Set;
18
import java.util.UUID;
17 19

  
18 20
import org.springframework.beans.factory.annotation.Autowired;
19 21
import org.springframework.beans.factory.annotation.Qualifier;
......
60 62
     * {@inheritDoc}
61 63
     */
62 64
    @Override
65
    @Transactional(readOnly = true)
63 66
    public Pager<Registration> page(Optional<Reference> reference, Collection<RegistrationStatus> includedStatus,
64 67
            Integer pageSize, Integer pageIndex, List<String> propertyPaths) {
65 68

  
......
78 81
     * {@inheritDoc}
79 82
     */
80 83
    @Override
84
    @Transactional(readOnly = true)
81 85
    public Pager<Registration> page(User submitter, Collection<RegistrationStatus> includedStatus,
82 86
            String identifierFilterPattern, String taxonNameFilterPattern, Set<TypeDesignationStatusBase> typeDesignationStatus,
83 87
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths) {
84 88

  
85 89
        List<Restriction<? extends Object>> restrictions = new ArrayList<>();
86 90

  
91
        if( !userHelper.userIsAutheticated() || userHelper.userIsAnnonymous() ) {
92
            includedStatus = Arrays.asList(RegistrationStatus.PUBLISHED);
93
        }
94

  
87 95
        if(submitter != null){
88 96
            restrictions.add(new Restriction<>("submitter", MatchMode.EXACT, submitter));
89 97
        }
......
111 119
        return new DefaultPagerImpl<>(pageIndex, numberOfResults, pageSize, results);
112 120
    }
113 121

  
122
    @Override
123
    @Transactional(readOnly = true)
124
    public Pager<Registration> page(UUID submitterUuid, Collection<RegistrationStatus> includedStatus,
125
            String identifierFilterPattern, String taxonNameFilterPattern, Collection<UUID> typeDesignationStatusUuids,
126
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints, List<String> propertyPaths) {
127

  
128
        List<Restriction<? extends Object>> restrictions = new ArrayList<>();
129

  
130
        if( !userHelper.userIsAutheticated() || userHelper.userIsAnnonymous() ) {
131
            includedStatus = Arrays.asList(RegistrationStatus.PUBLISHED);
132
        }
133

  
134
        if(submitterUuid != null){
135
            restrictions.add(new Restriction<>("submitter.uuid", null, submitterUuid));
136
        }
137
        if(includedStatus != null && !includedStatus.isEmpty()){
138
            restrictions.add(new Restriction<>("status", null, includedStatus.toArray(new RegistrationStatus[includedStatus.size()])));
139
        }
140
        if(identifierFilterPattern != null){
141
            restrictions.add(new Restriction<>("identifier", MatchMode.LIKE, identifierFilterPattern));
142
        }
143
        if(taxonNameFilterPattern != null){
144
            restrictions.add(new Restriction<>("name.titleCache", MatchMode.LIKE, taxonNameFilterPattern));
145
        }
146
        if(typeDesignationStatusUuids != null){
147
            restrictions.add(new Restriction<>("typeDesignations.typeStatus.uuid", null, typeDesignationStatusUuids.toArray(new UUID[typeDesignationStatusUuids.size()])));
148
        }
149

  
150
        long numberOfResults = dao.count(Registration.class, restrictions);
151

  
152
        List<Registration> results = new ArrayList<>();
153
        if(pageIndex == null){
154
            pageIndex = 0;
155
        }
156
        Integer [] limitStart = AbstractPagerImpl.limitStartforRange(numberOfResults, pageIndex, pageSize);
157
        if(limitStart != null) {
158
            results = dao.list(Registration.class, restrictions, limitStart[0], limitStart[1], orderHints, propertyPaths);
159
        }
160

  
161
        return new DefaultPagerImpl<>(pageIndex, numberOfResults, pageSize, results);
162
    }
163

  
114 164
    /**
115 165
     * @param identifier
116 166
     * @param validateUniqueness
......
119 169
     * @throws IOException
120 170
     */
121 171
    @Override
172
    @Transactional(readOnly = true)
122 173
    public Pager<Registration> pageByIdentifier(String identifier, Integer pageIndex,  Integer pageSize, List<String> propertyPaths) throws IOException {
123 174

  
124 175
        List<Restriction<?>> restrictions = new ArrayList<>();
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/pager/impl/AbstractPagerImpl.java
321 321
     *
322 322
     * @param numberOfResults
323 323
     * @param pageIndex
324
     *  will be set to <code>0</code> if <code>null</code>
324 325
     * @param pageSize
325 326
     * @return An <code>Integer</code> array containing limit and start: <code>new int[]{limit, start}</code> or null if there is no result in the range of
326 327
     *  <code>pageIndex</code> and <code>pageSize</code>.
327 328
     *
328 329
     */
329 330
    public static Integer[] limitStartforRange(Long numberOfResults, Integer pageIndex, Integer pageSize) {
331
        if(pageIndex == null){
332
            pageIndex = 0;
333
        }
330 334
        if(hasResultsInRange(numberOfResults, pageIndex, pageSize)){
331 335
            return  new Integer[]{PagerUtils.limitFor(pageSize), PagerUtils.startFor(pageSize, pageIndex)};
332 336
        }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/registration/IRegistrationWorkingSetService.java
10 10

  
11 11
import java.io.IOException;
12 12
import java.util.Collection;
13
import java.util.List;
13 14
import java.util.Set;
14 15
import java.util.UUID;
15 16

  
......
18 19
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
19 20
import eu.etaxonomy.cdm.api.service.pager.Pager;
20 21
import eu.etaxonomy.cdm.model.common.User;
22
import eu.etaxonomy.cdm.model.name.Registration;
21 23
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
22 24
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
25
import eu.etaxonomy.cdm.persistence.query.OrderHint;
23 26

  
24 27
/**
25 28
 * @author a.kohlbecker
......
40 43

  
41 44
    public Pager<RegistrationDTO> pageDTOs(User submitter, Collection<RegistrationStatus> includedStatus,
42 45
            String identifierFilterPattern, String taxonNameFilterPattern, Set<TypeDesignationStatusBase> typeStatusFilter,
43
            Integer pageSize, Integer pageIndex);
46
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints);
44 47

  
45 48
    public Pager<RegistrationDTO> pageDTOs(String identifier, Integer pageIndex,  Integer pageSize) throws IOException;
46 49

  
......
63 66

  
64 67
    public Set<RegistrationDTO> loadBlockingRegistrations(UUID blockedRegistrationUuid);
65 68

  
69
    Pager<RegistrationDTO> convertToDTOPager(Pager<Registration> regPager);
70

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

  
66 74
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/registration/RegistrationWorkingSetService.java
181 181
    public Pager<RegistrationDTO> pageDTOs(String identifier, Integer pageIndex,  Integer pageSize) throws IOException {
182 182

  
183 183
        Pager<Registration> regPager = repo.getRegistrationService().pageByIdentifier(identifier, pageIndex, pageSize, REGISTRATION_DTO_INIT_STRATEGY);
184
        List<RegistrationDTO> dtoList = new ArrayList<>(regPager.getRecords().size());
185
        for(Registration reg : regPager.getRecords()){
186
            inititializeSpecimen(reg);
187
            dtoList.add(new RegistrationDTO(reg));
188
        }
189
        return new DefaultPagerImpl<RegistrationDTO>(pageIndex, regPager.getCount(), pageSize, dtoList);
184
        return convertToDTOPager(regPager);
185
    }
186

  
187

  
188
    /**
189
     * @param regPager
190
     * @return
191
     */
192
    @Override
193
    public Pager<RegistrationDTO> convertToDTOPager(Pager<Registration> regPager) {
194
        return new DefaultPagerImpl<RegistrationDTO>(regPager.getCurrentIndex(), regPager.getCount(), regPager.getPageSize(), makeDTOs(regPager.getRecords()));
190 195
    }
191 196

  
192 197

  
193 198
    @Override
194 199
    public Pager<RegistrationDTO> pageDTOs(Integer pageSize, Integer pageIndex) {
195 200

  
196
        return pageDTOs(null, null, null, null, null, pageSize, pageIndex);
201
        return pageDTOs((User)null, null, null, null, null, pageSize, pageIndex, null);
197 202
    }
198 203

  
199 204
    /**
......
202 207
    @Override
203 208
    public Pager<RegistrationDTO> pageDTOs(User submitter, Collection<RegistrationStatus> includedStatus,
204 209
            String identifierFilterPattern, String taxonNameFilterPattern, Set<TypeDesignationStatusBase> typeStatusFilter,
205
            Integer pageSize, Integer pageIndex) {
210
            Integer pageSize, Integer pageIndex, List<OrderHint> orderHints) {
206 211

  
207 212
        if(pageSize == null){
208 213
            pageSize = PAGE_SIZE;
209 214
        }
210 215

  
211
        List<OrderHint> orderHints = Arrays.asList(new OrderHint("identifier", SortOrder.ASCENDING));
216
        if(orderHints == null){
217
            orderHints = Arrays.asList(new OrderHint("identifier", SortOrder.ASCENDING));
218
        }
212 219

  
213 220
        Pager<Registration> pager = repo.getRegistrationService().page(submitter, includedStatus, identifierFilterPattern, taxonNameFilterPattern,
214 221
                typeStatusFilter, PAGE_SIZE, pageIndex , orderHints, REGISTRATION_DTO_INIT_STRATEGY);
215
        List<Registration> registrations = pager.getRecords();
216
        Pager<RegistrationDTO> dtoPager = new DefaultPagerImpl(pager.getCurrentIndex(), pager.getCount(), pager.getPageSize(), makeDTOs(registrations));
222

  
223
        Pager<RegistrationDTO> dtoPager = convertToDTOPager(pager);
217 224
        if(logger.isDebugEnabled()){
218
            logger.debug(String.format("pageDTOs() pageIndex: $1%d, pageSize: $2%d, includedStatus: $3%s, identifierFilterPattern: $4%s, taxonNameFilterPattern: $5%s",
219
                    pageIndex, pageSize, includedStatus, identifierFilterPattern, taxonNameFilterPattern));
225
            logger.debug(String.format("pageDTOs() pageIndex: $1%d, pageSize: $2%d, includedStatus: $3%s, identifierFilterPattern: $4%s, taxonNameFilterPattern: $5%s, submitter: $6%s",
226
                    pageIndex, pageSize, includedStatus, identifierFilterPattern, taxonNameFilterPattern, submitter));
220 227
            logger.debug("pageDTOs() result: " + pager.toString());
221 228
        }
222 229
        return dtoPager;
223 230
    }
224 231

  
232
    @Override
233
    public Pager<RegistrationDTO> pageDTOs(UUID submitterUuid, Collection<RegistrationStatus> includedStatus, String identifierFilterPattern,
234
            String taxonNameFilterPattern, Collection<UUID> typeDesignationStatusUuids, Integer pageSize,
235
            Integer pageIndex, List<OrderHint> orderHints){
236

  
237
            if(pageSize == null){
238
                pageSize = PAGE_SIZE;
239
            }
240

  
241
            if(orderHints == null){
242
                orderHints = Arrays.asList(new OrderHint("identifier", SortOrder.ASCENDING));
243
            }
244

  
245
            Pager<Registration> pager = repo.getRegistrationService().page(submitterUuid, includedStatus,
246
                    identifierFilterPattern, taxonNameFilterPattern,
247
                    typeDesignationStatusUuids, PAGE_SIZE, pageIndex , orderHints, REGISTRATION_DTO_INIT_STRATEGY);
248

  
249
            Pager<RegistrationDTO> dtoPager = convertToDTOPager(pager);
250
            if(logger.isDebugEnabled()){
251
                logger.debug(String.format("pageDTOs() pageIndex: $1%d, pageSize: $2%d, includedStatusUuids: $3%s, typeDesignationStatusUuids: $4%s, taxonNameFilterPattern: $5%s, submitterUuid: $6%s",
252
                        pageIndex, pageSize, includedStatus, identifierFilterPattern, taxonNameFilterPattern, submitterUuid));
253
                logger.debug("pageDTOs() result: " + pager.toString());
254
            }
255
            return dtoPager;
256

  
257
    }
258

  
225 259

  
226 260
    /**
227 261
     * {@inheritDoc}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)