just commit

This commit is contained in:
2020-07-30 15:28:11 +06:00
parent 981a354441
commit 3795b85827
29 changed files with 429 additions and 47 deletions
postssystem.core.exposed
build.gradle
src
main
kotlin
com
insanusmokrassar
test
kotlin
com
insanusmokrassar
postssystem
postssystem.core.publishing.exposed
postssystem.core.publishing
build.gradle
src
commonMain
kotlin
com
insanusmokrassar
postssystem
postssystem.core
postssystem.exposed.commons
settings.gradle

@ -31,14 +31,14 @@ repositories {
} }
dependencies { dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "org.jetbrains.exposed:exposed-core:$exposed_version"
api "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core:$core_version" api "com.insanusmokrassar:postssystem.core:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else { } else {
implementation project(":postssystem.core") api project(":postssystem.core")
api project(":postssystem.exposed.commons")
} }
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version" testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"

@ -1,3 +0,0 @@
package com.insanusmokrassar.postssystem.core.exposed
internal const val ChannelDefaultSize = 64

@ -6,6 +6,7 @@ import com.insanusmokrassar.postssystem.core.exposed.content.*
import com.insanusmokrassar.postssystem.core.utils.generateContentId import com.insanusmokrassar.postssystem.core.utils.generateContentId
import com.insanusmokrassar.postssystem.core.utils.pagination.* import com.insanusmokrassar.postssystem.core.utils.pagination.*
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
@ -33,8 +34,8 @@ private class ContentAPIDatabaseTable(
} }
} }
private val contentCreatedBroadcastChannel = BroadcastChannel<RegisteredContent>(ChannelDefaultSize) private val contentCreatedBroadcastChannel = BroadcastChannel<RegisteredContent>(Channel.BUFFERED)
private val contentDeletedBroadcastChannel = BroadcastChannel<RegisteredContent>(ChannelDefaultSize) private val contentDeletedBroadcastChannel = BroadcastChannel<RegisteredContent>(Channel.BUFFERED)
override val contentCreatedFlow: Flow<RegisteredContent> = contentCreatedBroadcastChannel.asFlow() override val contentCreatedFlow: Flow<RegisteredContent> = contentCreatedBroadcastChannel.asFlow()
override val contentDeletedFlow: Flow<RegisteredContent> = contentDeletedBroadcastChannel.asFlow() override val contentDeletedFlow: Flow<RegisteredContent> = contentDeletedBroadcastChannel.asFlow()

@ -2,11 +2,12 @@ package com.insanusmokrassar.postssystem.core.exposed
import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.*
import com.insanusmokrassar.postssystem.core.post.api.PostsAPI import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo
import com.insanusmokrassar.postssystem.core.utils.generatePostId import com.insanusmokrassar.postssystem.core.utils.generatePostId
import com.insanusmokrassar.postssystem.core.utils.pagination.* import com.insanusmokrassar.postssystem.core.utils.pagination.*
import com.soywiz.klock.* import com.soywiz.klock.*
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
@ -58,9 +59,9 @@ private class PostsAPIContentRelations(
private val dateTimeFormat = DateFormat("EEE, dd MMM yyyy HH:mm:ss z") private val dateTimeFormat = DateFormat("EEE, dd MMM yyyy HH:mm:ss z")
private class PostsAPIDatabaseTable( private class PostsRepoDatabaseTable(
private val database: Database private val database: Database
) : PostsAPI, Table() { ) : PostsRepo, Table() {
private val contentsTable = PostsAPIContentRelations(database) private val contentsTable = PostsAPIContentRelations(database)
private val idColumn = text("postId") private val idColumn = text("postId")
@ -69,18 +70,18 @@ private class PostsAPIDatabaseTable(
) )
private val postCreatedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize) private val postCreatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postCreatedFlow: Flow<RegisteredPost> = postCreatedBroadcastChannel.asFlow() override val postCreatedFlow: Flow<RegisteredPost> = postCreatedBroadcastChannel.asFlow()
private val postDeletedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize) private val postDeletedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postDeletedFlow: Flow<RegisteredPost> = postDeletedBroadcastChannel.asFlow() override val postDeletedFlow: Flow<RegisteredPost> = postDeletedBroadcastChannel.asFlow()
private val postUpdatedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize) private val postUpdatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postUpdatedFlow: Flow<RegisteredPost> = postUpdatedBroadcastChannel.asFlow() override val postUpdatedFlow: Flow<RegisteredPost> = postUpdatedBroadcastChannel.asFlow()
init { init {
transaction(database) { transaction(database) {
SchemaUtils.createMissingTablesAndColumns(this@PostsAPIDatabaseTable) SchemaUtils.createMissingTablesAndColumns(this@PostsRepoDatabaseTable)
} }
} }
@ -170,6 +171,6 @@ private class PostsAPIDatabaseTable(
} }
class ExposedPostsAPI ( class ExposedPostsRepo (
database: Database database: Database
) : PostsAPI by PostsAPIDatabaseTable(database) ) : PostsRepo by PostsRepoDatabaseTable(database)

