Project

General

Profile

Revision c40f420c

IDc40f420c355ee29b3b31e575c8d630f59cf55c0e
Parent f54d835b
Child 5f71008d

Added by Andreas Kohlbecker about 1 year ago

fix #8287 implementing support for null type status as filter value in Registration service

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/RegistrationDaoHibernateImpl.java
259 259
            parameters.put("referenceFilterPattern", MatchMode.ANYWHERE.queryStringFrom(referenceFilterPattern));
260 260
        }
261 261
        if(doTypeStatusFilter){
262
            where += " AND typeStatus.uuid in (:typeDesignationStatusUuids)";
263
            parameters.put("typeDesignationStatusUuids", typeDesignationStatusUuids);
262
            boolean addNullFilter = false;
263
            while(typeDesignationStatusUuids.contains(null)){
264
                addNullFilter = true;
265
                typeDesignationStatusUuids.remove(null);
266
            }
267
            String typeStatusWhere = "";
268
            if(!typeDesignationStatusUuids.isEmpty()){
269
                typeStatusWhere += " typeStatus.uuid in (:typeDesignationStatusUuids)";
270
                parameters.put("typeDesignationStatusUuids", typeDesignationStatusUuids);
271
            }
272
            if(addNullFilter){
273
                typeStatusWhere += (!typeStatusWhere.isEmpty() ? " OR ":"") + "typeStatus is null";
274
            }
275
            where += " AND ( " +  typeStatusWhere + ")";
264 276
        }
265 277
        String hql = select + from + where + orderBy;
266 278
        Query query = getSession().createQuery(hql);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TypeDesignationStatusFilter.java
123 123
    public static Set<UUID> toTypeDesignationStatusUuids(Set<TypeDesignationStatusFilter> filterTerms){
124 124
        Set<UUID> uuids = new HashSet<>();
125 125
        for(TypeDesignationStatusFilter f : filterTerms){
126
            uuids.addAll(f.getUuids());
126
            if(f != null){
127
                uuids.addAll(f.getUuids());
128
            } else {
129
                uuids.add(null);
130
            }
127 131
        }
128 132
        return uuids;
129 133
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)