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
19
Issues
19
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
3aa5a897
Commit
3aa5a897
authored
Oct 10, 2018
by
Matija Obreza
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: getAccessions by UUIDs sublist bug
parent
35320b92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
17 deletions
+30
-17
src/main/java/org/genesys2/server/service/impl/AccessionServiceImpl.java
...rg/genesys2/server/service/impl/AccessionServiceImpl.java
+2
-2
src/main/java/org/genesys2/server/service/worker/AccessionRefAspect.java
...rg/genesys2/server/service/worker/AccessionRefAspect.java
+9
-0
src/test/java/org/genesys/test/server/api/v1/AccessionControllerTest.java
...g/genesys/test/server/api/v1/AccessionControllerTest.java
+19
-15
No files found.
src/main/java/org/genesys2/server/service/impl/AccessionServiceImpl.java
View file @
3aa5a897
...
...
@@ -137,8 +137,8 @@ public class AccessionServiceImpl implements AccessionService {
List
<
UUID
>
uuidList
=
new
ArrayList
<>(
uuids
);
List
<
Accession
>
accessions
=
new
ArrayList
<>(
uuidList
.
size
());
for
(
int
i
=
0
;
i
<
uuid
List
.
size
();
i
+=
chunkSize
){
List
<
UUID
>
chunk
=
uuidList
.
subList
(
i
,
i
+
chunkSize
);
for
(
int
i
=
0
;
i
<
uuid
s
.
size
();
i
+=
chunkSize
){
List
<
UUID
>
chunk
=
uuidList
.
subList
(
i
,
Math
.
min
(
uuids
.
size
(),
i
+
chunkSize
)
);
accessions
.
addAll
((
List
<
Accession
>)
accessionRepository
.
findAll
(
QAccession
.
accession
.
accessionId
.
uuid
.
in
(
chunk
)));
}
...
...
src/main/java/org/genesys2/server/service/worker/AccessionRefAspect.java
View file @
3aa5a897
...
...
@@ -17,7 +17,9 @@ package org.genesys2.server.service.worker;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.time.StopWatch
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
...
...
@@ -58,6 +60,7 @@ public class AccessionRefAspect {
@Before
(
value
=
"execution(* org.genesys2.server.persistence.AccessionRepository.delete(*)) && args(arg)"
)
public
void
beforeDeleteAccession
(
JoinPoint
joinPoint
,
Object
arg
)
throws
Throwable
{
StopWatch
stopWatch
=
StopWatch
.
createStarted
();
LOG
.
trace
(
"Before delete accession"
+
arg
);
if
(
arg
==
null
)
{
return
;
...
...
@@ -67,9 +70,11 @@ public class AccessionRefAspect {
datasetsDereference
((
Accession
)
accession
);
subsetsDereference
((
Accession
)
accession
);
});
LOG
.
warn
(
"Dereferencing AccessionRefs for {} accession took {}ms"
,
((
Collection
<?>)
arg
).
size
(),
stopWatch
.
getTime
(
TimeUnit
.
MILLISECONDS
));
}
else
if
(
arg
instanceof
Accession
)
{
datasetsDereference
((
Accession
)
arg
);
subsetsDereference
((
Accession
)
arg
);
LOG
.
warn
(
"Dereferencing AccessionRefs for 1 accession took {}ms"
,
stopWatch
.
getTime
(
TimeUnit
.
MILLISECONDS
));
}
}
...
...
@@ -97,14 +102,18 @@ public class AccessionRefAspect {
if
(
returnObject
==
null
)
{
return
;
}
StopWatch
stopWatch
=
StopWatch
.
createStarted
();
if
(
returnObject
instanceof
Collection
<?>)
{
((
Collection
<?>)
returnObject
).
forEach
(
accession
->
{
updateDatasets
((
Accession
)
accession
);
updateSubsets
((
Accession
)
accession
);
});
LOG
.
warn
(
"Re-referencing AccessionRefs for {} accessions took {}ms"
,
((
Collection
<?>)
returnObject
).
size
(),
stopWatch
.
getTime
(
TimeUnit
.
MILLISECONDS
));
}
else
if
(
returnObject
instanceof
Accession
)
{
updateDatasets
((
Accession
)
returnObject
);
updateSubsets
((
Accession
)
returnObject
);
LOG
.
warn
(
"Re-referencing AccessionRefs for 1 accession took {}ms"
,
stopWatch
.
getTime
(
TimeUnit
.
MILLISECONDS
));
}
}
...
...
src/test/java/org/genesys/test/server/api/v1/AccessionControllerTest.java
View file @
3aa5a897
...
...
@@ -156,21 +156,25 @@ public class AccessionControllerTest extends AbstractApiTest {
public
void
getAccessionsTest
()
throws
Exception
{
// Also works with 2000, 5000, 10000, 15000
int
amount
=
1000
;
List
<
Accession
>
accessions
=
setUpAccessions
(
amount
);
assertThat
(
accessionRepository
.
count
(),
is
((
long
)(
amount
)));
List
<
UUID
>
uuids
=
accessions
.
stream
().
map
(
Accession:
:
getAccessionId
).
map
(
AccessionId:
:
getUuid
).
collect
(
Collectors
.
toList
());
final
String
s
=
objectMapper
.
writeValueAsString
(
uuids
);
mockMvc
.
perform
(
post
(
org
.
genesys2
.
server
.
api
.
v1
.
AccessionController
.
API_BASE
+
"/for-uuid"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
s
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$"
,
hasSize
(
amount
)));
int
amounts
[]
=
{
10
,
99
,
100
,
101
,
1000
};
List
<
Accession
>
accessions
=
setUpAccessions
(
2000
);
assertThat
(
accessionRepository
.
count
(),
is
(
2000L
));
for
(
int
amount:
amounts
)
{
List
<
UUID
>
uuids
=
accessions
.
subList
(
0
,
amount
).
stream
().
map
(
Accession:
:
getAccessionId
).
map
(
AccessionId:
:
getUuid
).
collect
(
Collectors
.
toList
());
final
String
s
=
objectMapper
.
writeValueAsString
(
uuids
);
/*@formatter:off*/
mockMvc
.
perform
(
post
(
org
.
genesys2
.
server
.
api
.
v1
.
AccessionController
.
API_BASE
+
"/for-uuid"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
s
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$"
,
hasSize
(
amount
)));
/*@formatter:on*/
}
}
...
...
Matija Obreza
@mobreza
mentioned in issue
#360 (closed)
·
Oct 11, 2018
mentioned in issue
#360 (closed)
mentioned in issue #360
Toggle commit list
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