Skip to content

Commit 061b475

Browse files
authored
Merge pull request #75 from modelix/text-editor2
Several fixes for the usage of the model-client in modelix.text-editor
2 parents 2a392e5 + 0fd9a0e commit 061b475

File tree

10 files changed

+304
-278
lines changed

10 files changed

+304
-278
lines changed

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ subprojects {
2828
version = rootProject.version
2929
group = rootProject.group
3030

31+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
32+
kotlinOptions {
33+
jvmTarget = "11"
34+
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
35+
}
36+
}
37+
3138
repositories {
3239
mavenLocal()
3340
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }

light-model-client/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ val kotlinLoggingVersion: String by rootProject
1010
val kotlinxHtmlVersion: String by rootProject
1111
val modelixIncrementalVersion: String by rootProject
1212

13-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
14-
kotlinOptions {
15-
jvmTarget = "11"
16-
}
17-
}
18-
1913
kotlin {
2014
jvm()
2115
js(IR) {

model-api/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ configurations {
1212

1313
description = "API to access models stored in Modelix"
1414

15-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
16-
kotlinOptions {
17-
jvmTarget = "11"
18-
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
19-
}
20-
}
21-
2215
ktlint {
2316
disabledRules.add("no-wildcard-imports")
2417
outputToConsole.set(true)

model-api/src/commonMain/kotlin/org/modelix/model/api/ConceptReference.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ data class ConceptReference(val uid: String) : IConceptReference {
2929
override fun serialize(): String {
3030
return uid
3131
}
32+
33+
override fun toString(): String {
34+
return uid
35+
}
3236
}

model-client/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ configurations {
1111
ktlint
1212
}
1313

14-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
15-
kotlinOptions {
16-
jvmTarget = "11"
17-
}
18-
}
19-
2014
java {
2115
toolchain {
2216
languageVersion.set(JavaLanguageVersion.of(11))

model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLVersion.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ package org.modelix.model.lazy
1717

1818
import kotlinx.datetime.Clock
1919
import kotlinx.datetime.Instant
20+
import kotlinx.datetime.TimeZone
21+
import kotlinx.datetime.toInstant
2022
import org.modelix.model.IVersion
2123
import org.modelix.model.api.INodeReference
2224
import org.modelix.model.api.LocalPNodeReference
@@ -103,9 +105,21 @@ class CLVersion : IVersion {
103105
val id: Long
104106
get() = data!!.id
105107

108+
@Deprecated("Use getTimestamp()")
106109
val time: String?
107110
get() = data!!.time
108111

112+
fun getTimestamp(): Instant? {
113+
val dateTimeStr = data!!.time ?: return null
114+
try {
115+
return Instant.fromEpochSeconds(dateTimeStr.toLong())
116+
} catch (ex: Exception) {}
117+
try {
118+
return kotlinx.datetime.LocalDateTime.parse(dateTimeStr).toInstant(TimeZone.currentSystemDefault())
119+
} catch (ex: Exception) {}
120+
return null
121+
}
122+
109123
@Deprecated("Use getContentHash()", ReplaceWith("getContentHash()"))
110124
val hash: String
111125
get() = data!!.hash

model-server/src/main/kotlin/org/modelix/model/server/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ object Main {
132132
)
133133
}
134134

135-
val historyHandler = HistoryHandler(localModelClient)
136135
val jsonModelServer = DeprecatedLightModelServer(localModelClient)
137136
val repositoriesManager = RepositoriesManager(localModelClient)
137+
val historyHandler = HistoryHandler(localModelClient, repositoriesManager)
138138
val modelReplicationServer = ModelReplicationServer(repositoriesManager)
139139
val ktorServer: NettyApplicationEngine = embeddedServer(Netty, port = port) {
140140
install(Routing)

0 commit comments

Comments
 (0)