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
cbca1b79
Commit
cbca1b79
authored
Aug 13, 2019
by
Piotr Gawron
Browse files
export of map with empty background should reset color in exported file
parent
09b6d0b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelController.java
View file @
cbca1b79
...
...
@@ -94,6 +94,7 @@ public class ModelController extends BaseController {
@PathVariable
(
value
=
"modelId"
)
String
modelId
,
@RequestParam
(
value
=
"handlerClass"
)
String
handlerClass
,
@RequestParam
(
value
=
"overlayIds"
,
defaultValue
=
""
)
String
overlayIds
,
@RequestParam
(
value
=
"backgroundOverlayId"
,
defaultValue
=
""
)
String
backgroundOverlayId
,
@RequestParam
(
value
=
"polygonString"
,
defaultValue
=
""
)
String
polygonString
,
@RequestParam
(
value
=
"elementIds"
,
defaultValue
=
""
)
String
elementIds
,
@RequestParam
(
value
=
"reactionIds"
,
defaultValue
=
""
)
String
reactionIds
)
...
...
@@ -101,7 +102,7 @@ public class ModelController extends BaseController {
ConverterException
,
InconsistentModelException
{
User
user
=
userService
.
getUserByLogin
(
authentication
.
getName
());
FileEntry
file
=
modelController
.
getModelAsModelFile
(
projectId
,
modelId
,
handlerClass
,
overlayIds
,
polygonString
,
elementIds
,
reactionIds
,
user
);
projectId
,
modelId
,
handlerClass
,
overlayIds
,
polygonString
,
elementIds
,
reactionIds
,
user
,
backgroundOverlayId
);
return
ResponseEntity
.
ok
().
contentLength
(
file
.
getFileContent
().
length
)
.
contentType
(
MediaType
.
APPLICATION_OCTET_STREAM
)
.
header
(
"Content-Disposition"
,
"attachment; filename="
+
file
.
getOriginalFileName
())
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java
View file @
cbca1b79
...
...
@@ -170,9 +170,12 @@ public class ModelRestImpl extends BaseRestImpl {
public
FileEntry
getModelAsModelFile
(
String
projectId
,
String
modelId
,
String
handlerClass
,
String
overlayIds
,
String
polygonString
,
String
elementIds
,
String
reactionIds
,
User
user
)
String
reactionIds
,
User
user
,
String
backgroundOverlayId
)
throws
QueryException
,
IOException
,
InvalidColorSchemaException
,
CommandExecutionException
,
ConverterException
,
InconsistentModelException
{
Project
project
=
getProjectService
().
getProjectByProjectId
(
projectId
);
Model
originalModel
=
getModelByModelId
(
projectId
,
modelId
);
Path2D
polygon
=
stringToPolygon
(
polygonString
,
originalModel
);
...
...
@@ -188,10 +191,24 @@ public class ModelRestImpl extends BaseRestImpl {
String
[]
overlayIdsList
=
stringListToArray
(
overlayIds
);
// Remove all colors
if
(
overlayIdsList
.
length
>
0
)
{
for
(
Element
element
:
part
.
getElements
())
{
element
.
setColor
(
Color
.
WHITE
);
new
ClearColorModelCommand
(
part
).
execute
();
}
if
(!
backgroundOverlayId
.
equals
(
""
))
{
Layout
overlay
=
project
.
getLayoutByIdentifier
(
Integer
.
valueOf
(
backgroundOverlayId
));
if
(
overlay
==
null
)
{
throw
new
ObjectNotFoundException
(
"Unknown overlay in model. Layout.id="
+
backgroundOverlayId
);
}
if
(
overlay
.
getTitle
().
equals
(
BuildInLayout
.
CLEAN
.
getTitle
()))
{
// this might not return true if we change CLEAN.title in future...
// if it's clean then remove coloring
new
ClearColorModelCommand
(
part
).
execute
();
}
}
// Color with overlays
for
(
String
overlayId
:
overlayIdsList
)
{
Layout
overlay
=
layoutService
.
getLayoutById
(
Integer
.
parseInt
(
overlayId
.
trim
()));
...
...
rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java
View file @
cbca1b79
...
...
@@ -108,20 +108,20 @@ public class ModelRestImplTest extends RestTestFunctions {
@Test
(
expected
=
QueryException
.
class
)
public
void
testGetModelAsFileModel
()
throws
Exception
{
ModelRestImpl
modelRest
=
createMockProjectRest
(
"testFiles/model/sample.xml"
);
modelRest
.
getModelAsModelFile
(
"sample"
,
"0"
,
""
,
""
,
""
,
null
,
null
,
null
);
modelRest
.
getModelAsModelFile
(
"sample"
,
"0"
,
""
,
""
,
""
,
null
,
null
,
null
,
""
);
}
@Test
public
void
testGetModelAsFileModel2
()
throws
Exception
{
ModelRestImpl
modelRest
=
createMockProjectRest
(
"testFiles/model/sample.xml"
);
modelRest
.
getModelAsModelFile
(
"sample"
,
"0"
,
CellDesignerXmlParser
.
class
.
getCanonicalName
(),
""
,
"0,0;90,0;90,90;90,0"
,
null
,
null
,
null
);
"0,0;90,0;90,90;90,0"
,
null
,
null
,
null
,
""
);
}
@Test
(
expected
=
QueryException
.
class
)
public
void
testGetModelAsFileModel3
()
throws
Exception
{
ModelRestImpl
modelRest
=
createMockProjectRest
(
"testFiles/model/sample.xml"
);
modelRest
.
getModelAsModelFile
(
"sample"
,
"0"
,
""
,
""
,
"0,0;90,0;90,90;90,0"
,
null
,
null
,
null
);
modelRest
.
getModelAsModelFile
(
"sample"
,
"0"
,
""
,
""
,
"0,0;90,0;90,90;90,0"
,
null
,
null
,
null
,
""
);
}
@Test
...
...
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