Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
cb0f7bdb
Commit
cb0f7bdb
authored
Jun 02, 2017
by
Piotr Gawron
Browse files
JS uses new api for search
parent
714f6d59
Changes
11
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/ServerConnector.js
View file @
cb0f7bdb
...
...
@@ -205,9 +205,12 @@ ServerConnector.createGetParams = function(params) {
for
(
var
i
=
0
;
i
<
sorted
.
length
;
i
++
)
{
var
key
=
sorted
[
i
];
var
value
=
params
[
key
];
if
(
Object
.
prototype
.
toString
.
call
(
value
)
===
'
[object Array]
'
)
{
if
(
value
instanceof
google
.
maps
.
Point
)
{
value
=
this
.
pointToString
(
value
);
}
else
if
(
Object
.
prototype
.
toString
.
call
(
value
)
===
'
[object Array]
'
)
{
value
=
this
.
idsToString
(
value
);
}
if
(
value
!==
undefined
&&
value
!==
""
)
{
result
+=
key
+
"
=
"
+
value
+
"
&
"
;
}
...
...
@@ -443,9 +446,9 @@ ServerConnector.getModelsUrl = function(params) {
});
};
ServerConnector
.
getBioEntitiesUrl
=
function
(
p
arams
)
{
ServerConnector
.
getBioEntitiesUrl
=
function
(
queryP
arams
)
{
return
this
.
getApiUrl
({
url
:
this
.
getModelsUrl
(
p
arams
)
+
"
bioEntities/
"
,
url
:
this
.
getModelsUrl
(
queryP
arams
)
+
"
bioEntities/
"
,
});
};
...
...
@@ -482,41 +485,10 @@ ServerConnector.getConfigurationUrl = function(token) {
return
result
;
};
ServerConnector
.
getClosestElementsByCoordinatesUrl
=
function
(
params
)
{
var
coordinates
=
this
.
pointToString
(
params
.
coordinates
);
var
projectId
=
params
.
projectId
;
var
modelId
=
params
.
modelId
;
var
token
=
params
.
token
;
var
count
=
params
.
count
;
ServerConnector
.
getSearchUrl
=
function
(
queryParams
,
filterParams
)
{
return
this
.
getApiUrl
({
type
:
"
project
"
,
method
:
"
getClosestElementsByCoordinates
"
,
params
:
{
projectId
:
projectId
,
coordinates
:
coordinates
,
modelId
:
modelId
,
count
:
count
,
token
:
token
},
});
};
ServerConnector
.
getElementsByQueryUrl
=
function
(
params
)
{
var
query
=
params
.
query
;
var
projectId
=
params
.
projectId
;
var
token
=
params
.
token
;
var
perfectMatch
=
params
.
perfectMatch
;
return
this
.
getApiUrl
({
type
:
"
project
"
,
method
:
"
getElementsByQuery
"
,
params
:
{
projectId
:
projectId
,
query
:
query
,
perfectMatch
:
perfectMatch
,
token
:
token
},
url
:
this
.
getModelsUrl
(
queryParams
)
+
"
bioEntities:search
"
,
params
:
filterParams
,
});
};
...
...
@@ -1020,12 +992,19 @@ ServerConnector.getSessionData = function(project) {
ServerConnector
.
getClosestElementsByCoordinates
=
function
(
params
)
{
var
self
=
this
;
var
queryParams
=
{
modelId
:
params
.
modelId
};
var
filterParams
=
{
coordinates
:
params
.
coordinates
,
count
:
params
.
count
,
};
return
self
.
getProjectId
(
params
.
projectId
).
then
(
function
(
result
)
{
p
arams
.
projectId
=
result
;
queryP
arams
.
projectId
=
result
;
return
self
.
getToken
();
}).
then
(
function
(
token
)
{
p
arams
.
token
=
token
;
return
self
.
readFile
(
self
.
get
ClosestElementsByCoordinatesUrl
(
p
arams
));
filterP
arams
.
token
=
token
;
return
self
.
readFile
(
self
.
get
SearchUrl
(
queryParams
,
filterP
arams
));
}).
then
(
function
(
content
)
{
var
array
=
JSON
.
parse
(
content
);
var
result
=
[];
...
...
@@ -1079,12 +1058,20 @@ ServerConnector.logout = function() {
ServerConnector
.
getElementsByQuery
=
function
(
params
)
{
var
self
=
this
;
var
queryParams
=
{
modelId
:
params
.
modelId
};
var
filterParams
=
{
query
:
params
.
query
,
perfectMatch
:
params
.
perfectMatch
,
};
return
self
.
getProjectId
(
params
.
projectId
).
then
(
function
(
result
)
{
p
arams
.
projectId
=
result
;
queryP
arams
.
projectId
=
result
;
return
self
.
getToken
();
}).
then
(
function
(
token
)
{
p
arams
.
token
=
token
;
return
self
.
readFile
(
self
.
get
ElementsByQueryUrl
(
p
arams
));
filterP
arams
.
token
=
token
;
return
self
.
readFile
(
self
.
get
SearchUrl
(
queryParams
,
filterP
arams
));
}).
then
(
function
(
content
)
{
var
array
=
JSON
.
parse
(
content
);
var
result
=
[];
...
...
frontend-js/src/test/js/ServerConnector-mock.js
View file @
cb0f7bdb
...
...
@@ -22,8 +22,9 @@ ServerConnectorMock.init = function() {
ServerConnectorMock
.
init
();
function
replaceAsterisk
(
str
)
{
return
str
.
replace
(
/
\*
/g
,
"
all
"
);
return
str
.
replace
(
/
\*
/g
,
"
all
"
)
.
replace
(
/
\:
/g
,
"
.
"
)
;
}
ServerConnectorMock
.
_readFile
=
function
(
url
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
url
.
indexOf
(
"
http
"
)
===
0
)
{
...
...
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates/coordinates=2.00,12.00&modelId=102&projectId=sample
&token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/102/bioEntities.search/coordinates=2.00,12.00
&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates
/coordinates=184.79,365.76&count=1&
modelId=15781&projectId=sample&
token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search
/coordinates=184.79,365.76&count=1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates/coordinates=2.00,12.00&modelId=15781&projectId=sample
&token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search/coordinates=2.00,12.00
&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates
/coordinates=207.73,479.18&count=1&
modelId=15781&projectId=sample&
token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search
/coordinates=207.73,479.18&count=1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates
/coordinates=316.05,253.61&count=1&
modelId=15781&projectId=sample&
token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search
/coordinates=316.05,253.61&count=1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates
/coordinates=457.51,356.84&count=1&
modelId=15781&projectId=sample&
token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search
/coordinates=457.51,356.84&count=1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getClosestElementsByCoordinates
/coordinates=553.10,479.18&count=1&
modelId=15781&projectId=sample&
token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/15781/bioEntities.search
/coordinates=553.10,479.18&count=1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getElementsByQuery
/perfectMatch=false&
projectId=sample&
query=s1&token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/all/bioEntities.search
/perfectMatch=false&query=s1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
frontend-js/testFiles/apiCalls/project
/getElementsByQuery/projectId=sample&
query=s1&token=MOCK_TOKEN_ID&
→
frontend-js/testFiles/apiCalls/project
s/sample/models/all/bioEntities.search/
query=s1&token=MOCK_TOKEN_ID&
View file @
cb0f7bdb
File moved
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