@ -8,12 +8,12 @@ import java.io.File
import java.sql.Connection import java.sql.Connection
import kotlin.test.* import kotlin.test.*
class ExposedPostsAPICommonTests { class ExposedPostsRepoCommonTests {
private val tempFolder = System.getProperty("java.io.tmpdir")!! private val tempFolder = System.getProperty("java.io.tmpdir")!!
private val numberOfDatabases = 8 private val numberOfDatabases = 8
private lateinit var databaseFiles: List<File> private lateinit var databaseFiles: List<File>
private lateinit var apis: List<ExposedPostsAPI> private lateinit var apis: List<ExposedPostsRepo>
@BeforeTest @BeforeTest
fun prepare() { fun prepare() {
@ -24,7 +24,7 @@ class ExposedPostsAPICommonTests {
val database = Database.connect("jdbc:sqlite:${it.absolutePath}").also { val database = Database.connect("jdbc:sqlite:${it.absolutePath}").also {
it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
} }
ExposedPostsAPI( ExposedPostsRepo(
database database
) )
} }

@ -0,0 +1,47 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
}
}
plugins {
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}
project.version = "$core_version"
project.group = "com.insanusmokrassar"
apply plugin: "java-library"
apply plugin: "kotlin"
apply from: "./publish.gradle"
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core.publishing:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else {
api project(":postssystem.core.publishing")
api project(":postssystem.exposed.commons")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}

@ -0,0 +1,2 @@
exposed_version=0.23.1
test_sqlite_version=3.28.0

@ -0,0 +1,53 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
}
afterEvaluate {
project.publishing.publications.all {
// rename artifacts
groupId "${project.group}"
if (it.name.contains('kotlinMultiplatform')) {
artifactId = "${project.name}"
} else {
artifactId = "${project.name}-$name"
}
}
}
publishing {
publications.all {
artifact javadocsJar
pom {
description = "Exposed realisation for PostsSystem Core Publishing subsystem"
name = "PostsSystem Core Publishing Exposed realization"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/"
scm {
developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"
}
}
}
}
}

@ -0,0 +1,55 @@
apply plugin: 'com.jfrog.bintray'
apply from: "maven.publish.gradle"
bintray {
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
filesSpec {
from "${buildDir}/publications/"
eachFile {
String directorySubname = it.getFile().parentFile.name
if (it.getName() == "module.json") {
if (directorySubname == "kotlinMultiplatform") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
} else {
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
}
} else {
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
} else {
it.exclude()
}
}
}
into "${project.group}".replace(".", "/")
}
pkg {
repo = "InsanusMokrassar"
name = "${project.name}"
vcsUrl = "https://github.com/PostsSystem/PostsSystemCore"
licenses = ["Apache-2.0"]
version {
name = "${project.version}"
released = new Date()
vcsTag = "${project.version}"
gpg {
sign = true
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
}
}
}
}
bintrayUpload.doFirst {
publications = publishing.publications.collect {
if (it.name.contains('kotlinMultiplatform')) {
null
} else {
it.name
}
} - null
}
bintrayUpload.dependsOn publishToMavenLocal

