From 26a52d54e9f5311cd5f9bd7d77729c86cf9fddb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Wed, 20 May 2020 14:59:08 +0200 Subject: [PATCH] ide suggestions --- docker-compose.yml | 2 +- src/Application.kt | 20 ++----- src/OutputServiceRDB.kt | 6 -- src/OutputServiceRDBClient.kt | 77 ------------------------- src/api/model/ApiObject.kt | 1 - src/api/route/OutputServiceRDBServer.kt | 6 +- 6 files changed, 9 insertions(+), 103 deletions(-) delete mode 100644 src/OutputServiceRDB.kt delete mode 100644 src/OutputServiceRDBClient.kt diff --git a/docker-compose.yml b/docker-compose.yml index 0db1d5f..6f6b135 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: POSTGRES_DB: "output-service-rdb" output-service-rdb: - image: "registry.kmlabz.com/tormakris/output-service-rdb" + image: "registry.kmlabz.com/birbnetes/output-service-rdb" restart: "always" ports: - "127.0.0.1:8080:8080" diff --git a/src/Application.kt b/src/Application.kt index 7c05bee..23a9ee3 100644 --- a/src/Application.kt +++ b/src/Application.kt @@ -9,9 +9,6 @@ import io.ktor.routing.* import io.ktor.http.* import io.ktor.gson.* import io.ktor.features.* -import io.ktor.client.* -import io.ktor.client.engine.apache.* -import io.ktor.auth.* import org.apache.http.HttpException import com.kmalbz.database.DatabaseFactory import com.kmalbz.database.dao.ResultObjects @@ -31,19 +28,12 @@ fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) @KtorExperimentalAPI @Suppress("unused") // Referenced in application.conf -@kotlin.jvm.JvmOverloads -fun Application.module(testing: Boolean = false) { +fun Application.module() { install(ContentNegotiation) { gson { } } - val client = HttpClient(Apache) { - } - - install(Authentication) { - } - DatabaseFactory.init() transaction{ SchemaUtils.create(ResultObjects) @@ -82,19 +72,19 @@ fun Application.module(testing: Boolean = false) { routing { install(StatusPages) { - exception { _ -> + exception { call.respond(HttpStatusCode.Unauthorized) } - exception { _ -> + exception { call.respond(HttpStatusCode.Forbidden) } - exception { _ -> + exception { call.respond(HttpStatusCode.BadRequest) } - exception { _ -> + exception { call.respond(HttpStatusCode.NotAcceptable) } } diff --git a/src/OutputServiceRDB.kt b/src/OutputServiceRDB.kt deleted file mode 100644 index 2baa16e..0000000 --- a/src/OutputServiceRDB.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.kmalbz - -data class ApiResponse( - val status: String, - val message: String -) diff --git a/src/OutputServiceRDBClient.kt b/src/OutputServiceRDBClient.kt deleted file mode 100644 index bd320dd..0000000 --- a/src/OutputServiceRDBClient.kt +++ /dev/null @@ -1,77 +0,0 @@ -package com.kmalbz - -import io.ktor.client.* -import io.ktor.client.request.* -import java.util.* -import com.kmalbz.database.model.ResultObject - -/** - * Output Service - RDB Client - * - * This is the feature extraction interface of the Birbnetes system. - */ -open class OutputServiceRDBClient(val endpoint: String, val client: HttpClient = HttpClient()) { - /** - * Get all negative decision objects - * - * @return Array of decision objects - */ - suspend fun getallnegative( - ): List { - return client.get>("$endpoint/output/filter/negative") { - } - } - - /** - * Get positive decision objects - * - * @return Array of decision objects - */ - suspend fun getallpositive( - ): List { - return client.get>("$endpoint/output/filter/positive") { - } - } - - /** - * Get decision before a date - * - * @param dateAfter Date of filter - * - * @return Array of decision objects - */ - suspend fun getallafter( - dateAfter: Date // PATH - ): List { - return client.get>("$endpoint/output/after/$dateAfter") { - } - } - - /** - * Get decision before a date - * - * @param dateBefore Date of filter - * - * @return Array of decision objects - */ - suspend fun getallbefore( - dateBefore: Date // PATH - ): List { - return client.get>("$endpoint/output/before/$dateBefore") { - } - } - - /** - * Get decision by ID - * - * @param tagID ID of wave file - * - * @return Decision object - */ - suspend fun getDecision( - tagID: Int // PATH - ): ResultObject { - return client.get("$endpoint/output/$tagID") { - } - } -} diff --git a/src/api/model/ApiObject.kt b/src/api/model/ApiObject.kt index 1a68a0a..6fda350 100644 --- a/src/api/model/ApiObject.kt +++ b/src/api/model/ApiObject.kt @@ -1,7 +1,6 @@ package com.kmalbz.api.model import com.google.gson.annotations.SerializedName -import java.time.LocalDate data class ApiObject( @SerializedName("tag") val tag: String, diff --git a/src/api/route/OutputServiceRDBServer.kt b/src/api/route/OutputServiceRDBServer.kt index d5a302c..1fefd54 100644 --- a/src/api/route/OutputServiceRDBServer.kt +++ b/src/api/route/OutputServiceRDBServer.kt @@ -13,7 +13,7 @@ import java.time.format.DateTimeFormatter * * This is the output interface of the Birbnetes system. */ -class OutputServiceRDBServer() { +class OutputServiceRDBServer { /** * output */ @@ -45,7 +45,7 @@ class OutputServiceRDBServer() { val dateAfter = call.parameters["dateAfter"] ?: error(HttpStatusCode.NotAcceptable) val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE val localDateAfter : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter) - val resultList = resultObjectService.getResultObjectbeforeDate(localDateAfter) ?: call.respond(HttpStatusCode.NotFound) + val resultList = resultObjectService.getResultObjectafterDate(localDateAfter) ?: call.respond(HttpStatusCode.NotFound) call.respond(resultList) } @@ -54,7 +54,7 @@ class OutputServiceRDBServer() { val dateAfter = call.parameters["dateBefore"] ?: error(HttpStatusCode.NotAcceptable) val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE val localDateBefore : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter) - val resultList = resultObjectService.getResultObjectafterDate(localDateBefore) ?: call.respond(HttpStatusCode.NotFound) + val resultList = resultObjectService.getResultObjectbeforeDate(localDateBefore) ?: call.respond(HttpStatusCode.NotFound) call.respond(resultList) }