Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
search
Commits
b3b25d62
Commit
b3b25d62
authored
May 18, 2021
by
Gradl, Tobias
Browse files
427: Make grammar compilation available from within container (OPENED)
Task-Url:
#427
parent
a79cf0f1
Changes
6
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
b3b25d62
...
...
@@ -19,8 +19,8 @@ allprojects {
}
ext
{
coreVersion
=
"6.2-SNAPSHOT"
gtfVersion
=
"2.
0
.0-SNAPSHOT"
processingVersion
=
"4.
1
.0-SNAPSHOT"
gtfVersion
=
"2.
1
.0-SNAPSHOT"
processingVersion
=
"4.
2
.0-SNAPSHOT"
colregModelVersion
=
"4.3.4-RELEASE"
dariahSpVersion
=
"2.1.6-RELEASE"
...
...
search-core/src/main/java/eu/dariah/de/search/es/client/IndexClient.java
View file @
b3b25d62
...
...
@@ -11,6 +11,4 @@ public interface IndexClient extends BaseEsClient {
public
String
[]
getIndexNames
();
public
String
getIndexNameForDatamodelId
(
String
modelId
);
public
String
getIndexConfigPath
();
}
search-core/src/main/java/eu/dariah/de/search/es/client/IndexClientImpl.java
View file @
b3b25d62
...
...
@@ -30,11 +30,7 @@ public class IndexClientImpl extends BaseEsClientImpl implements IndexClient, In
private
Pattern
indexNamePattern
;
@Autowired
private
File
indexConfigFile
;
@Override
public
String
getIndexConfigPath
()
{
return
indexConfigFile
.
getAbsolutePath
();
}
@Autowired
private
Settings
indexConfigSettings
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
...
...
@@ -55,20 +51,13 @@ public class IndexClientImpl extends BaseEsClientImpl implements IndexClient, In
@Override
public
boolean
createIndex
(
String
indexName
)
{
Assert
.
notNull
(
indexName
,
"Index name cannot be null"
);
Settings
settings
=
null
;
try
{
if
(
this
.
indexExists
(
indexName
))
{
throw
new
ElasticsearchAdminException
(
String
.
format
(
"Index [%s] already exists and needs to be deleted manually"
,
indexName
));
}
if
(
this
.
getIndexConfigPath
()!=
null
)
{
settings
=
Settings
.
builder
().
loadFromPath
(
Paths
.
get
(
getIndexConfigPath
())).
build
();
}
CreateIndexRequest
request
=
new
CreateIndexRequest
(
indexName
);
if
(
settings
==
null
)
{
logger
.
warn
(
"No index configuration available. Please check configuration of this search instance"
);
}
request
.
settings
(
settings
);
request
.
settings
(
indexConfigSettings
);
return
client
.
indices
().
create
(
request
,
RequestOptions
.
DEFAULT
).
isAcknowledged
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Failed to create index settings"
,
e
);
...
...
search-core/src/test/java/eu/dariah/de/search/es/client/base/BaseEsClientTest.java
View file @
b3b25d62
...
...
@@ -29,6 +29,6 @@ public class BaseEsClientTest extends BaseEsIntegrationTest {
@BeforeEach
public
void
setup
()
throws
Exception
{
Mockito
.
when
(
indexClient
.
getIndexConfigPath
()).
thenReturn
(
indexConfig
.
getAbsolutePath
());
//
Mockito.when(indexClient.getIndexConfigPath()).thenReturn(indexConfig.getAbsolutePath());
}
}
search-ui/src/main/java/eu/dariah/de/search/config/MainConfig.java
View file @
b3b25d62
...
...
@@ -9,6 +9,7 @@ import java.security.NoSuchAlgorithmException;
import
javax.annotation.PostConstruct
;
import
org.elasticsearch.common.settings.Settings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -111,15 +112,12 @@ public class MainConfig extends MainConfigProperties {
}
@Bean
public
File
indexConfig
File
()
throws
ConfigurationException
,
IOException
{
public
Settings
indexConfig
Settings
()
throws
ConfigurationException
,
IOException
{
File
indexConfig
=
new
File
(
this
.
getPaths
().
getConfig
()
+
File
.
separator
+
this
.
getIndexing
().
getIndexConfigFile
());
if
(
!
indexConfig
.
exists
())
{
indexConfig
=
resourceLoader
.
getResource
(
"classpath:conf/"
+
th
i
s
.
get
Indexing
().
getIndexConfigFile
()).
getF
il
e
();
if
(
indexConfig
.
exists
())
{
return
Settings
.
builder
().
loadFromPath
(
Pa
ths
.
get
(
indexConfig
.
getAbsolutePath
())).
bu
il
d
();
}
if
(!
indexConfig
.
exists
())
{
throw
new
ConfigurationException
(
"Index config (index_config.json) not provided or does not exist"
);
}
return
indexConfig
;
return
Settings
.
builder
().
loadFromStream
(
"index_config.json"
,
resourceLoader
.
getResource
(
"classpath:conf/"
+
this
.
getIndexing
().
getIndexConfigFile
()).
getInputStream
(),
true
).
build
();
}
@Bean
...
...
search-ui/src/main/java/eu/dariah/de/search/config/WebConfig.java
View file @
b3b25d62
...
...
@@ -62,10 +62,10 @@ public class WebConfig implements WebMvcConfigurer {
@Bean
public
Navigation
navigation
(
ObjectMapper
objectMapper
)
throws
IOException
{
File
navigation
=
new
File
(
mainConfig
.
getPaths
().
getConfig
()
+
File
.
separator
+
"navigation.json"
);
if
(
!
navigation
.
exists
())
{
navigation
=
resourceLoader
.
getResource
(
"classpath:conf/navigation.json"
).
getFile
(
);
}
return
objectMapper
.
readValue
(
navigation
,
Navigation
.
class
);
if
(
navigation
.
exists
())
{
return
objectMapper
.
readValue
(
navigation
,
Navigation
.
class
);
}
return
objectMapper
.
readValue
(
resourceLoader
.
getResource
(
"classpath:conf/navigation.json"
).
getInputStream
()
,
Navigation
.
class
);
}
@Bean
...
...
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