@ -0,0 +1 @@
{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Publishing Exposed realization","description":"Exposed realisation for PostsSystem Core Publishing subsystem","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}

@ -0,0 +1,56 @@
package com.insanusmokrassar.postssystem.core.publishing.exposed
import com.insanusmokrassar.postssystem.core.post.PostId
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
import org.jetbrains.exposed.sql.transactions.transaction
class ExposedPublishingKeysRepo(
private val database: Database
) : PublishingKeysRepo, Table() {
private val postIdColumn: Column<PostId> = text("postId")
private val triggerControlKeyColumn: Column<PostId> = text("triggerControlKey")
override val primaryKey: PrimaryKey = PrimaryKey(postIdColumn, triggerControlKeyColumn)
init {
transaction(database) {
SchemaUtils.createMissingTablesAndColumns(this@ExposedPublishingKeysRepo)
}
}
override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = newSuspendedTransaction(
db = database
) {
select { triggerControlKeyColumn.eq(key) }.limit(1).firstOrNull() ?.getOrNull(postIdColumn)
}
override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = newSuspendedTransaction(
db = database
) {
select { postIdColumn.eq(postId) }.limit(1).firstOrNull() ?.getOrNull(triggerControlKeyColumn)
}
override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = newSuspendedTransaction(
db = database
) {
unsetPostTriggerControlKey(postId)
insert {
it[postIdColumn] = postId
it[triggerControlKeyColumn] = triggerControlKeyColumn
}.getOrNull(postIdColumn) == postId
}
override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = newSuspendedTransaction(
db = database
) {
deleteWhere {
postIdColumn.eq(postId)
} > 0
}
}
class DatabasePublishingKeysRepo(
database: Database
): PublishingKeysRepo by ExposedPublishingKeysRepo(database)

@ -41,7 +41,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core:$core_version" api "com.insanusmokrassar:postssystem.core:$core_version"
} else { } else {
implementation project(":postssystem.core") api project(":postssystem.core")
} }
} }
} }
@ -68,7 +68,8 @@ kotlin {
} }
jsTest { jsTest {
dependencies { dependencies {
implementation kotlin('test-junit-js') implementation kotlin('test-js')
implementation kotlin('test-junit')
} }
} }
} }

