Project

General

Profile

Revision 68d2ffb7

ID68d2ffb71439fe3e86381475390ced4652e704ef
Parent d8ec06ee
Child 16ee34cb

Added by Andreas Kohlbecker over 1 year ago

fix #8149 inclusion of NULL and Genric ref types optional and fixing bugy refresh

View differences:

src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java
39 39
    @Qualifier("cdmRepository")
40 40
    private CdmRepository repo;
41 41

  
42

  
43
    public CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider(){
44
        return inReferencePagingProvider(null);
42
    public CdmFilterablePagingProvider<Reference, Reference> referencePagingProvider() {
43
        return inReferencePagingProvider(null, false);
45 44
    }
46 45

  
47
    public CdmFilterablePagingProvider<Reference,Reference> inReferencePagingProvider(ReferenceType subReferenceType){
46
    /**
47
     *
48
     * @param subReferenceType
49
     *            the type of the reference for which to the paging provider is
50
     *            to be created
51
     * @param includeUnspecificTypes
52
     *            Whether to include references with the types
53
     *            {@link ReferenceType.Generic Generic} and {@code null},
54
     * @return
55
     */
56
    public CdmFilterablePagingProvider<Reference, Reference> inReferencePagingProvider(ReferenceType subReferenceType,
57
            boolean includeUnspecificTypes) {
48 58
        List<OrderHint> referenceOrderHints = new ArrayList<OrderHint>();
49 59
        referenceOrderHints.add(OrderHint.ORDER_BY_TITLE_CACHE);
50 60
        referenceOrderHints.add(new OrderHint("issn", SortOrder.ASCENDING));
51 61
        referenceOrderHints.add(new OrderHint("isbn", SortOrder.ASCENDING));
52
        CdmFilterablePagingProvider<Reference,Reference> pagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(
62
        CdmFilterablePagingProvider<Reference, Reference> pagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(
53 63
                repo.getReferenceService(), MatchMode.ANYWHERE, referenceOrderHints);
54 64

  
55 65
        Set<ReferenceType> inRefTypes = subReferenceType.inReferenceContraints(subReferenceType);
56 66

  
57
        if(!inRefTypes.isEmpty()){
58
            inRefTypes.add(ReferenceType.Generic); // generic references and those with missing type are always valid
59
            inRefTypes.add(null);
60
            pagingProvider.addRestriction(new Restriction<ReferenceType>("type", null, inRefTypes.toArray(new ReferenceType[inRefTypes.size()])));
67
        if (!inRefTypes.isEmpty()) {
68
            if (includeUnspecificTypes) {
69
                inRefTypes.add(ReferenceType.Generic);
70
                inRefTypes.add(null);
71
            }
72
            pagingProvider.addRestriction(new Restriction<ReferenceType>("type", null,
73
                    inRefTypes.toArray(new ReferenceType[inRefTypes.size()])));
61 74
        }
62 75

  
63 76
        return pagingProvider;
64 77
    }
65 78

  
66
    public TypifiedEntityFilterablePagingProvider<Reference> referenceEntityReferencePagingProvider(ReferenceEllypsisFormatter labelProvider, List<String> initStrategy){
79
    public TypifiedEntityFilterablePagingProvider<Reference> referenceEntityReferencePagingProvider(
80
            ReferenceEllypsisFormatter labelProvider, List<String> initStrategy) {
67 81
        List<OrderHint> referenceOrderHints = new ArrayList<OrderHint>();
68 82
        referenceOrderHints.add(OrderHint.ORDER_BY_TITLE_CACHE);
69 83
        referenceOrderHints.add(new OrderHint("issn", SortOrder.ASCENDING));
......
75 89
        return pagingProvider;
76 90
    }
77 91

  
78
    public CdmFilterablePagingProvider<TaxonName, TaxonName> taxonNamesWithoutOrthophicIncorrect(){
92
    public CdmFilterablePagingProvider<TaxonName, TaxonName> taxonNamesWithoutOrthophicIncorrect() {
79 93

  
80 94
        CdmFilterablePagingProvider<TaxonName, TaxonName> pagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(
81 95
                repo.getNameService());
82
        pagingProvider.setInitStrategy(Arrays.asList("registrations", "nomenclaturalReference", "nomenclaturalReference.inReference"));
83
        //pagingProvider.addRestriction(new Restriction<>("relationsFromThisName.type", Operator.AND_NOT, null, NameRelationshipType.ORTHOGRAPHIC_VARIANT()));
96
        pagingProvider.setInitStrategy(
97
                Arrays.asList("registrations", "nomenclaturalReference", "nomenclaturalReference.inReference"));
98
        // pagingProvider.addRestriction(new
99
        // Restriction<>("relationsFromThisName.type", Operator.AND_NOT, null,
100
        // NameRelationshipType.ORTHOGRAPHIC_VARIANT()));
84 101
        return pagingProvider;
85 102
    }
86 103

  
87

  
88 104
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
81 81
    public void handleViewEntered() {
82 82
        super.handleViewEntered();
83 83

  
84

  
85
        updateInReferencePageProvider();
84
        getView().getTypeSelect().addValueChangeListener(e -> updateInReferencePageProvider());
86 85
        getView().getInReferenceCombobox().getSelect().setCaptionGenerator(new CaptionGenerator<Reference>(){
87 86

  
88 87
            @Override
......
113 112
                AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid()));
114 113
    }
115 114

  
116
    @Override
117
    protected void adaptDataProviders() {
118
//        updateInReferencePageProvider();
119
//        getView().getInReferenceCombobox().addValueChangeListener(e -> updateInReferencePageProvider());
120
    }
121

  
122 115

  
123 116
    /**
124 117
     * @param inReferencePagingProvider
125 118
     */
126 119
    public void updateInReferencePageProvider() {
127 120

  
128
        inReferencePagingProvider = pagingProviderFactory.inReferencePagingProvider((ReferenceType) getView().getTypeSelect().getValue());
121
        inReferencePagingProvider = pagingProviderFactory.inReferencePagingProvider((ReferenceType) getView().getTypeSelect().getValue(), false);
129 122
        Reference inReference = getView().getInReferenceCombobox().getValue();
130 123
        if(inReference != null){
131 124
            if(includeCurrentInReference == null){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)