Skip to content

Commit

Permalink
Merge pull request #1208 from MetadataConsulting/pagination-after-pos…
Browse files Browse the repository at this point in the history
…tfilter

do paginaton after post filter
  • Loading branch information
davidmilward authored Apr 16, 2018
2 parents b9c0363 + cbc6af7 commit 45adfd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ class DashboardService {
SearchQuery searchStatusQuery = new SearchQuery(statusList: statusList,
search: null,
metadataDomain: MetadataDomain.DATA_MODEL)
dataModelGormService.findAllBySearchStatusQuery(searchStatusQuery, null, null, [])

dataModelGormService.findAllBySearchStatusQuery(searchStatusQuery, null, [])

.collect { DataModel dataModel ->
new IdName(id: dataModel.id,
name: "${dataModel.name} ${dataModel.semanticVersion} (${dataModel.status})".toString())
Expand Down Expand Up @@ -255,7 +257,8 @@ class DashboardService {
@CompileDynamic
@Transactional(readOnly = true)
CatalogueElementSearchResult findAllDataModelViewBySearchStatusQuery(SearchQuery searchQuery, SortQuery sortQuery, PaginationQuery paginationQuery) {
List<DataModel> dataModelList = dataModelGormService.findAllBySearchStatusQuery(searchQuery, sortQuery, paginationQuery, ['asset'])
List dataModelList = dataModelGormService.findAllBySearchStatusQuery(searchQuery, sortQuery, ['asset'])
dataModelList = MaxOffsetSublistUtils.subList(dataModelList, paginationQuery.toMap())

List<Long> dataModelIds = dataModelList*.id ?: [] as List<Long>
Map<Long, List<AssetViewModel>> dataModelToAssets = findAllAssetViewModelByPublishedStatus(dataModelIds, [PublishedStatus.PUBLISHED])
Expand Down Expand Up @@ -323,7 +326,7 @@ class DashboardService {

@Transactional(readOnly = true)
int countAllDataModelBySearchStatusQuery(SearchQuery searchStatusQuery) {
(dataModelGormService.findAllBySearchStatusQuery(searchStatusQuery, null, null, []) ?: [] ).size()
(dataModelGormService.findAllBySearchStatusQuery(searchStatusQuery, null, []) ?: [] ).size()
}

List<MetadataDomain> metadataDomainList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ class DataModelGormService implements WarnGormErrors {

@Transactional(readOnly = true)
@PostFilter("hasPermission(filterObject, read) or hasPermission(filterObject, admin) or hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISOR')")
List<DataModel> findAllBySearchStatusQuery(SearchQuery searchStatusQuery, SortQuery sortQuery, PaginationQuery paginationQuery, List<String> joinProperties) {
List<DataModel> findAllBySearchStatusQuery(SearchQuery searchStatusQuery, SortQuery sortQuery, List<String> joinProperties) {
DetachedCriteria<DataModel> query = findQueryBySearchStatusQuery(searchStatusQuery, sortQuery)
if ( joinProperties ) {
for ( String propertyName : joinProperties ) {
query.join(propertyName)
}
}
Map m = paginationQuery?.toMap() ?: Collections.emptyMap()
query.list(m)
query.list()
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 45adfd4

Please sign in to comment.