@@ -13,31 +13,17 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
13
13
import org.springframework.boot.runApplication
14
14
import org.springframework.boot.web.servlet.ServletComponentScan
15
15
import org.springframework.context.annotation.Bean
16
+ import org.springframework.stereotype.Component
16
17
import java.io.BufferedInputStream
17
18
import java.io.IOException
18
19
import java.util.*
19
20
20
21
/* *
21
22
* Database source CDI consumer
22
23
*/
24
+ @Component
23
25
class DbDataSource {
24
- @Autowired lateinit var apps: AppRepository
25
- @Autowired lateinit var revs: AppUpdateRepository
26
- @Autowired lateinit var comments: CommentRepository
27
- @Autowired lateinit var users: UserRepository
28
- @Autowired lateinit var timeline: TimelineRepository
29
- @Autowired lateinit var notifications: NotificationRepository
30
- @Autowired lateinit var categories: CategoryRepository
31
- @Autowired lateinit var collaborators: CollabRelRepository
32
- @Autowired lateinit var follow: FollowRelRepository
33
- @Autowired lateinit var star: StarRelRepository
34
- fun dumpDb () {
35
- val rel = RelationMigrationRepositories (collaborators, follow, star)
36
-
37
- val a = MigrationRepositoriesA (apps, revs, comments)
38
- val b = MigrationRepositoriesB (users, timeline, notifications)
39
- val c = MigrationRepositoriesC (categories, rel)
40
-
26
+ fun dumpDb (a : MigrationRepositoriesA , b : MigrationRepositoriesB , c : MigrationRepositoriesC ) {
41
27
val migration = Migrates .Migration (a, b, c)
42
28
Migrates .dumpAll(migration)
43
29
}
@@ -53,6 +39,23 @@ class DbDataSource {
53
39
@SpringBootApplication
54
40
@EnableAutoConfiguration
55
41
class GeekApkApplication {
42
+ @Autowired(required = false ) lateinit var apps: AppRepository
43
+ @Autowired(required = false ) lateinit var revs: AppUpdateRepository
44
+ @Autowired(required = false ) lateinit var comments: CommentRepository
45
+ @Autowired(required = false ) lateinit var users: UserRepository
46
+ @Autowired(required = false ) lateinit var timeline: TimelineRepository
47
+ @Autowired(required = false ) lateinit var notifications: NotificationRepository
48
+ @Autowired(required = false ) lateinit var categories: CategoryRepository
49
+ @Autowired(required = false ) lateinit var collaborators: CollabRelRepository
50
+ @Autowired(required = false ) lateinit var follow: FollowRelRepository
51
+ @Autowired(required = false ) lateinit var star: StarRelRepository
52
+
53
+ fun rel () = RelationMigrationRepositories (collaborators, follow, star)
54
+
55
+ fun a () = MigrationRepositoriesA (apps, revs, comments)
56
+ fun b () = MigrationRepositoriesB (users, timeline, notifications)
57
+ fun c () = MigrationRepositoriesC (categories, rel())
58
+
56
59
/* *
57
60
* Print welcome message and (may process initialization files)
58
61
*/
@@ -91,7 +94,7 @@ class GeekApkApplication {
91
94
" --help" , " help" -> println (" Program usage: geekapk [version|help|licence]" +
92
95
" Find help at https://github.com/duangsuse/GeekApk" )
93
96
" --licence" , " licence" -> println (" Copyright (C) 2019 duangsuse, GeekApk Spring, licenced under GNU AGPL-3.0" )
94
- " dump!" -> DbDataSource ().dumpDb()
97
+ " dump!" -> DbDataSource ().dumpDb(a(), b(), c() )
95
98
else -> println (" Warning: unknown operation" )
96
99
}
97
100
else -> println (" Warning: unexpected argument vector length: ${args.size} " )
0 commit comments