Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RegApp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIT
reg-app
RegApp
Commits
67f7e229
Commit
67f7e229
authored
3 years ago
by
Michael Simon
Browse files
Options
Downloads
Patches
Plain Diff
re-fix sort order for new primefaces version
parent
1165fa81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/jpa/JpaBaseDao.java
+21
-0
21 additions, 0 deletions
.../src/main/java/edu/kit/scc/webreg/dao/jpa/JpaBaseDao.java
with
21 additions
and
0 deletions
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/jpa/JpaBaseDao.java
+
21
−
0
View file @
67f7e229
...
...
@@ -34,6 +34,7 @@ import javax.persistence.criteria.Root;
import
org.primefaces.model.FilterMeta
;
import
org.primefaces.model.MatchMode
;
import
org.primefaces.model.SortMeta
;
import
org.primefaces.model.SortOrder
;
import
edu.kit.scc.webreg.dao.BaseDao
;
import
edu.kit.scc.webreg.dao.GenericSortOrder
;
...
...
@@ -115,6 +116,8 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
// criteria.orderBy(getSortOrder(builder, root, sortField, sortOrder));
// }
criteria
.
orderBy
(
getSortOrder
(
builder
,
root
,
sortBy
));
Query
q
=
em
.
createQuery
(
criteria
);
q
.
setFirstResult
(
first
).
setMaxResults
(
pageSize
);
...
...
@@ -333,6 +336,24 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
return
path
;
}
}
protected
List
<
Order
>
getSortOrder
(
CriteriaBuilder
builder
,
Root
<
T
>
root
,
Map
<
String
,
SortMeta
>
sortBy
)
{
List
<
Order
>
orderList
=
new
ArrayList
<
Order
>();
if
(
sortBy
!=
null
)
{
for
(
Entry
<
String
,
SortMeta
>
entry
:
sortBy
.
entrySet
())
{
if
(
entry
.
getValue
()
!=
null
&&
entry
.
getValue
().
getOrder
()
!=
null
&&
entry
.
getValue
().
getField
()
!=
null
)
{
if
(
entry
.
getValue
().
getOrder
().
equals
(
SortOrder
.
ASCENDING
))
orderList
.
add
(
builder
.
asc
(
resolvePath
(
root
,
entry
.
getValue
().
getField
())));
else
if
(
entry
.
getValue
().
getOrder
().
equals
(
SortOrder
.
DESCENDING
))
orderList
.
add
(
builder
.
desc
(
resolvePath
(
root
,
entry
.
getValue
().
getField
())));
}
}
}
return
orderList
;
}
protected
Order
getSortOrder
(
CriteriaBuilder
builder
,
Root
<
T
>
root
,
String
sortField
,
GenericSortOrder
sortOrder
)
{
if
(
sortOrder
==
GenericSortOrder
.
ASC
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment