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
f8a73b0a
Commit
f8a73b0a
authored
Aug 28, 2019
by
Piotr Gawron
Browse files
ColorSchemaType is obligatory
parent
f663508f
Pipeline
#13315
passed with stage
in 10 minutes and 11 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java
View file @
f8a73b0a
...
...
@@ -12,10 +12,12 @@ import org.apache.commons.io.IOUtils;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
lcsb.mapviewer.common.TextFileUtils
;
import
lcsb.mapviewer.common.exception.*
;
import
lcsb.mapviewer.common.exception.InvalidClassException
;
import
lcsb.mapviewer.converter.zip.*
;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.map.layout.ColorSchemaType
;
import
lcsb.mapviewer.model.map.layout.Layout
;
import
lcsb.mapviewer.model.map.model.*
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
...
...
@@ -310,6 +312,18 @@ public class ComplexZipConverter {
fileEntry
.
setFileContent
(
IOUtils
.
toByteArray
(
zipFile
.
getInputStream
(
entry
)));
fileEntry
.
setOriginalFileName
(
entry
.
getName
());
fileEntry
.
setLength
(
fileEntry
.
getFileContent
().
length
);
Map
<
String
,
String
>
parameters
=
TextFileUtils
.
getHeaderParametersFromFile
(
zipFile
.
getInputStream
(
entry
));
ColorSchemaType
colorSchemaType
=
null
;
String
type
=
parameters
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
);
if
(
type
!=
null
)
{
colorSchemaType
=
ColorSchemaType
.
valueOf
(
type
);
}
if
(
colorSchemaType
==
null
)
{
colorSchemaType
=
ColorSchemaType
.
GENERIC
;
}
layout
.
setColorSchemaType
(
colorSchemaType
);
layout
.
setInputData
(
fileEntry
);
layout
.
setPublicLayout
(
true
);
layout
.
setTitle
(
layoutEntry
.
getName
());
...
...
service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java
View file @
f8a73b0a
package
lcsb.mapviewer.services.impl
;
import
java.awt.
*
;
import
java.awt.
Color
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.Comparator
;
import
java.util.List
;
import
javax.mail.MessagingException
;
...
...
@@ -153,6 +152,17 @@ public class LayoutService implements ILayoutService {
public
Layout
createLayout
(
final
CreateLayoutParams
params
)
throws
IOException
,
InvalidColorSchemaException
{
ColorSchemaReader
reader
=
new
ColorSchemaReader
();
Map
<
String
,
String
>
parameters
=
TextFileUtils
.
getHeaderParametersFromFile
(
params
.
getColorInputStream
());
ColorSchemaType
colorSchemaType
=
params
.
getColorSchemaType
();
if
(
colorSchemaType
==
null
)
{
String
type
=
parameters
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
);
if
(
type
!=
null
)
{
colorSchemaType
=
ColorSchemaType
.
valueOf
(
type
);
}
}
if
(
colorSchemaType
==
null
)
{
colorSchemaType
=
ColorSchemaType
.
GENERIC
;
}
if
(
parameters
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
)
==
null
&&
params
.
getColorSchemaType
()
!=
null
)
{
parameters
.
put
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
,
params
.
getColorSchemaType
().
name
());
}
...
...
@@ -171,7 +181,7 @@ public class LayoutService implements ILayoutService {
layoutDao
.
flush
();
Layout
topLayout
=
new
Layout
(
params
.
getName
(),
false
);
topLayout
.
setColorSchemaType
(
params
.
getC
olorSchemaType
()
);
topLayout
.
setColorSchemaType
(
c
olorSchemaType
);
if
(
params
.
getUser
()
==
null
)
{
topLayout
.
setPublicLayout
(
true
);
}
else
{
...
...
service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java
View file @
f8a73b0a
...
...
@@ -773,6 +773,7 @@ public class ProjectService implements IProjectService {
for
(
BuildInLayout
buildInLayout
:
buildInLayouts
)
{
int
submodelId
=
0
;
Layout
topLayout
=
new
Layout
(
buildInLayout
.
getTitle
(),
true
);
topLayout
.
setColorSchemaType
(
ColorSchemaType
.
GENERIC
);
topLayout
.
setStatus
(
LayoutStatus
.
NA
);
topLayout
.
setProgress
(
0.0
);
topLayout
.
setHierarchicalView
(
buildInLayout
.
isNested
());
...
...
@@ -787,6 +788,7 @@ public class ProjectService implements IProjectService {
if
(
params
.
isSemanticZoomContainsMultipleLayouts
()
&&
buildInLayout
==
BuildInLayout
.
NESTED
)
{
for
(
int
i
=
0
;
i
<=
topModel
.
getZoomLevels
();
i
++)
{
Layout
semanticOverlay
=
new
Layout
(
buildInLayout
.
getTitle
()
+
"-"
+
i
,
true
);
semanticOverlay
.
setColorSchemaType
(
ColorSchemaType
.
GENERIC
);
String
directory
=
params
.
getProjectDir
()
+
"/"
+
buildInLayout
.
getDirectorySuffix
()
+
"-"
+
i
+
"-"
+
topModel
.
getId
()
+
"/"
;
...
...
web/src/test/java/lcsb/mapviewer/web/ControllerIntegrationTest.java
View file @
f8a73b0a
...
...
@@ -31,6 +31,7 @@ import lcsb.mapviewer.model.Project;
import
lcsb.mapviewer.model.ProjectStatus
;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.graphics.PolylineData
;
import
lcsb.mapviewer.model.map.layout.ColorSchemaType
;
import
lcsb.mapviewer.model.map.layout.Layout
;
import
lcsb.mapviewer.model.map.model.ModelData
;
import
lcsb.mapviewer.model.map.reaction.*
;
...
...
@@ -302,6 +303,7 @@ abstract public class ControllerIntegrationTest {
file
.
setLength
(
content
.
getBytes
().
length
);
Layout
overlay
=
new
Layout
();
overlay
.
setColorSchemaType
(
ColorSchemaType
.
GENERIC
);
overlay
.
setInputData
(
file
);
overlay
.
setProject
(
project
);
overlay
.
setCreator
(
admin
);
...
...
web/src/test/java/lcsb/mapviewer/web/OverlayControllerIntegrationTest.java
View file @
f8a73b0a
...
...
@@ -83,15 +83,9 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
User
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
Layout
layout
=
new
Layout
();
layout
.
setCreator
(
user
);
layout
.
setProject
(
project
);
layoutDao
.
add
(
layout
);
createOverlay
(
project
,
user
);
Layout
curatorLayout
=
new
Layout
();
curatorLayout
.
setCreator
(
curator
);
curatorLayout
.
setProject
(
project
);
layoutDao
.
add
(
curatorLayout
);
createOverlay
(
project
,
curator
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
...
...
@@ -112,8 +106,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
public
void
testListPublicOverlaysOverlaysWhenCreatorEmpty
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Layout
layout
=
new
Layout
();
layout
.
setProject
(
project
);
Layout
layout
=
createOverlay
(
project
,
null
);
layout
.
setPublicLayout
(
true
);
layoutDao
.
add
(
layout
);
...
...
@@ -136,8 +129,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
public
void
testListNonPublicOverlaysOverlaysWhenCreatorEmpty
()
throws
Exception
{
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Layout
layout
=
new
Layout
();
layout
.
setProject
(
project
);
Layout
layout
=
createOverlay
(
project
,
null
);
layout
.
setPublicLayout
(
true
);
layoutDao
.
add
(
layout
);
...
...
@@ -164,15 +156,12 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
Layout
layout
=
new
Layout
();
layout
.
setProject
(
project
);
Layout
layout
=
createOverlay
(
project
,
null
);
layout
.
setPublicLayout
(
true
);
layoutDao
.
add
(
layout
);
Layout
curatorLayout
=
new
Layout
(
);
Layout
curatorLayout
=
createOverlay
(
project
,
curator
);
curatorLayout
.
setPublicLayout
(
false
);
curatorLayout
.
setCreator
(
curator
);
curatorLayout
.
setProject
(
project
);
layoutDao
.
add
(
curatorLayout
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
...
...
@@ -197,15 +186,12 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
User
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
Layout
layout
=
new
Layout
();
layout
.
setProject
(
project
);
Layout
layout
=
createOverlay
(
project
,
null
);
layout
.
setPublicLayout
(
true
);
layoutDao
.
add
(
layout
);
Layout
userLayout
=
new
Layout
(
);
Layout
userLayout
=
createOverlay
(
project
,
user
);
userLayout
.
setPublicLayout
(
false
);
userLayout
.
setCreator
(
user
);
userLayout
.
setProject
(
project
);
layoutDao
.
add
(
userLayout
);
MockHttpSession
session
=
createSession
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -227,20 +213,16 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
public
void
testUserShouldSeeAllPublicOverlaysAndOverlays
()
throws
Exception
{
User
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
project
);
Layout
layout
=
new
Layout
();
layout
.
setProject
(
project
);
Layout
layout
=
createOverlay
(
project
,
null
);
layout
.
setPublicLayout
(
true
);
layoutDao
.
add
(
layout
);
Layout
hiddenLayout
=
new
Layout
();
hiddenLayout
.
setProject
(
project
);
Layout
hiddenLayout
=
createOverlay
(
project
,
null
);
hiddenLayout
.
setPublicLayout
(
false
);
layoutDao
.
add
(
hiddenLayout
);
Layout
userLayout
=
new
Layout
(
);
Layout
userLayout
=
createOverlay
(
project
,
user
);
userLayout
.
setPublicLayout
(
false
);
userLayout
.
setCreator
(
user
);
userLayout
.
setProject
(
project
);
layoutDao
.
add
(
userLayout
);
MockHttpSession
session
=
createSession
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
...
...
@@ -277,10 +259,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
User
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
project
);
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Layout
overlay
=
new
Layout
();
overlay
.
setProject
(
project
);
overlay
.
setCreator
(
user
);
layoutDao
.
add
(
overlay
);
Layout
overlay
=
createOverlay
(
project
,
user
);
MockHttpSession
session
=
createSession
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
...
...
@@ -298,10 +277,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
User
curator
=
createCurator
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
userService
.
grantUserPrivilege
(
curator
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
Layout
overlay
=
new
Layout
();
overlay
.
setProject
(
project
);
overlay
.
setCreator
(
user
);
layoutDao
.
add
(
overlay
);
Layout
overlay
=
createOverlay
(
project
,
user
);
MockHttpSession
session
=
createSession
(
TEST_CURATOR_LOGIN
,
TEST_CURATOR_PASSWORD
);
...
...
@@ -317,10 +293,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
public
void
testUserCanAccessHisOwnOverlay
()
throws
Exception
{
User
user
=
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
project
);
Layout
overlay
=
new
Layout
();
overlay
.
setProject
(
project
);
overlay
.
setCreator
(
user
);
layoutDao
.
add
(
overlay
);
Layout
overlay
=
createOverlay
(
project
,
user
);
MockHttpSession
session
=
createSession
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
...
...
@@ -337,10 +310,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
project
);
User
admin
=
createAdmin
(
TEST_ADMIN_LOGIN
,
TEST_ADMIN_PASSWORD
);
Layout
overlay
=
new
Layout
();
overlay
.
setProject
(
project
);
overlay
.
setCreator
(
admin
);
layoutDao
.
add
(
overlay
);
Layout
overlay
=
createOverlay
(
project
,
admin
);
MockHttpSession
session
=
createSession
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
);
...
...
@@ -922,8 +892,7 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
public
void
testUserCanAccessPublicOverlay
()
throws
Exception
{
createUser
(
TEST_USER_LOGIN
,
TEST_USER_PASSWORD
,
project
);
Layout
overlay
=
new
Layout
();
overlay
.
setProject
(
project
);
Layout
overlay
=
createOverlay
(
project
,
null
);
overlay
.
setPublicLayout
(
true
);
layoutDao
.
add
(
overlay
);
...
...
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