Skip to content

Commit 89105fd

Browse files
Artem-RzhankoffItIsMrLaGRozhkovAleksandr
authored
Beta version (#25)
* feat: Implement saving data between program runs * fix(RBStruct): Remove infinite loop in postorder, correct comparison in restoreStruct * feat(neo4j): Implement saving many trees * refactor: Rename some classes and packages * feat: Implement checking code coverage in CI * feat: Implement checking code coverage in CI * fix: Deleting node with one child * fix: Problems with Serializable connection; Refactor commonObjects package and Tree.putItem method; fix #21 - issue fix: Problems with Serializable connection; Refactor commonObjects package and Tree.putItem method; fix #21 - issue * feat(.json files): Implement saving many trees * refactor: Change argument name in balance method * refactor: Exceptions throwing - #22. * refactor: Remove "turns" from interface Balancer. * Feat: add tests for BINStruct, AVLTree * feat: Implement a sketch of the application start window * feat: Implement a name getter for all trees (BIN, RBT) * feat: Implement saving AVLStruct in SQLite via exposed-ORM (#23). refactor: .... * feat: Implement TreeManager interface for interacting with controller * refactor: Remove warnings after intellij hints * feat: Redesign interface TreeManager; Implement AVLTreeManager * refactor: Redesign SQLiteRepositoryExposed * feat: Implement searching file in neo4j and json repo * feat: Implement Controller sketch * feat: Implement some MenuItems * feat: Implement common methods of Managers classes * fix: Change some input parameters * fix: Add functionality to the menu * fix: Completely redesigned homepage * feat: Implement basic architecture of trees rendering without positioning; Create an implementation of BIN rendering without padding. (#24) * feat: Implement FileDialog to select files * refactor: architecture of database interaction with trees - rewrite logic TreeManagers (#24). * feat: Implement a user input validator * Implement saveDialog to save trees * feat: Implement DeleteDialog for tree removal * refactor: Structure files (ui) * refactor: Rewrite architecture responsible for working with databases, interacting with data structures (TreeStructs); implement binary tree coordinates counting (#24). * feat: Implement methods for DrawableTrees displaying - TreeDrawingUtils (#24). * refactor: Structure files (ui) * feat: Implement displaying of RBDrawableTree and AVLDrawableTree (#24). * fix: Visual representation of the tree * feat: Implement DrawTree interface (#24). * fix: Move displayTree method inside DrawableTree (#24). * feat: Update DrawTree interface: make name and root of a DrawableTree var instead of val; create method - split methods deleteTree and deleteTreeFromDB (#24). * feat: Implement the integration of trees in the main interface * fix: Remove generics from DrawTree interface (#24). * fix: Display of the node data element * fix: Interacting with neo4j (find) * fix: Bugs in saving trees in databases. * feat: Implement saving trees to the database using ui * fix: Fix tests for trees --------- Co-authored-by: Georgy S <[email protected]> Co-authored-by: Aleksandr <[email protected]>
1 parent dd91b24 commit 89105fd

File tree

99 files changed

+3027
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3027
-527
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ jobs:
3232
with:
3333
generate-branches-badge: true
3434
jacoco-csv-file: lib/build/jacoco/report.csv
35+
36+
- if: ${{ github.event_name == 'pull_request' }}
37+
name: Jacoco Test Coverage Verification
38+
run: ./gradlew jacocoTestCoverageVerification

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
/lib/build/
55
/lib/TEST_TEST/
66
/gradle/
7+
/neo4jDB/
8+
/saved-trees/
9+
/sqliteDB/

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3.9'
2+
3+
services:
4+
neo4j:
5+
image: neo4j:latest
6+
volumes:
7+
- ./neo4jDB:/data
8+
container_name: neo4j-db
9+
ports:
10+
- "7474:7474"
11+
- "7687:7687"
12+
environment:
13+
- NEO4J_AUTH=neo4j/password

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
kotlinVersion=1.8.10
22
sqliteJdbcVersion=3.41.2.1
3+
exposedVersion=0.40.1

lib/build.gradle.kts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
val sqliteJdbcVersion: String by project
21
plugins {
32
java
43
kotlin("jvm") version "1.8.10"
54
jacoco
65
`java-library`
76
`maven-publish`
7+
kotlin("plugin.serialization") version "1.5.0"
88
// checkstyle
9+
id("org.jetbrains.compose") version "1.4.0"
910
}
1011

1112
java {
@@ -16,6 +17,7 @@ java {
1617

1718
repositories {
1819
mavenLocal()
20+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
1921
mavenCentral()
2022
}
2123

@@ -31,8 +33,18 @@ dependencies {
3133
implementation("org.neo4j", "neo4j-ogm-bolt-driver", neo4jCore)
3234

3335
// JDBC Sqlite
36+
val sqliteJdbcVersion: String by project
3437
implementation("org.xerial", "sqlite-jdbc", sqliteJdbcVersion)
3538

39+
val exposedVersion: String by project
40+
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
41+
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
42+
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
43+
44+
implementation(kotlin("stdlib-jdk8"))
45+
implementation(compose.desktop.currentOs)
46+
implementation(compose.material3)
47+
3648
testImplementation("io.mockk:mockk:1.13.4")
3749
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:1.8.10")
3850
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.2")
@@ -41,6 +53,12 @@ dependencies {
4153

4254
}
4355

56+
compose.desktop {
57+
application {
58+
mainClass = "MainKt"
59+
}
60+
}
61+
4462
tasks.test {
4563
finalizedBy(tasks.jacocoTestReport)
4664
useJUnitPlatform()
@@ -92,7 +110,7 @@ tasks.jacocoTestReport {
92110
tasks.jacocoTestCoverageVerification {
93111
classDirectories.setFrom( classDirectories.files.flatMap { fileTree(it) {
94112
include("**/RBBalancer.class", "**/AVLBalancer.class", "**/BINStruct", "**/AVLStruct.class", "**/BINStruct.class")
95-
exclude("**/singleObjects/**", "**/RBVertex.class", "**/AVLVertex.class", "**/BINVertex.class", "**/Vertex.class", "**/BINStruct.class", "**/AVLStruct.class", "**/RBStruct.class", "**/TreeStruct.class")
113+
exclude("**/commonObjects/**", "**/RBVertex.class", "**/AVLVertex.class", "**/BINVertex.class", "**/Vertex.class", "**/BINStruct.class", "**/AVLStruct.class", "**/RBStruct.class", "**/TreeStruct.class")
96114
} })
97115
dependsOn(tasks.jacocoTestReport)
98116
violationRules {

lib/src/main/kotlin/controller/BINTreeManager.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package controller
2+
3+
import databaseManage.AVLTreeManager
4+
import databaseManage.BINTreeManager
5+
import databaseManage.RBTreeManager
6+
import treelib.commonObjects.Container
7+
import viewPart.nodes.drawableAVL.AVLDrawableTree
8+
import viewPart.nodes.drawableBIN.BINDrawableTree
9+
import viewPart.nodes.drawableRB.RBDrawableTree
10+
import viewPart.nodes.drawableTree.DrawTree
11+
import java.io.File
12+
import java.lang.Integer.min
13+
14+
15+
class Controller {
16+
17+
private val avlManager = AVLTreeManager()
18+
private val rbManager = RBTreeManager()
19+
private val binManager = BINTreeManager()
20+
21+
22+
var tree: DrawTree? = null
23+
24+
fun showFiles(): List<List<String>> {
25+
val avlTrees = avlManager.getSavedTreesNames()
26+
val rbTrees = rbManager.getSavedTreesNames()
27+
28+
createDummyFiles(avlTrees, rbTrees)
29+
30+
return listOf(
31+
rbTrees.subList(0, min(3, rbTrees.size)),
32+
avlTrees.subList(0, min(3, avlTrees.size)),
33+
binManager.getSavedTreesNames()
34+
)
35+
}
36+
37+
private fun createDummyFiles(avlTrees: List<String>, rbTrees: List<String>) {
38+
val avlPath = System.getProperty("user.dir") + "/saved-trees/AVL-trees"
39+
val rbPath = System.getProperty("user.dir") + "/saved-trees/RB-trees"
40+
41+
File(avlPath).mkdirs()
42+
File(rbPath).mkdirs()
43+
44+
if (avlTrees.isNotEmpty()) {
45+
for (name in avlTrees) {
46+
File(avlPath, name).run {
47+
createNewFile()
48+
}
49+
}
50+
}
51+
52+
if (rbTrees.isNotEmpty()) {
53+
for (name in rbTrees) {
54+
File(rbPath, name).run {
55+
createNewFile()
56+
}
57+
}
58+
}
59+
60+
}
61+
62+
fun createTree(treeName: String, id: Int): DrawTree {
63+
when (id) {
64+
0 -> tree = RBDrawableTree(treeName, rbManager)
65+
1 -> tree = AVLDrawableTree(treeName, avlManager)
66+
2 -> tree = BINDrawableTree(treeName, binManager)
67+
}
68+
69+
tree?.initTree()
70+
71+
return tree ?: throw NullPointerException()
72+
}
73+
74+
fun insert(value: String): DrawTree {
75+
val key = if (isInt(value.trim())) value.toInt() else value.hashCode()
76+
77+
tree?.insert(Container(Pair(key, value))) ?: throw NullPointerException()
78+
tree?.updateTree() ?: throw NullPointerException()
79+
tree?.repositisonTree(800f, 10f) ?: throw NullPointerException()
80+
81+
return tree ?: throw NullPointerException()
82+
}
83+
84+
fun find(value: String): DrawTree {
85+
val key = if (isInt(value.trim())) value.toInt() else value.hashCode()
86+
87+
tree?.find(key) ?: throw NullPointerException()
88+
89+
return tree ?: throw NullPointerException()
90+
91+
}
92+
93+
fun delete(value: String): DrawTree {
94+
val key = if (isInt(value.trim())) value.toInt() else value.hashCode()
95+
96+
tree?.delete(Container(Pair(key, ""))) ?: throw NullPointerException()
97+
tree?.updateTree() ?: throw NullPointerException()
98+
tree?.repositisonTree(800f, 10f) ?: throw NullPointerException()
99+
100+
return tree ?: throw NullPointerException()
101+
}
102+
103+
104+
private fun isInt(value: String): Boolean {
105+
return try {
106+
Integer.parseInt(value.trim())
107+
true
108+
} catch (ex: NumberFormatException) {
109+
false
110+
}
111+
}
112+
113+
fun deleteTree(): DrawTree {
114+
tree?.deleteTree()
115+
return tree ?: throw Exception("Tree not initialized")
116+
}
117+
118+
fun saveTree(fileName: String) {
119+
if (tree == null)
120+
throw Exception("Tree not initialized")
121+
122+
tree?.name = fileName
123+
tree?.saveTreeToDB() ?: throw Exception()
124+
125+
}
126+
127+
128+
}
129+

lib/src/main/kotlin/controller/RBTreeManager.kt

Lines changed: 0 additions & 40 deletions
This file was deleted.

lib/src/main/kotlin/controller/SQLiteController.kt

Lines changed: 0 additions & 58 deletions
This file was deleted.

lib/src/main/kotlin/controller/TreeManager.kt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)