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
44
Issues
44
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
f577f04b
Commit
f577f04b
authored
Oct 31, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dataset: upserting accessions does not return Accession data with AccessionRef
parent
af9ff4e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
5 deletions
+12
-5
src/main/java/org/genesys/catalog/api/ApiExceptionHandler.java
...ain/java/org/genesys/catalog/api/ApiExceptionHandler.java
+1
-1
src/main/java/org/genesys/catalog/api/v0/DatasetController.java
...in/java/org/genesys/catalog/api/v0/DatasetController.java
+2
-0
src/main/java/org/genesys/catalog/model/dataset/Dataset.java
src/main/java/org/genesys/catalog/model/dataset/Dataset.java
+1
-1
src/main/java/org/genesys/catalog/service/impl/DatasetServiceImpl.java
.../org/genesys/catalog/service/impl/DatasetServiceImpl.java
+8
-3
No files found.
src/main/java/org/genesys/catalog/api/ApiExceptionHandler.java
View file @
f577f04b
...
...
@@ -121,7 +121,7 @@ public class ApiExceptionHandler {
@ExceptionHandler
(
MethodArgumentTypeMismatchException
.
class
)
@ResponseBody
public
ApiError
<
Exception
>
handleConverterArgumentError
(
final
MethodArgumentTypeMismatchException
e
,
final
HttpServletRequest
request
)
{
LOG
.
warn
(
"Invalid argument {} for {} provided {} {}"
,
e
.
getName
(),
e
.
getParameter
(),
request
.
getMethod
(),
request
.
getRequestURL
()
,
e
);
LOG
.
warn
(
"Invalid argument {} for {} provided {} {}"
,
e
.
getName
(),
e
.
getParameter
(),
request
.
getMethod
(),
request
.
getRequestURL
());
return
new
ApiError
<>(
e
);
}
...
...
src/main/java/org/genesys/catalog/api/v0/DatasetController.java
View file @
f577f04b
...
...
@@ -199,9 +199,11 @@ public class DatasetController {
* @throws NotFoundElement the not found element
*/
@PostMapping
(
value
=
"/upsertaccessions/{UUID},{version}"
)
@JsonView
(
JsonViews
.
Minimal
.
class
)
public
Dataset
upsertAccessions
(
@PathVariable
(
"UUID"
)
final
UUID
uuid
,
@PathVariable
(
"version"
)
final
int
version
,
@RequestBody
final
Set
<
AccessionRef
>
accessionRefs
)
throws
NotFoundElement
{
final
Dataset
dataset
=
datasetService
.
loadDataset
(
uuid
,
version
);
LOG
.
debug
(
"Received {} refs for Dataset {}"
,
accessionRefs
.
size
(),
uuid
);
return
datasetService
.
upsertAccessions
(
dataset
,
accessionRefs
);
}
...
...
src/main/java/org/genesys/catalog/model/dataset/Dataset.java
View file @
f577f04b
...
...
@@ -78,7 +78,7 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
// index
indexes
=
{
@Index
(
columnList
=
"datasetId, instCode, acceNumb"
),
@Index
(
columnList
=
"datasetId, genus"
)
})
@Field
(
type
=
FieldType
.
Object
)
@JsonView
({
JsonViews
.
Public
.
class
})
@JsonView
({
JsonViews
.
Minimal
.
class
})
private
Set
<
AccessionRef
>
accessionRefs
;
/** The descriptors. */
...
...
src/main/java/org/genesys/catalog/service/impl/DatasetServiceImpl.java
View file @
f577f04b
...
...
@@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang3.time.StopWatch
;
import
org.genesys.blocks.security.service.CustomAclService
;
import
org.genesys.catalog.model.Partner
;
import
org.genesys.catalog.model.dataset.Dataset
;
...
...
@@ -525,7 +526,10 @@ public class DatasetServiceImpl implements DatasetService {
if
(
loadedDataset
==
null
)
{
throw
new
NotFoundElement
(
"Dataset doesn't exist"
);
}
loadedDataset
.
setState
(
PublishState
.
DRAFT
);
if
(
loadedDataset
.
getState
()
!=
PublishState
.
DRAFT
)
{
throw
new
InvalidApiUsageException
(
"Dataset should in draft state"
);
}
loadedDataset
.
setAccessionRefs
(
lookupMatchingAccessions
(
accessionRefs
));
return
lazyLoad
(
datasetRepository
.
save
(
loadedDataset
));
}
...
...
@@ -842,9 +846,10 @@ public class DatasetServiceImpl implements DatasetService {
* @return accessionRefs with matching accessions from Genesys
*/
private
Set
<
AccessionRef
>
lookupMatchingAccessions
(
final
Set
<
AccessionRef
>
accessionRefs
)
{
StopWatch
stopWatch
=
StopWatch
.
createStarted
();
List
<
AccessionRef
>
list
=
new
ArrayList
<
AccessionRef
>(
accessionRefs
);
List
<
Accession
>
foundAccessions
=
accessionRepository
.
find
(
list
);
LOG
.
warn
(
"Found {} matches for {} identifiers after {}ms"
,
foundAccessions
.
size
(),
accessionRefs
.
size
(),
stopWatch
.
getTime
());
LOG
.
info
(
"Found {} matches for {} identifiers"
,
foundAccessions
.
size
(),
accessionRefs
.
size
());
accessionRefs
.
forEach
(
ref
->
{
...
...
@@ -860,7 +865,7 @@ public class DatasetServiceImpl implements DatasetService {
LOG
.
debug
(
"No match for {}"
,
ref
);
}
});
LOG
.
warn
(
"Matched accessions after {}ms"
,
stopWatch
.
getTime
());
return
accessionRefs
;
}
...
...
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