Project

General

Profile

Revision 189558f3

ID189558f382db666a79529c383b85a7ecaae2fb85
Parent 21d66ebf
Child ff7f5e37

Added by Andreas Müller about 3 years ago

ref #6065 improved Pager handling

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
118 118

  
119 119
        allRecords.addAll(synList);
120 120

  
121

  
122 121
        List<TaxonNodeDto> dtos = new ArrayList<>(pageSize==null?25:pageSize);
123
        Integer start = PagerUtils.startFor(pageSize, pageIndex);
124
        Integer limit = PagerUtils.limitFor(pageSize);
125
        limit = limit == null ? Integer.MAX_VALUE : limit;
126 122
        Long totalCount = Long.valueOf(allRecords.size());
127 123

  
128
            TaxonNameBase<?,?> parentName = null;
129

  
130
//            for(int i = start; i < Math.min(totalCount, start + limit); i++) {
131
            for(CdmBase record : PagerUtils.pageList(allRecords, pageIndex, pageSize)) {
132
                if (record.isInstanceOf(TaxonNode.class)){
133
                    dtos.add(new TaxonNodeDto(CdmBase.deproxy(record, TaxonNode.class)));
134
                }else if (record.isInstanceOf(Synonym.class)){
135
                    Synonym synonym = CdmBase.deproxy(record, Synonym.class);
136
                    parentName = parentName == null? parentNode.getTaxon().getName(): parentName;
137
                    boolean isHomotypic = synonym.getName().isHomotypic(parentName);
138
                    dtos.add(new TaxonNodeDto(synonym, isHomotypic));
139
                }
140
            }
141

  
142
//        }
124
        TaxonNameBase<?,?> parentName = null;
143 125

  
126
        for(CdmBase record : PagerUtils.pageList(allRecords, pageIndex, pageSize)) {
127
            if (record.isInstanceOf(TaxonNode.class)){
128
                dtos.add(new TaxonNodeDto(CdmBase.deproxy(record, TaxonNode.class)));
129
            }else if (record.isInstanceOf(Synonym.class)){
130
                Synonym synonym = CdmBase.deproxy(record, Synonym.class);
131
                parentName = parentName == null? parentNode.getTaxon().getName(): parentName;
132
                boolean isHomotypic = synonym.getName().isHomotypic(parentName);
133
                dtos.add(new TaxonNodeDto(synonym, isHomotypic));
134
            }
135
        }
144 136
        return new DefaultPagerImpl<TaxonNodeDto>(pageIndex, totalCount, pageSize , dtos);
145 137
    }
146 138

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)