This commit is contained in:
		@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -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<String>): 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<AuthenticationException> { _ ->
 | 
			
		||||
            exception<AuthenticationException> {
 | 
			
		||||
                call.respond(HttpStatusCode.Unauthorized)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            exception<AuthorizationException> { _ ->
 | 
			
		||||
            exception<AuthorizationException> {
 | 
			
		||||
                call.respond(HttpStatusCode.Forbidden)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            exception<HttpException> { _ ->
 | 
			
		||||
            exception<HttpException> {
 | 
			
		||||
                call.respond(HttpStatusCode.BadRequest)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            exception<IllegalStateException> { _ ->
 | 
			
		||||
            exception<IllegalStateException> {
 | 
			
		||||
                call.respond(HttpStatusCode.NotAcceptable)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +0,0 @@
 | 
			
		||||
package com.kmalbz
 | 
			
		||||
 | 
			
		||||
data class ApiResponse(
 | 
			
		||||
    val status: String,
 | 
			
		||||
    val message: String
 | 
			
		||||
)
 | 
			
		||||
@@ -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<ResultObject> {
 | 
			
		||||
        return client.get<List<ResultObject>>("$endpoint/output/filter/negative") {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get positive decision objects
 | 
			
		||||
     * 
 | 
			
		||||
     * @return Array of decision objects
 | 
			
		||||
     */
 | 
			
		||||
    suspend fun getallpositive(
 | 
			
		||||
    ): List<ResultObject> {
 | 
			
		||||
        return client.get<List<ResultObject>>("$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<ResultObject> {
 | 
			
		||||
        return client.get<List<ResultObject>>("$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<ResultObject> {
 | 
			
		||||
        return client.get<List<ResultObject>>("$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<ResultObject>("$endpoint/output/$tagID") {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user