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
20ad681a
Commit
20ad681a
authored
Feb 13, 2020
by
Piotr Gawron
Browse files
documentation of download map as image API call
parent
89c511ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
web/src/main/asciidoc/projects/project_maps.adoc
View file @
20ad681a
...
...
@@ -67,6 +67,7 @@ include::{snippets}/projects/project_maps/get_connections/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/get_connections/response-body.adoc[]
== Download map
Download map in a standard format.
...
...
@@ -84,3 +85,19 @@ include::{snippets}/projects/project_maps/download_from_polygon/curl-request.ado
=== CURL sample 3
include::{snippets}/projects/project_maps/download_with_element_list/curl-request.adoc[]
== Download map as image
Download map as image.
=== Path Parameters
include::{snippets}/projects/project_maps/download_image_simple/path-parameters.adoc[]
=== Request Parameters
include::{snippets}/projects/project_maps/download_image_simple/request-parameters.adoc[]
=== CURL sample 1
include::{snippets}/projects/project_maps/download_image_simple/curl-request.adoc[]
=== CURL sample 2
include::{snippets}/projects/project_maps/download_image_polygon/curl-request.adoc[]
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java
View file @
20ad681a
...
...
@@ -28,6 +28,7 @@ import com.google.gson.JsonParser;
import
lcsb.mapviewer.common.Configuration
;
import
lcsb.mapviewer.common.MimeType
;
import
lcsb.mapviewer.converter.graphics.PdfImageGenerator
;
import
lcsb.mapviewer.converter.graphics.PngImageGenerator
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.converter.model.sbgnml.SbgnmlXmlConverter
;
...
...
@@ -338,15 +339,53 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
MockHttpSession
session
=
createSession
(
ControllerIntegrationTest
.
BUILT_IN_TEST_ADMIN_LOGIN
,
ControllerIntegrationTest
.
BUILT_IN_TEST_ADMIN_PASSWORD
);
RequestBuilder
request
=
get
(
"/projects/"
+
TEST_PROJECT
+
"/models/"
+
map
.
getId
()
+
":downloadImage?"
+
"handlerClass="
+
PngImageGenerator
.
class
.
getCanonicalName
())
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
RequestBuilder
request
=
get
(
"/projects/{projectId}/models/{mapId}:downloadImage?"
+
"handlerClass="
+
PngImageGenerator
.
class
.
getCanonicalName
(),
TEST_PROJECT
,
map
.
getId
())
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"projects/project_maps/download_image_simple"
,
downloadImageRequestParameters
(),
pathParameters
(
parameterWithName
(
"projectId"
).
description
(
"project identifier"
),
parameterWithName
(
"mapId"
).
description
(
"map identifier"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
testDownloadImagePolygon
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
ControllerIntegrationTest
.
BUILT_IN_TEST_ADMIN_LOGIN
,
ControllerIntegrationTest
.
BUILT_IN_TEST_ADMIN_PASSWORD
);
RequestBuilder
request
=
get
(
"/projects/{projectId}/models/{mapId}:downloadImage?"
+
"handlerClass="
+
PdfImageGenerator
.
class
.
getCanonicalName
()
+
"&polygonString=0,0;100,0;100,100;0,100"
,
TEST_PROJECT
,
map
.
getId
())
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andDo
(
document
(
"projects/project_maps/download_image_polygon"
,
downloadImageRequestParameters
(),
pathParameters
(
parameterWithName
(
"projectId"
).
description
(
"project identifier"
),
parameterWithName
(
"mapId"
).
description
(
"map identifier"
))))
.
andExpect
(
status
().
is2xxSuccessful
());
}
private
RequestParametersSnippet
downloadImageRequestParameters
()
{
return
requestParameters
(
parameterWithName
(
"handlerClass"
).
description
(
"class preparing image. Available options: "
+
snippets
.
getImageConverters
()),
parameterWithName
(
"polygonString"
).
description
(
"polygon defining part of the map to be downloaded"
)
.
optional
(),
parameterWithName
(
"backgroundOverlayId"
)
.
description
(
"identifier of the overlay used as a background when creating image"
)
.
optional
(),
parameterWithName
(
"zoomLevel"
)
.
description
(
"zoom level at which image should be generated (min value used by default)"
)
.
optional
(),
parameterWithName
(
"overlayIds"
)
.
description
(
"comma separated list of overlay identifiers that should be included in the image"
)
.
optional
());
}
@Test
public
void
testDownloadImageWithUndefinedProject
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
ControllerIntegrationTest
.
BUILT_IN_TEST_ADMIN_LOGIN
,
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectSnippets.java
View file @
20ad681a
...
...
@@ -9,11 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.restdocs.payload.ResponseFieldsSnippet
;
import
org.springframework.stereotype.Component
;
import
lcsb.mapviewer.common.Pair
;
import
lcsb.mapviewer.converter.Converter
;
import
lcsb.mapviewer.converter.graphics.AbstractImageGenerator
;
import
lcsb.mapviewer.converter.graphics.ImageGenerators
;
import
lcsb.mapviewer.model.ProjectStatus
;
import
lcsb.mapviewer.model.graphics.MapCanvasType
;
@Component
public
class
ProjectSnippets
{
...
...
@@ -98,4 +100,16 @@ public class ProjectSnippets {
return
StringUtils
.
join
(
options
,
", "
);
}
public
String
getImageConverters
()
{
List
<
String
>
options
=
new
ArrayList
<>();
ImageGenerators
imageGenerators
=
new
ImageGenerators
();
List
<
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>>
imageGeneratorList
=
imageGenerators
.
getAvailableImageGenerators
();
for
(
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>
element
:
imageGeneratorList
)
{
options
.
add
(
element
.
getRight
().
getCanonicalName
());
}
return
StringUtils
.
join
(
options
,
", "
);
}
}
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