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
16e25275
Commit
16e25275
authored
Jun 22, 2021
by
Piotr Gawron
Browse files
modelConverters and imageConverters moved to controller
parent
8fcfe4c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationController.java
View file @
16e25275
...
...
@@ -18,6 +18,10 @@ import org.springframework.web.bind.annotation.*;
import
lcsb.mapviewer.annotation.services.dapi.DapiConnectionException
;
import
lcsb.mapviewer.annotation.services.dapi.dto.UserDto
;
import
lcsb.mapviewer.api.BaseController
;
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.security.PrivilegeType
;
import
lcsb.mapviewer.model.user.ConfigurationOption
;
import
lcsb.mapviewer.services.QueryException
;
...
...
@@ -33,12 +37,16 @@ public class ConfigurationController extends BaseController {
private
IConfigurationService
configurationService
;
private
ServletContext
context
;
private
List
<
Converter
>
modelConverters
;
@Autowired
public
ConfigurationController
(
ConfigurationRestImpl
configurationController
,
IConfigurationService
configurationService
,
ServletContext
context
)
{
ServletContext
context
,
List
<
Converter
>
modelConverters
)
{
this
.
configurationRestImpl
=
configurationController
;
this
.
configurationService
=
configurationService
;
this
.
modelConverters
=
modelConverters
;
this
.
context
=
context
;
}
...
...
@@ -46,8 +54,8 @@ public class ConfigurationController extends BaseController {
public
Map
<
String
,
Object
>
getConfiguration
(
Authentication
authentication
)
{
Map
<
String
,
Object
>
result
=
new
TreeMap
<>();
result
.
put
(
"options"
,
getOptions
(
authentication
));
result
.
put
(
"imageFormats"
,
configurationRestImpl
.
getImageFormats
());
result
.
put
(
"modelFormats"
,
configurationRestImpl
.
getModelFormats
());
result
.
put
(
"imageFormats"
,
getImageFormats
());
result
.
put
(
"modelFormats"
,
getModelFormats
());
result
.
put
(
"overlayTypes"
,
configurationRestImpl
.
getOverlayTypes
());
result
.
put
(
"elementTypes"
,
configurationRestImpl
.
getElementTypes
());
result
.
put
(
"reactionTypes"
,
configurationRestImpl
.
getReactionTypes
());
...
...
@@ -110,4 +118,34 @@ public class ConfigurationController extends BaseController {
Map
<
String
,
Object
>
data
=
getData
(
node
,
"option"
);
return
configurationRestImpl
.
updateOption
(
option
,
data
);
}
public
List
<
Map
<
String
,
Object
>>
getImageFormats
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
ImageGenerators
imageGenerators
=
new
ImageGenerators
();
List
<
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>>
imageGeneratorList
=
imageGenerators
.
getAvailableImageGenerators
();
for
(
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>
element
:
imageGeneratorList
)
{
Map
<
String
,
Object
>
row
=
new
TreeMap
<>();
row
.
put
(
"name"
,
element
.
getLeft
());
row
.
put
(
"handler"
,
element
.
getRight
().
getCanonicalName
());
row
.
put
(
"extension"
,
imageGenerators
.
getExtension
(
element
.
getRight
()));
result
.
add
(
row
);
}
return
result
;
}
public
List
<
Map
<
String
,
Object
>>
getModelFormats
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Converter
converter
:
modelConverters
)
{
Map
<
String
,
Object
>
row
=
new
TreeMap
<>();
row
.
put
(
"name"
,
converter
.
getCommonName
());
row
.
put
(
"handler"
,
converter
.
getClass
().
getCanonicalName
());
row
.
put
(
"extension"
,
converter
.
getFileExtension
());
result
.
add
(
row
);
}
return
result
;
}
}
\ No newline at end of file
rest-api/src/main/java/lcsb/mapviewer/api/configuration/ConfigurationRestImpl.java
View file @
16e25275
...
...
@@ -16,11 +16,7 @@ import lcsb.mapviewer.annotation.services.dapi.DapiConnector;
import
lcsb.mapviewer.annotation.services.dapi.dto.ReleaseDto
;
import
lcsb.mapviewer.annotation.services.dapi.dto.UserDto
;
import
lcsb.mapviewer.api.BaseRestImpl
;
import
lcsb.mapviewer.common.Pair
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.converter.Converter
;
import
lcsb.mapviewer.converter.graphics.AbstractImageGenerator
;
import
lcsb.mapviewer.converter.graphics.ImageGenerators
;
import
lcsb.mapviewer.model.graphics.MapCanvasType
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.kinetics.SbmlUnitType
;
...
...
@@ -78,37 +74,6 @@ public class ConfigurationRestImpl extends BaseRestImpl {
this
.
configurationService
=
configurationService
;
}
public
List
<
Map
<
String
,
Object
>>
getImageFormats
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
ImageGenerators
imageGenerators
=
new
ImageGenerators
();
List
<
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>>
imageGeneratorList
=
imageGenerators
.
getAvailableImageGenerators
();
for
(
Pair
<
String
,
Class
<?
extends
AbstractImageGenerator
>>
element
:
imageGeneratorList
)
{
Map
<
String
,
Object
>
row
=
new
TreeMap
<>();
row
.
put
(
"name"
,
element
.
getLeft
());
row
.
put
(
"handler"
,
element
.
getRight
().
getCanonicalName
());
row
.
put
(
"extension"
,
imageGenerators
.
getExtension
(
element
.
getRight
()));
result
.
add
(
row
);
}
return
result
;
}
public
List
<
Map
<
String
,
Object
>>
getModelFormats
()
{
List
<
Converter
>
converters
=
getModelConverters
();
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Converter
converter
:
converters
)
{
Map
<
String
,
Object
>
row
=
new
TreeMap
<>();
row
.
put
(
"name"
,
converter
.
getCommonName
());
row
.
put
(
"handler"
,
converter
.
getClass
().
getCanonicalName
());
row
.
put
(
"extension"
,
converter
.
getFileExtension
());
result
.
add
(
row
);
}
return
result
;
}
public
List
<
Map
<
String
,
Object
>>
getOverlayTypes
()
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
DataOverlayType
type
:
DataOverlayType
.
values
())
{
...
...
rest-api/src/test/java/lcsb/mapviewer/api/configuration/ConfigurationRestImplTest.java
View file @
16e25275
...
...
@@ -53,18 +53,6 @@ public class ConfigurationRestImplTest extends RestTestFunctions {
assertNotNull
(
result
);
}
@Test
public
void
testImageFormats
()
throws
Exception
{
List
<
Map
<
String
,
Object
>>
list
=
configurationRestImpl
.
getImageFormats
();
assertTrue
(
list
.
size
()
>
0
);
}
@Test
public
void
testModelFormats
()
throws
Exception
{
List
<
Map
<
String
,
Object
>>
list
=
configurationRestImpl
.
getModelFormats
();
assertTrue
(
list
.
size
()
>
0
);
}
@Test
public
void
testGetElementTypes
()
throws
Exception
{
Set
<
Map
<
String
,
String
>>
list
=
configurationRestImpl
.
getElementTypes
();
...
...
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