Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
8579e132
Commit
8579e132
authored
Aug 13, 2019
by
Piotr Gawron
Browse files
submap id is taken into consideration when searching map
parent
570a413a
Changes
4
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java
View file @
8579e132
...
...
@@ -58,7 +58,7 @@ public class BioEntitiesController extends BaseController {
if
(
count
.
trim
().
isEmpty
())
{
count
=
"100"
;
}
return
bioEntitiesRestImpl
.
getElementsByQuery
(
projectId
,
query
,
Integer
.
valueOf
(
count
),
return
bioEntitiesRestImpl
.
getElementsByQuery
(
projectId
,
query
,
modelId
,
Integer
.
valueOf
(
count
),
perfectMatch
);
}
else
{
return
new
ArrayList
<>();
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesRestImpl.java
View file @
8579e132
...
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
lcsb.mapviewer.api.BaseRestImpl
;
import
lcsb.mapviewer.api.ObjectNotFoundException
;
import
lcsb.mapviewer.model.map.BioEntity
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.services.interfaces.ISearchService
;
...
...
@@ -32,13 +33,18 @@ public class BioEntitiesRestImpl extends BaseRestImpl {
}
public
List
<
Map
<
String
,
Object
>>
getClosestElementsByCoordinates
(
String
projectId
,
String
modelId
,
Point2D
coordinates
,
Integer
count
,
String
perfectMatch
,
String
type
)
{
String
projectId
,
String
modelId
,
Point2D
coordinates
,
Integer
count
,
String
perfectMatch
,
String
type
)
throws
ObjectNotFoundException
{
List
<
Map
<
String
,
Object
>>
resultMap
=
new
ArrayList
<>();
Model
model
=
getModelService
().
getLastModelByProjectId
(
projectId
);
Model
submodel
=
model
.
getSubmodelById
(
modelId
);
if
(
submodel
==
null
)
{
throw
new
ObjectNotFoundException
(
"Model with given id doesn't exist"
);
}
Set
<
String
>
types
=
new
LinkedHashSet
<>();
if
(!
type
.
isEmpty
())
{
for
(
String
str
:
type
.
split
(
","
))
{
...
...
@@ -55,11 +61,17 @@ public class BioEntitiesRestImpl extends BaseRestImpl {
return
resultMap
;
}
public
List
<
Map
<
String
,
Object
>>
getElementsByQuery
(
String
projectId
,
String
query
,
Integer
maxElements
,
String
perfectMatch
)
{
public
List
<
Map
<
String
,
Object
>>
getElementsByQuery
(
String
projectId
,
String
query
,
String
modelId
,
Integer
maxElements
,
String
perfectMatch
)
throws
ObjectNotFoundException
{
List
<
Map
<
String
,
Object
>>
resultMap
=
new
ArrayList
<>();
Model
model
=
getModelService
().
getLastModelByProjectId
(
projectId
);
if
(!
modelId
.
equals
(
"*"
))
{
model
=
model
.
getSubmodelById
(
modelId
);
}
if
(
model
==
null
)
{
throw
new
ObjectNotFoundException
(
"Model with given id doesn't exist"
);
}
boolean
match
=
perfectMatch
.
equals
(
"true"
);
List
<
BioEntity
>
elements
=
searchService
.
searchByQuery
(
model
,
query
,
maxElements
,
match
);
...
...
service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java
View file @
8579e132
...
...
@@ -322,7 +322,7 @@ public class SearchService implements ISearchService {
Collection
<
String
>
types
)
{
List
<
BioEntity
>
result
=
new
ArrayList
<>();
// probably this could be improved algorithmi
ti
cally, right now all objects
// probably this could be improved algorithmically, right now all objects
// are sorted by distance, and numberOfElements closest are chosen as a list
// of results
List
<
DistanceToObject
>
tmpList
=
new
ArrayList
<>();
...
...
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java
View file @
8579e132
...
...
@@ -88,6 +88,42 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
testSearchBioEntitiesByCoordinatesWithInvalidModelId
()
throws
Exception
{
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
RequestBuilder
request
=
get
(
"/projects/"
+
TEST_PROJECT
+
"/models/-1/bioEntities:search?coordinates=104.36,182.81"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testSearchBioEntitiesWithInvalidModelId
()
throws
Exception
{
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
RequestBuilder
request
=
get
(
"/projects/"
+
TEST_PROJECT
+
"/models/-1/bioEntities:search?query=s1"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isNotFound
());
}
@Test
public
void
testSearchBioEntitiesOnEverySubmap
()
throws
Exception
{
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
RequestBuilder
request
=
get
(
"/projects/"
+
TEST_PROJECT
+
"/models/*/bioEntities:search?query=s1"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
testGetMapById
()
throws
Exception
{
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
...
...
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