/**
* Swaggy Jenkins
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.5.1-pre.0
* Contact: blah@cliffano.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.database.models

import org.ktorm.dsl.*
import org.ktorm.schema.*
import org.ktorm.database.Database
import .*


/**
 * 
 * @param propertyClass 
 * @param assignedLabels 
 * @param mode 
 * @param nodeDescription 
 * @param nodeName 
 * @param numExecutors 
 * @param description 
 * @param jobs 
 * @param primaryView 
 * @param quietingDown 
 * @param slaveAgentPort 
 * @param unlabeledLoad 
 * @param useCrumbs 
 * @param useSecurity 
 * @param views 
 */
object Hudsons : BaseTable<Hudson>("Hudson") {
    val propertyClass = text("_class") /* null */
    val mode = text("mode") /* null */
    val nodeDescription = text("nodeDescription") /* null */
    val nodeName = text("nodeName") /* null */
    val numExecutors = int("numExecutors") /* null */
    val description = text("description") /* null */
    val primaryView = long("primaryView") /* null */
    val quietingDown = boolean("quietingDown") /* null */
    val slaveAgentPort = int("slaveAgentPort") /* null */
    val unlabeledLoad = long("unlabeledLoad") /* null */
    val useCrumbs = boolean("useCrumbs") /* null */
    val useSecurity = boolean("useSecurity") /* null */

    /**
     * Create an entity of type Hudson from the model
     */
    override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean) = Hudson(
        propertyClass = row[propertyClass]  /* kotlin.String? */,
        assignedLabels = emptyList() /* kotlin.Array<HudsonassignedLabels>? */,
        mode = row[mode]  /* kotlin.String? */,
        nodeDescription = row[nodeDescription]  /* kotlin.String? */,
        nodeName = row[nodeName]  /* kotlin.String? */,
        numExecutors = row[numExecutors]  /* kotlin.Int? */,
        description = row[description]  /* kotlin.String? */,
        jobs = emptyList() /* kotlin.Array<FreeStyleProject>? */,
        primaryView = AllViews.createEntity(row, withReferences) /* AllView? */,
        quietingDown = row[quietingDown]  /* kotlin.Boolean? */,
        slaveAgentPort = row[slaveAgentPort]  /* kotlin.Int? */,
        unlabeledLoad = UnlabeledLoadStatisticss.createEntity(row, withReferences) /* UnlabeledLoadStatistics? */,
        useCrumbs = row[useCrumbs]  /* kotlin.Boolean? */,
        useSecurity = row[useSecurity]  /* kotlin.Boolean? */,
        views = emptyList() /* kotlin.Array<AllView>? */
    )

    /**
    * Assign all the columns from the entity of type Hudson to the DML expression.
    *
    * Usage:
    *
    * ```kotlin
    * let entity = Hudson()
    * database.update(Hudsons, {
    *     assignFrom(entity)
    * })
    * ```
    * @return the builder with the columns for the update or insert.
    */
    fun AssignmentsBuilder.assignFrom(entity: Hudson) {
        this.apply {
            set(Hudsons.propertyClass, entity.propertyClass)
            set(Hudsons.mode, entity.mode)
            set(Hudsons.nodeDescription, entity.nodeDescription)
            set(Hudsons.nodeName, entity.nodeName)
            set(Hudsons.numExecutors, entity.numExecutors)
            set(Hudsons.description, entity.description)
            set(Hudsons.primaryView, entity.primaryView)
            set(Hudsons.quietingDown, entity.quietingDown)
            set(Hudsons.slaveAgentPort, entity.slaveAgentPort)
            set(Hudsons.unlabeledLoad, entity.unlabeledLoad)
            set(Hudsons.useCrumbs, entity.useCrumbs)
            set(Hudsons.useSecurity, entity.useSecurity)
        }
    }

}


object HudsonHudsonassignedLabels : BaseTable<Pair<kotlin.Long, kotlin.Long>>("HudsonHudsonassignedLabels") {
    val hudson = long("hudson")
    val hudsonassignedLabels = long("hudsonassignedLabels")

    override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Pair<kotlin.Long, kotlin.Long> =
        Pair(row[hudson] ?: 0, row[hudsonassignedLabels] ?: 0)

    fun AssignmentsBuilder.assignFrom(entity: Pair<kotlin.Long, kotlin.Long>) {
        this.apply {
            set(HudsonHudsonassignedLabels.hudson, entity.first)
            set(HudsonHudsonassignedLabels.hudsonassignedLabels, entity.second)
        }
    }

}

object HudsonFreeStyleProject : BaseTable<Pair<kotlin.Long, kotlin.Long>>("HudsonFreeStyleProject") {
    val hudson = long("hudson")
    val freeStyleProject = long("freeStyleProject")

    override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Pair<kotlin.Long, kotlin.Long> =
        Pair(row[hudson] ?: 0, row[freeStyleProject] ?: 0)

    fun AssignmentsBuilder.assignFrom(entity: Pair<kotlin.Long, kotlin.Long>) {
        this.apply {
            set(HudsonFreeStyleProject.hudson, entity.first)
            set(HudsonFreeStyleProject.freeStyleProject, entity.second)
        }
    }

}

object HudsonAllView : BaseTable<Pair<kotlin.Long, kotlin.Long>>("HudsonAllView") {
    val hudson = long("hudson")
    val allView = long("allView")

    override fun doCreateEntity(row: QueryRowSet, withReferences: Boolean): Pair<kotlin.Long, kotlin.Long> =
        Pair(row[hudson] ?: 0, row[allView] ?: 0)

    fun AssignmentsBuilder.assignFrom(entity: Pair<kotlin.Long, kotlin.Long>) {
        this.apply {
            set(HudsonAllView.hudson, entity.first)
            set(HudsonAllView.allView, entity.second)
        }
    }

}

