-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create domain models and response models for Bygning/Bruksenhet and m…
…ove models around to better see where they are used
- Loading branch information
1 parent
6a5be3d
commit c6431da
Showing
14 changed files
with
156 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/main/kotlin/no/kartverket/matrikkel/bygning/matrikkel/Bygning.kt
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/no/kartverket/matrikkel/bygning/matrikkel/BygningClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/no/kartverket/matrikkel/bygning/models/Bygning.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package no.kartverket.matrikkel.bygning.models | ||
|
||
import no.kartverket.matrikkel.bygning.models.kodelister.AvlopKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.EnergikildeKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.OppvarmingKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.VannforsyningKode | ||
|
||
// TODO Sette opp DTOer for Bygning/Bruksenhet hentet fra Matrikkel | ||
data class Bygning( | ||
val bygningId: Long, | ||
val bygningNummer: Long, | ||
val bruksenheter: List<Bruksenhet>, | ||
val byggeaar: Int? = null, | ||
val bruksareal: Double? = null, | ||
val vannforsyning: VannforsyningKode? = null, | ||
val avlop: AvlopKode? = null, | ||
) { | ||
fun withEgenregistrertData(bygningRegistrering: BygningRegistrering): Bygning { | ||
return this.copy( | ||
byggeaar = bygningRegistrering.byggeaarRegistrering?.byggeaar, | ||
bruksareal = bygningRegistrering.bruksarealRegistrering?.bruksareal, | ||
vannforsyning = bygningRegistrering.vannforsyningRegistrering?.vannforsyning, | ||
avlop = bygningRegistrering.avlopRegistrering?.avlop, | ||
) | ||
} | ||
} | ||
|
||
data class Bruksenhet( | ||
val bruksenhetId: Long, | ||
val bygningId: Long, | ||
val bruksareal: Double? = null, | ||
val energikilder: List<EnergikildeKode> = emptyList(), | ||
val oppvarminger: List<OppvarmingKode> = emptyList(), | ||
) { | ||
fun withEgenregistrertData(bruksenhetRegistrering: BruksenhetRegistrering): Bruksenhet { | ||
return this.copy( | ||
bruksareal = bruksenhetRegistrering.bruksarealRegistrering?.bruksareal, | ||
energikilder = bruksenhetRegistrering.energikildeRegistrering?.energikilder ?: emptyList(), | ||
oppvarminger = bruksenhetRegistrering.oppvarmingRegistrering?.oppvarminger ?: emptyList(), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...odels/requests/EgenregistreringRequest.kt → ...v1/dto/request/EgenregistreringRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/no/kartverket/matrikkel/bygning/routes/v1/dto/response/Bygning.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package no.kartverket.matrikkel.bygning.routes.v1.dto.response | ||
|
||
import kotlinx.serialization.Serializable | ||
import no.kartverket.matrikkel.bygning.models.Bruksenhet | ||
import no.kartverket.matrikkel.bygning.models.Bygning | ||
import no.kartverket.matrikkel.bygning.models.kodelister.AvlopKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.EnergikildeKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.OppvarmingKode | ||
import no.kartverket.matrikkel.bygning.models.kodelister.VannforsyningKode | ||
|
||
@Serializable | ||
data class BygningResponse( | ||
val bygningId: Long, | ||
val bygningNummer: Long, | ||
val byggeaar: Int? = null, | ||
val bruksareal: Double? = null, | ||
val vannforsyning: VannforsyningKode? = null, | ||
val avlop: AvlopKode? = null, | ||
val bruksenheter: List<BruksenhetResponse>, | ||
) | ||
|
||
fun Bygning.toBygningResponse(): BygningResponse = BygningResponse( | ||
bygningId = this.bygningId, | ||
bygningNummer = this.bygningNummer, | ||
bruksareal = this.bruksareal, | ||
byggeaar = this.byggeaar, | ||
bruksenheter = this.bruksenheter.map { it.toBruksenhetResponse() }, | ||
vannforsyning = this.vannforsyning, | ||
avlop = this.avlop, | ||
) | ||
|
||
@Serializable | ||
data class BruksenhetResponse( | ||
val bruksenhetId: Long, | ||
val bruksareal: Double? = null, | ||
val energikilder: List<EnergikildeKode> = emptyList(), | ||
val oppvarminger: List<OppvarmingKode> = emptyList(), | ||
) | ||
|
||
fun Bruksenhet.toBruksenhetResponse(): BruksenhetResponse = BruksenhetResponse( | ||
bruksenhetId = this.bruksenhetId, | ||
bruksareal = this.bruksareal, | ||
energikilder = this.energikilder, | ||
oppvarminger = this.oppvarminger, | ||
) |
Oops, something went wrong.