Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Merge requests
!406
Draft: WIP
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Closed
Draft: WIP
485-fixity-checks
into
dev
Overview
0
Commits
6
Pipelines
0
Changes
7
Closed
Draft: WIP
Martin Weise
requested to merge
485-fixity-checks
into
dev
3 months ago
Overview
0
Commits
6
Pipelines
0
Changes
7
Signed-off-by: Martin Weise
martin.weise@tuwien.ac.at
Closes #485
0
0
Merge request reports
Compare
dev
version 5
b085520d
2 months ago
version 4
4259ebcd
2 months ago
version 3
1e019065
3 months ago
version 2
b09d5d04
3 months ago
version 1
f8baeee9
3 months ago
dev (base)
and
version 4
latest version
d8e28e20
6 commits,
2 months ago
version 5
b085520d
5 commits,
2 months ago
version 4
4259ebcd
4 commits,
2 months ago
version 3
1e019065
3 commits,
3 months ago
version 2
b09d5d04
2 commits,
3 months ago
version 1
f8baeee9
1 commit,
3 months ago
7 files
+
232
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
dbrepo-data-service/rest-service/src/main/java/at/ac/tuwien/ifs/dbrepo/DataServiceApplication.java
+
73
−
1
View file @ 4259ebcd
Edit in single-file editor
Open in Web IDE
package
at.ac.tuwien.ifs.dbrepo
;
import
at.ac.tuwien.ifs.dbrepo.core.api.database.DatabaseBriefDto
;
import
at.ac.tuwien.ifs.dbrepo.core.api.database.DatabaseDto
;
import
at.ac.tuwien.ifs.dbrepo.core.api.database.ViewDto
;
import
at.ac.tuwien.ifs.dbrepo.core.api.database.table.TableDto
;
import
at.ac.tuwien.ifs.dbrepo.core.exception.*
;
import
at.ac.tuwien.ifs.dbrepo.gateway.MetadataServiceGateway
;
import
at.ac.tuwien.ifs.dbrepo.service.CacheService
;
import
at.ac.tuwien.ifs.dbrepo.service.ContainerService
;
import
at.ac.tuwien.ifs.dbrepo.service.DatabaseService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
java.sql.SQLException
;
import
java.util.List
;
@Slf4j
@EnableScheduling
@SpringBootApplication
public
class
DataServiceApplication
{
public
class
DataServiceApplication
implements
CommandLineRunner
{
private
final
CacheService
cacheService
;
private
final
DatabaseService
databaseService
;
private
final
ContainerService
containerService
;
private
final
ApplicationContext
applicationContext
;
private
final
MetadataServiceGateway
metadataServiceGateway
;
@Autowired
public
DataServiceApplication
(
CacheService
cacheService
,
DatabaseService
databaseService
,
ContainerService
containerService
,
ApplicationContext
applicationContext
,
MetadataServiceGateway
metadataServiceGateway
)
{
this
.
cacheService
=
cacheService
;
this
.
databaseService
=
databaseService
;
this
.
containerService
=
containerService
;
this
.
applicationContext
=
applicationContext
;
this
.
metadataServiceGateway
=
metadataServiceGateway
;
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DataServiceApplication
.
class
,
args
);
}
@Override
public
void
run
(
String
...
args
)
throws
MetadataServiceException
,
RemoteUnavailableException
,
SQLException
,
DatabaseNotFoundException
,
QueryStoreCreateException
,
TableNotFoundException
,
DatabaseMalformedException
,
ViewNotFoundException
{
if
(
args
.
length
==
0
)
{
return
;
}
for
(
DatabaseBriefDto
d
:
metadataServiceGateway
.
getDatabases
())
{
final
DatabaseDto
database
=
cacheService
.
getDatabase
(
d
.
getId
());
containerService
.
createQueryStore
(
database
.
getContainer
(),
database
.
getInternalName
());
final
List
<
TableDto
>
tables
=
databaseService
.
exploreTables
(
database
);
if
(
database
.
getTables
().
size
()
!=
tables
.
size
())
{
final
List
<
TableDto
>
missingTables
=
tables
.
stream
()
.
filter
(
table
->
database
.
getTables
()
.
stream
()
.
noneMatch
(
t
->
table
.
getInternalName
().
equals
(
t
.
getInternalName
())))
.
toList
();
if
(!
missingTables
.
isEmpty
())
{
log
.
warn
(
"Failed to obtain metadata on table(s): {}"
,
missingTables
);
metadataServiceGateway
.
updateTableSchemas
(
d
.
getId
());
}
}
final
List
<
ViewDto
>
views
=
databaseService
.
exploreViews
(
database
);
if
(
database
.
getViews
().
size
()
!=
views
.
size
())
{
final
List
<
ViewDto
>
missingViews
=
views
.
stream
()
.
filter
(
view
->
database
.
getTables
()
.
stream
()
.
noneMatch
(
v
->
view
.
getInternalName
().
equals
(
v
.
getInternalName
())))
.
toList
();
if
(!
missingViews
.
isEmpty
())
{
log
.
warn
(
"Failed to obtain metadata on view(s): {}"
,
missingViews
);
metadataServiceGateway
.
updateViewSchemas
(
d
.
getId
());
}
}
}
log
.
info
(
"Finished initialization"
);
SpringApplication
.
exit
(
applicationContext
,
()
->
0
);
}
}
Loading