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
12
Issues
12
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
5dd0a047
Commit
5dd0a047
authored
Aug 25, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed LucenePage
parent
c2229e34
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
142 deletions
+3
-142
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
.../org/genesys2/server/service/impl/GenesysServiceImpl.java
+3
-1
src/main/java/org/genesys2/server/service/impl/LucenePage.java
...ain/java/org/genesys2/server/service/impl/LucenePage.java
+0
-141
No files found.
src/main/java/org/genesys2/server/service/impl/GenesysServiceImpl.java
View file @
5dd0a047
...
...
@@ -34,6 +34,7 @@ import java.util.Set;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
org.apache.commons.collections.ListUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.Predicate
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -96,6 +97,7 @@ import org.genesys2.spring.SecurityContextUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.IncorrectResultSizeDataAccessException
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort.Direction
;
...
...
@@ -524,7 +526,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
public
Page
<
Accession
>
listAccessionsByOrganization
(
Organization
organization
,
Pageable
pageable
)
{
final
List
<
FaoInstitute
>
members
=
organizationRepository
.
findInstitutesByOrganization
(
organization
);
if
(
members
==
null
||
members
.
size
()
==
0
)
{
return
new
LucenePage
<
Accession
>(
0
,
0
);
return
new
PageImpl
<
Accession
>(
ListUtils
.
EMPTY_LIST
);
}
return
accessionRepository
.
findByInstitute
(
members
,
pageable
);
}
...
...
src/main/java/org/genesys2/server/service/impl/LucenePage.java
deleted
100644 → 0
View file @
c2229e34
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service.impl
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
public
class
LucenePage
<
T
>
implements
Page
<
T
>
{
private
final
int
number
;
private
final
int
size
;
private
long
totalElements
;
private
List
<
T
>
content
;
public
LucenePage
(
int
number
,
int
size
)
{
this
.
number
=
number
;
this
.
size
=
size
;
}
@Override
public
List
<
T
>
getContent
()
{
return
content
;
}
@Override
public
int
getNumber
()
{
return
number
;
}
@Override
public
int
getNumberOfElements
()
{
return
content
.
size
();
}
@Override
public
int
getSize
()
{
return
size
;
}
@Override
public
Sort
getSort
()
{
return
null
;
}
@Override
public
long
getTotalElements
()
{
return
totalElements
;
}
public
void
setTotalElements
(
long
totalElements
)
{
this
.
totalElements
=
totalElements
;
}
@Override
public
int
getTotalPages
()
{
return
(
int
)
Math
.
ceil
((
double
)
totalElements
/
(
double
)
size
);
}
@Override
public
boolean
hasContent
()
{
return
content
!=
null
&&
content
.
size
()
>
0
;
}
@Override
public
boolean
hasNextPage
()
{
return
content
.
size
()
==
size
;
}
@Override
public
boolean
hasPreviousPage
()
{
return
number
>
1
;
}
@Override
public
boolean
isFirstPage
()
{
return
number
==
0
;
}
@Override
public
boolean
isLastPage
()
{
return
content
.
size
()
<
size
;
}
@Override
public
Iterator
<
T
>
iterator
()
{
return
content
.
iterator
();
}
public
void
setContent
(
List
<
T
>
data
)
{
content
=
data
;
}
@Override
public
Pageable
nextPageable
()
{
return
new
PageRequest
(
number
+
1
,
size
,
getSort
());
}
@Override
public
Pageable
previousPageable
()
{
return
new
PageRequest
(
number
-
1
,
size
,
getSort
());
}
@Override
public
boolean
hasNext
()
{
return
content
.
size
()
==
size
;
}
@Override
public
boolean
hasPrevious
()
{
return
number
>
1
;
}
@Override
public
boolean
isFirst
()
{
return
number
==
0
;
}
@Override
public
boolean
isLast
()
{
return
content
.
size
()
<
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