@ -2,7 +2,7 @@ package com.insanusmokrassar.postssystem.core.publishing
import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.PostId
import com.insanusmokrassar.postssystem.core.post.RegisteredPost import com.insanusmokrassar.postssystem.core.post.RegisteredPost
import com.insanusmokrassar.postssystem.core.post.api.PostsAPI import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
@ -17,7 +17,7 @@ interface PublishingTrigger {
} }
class BusinessPublishingTrigger( class BusinessPublishingTrigger(
private val postsAPI: PostsAPI, private val postsRepo: PostsRepo,
private val publishingKeysRepo: PublishingKeysRepo private val publishingKeysRepo: PublishingKeysRepo
) : PublishingTrigger { ) : PublishingTrigger {
private val postingTriggeredChannel: BroadcastChannel<RegisteredPost> = BroadcastChannel(Channel.BUFFERED) private val postingTriggeredChannel: BroadcastChannel<RegisteredPost> = BroadcastChannel(Channel.BUFFERED)
@ -27,8 +27,8 @@ class BusinessPublishingTrigger(
val postId = publishingKeysRepo.getPostIdByTriggerControlKey(triggerControlKey) ?: return null val postId = publishingKeysRepo.getPostIdByTriggerControlKey(triggerControlKey) ?: return null
publishingKeysRepo.unsetPostTriggerControlKey(postId) publishingKeysRepo.unsetPostTriggerControlKey(postId)
return postsAPI.getPostById(postId) ?.let { post -> return postsRepo.getPostById(postId) ?.let { post ->
if (postsAPI.deletePost(postId)) { if (postsRepo.deletePost(postId)) {
postingTriggeredChannel.send(post) postingTriggeredChannel.send(post)
postId postId
} else { } else {

@ -19,7 +19,7 @@ interface WritePublishingKeysRepo {
): Boolean ): Boolean
suspend fun unsetPostTriggerControlKey( suspend fun unsetPostTriggerControlKey(
postId: PostId postId: PostId
) ): Boolean
} }
interface PublishingKeysRepo : ReadPublishingKeysRepo, WritePublishingKeysRepo interface PublishingKeysRepo : ReadPublishingKeysRepo, WritePublishingKeysRepo

@ -71,7 +71,8 @@ kotlin {
} }
jsTest { jsTest {
dependencies { dependencies {
implementation kotlin('test-junit-js') implementation kotlin('test-js')
implementation kotlin('test-junit')
} }
} }
} }

@ -33,7 +33,7 @@ data class BinaryContent(
/** /**
* Content which is already registered in database. Using its [id] you can retrieve all known * Content which is already registered in database. Using its [id] you can retrieve all known
* [com.insanusmokrassar.postssystem.core.post.RegisteredPost]s by using * [com.insanusmokrassar.postssystem.core.post.RegisteredPost]s by using
* [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI.getPostsByContent] * [com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo.getPostsByContent]
*/ */
@Serializable @Serializable
data class RegisteredContent( data class RegisteredContent(

@ -1,21 +1,21 @@
package com.insanusmokrassar.postssystem.core.post package com.insanusmokrassar.postssystem.core.post
import com.insanusmokrassar.postssystem.core.post.api.PostsAPI import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo
class BusinessPublishablePostsAPI( class BusinessPublishablePostsRepo(
/** /**
* Will be used for storing of unpublished data * Will be used for storing of unpublished data
*/ */
private val repoPostsAPI: PostsAPI, private val repoPostsRepo: PostsRepo,
/** /**
* Will be used to send information ab * Will be used to send information ab
*/ */
private val publishedPostsAPI: PostsAPI private val publishedPostsRepo: PostsRepo
) : PostsAPI by repoPostsAPI { ) : PostsRepo by repoPostsRepo {
override suspend fun deletePost(id: PostId): Boolean { override suspend fun deletePost(id: PostId): Boolean {
return getPostById(id) ?.let { post -> return getPostById(id) ?.let { post ->
publishedPostsAPI.createPost(post) publishedPostsRepo.createPost(post)
repoPostsAPI.deletePost(id) repoPostsRepo.deletePost(id)
} ?: return false } ?: return false
} }
} }

@ -14,8 +14,8 @@ interface Post {
} }
/** /**
* Root entity of whole system. Can be retrieved from [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI] by * Root entity of whole system. Can be retrieved from [com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo] by
* getting and created in [com.insanusmokrassar.postssystem.core.post.api.WritePostsAPI] by inserting of [Post] instance * getting and created in [com.insanusmokrassar.postssystem.core.post.repo.WritePostsRepo] by inserting of [Post] instance
*/ */
interface RegisteredPost : Post { interface RegisteredPost : Post {
val id: PostId val id: PostId

@ -1,3 +0,0 @@
package com.insanusmokrassar.postssystem.core.post.api
interface PostsAPI : ReadPostsAPI, WritePostsAPI

@ -0,0 +1,3 @@
package com.insanusmokrassar.postssystem.core.post.repo
interface PostsRepo : ReadPostsRepo, WritePostsRepo

@ -1,4 +1,4 @@
package com.insanusmokrassar.postssystem.core.post.api package com.insanusmokrassar.postssystem.core.post.repo
import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.post.PostId import com.insanusmokrassar.postssystem.core.post.PostId
@ -12,7 +12,7 @@ import com.soywiz.klock.DateTime
/** /**
* Simple read API by different properties * Simple read API by different properties
*/ */
interface ReadPostsAPI { interface ReadPostsRepo {
/** /**
* @return [Set] of [PostId]s which can be used to get data using [getPostById] * @return [Set] of [PostId]s which can be used to get data using [getPostById]
*/ */
@ -39,7 +39,7 @@ interface ReadPostsAPI {
suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<RegisteredPost> suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<RegisteredPost>
} }
suspend fun ReadPostsAPI.getPostsByCreatingDates( suspend fun ReadPostsRepo.getPostsByCreatingDates(
from: DateTime? = null, from: DateTime? = null,
to: DateTime? = null to: DateTime? = null
) = getPostsByCreatingDates( ) = getPostsByCreatingDates(

@ -1,9 +1,9 @@
package com.insanusmokrassar.postssystem.core.post.api package com.insanusmokrassar.postssystem.core.post.repo
import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.*
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
interface WritePostsAPI { interface WritePostsRepo {
val postCreatedFlow: Flow<RegisteredPost> val postCreatedFlow: Flow<RegisteredPost>
val postDeletedFlow: Flow<RegisteredPost> val postDeletedFlow: Flow<RegisteredPost>
val postUpdatedFlow: Flow<RegisteredPost> val postUpdatedFlow: Flow<RegisteredPost>

@ -0,0 +1,47 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
}
}
plugins {
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}
project.version = "$core_version"
project.group = "com.insanusmokrassar"
apply plugin: "java-library"
apply plugin: "kotlin"
apply from: "./publish.gradle"
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "org.jetbrains.exposed:exposed-core:$exposed_version"
api "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core:$core_version"
} else {
api project(":postssystem.core")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}

@ -0,0 +1,2 @@
exposed_version=0.23.1
test_sqlite_version=3.28.0

@ -0,0 +1,53 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
}
afterEvaluate {
project.publishing.publications.all {
// rename artifacts
groupId "${project.group}"
if (it.name.contains('kotlinMultiplatform')) {
artifactId = "${project.name}"
} else {
artifactId = "${project.name}-$name"
}
}
}
publishing {
publications.all {
artifact javadocsJar
pom {
description = "Common utils for all exposed modules"
name = "PostsSystem Exposed commons"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/"
scm {
developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"
}
}
}
}
}

@ -0,0 +1,55 @@
apply plugin: 'com.jfrog.bintray'
apply from: "maven.publish.gradle"
bintray {
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
filesSpec {
from "${buildDir}/publications/"
eachFile {
String directorySubname = it.getFile().parentFile.name
if (it.getName() == "module.json") {
if (directorySubname == "kotlinMultiplatform") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
} else {
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
}
} else {
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
} else {
it.exclude()
}
}
}
into "${project.group}".replace(".", "/")
}
pkg {
repo = "InsanusMokrassar"
name = "${project.name}"
vcsUrl = "https://github.com/PostsSystem/PostsSystemCore"
licenses = ["Apache-2.0"]
version {
name = "${project.version}"
released = new Date()
vcsTag = "${project.version}"
gpg {
sign = true
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
}
}
}
}
bintrayUpload.doFirst {
publications = publishing.publications.collect {
if (it.name.contains('kotlinMultiplatform')) {
null
} else {
it.name
}
} - null
}
bintrayUpload.dependsOn publishToMavenLocal

@ -0,0 +1 @@
{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Exposed commons","description":"Common utils for all exposed modules","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}

@ -0,0 +1,7 @@
package com.insanusmokrassar.postssystem.exposed.commons
import com.insanusmokrassar.postssystem.core.utils.pagination.Pagination
import com.insanusmokrassar.postssystem.core.utils.pagination.firstIndex
import org.jetbrains.exposed.sql.Query
fun Query.paginate(pagination: Pagination) = limit(pagination.size, pagination.firstIndex.toLong())

@ -1,4 +1,6 @@
rootProject.name='postssystem' rootProject.name='postssystem'
include ':postssystem.exposed.commons'
include ':postssystem.core' include ':postssystem.core'
include ':postssystem.core.exposed' include ':postssystem.core.exposed'
include ':postssystem.core.publishing' include ':postssystem.core.publishing'
include ':postssystem.core.publishing.exposed'