Project

General

Profile

« Previous | Next » 

Revision 46418777

Added by Andreas Müller over 2 years ago

ref #8547 make ReferenceType.inReferenceContraints() a list (adapt vaadin)

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java
11 11
import java.util.ArrayList;
12 12
import java.util.Arrays;
13 13
import java.util.List;
14
import java.util.Set;
15 14

  
16 15
import org.springframework.beans.factory.annotation.Autowired;
17 16
import org.springframework.beans.factory.annotation.Qualifier;
......
58 57
     */
59 58
    public CdmFilterablePagingProvider<Reference, Reference> inReferencePagingProvider(ReferenceType subReferenceType,
60 59
            boolean includeUnspecificTypes) {
61
        List<OrderHint> referenceOrderHints = new ArrayList<OrderHint>();
60
        List<OrderHint> referenceOrderHints = new ArrayList<>();
62 61
        referenceOrderHints.add(OrderHint.ORDER_BY_TITLE_CACHE);
63 62
        referenceOrderHints.add(new OrderHint("issn", SortOrder.ASCENDING));
64 63
        referenceOrderHints.add(new OrderHint("isbn", SortOrder.ASCENDING));
65 64
        CdmFilterablePagingProvider<Reference, Reference> pagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(
66 65
                repo.getReferenceService(), MatchMode.BEGINNING, referenceOrderHints);
67 66

  
68
        Set<ReferenceType> inRefTypes = subReferenceType.inReferenceContraints(subReferenceType);
67
        List<ReferenceType> inRefTypes = ReferenceType.inReferenceContraints(subReferenceType);
69 68

  
70 69
        if (!inRefTypes.isEmpty()) {
71 70
            if (includeUnspecificTypes) {
src/main/java/eu/etaxonomy/cdm/vaadin/data/validator/InReferenceTypeValidator.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.data.validator;
10 10

  
11
import java.util.List;
11 12
import java.util.Objects;
12
import java.util.Set;
13 13

  
14 14
import com.vaadin.data.Validator;
15 15
import com.vaadin.ui.AbstractSelect;
......
20 20
/**
21 21
 * @author a.kohlbecker
22 22
 * @since Dec 20, 2018
23
 *
24 23
 */
25 24
public class InReferenceTypeValidator implements Validator {
26 25

  
27

  
28 26
    private static final long serialVersionUID = 5704902636623629859L;
29 27
    private AbstractSelect referenceTypeSelect;
30 28

  
......
32 30
        this.referenceTypeSelect = referenceTypeSelect;
33 31
    }
34 32

  
35
    /**
36
     * {@inheritDoc}
37
     */
38 33
    @Override
39 34
    public void validate(Object value) throws InvalidValueException {
40 35
        ReferenceType type = (ReferenceType)referenceTypeSelect.getValue();
41 36
        if(value != null){
42
            Set<ReferenceType> applicableInRefTypes = type.inReferenceContraints(type);
37
            List<ReferenceType> applicableInRefTypes = ReferenceType.inReferenceContraints(type);
43 38
            Reference inReference = (Reference)value;
44 39
            if(!applicableInRefTypes.contains(inReference.getType())){
45 40
                throw new InvalidValueException(Objects.toString(inReference.getType(), "[NULL]") + " is not a suitable in-reference type for " + Objects.toString(type, "[NULL]") );
......
47 42
        }
48 43

  
49 44
    }
50

  
51 45
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
12 12
import java.util.Arrays;
13 13
import java.util.EnumSet;
14 14
import java.util.List;
15
import java.util.Set;
16 15
import java.util.UUID;
17 16

  
18 17
import org.apache.log4j.Logger;
......
212 211
       }
213 212

  
214 213
       if(ToOneRelatedEntityField.class.isAssignableFrom(editorAction.getTarget().getClass())){
215
           Set<ReferenceType> applicableTypes = ReferenceType.inReferenceContraints((ReferenceType) getView().getTypeSelect().getValue());
214
           List<ReferenceType> applicableTypes = ReferenceType.inReferenceContraints((ReferenceType) getView().getTypeSelect().getValue());
216 215
           if(editorAction.isAddAction()){
217 216
               inReferencePopup = openPopupEditor(ReferencePopupEditor.class, editorAction);
218 217
               if(!applicableTypes.isEmpty()){

Also available in: Unified diff