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
46
Issues
46
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
0e17f67c
Commit
0e17f67c
authored
Feb 03, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accession API updates
- /acn/filter uses sort by seqNo - /acn/details by AID4 lists accession details
parent
552e6723
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
15 deletions
+45
-15
src/main/java/org/genesys2/server/service/GenesysService.java
...main/java/org/genesys2/server/service/GenesysService.java
+3
-2
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
.../org/genesys2/server/service/impl/GenesysServiceImpl.java
+30
-12
src/main/java/org/genesys2/server/servlet/controller/rest/AccessionController.java
...2/server/servlet/controller/rest/AccessionController.java
+12
-1
No files found.
src/main/java/org/genesys2/server/service/GenesysService.java
View file @
0e17f67c
...
...
@@ -52,11 +52,10 @@ import org.genesys2.server.model.impl.Organization;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
import
org.genesys2.server.service.impl.NoSuchAccessionException
;
import
org.genesys2.server.service.impl.NonUniqueAccessionException
;
import
org.genesys2.server.servlet.controller.rest.model.AccessionHeaderJson
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
javax.servlet.http.HttpServletResponse
;
public
interface
GenesysService
{
/**
...
...
@@ -227,6 +226,8 @@ public interface GenesysService {
AccessionDetails
getAccessionDetails
(
long
accessionId
);
List
<
AccessionDetails
>
getAccessionDetails
(
Set
<
AccessionHeaderJson
>
acceIds
);
List
<
AccessionCollect
>
removeCollecting
(
List
<
AccessionCollect
>
toRemove
);
List
<
AccessionGeo
>
removeGeo
(
List
<
AccessionGeo
>
toRemove
);
...
...
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
0e17f67c
...
...
@@ -107,6 +107,7 @@ import org.genesys2.server.service.HtmlSanitizer;
import
org.genesys2.server.service.OrganizationService
;
import
org.genesys2.server.service.TaxonomyService
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
import
org.genesys2.server.servlet.controller.rest.model.AccessionHeaderJson
;
import
org.genesys2.util.NumberUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -325,17 +326,17 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
}
/**
* {@inheritDoc}
*/
@Override
public
List
<
Accession
>
listAccessions
(
final
String
acceNumb
)
{
List
<
Accession
>
accessions
=
new
ArrayList
<>();
for
(
final
Accession
accession
:
accessionRepository
.
findByAccessionName
(
acceNumb
))
{
accessions
.
add
(
lazyLoadAccession
(
accession
));
}
return
accessions
;
}
/**
* {@inheritDoc}
*/
@Override
public
List
<
Accession
>
listAccessions
(
final
String
acceNumb
)
{
List
<
Accession
>
accessions
=
new
ArrayList
<>();
for
(
final
Accession
accession
:
accessionRepository
.
findByAccessionName
(
acceNumb
))
{
accessions
.
add
(
lazyLoadAccession
(
accession
));
}
return
accessions
;
}
@Override
public
Accession
getAccession
(
String
instCode
,
String
doi
,
String
acceNumb
,
String
genus
)
throws
NonUniqueAccessionException
{
...
...
@@ -439,6 +440,23 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return
set
;
}
@Override
public
List
<
AccessionDetails
>
getAccessionDetails
(
Set
<
AccessionHeaderJson
>
acceIds
)
{
Set
<
Long
>
accessionIds
=
acceIds
.
stream
().
filter
(
id
->
id
!=
null
)
// to Accession
.
map
(
acceId
->
accessionRepository
.
findOne
(
// institute
instituteRepository
.
findByCode
(
acceId
.
getHoldingInstitute
()),
// identifiers
acceId
.
getDoi
(),
acceId
.
getAccessionNumber
(),
acceId
.
getGenus
()))
// to
.
filter
(
accession
->
accession
!=
null
)
// to id
.
map
(
accession
->
accession
.
getId
()).
collect
(
Collectors
.
toSet
());
return
getAccessionDetails
(
accessionIds
);
}
@Override
public
List
<
Accession
>
listAccessions
(
FaoInstitute
faoInstitute
,
String
accessionName
)
{
return
accessionRepository
.
findByInstituteAndAccessionName
(
faoInstitute
,
accessionName
);
...
...
@@ -1908,7 +1926,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
public
List
<
Object
[]>
getLastUpdatedStatistics
(
FaoInstitute
faoInstitute
)
{
return
accessionRepository
.
lastUpdatedStatistics
(
faoInstitute
);
}
@Override
@Cacheable
(
value
=
"statistics"
,
unless
=
"#result == null"
,
key
=
"'stats.' + #root.methodName + '-' + #faoInstitute.code + '-' + #historic"
)
public
List
<
Object
[]>
getLastUpdatedStatistics
(
FaoInstitute
faoInstitute
,
boolean
historic
)
{
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/AccessionController.java
View file @
0e17f67c
...
...
@@ -57,11 +57,13 @@ import org.springframework.dao.CannotAcquireLockException;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.MediaType
;
import
org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -494,9 +496,18 @@ public class AccessionController extends RestController {
LOG
.
debug
(
appliedFilters
.
toString
());
}
Page
<
AccessionDetails
>
accessions
=
filterService
.
listAccessionDetails
(
appliedFilters
,
new
PageRequest
(
page
,
Integer
.
min
(
pageSize
,
maxPageSize
)));
Page
<
AccessionDetails
>
accessions
=
filterService
.
listAccessionDetails
(
appliedFilters
,
new
PageRequest
(
page
,
Integer
.
min
(
pageSize
,
maxPageSize
)
,
new
Sort
(
"seqNo"
)
));
return
accessions
;
}
@PostMapping
(
value
=
"/details"
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
public
List
<
AccessionDetails
>
getDetails
(
@RequestBody
Set
<
AccessionHeaderJson
>
acceIds
)
throws
RESTApiException
{
if
(
acceIds
.
size
()
>
100
)
{
throw
new
RESTApiException
(
"Can't request data for over 100 IDs at a time"
);
}
return
genesysService
.
getAccessionDetails
(
acceIds
);
}
public
static
class
JsonData
{
public
String
crop
;
...
...
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