Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
9396a52c
Commit
9396a52c
authored
Nov 21, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: AccessionRef serialization for Datasets, batch load in AccessionRepository#find()
parent
d6cde111
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
21 deletions
+27
-21
src/main/java/org/genesys2/server/api/v1/DatasetController.java
...in/java/org/genesys2/server/api/v1/DatasetController.java
+1
-1
src/main/java/org/genesys2/server/persistence/AccessionRepositoryCustomImpl.java
...ys2/server/persistence/AccessionRepositoryCustomImpl.java
+26
-20
No files found.
src/main/java/org/genesys2/server/api/v1/DatasetController.java
View file @
9396a52c
...
...
@@ -226,7 +226,7 @@ public class DatasetController extends ApiBaseController {
* @return the page
* @throws NotFoundElement
*/
@JsonView
({
JsonViews
.
Minimal
.
class
})
@JsonView
({
JsonViews
.
Public
.
class
})
@GetMapping
(
value
=
"/accessions/{uuid}"
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
Page
<
AccessionRef
>
listAccessions
(
@PathVariable
(
"uuid"
)
final
UUID
uuid
,
final
Pagination
page
)
throws
NotFoundElement
{
return
datasetService
.
listAccessions
(
datasetService
.
loadDataset
(
uuid
),
page
.
toPageRequest
(
100
));
...
...
src/main/java/org/genesys2/server/persistence/AccessionRepositoryCustomImpl.java
View file @
9396a52c
...
...
@@ -88,30 +88,36 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
cq
.
distinct
(
true
);
cq
.
select
(
root
.
get
(
"id"
));
List
<
Predicate
>
restrictions
=
new
ArrayList
<
Predicate
>();
Set
<
String
>
uniqueDois
=
forUpdate
.
stream
().
map
(
aid
->
aid
.
getDoi
()).
filter
(
doi
->
doi
!=
null
).
distinct
().
collect
(
Collectors
.
toSet
());
List
<
Accession
>
res
=
new
ArrayList
<>(
forUpdate
.
size
());
Path
<
Object
>
theDoi
=
root
.
get
(
"doi"
);
Path
<
Object
>
theInstCode
=
root
.
get
(
"instituteCode"
);
Path
<
Object
>
theAcceNumb
=
root
.
get
(
"accessionNumber"
);
Path
<
Object
>
theGenus
=
root
.
get
(
"genus"
);
final
int
chunkSize
=
200
;
for
(
int
fromIndex
=
0
;
fromIndex
<
forUpdate
.
size
();
fromIndex
+=
chunkSize
)
{
List
<?
extends
AccessionIdentifier3
>
sublist
=
forUpdate
.
subList
(
fromIndex
,
Math
.
min
(
forUpdate
.
size
(),
fromIndex
+
chunkSize
));
if
(
uniqueDois
.
size
()
>
0
)
{
restrictions
.
add
(
theDoi
.
in
(
uniqueDois
));
LOG
.
trace
(
"*** {} dois={}"
,
uniqueDois
.
size
(),
uniqueDois
);
}
// A lot of .. (instCode=? and acceNumb=? and genus=?)
for
(
AccessionIdentifier3
ah
:
forUpdate
)
{
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
theInstCode
,
ah
.
getHoldingInstitute
()),
criteriaBuilder
.
equal
(
theAcceNumb
,
ah
.
getAccessionNumber
()),
criteriaBuilder
.
equal
(
theGenus
,
ah
.
getGenus
())));
List
<
Predicate
>
restrictions
=
new
ArrayList
<
Predicate
>();
Set
<
String
>
uniqueDois
=
sublist
.
stream
().
map
(
aid
->
aid
.
getDoi
()).
filter
(
doi
->
doi
!=
null
).
distinct
().
collect
(
Collectors
.
toSet
());
Path
<
Object
>
theDoi
=
root
.
get
(
"doi"
);
Path
<
Object
>
theInstCode
=
root
.
get
(
"instituteCode"
);
Path
<
Object
>
theAcceNumb
=
root
.
get
(
"accessionNumber"
);
Path
<
Object
>
theGenus
=
root
.
get
(
"genus"
);
if
(
uniqueDois
.
size
()
>
0
)
{
restrictions
.
add
(
theDoi
.
in
(
uniqueDois
));
LOG
.
trace
(
"*** {} dois={}"
,
uniqueDois
.
size
(),
uniqueDois
);
}
// A lot of .. (instCode=? and acceNumb=? and genus=?)
for
(
AccessionIdentifier3
ah
:
sublist
)
{
restrictions
.
add
(
criteriaBuilder
.
and
(
criteriaBuilder
.
equal
(
theInstCode
,
ah
.
getHoldingInstitute
()),
criteriaBuilder
.
equal
(
theAcceNumb
,
ah
.
getAccessionNumber
()),
criteriaBuilder
.
equal
(
theGenus
,
ah
.
getGenus
())));
}
cq
.
where
(
criteriaBuilder
.
or
(
restrictions
.
toArray
(
EMPTY_PREDICATE_ARRAY
)));
res
.
addAll
(
jpaQueryFactory
.
selectFrom
(
QAccession
.
accession
).
where
(
QAccession
.
accession
.
id
.
in
(
em
.
createQuery
(
cq
).
getResultList
())).
fetch
());
}
cq
.
where
(
criteriaBuilder
.
or
(
restrictions
.
toArray
(
EMPTY_PREDICATE_ARRAY
)));
List
<
Accession
>
res
=
jpaQueryFactory
.
selectFrom
(
QAccession
.
accession
).
where
(
QAccession
.
accession
.
id
.
in
(
em
.
createQuery
(
cq
).
getResultList
())).
fetch
();
if
(
LOG
.
isDebugEnabled
())
LOG
.
trace
(
"*** Loaded accessions {} of {}"
,
res
.
size
(),
forUpdate
.
size
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment