Skip to content

Commit

Permalink
refactor: moved to a package by feature structure (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianEstrada authored May 6, 2024
1 parent 0fa2eda commit 9035965
Show file tree
Hide file tree
Showing 69 changed files with 261 additions and 245 deletions.
4 changes: 2 additions & 2 deletions v16/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id("com.google.devtools.ksp")
}

group = "com.monta.ocpp.emulator.v16"
group = "com.monta.ocpp.emulator"
version = "2.3.1"

kotlin {
Expand Down Expand Up @@ -108,7 +108,7 @@ compose.desktop {
configurationFiles.from(project.file("compose-desktop.pro"))
}

mainClass = "com.monta.ocpp.emulator.v16.AppKt"
mainClass = "com.monta.ocpp.emulator.AppKt"

nativeDistributions {
modules("java.naming", "java.instrument", "java.management", "java.sql", "jdk.unsupported")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.monta.ocpp.emulator.v16
package com.monta.ocpp.emulator

import androidx.compose.ui.window.application
import com.monta.ocpp.emulator.CommonKoinModule
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.interceptor.view.EditMessageWindow
import com.monta.ocpp.emulator.interceptor.view.SendMessageWindow
import com.monta.ocpp.emulator.user.AnalyticsHelper
import com.monta.ocpp.emulator.v16.service.ocpp.connection.ConnectionManager
import com.monta.ocpp.emulator.v16.view.MainWindow
import com.monta.ocpp.emulator.v16.view.interceptor.EditMessageWindow
import com.monta.ocpp.emulator.v16.view.interceptor.SendMessageWindow
import com.monta.ocpp.emulator.v16.connection.ConnectionManager
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.koin.core.logger.Level
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.monta.ocpp.emulator.v16
package com.monta.ocpp.emulator

import com.monta.library.ocpp.common.session.OcppSessionRepository
import com.monta.library.ocpp.common.transport.OcppSettings
import com.monta.library.ocpp.v16.client.OcppClientV16Builder
import com.monta.ocpp.emulator.v16.service.interceptor.MessageInterceptor
import com.monta.ocpp.emulator.v16.service.ocpp.profile.OcppClientEventsHandler
import com.monta.ocpp.emulator.interceptor.MessageInterceptor
import com.monta.ocpp.emulator.v16.profile.OcppClientEventsHandler
import org.koin.dsl.module

object MainModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view
package com.monta.ocpp.emulator

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.material.MaterialTheme
Expand All @@ -9,14 +9,15 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.ApplicationScope
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.rememberWindowState
import com.monta.ocpp.emulator.chargepoint.view.createchargepoint.CreateChargePointPage
import com.monta.ocpp.emulator.chargepoint.view.screens.ChargePointPage
import com.monta.ocpp.emulator.chargepoint.view.screens.ChargePointsScreen
import com.monta.ocpp.emulator.common.BaseMontaWindow
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.common.view.NavigationViewModel
import com.monta.ocpp.emulator.theme.AppThemeViewModel
import com.monta.ocpp.emulator.update.view.UpdateDialog
import com.monta.ocpp.emulator.v16.view.chargepoint.ChargePointPage
import com.monta.ocpp.emulator.v16.view.chargepoints.ChargePointsScreen
import com.monta.ocpp.emulator.v16.view.createchargepoint.CreateChargePointPage
import com.monta.ocpp.emulator.v16.view.vehicle.VehicleScreen
import com.monta.ocpp.emulator.vehicle.view.VehicleScreen

@Preview
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16
package com.monta.ocpp.emulator

import org.koin.core.annotation.ComponentScan
import org.koin.core.annotation.Module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package com.monta.ocpp.emulator.v16.data.entity
package com.monta.ocpp.emulator.chargepoint.entity

import com.monta.library.ocpp.common.session.OcppSession
import com.monta.library.ocpp.v16.core.ChargePointErrorCode
import com.monta.library.ocpp.v16.core.ChargePointStatus
import com.monta.library.ocpp.v16.core.DataTransferRequest
import com.monta.library.ocpp.v16.firmware.DiagnosticsStatusNotificationStatus
import com.monta.library.ocpp.v16.firmware.FirmwareStatusNotificationStatus
import com.monta.ocpp.emulator.chargepoint.model.ChargePointConfiguration
import com.monta.ocpp.emulator.chargepoint.model.ChargePointMode
import com.monta.ocpp.emulator.chargepoint.model.LocalAuthList
import com.monta.ocpp.emulator.chargepoint.model.OcppVersion
import com.monta.ocpp.emulator.chargepointconnector.entity.ChargePointConnectorDAO
import com.monta.ocpp.emulator.chargepointconnector.entity.ChargePointConnectorTable
import com.monta.ocpp.emulator.chargepointtransaction.entity.ChargePointTransaction
import com.monta.ocpp.emulator.chargepointtransaction.entity.ChargePointTransactionDAO
import com.monta.ocpp.emulator.common.idValue
import com.monta.ocpp.emulator.common.util.MontaSerialization
import com.monta.ocpp.emulator.common.util.json
import com.monta.ocpp.emulator.common.util.randomString
import com.monta.ocpp.emulator.logger.Loggable
import com.monta.ocpp.emulator.v16.data.model.ChargePointConfiguration
import com.monta.ocpp.emulator.v16.data.model.ChargePointMode
import com.monta.ocpp.emulator.v16.data.model.LocalAuthList
import com.monta.ocpp.emulator.v16.data.model.OcppVersion
import com.monta.ocpp.emulator.v16.data.util.idValue
import org.jetbrains.exposed.dao.LongEntity
import org.jetbrains.exposed.dao.LongEntityClass
import org.jetbrains.exposed.dao.id.EntityID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.data.entity
package com.monta.ocpp.emulator.chargepoint.entity

import org.jetbrains.exposed.dao.LongEntity
import org.jetbrains.exposed.dao.LongEntityClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.monta.ocpp.emulator.v16.data.exception
package com.monta.ocpp.emulator.chargepoint.exception

class ChargePointNotFoundException : Exception("Charge point not found")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.data.model
package com.monta.ocpp.emulator.chargepoint.model

import com.monta.ocpp.emulator.eichrecht.EichrechtKey

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.data.model
package com.monta.ocpp.emulator.chargepoint.model

enum class ChargePointMode {
// Charge point will run automatically
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.data.model
package com.monta.ocpp.emulator.chargepoint.model

data class LocalAuthList(
var version: Int = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.data.model
package com.monta.ocpp.emulator.chargepoint.model

enum class OcppVersion(val version: String) {
V16("OCPP-1.6"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.monta.ocpp.emulator.v16.data.repository
package com.monta.ocpp.emulator.chargepoint.repository

import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.data.entity.ChargePointTable
import com.monta.ocpp.emulator.v16.data.util.createDatabaseListener
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointTable
import com.monta.ocpp.emulator.common.createDatabaseListener
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import org.jetbrains.exposed.sql.transactions.transaction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.monta.ocpp.emulator.v16.data.service
package com.monta.ocpp.emulator.chargepoint.service

import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.data.exception.ChargePointNotFoundException
import com.monta.ocpp.emulator.v16.data.repository.ChargePointRepository
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.exception.ChargePointNotFoundException
import com.monta.ocpp.emulator.chargepoint.repository.ChargePointRepository
import org.jetbrains.exposed.sql.transactions.transaction
import org.koin.core.annotation.Singleton

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.monta.ocpp.emulator.v16.data.service
package com.monta.ocpp.emulator.chargepoint.service

import com.monta.ocpp.emulator.v16.data.entity.PreviousMessagesDAO
import com.monta.ocpp.emulator.v16.data.entity.PreviousMessagesTable
import com.monta.ocpp.emulator.chargepoint.entity.PreviousMessagesDAO
import com.monta.ocpp.emulator.chargepoint.entity.PreviousMessagesTable
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint
package com.monta.ocpp.emulator.chargepoint.view.components

import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
Expand All @@ -18,11 +18,11 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.chargepointconnector.entity.ChargePointConnectorDAO
import com.monta.ocpp.emulator.common.components.RfidButton
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.common.util.launchThread
import com.monta.ocpp.emulator.v16.data.entity.ChargePointConnectorDAO
import com.monta.ocpp.emulator.v16.service.ocpp.ChargePointManager
import com.monta.ocpp.emulator.v16.ChargePointManager

@Composable
fun BoxScope.authorizeComponent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoints.component
package com.monta.ocpp.emulator.chargepoint.view.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -22,18 +22,18 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.common.components.MontaIcon
import com.monta.ocpp.emulator.common.components.MontaStateIcon
import com.monta.ocpp.emulator.common.components.TextTooltip
import com.monta.ocpp.emulator.common.components.getCardStyle
import com.monta.ocpp.emulator.common.components.toKilowattString
import com.monta.ocpp.emulator.common.idValue
import com.monta.ocpp.emulator.common.model.UrlChoice
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.common.util.launchThread
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.data.util.idValue
import com.monta.ocpp.emulator.v16.service.ocpp.connection.ConnectionManager
import com.monta.ocpp.emulator.v16.view.NavigationViewModel
import com.monta.ocpp.emulator.common.view.NavigationViewModel
import com.monta.ocpp.emulator.v16.connection.ConnectionManager
import org.jetbrains.exposed.sql.transactions.transaction

@OptIn(ExperimentalMaterialApi::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint
package com.monta.ocpp.emulator.chargepoint.view.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -20,12 +20,12 @@ import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import com.monta.library.ocpp.v16.core.ChargePointStatus
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.view.components.security.securityEventComponent
import com.monta.ocpp.emulator.common.components.getButtonStateColor
import com.monta.ocpp.emulator.common.components.getCardStyle
import com.monta.ocpp.emulator.common.components.toReadable
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.service.ocpp.setStatus
import com.monta.ocpp.emulator.v16.view.chargepoint.security.securityEventComponent
import com.monta.ocpp.emulator.v16.setStatus
import kotlinx.coroutines.launch

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint
package com.monta.ocpp.emulator.chargepoint.view.components

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
Expand All @@ -13,7 +13,7 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO

@Composable
fun chargePointDisplayComponent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint
package com.monta.ocpp.emulator.chargepoint.view.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -18,9 +18,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.common.components.getCardStyle
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.common.view.NavigationViewModel
import com.monta.ocpp.emulator.logger.ChargePointLogger
import com.monta.ocpp.emulator.theme.AppThemeViewModel
import com.monta.ocpp.emulator.v16.view.NavigationViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint.pbm
package com.monta.ocpp.emulator.chargepoint.view.components.pbm

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint.pbm
package com.monta.ocpp.emulator.chargepoint.view.components.pbm

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
Expand All @@ -19,7 +19,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import kotlinx.coroutines.launch

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.monta.ocpp.emulator.v16.view.chargepoint.pbm
package com.monta.ocpp.emulator.chargepoint.view.components.pbm

import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.toComposeImageBitmap
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import io.nayuki.qrcodegen.QrCode
import kotlinx.coroutines.flow.MutableStateFlow
import java.awt.image.BufferedImage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint.security
package com.monta.ocpp.emulator.chargepoint.view.components.security

enum class SecurityEvent(
val description: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.chargepoint.security
package com.monta.ocpp.emulator.chargepoint.view.components.security

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -15,11 +15,11 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.common.components.Spinner
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.common.util.launchThread
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.service.ocpp.ChargePointManager
import com.monta.ocpp.emulator.v16.ChargePointManager

@Composable
fun ColumnScope.securityEventComponent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.monta.ocpp.emulator.v16.view.createchargepoint
package com.monta.ocpp.emulator.chargepoint.view.createchargepoint

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -24,6 +24,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointDAO
import com.monta.ocpp.emulator.chargepoint.entity.ChargePointTable
import com.monta.ocpp.emulator.chargepoint.model.OcppVersion
import com.monta.ocpp.emulator.chargepoint.service.ChargePointService
import com.monta.ocpp.emulator.common.components.FormInput
import com.monta.ocpp.emulator.common.components.LabelledCheckBox
import com.monta.ocpp.emulator.common.components.MontaIcon
Expand All @@ -33,17 +37,16 @@ import com.monta.ocpp.emulator.common.components.getButtonStateColor
import com.monta.ocpp.emulator.common.components.getCardStyle
import com.monta.ocpp.emulator.common.model.UrlChoice
import com.monta.ocpp.emulator.common.util.injectAnywhere
import com.monta.ocpp.emulator.v16.data.entity.ChargePointDAO
import com.monta.ocpp.emulator.v16.data.entity.ChargePointTable
import com.monta.ocpp.emulator.v16.data.model.OcppVersion
import com.monta.ocpp.emulator.v16.data.service.ChargePointService
import com.monta.ocpp.emulator.v16.view.NavigationViewModel
import com.monta.ocpp.emulator.common.view.NavigationViewModel
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction
import org.koin.core.annotation.Factory

@Composable
fun ChargePointForm(viewModel: ChargePointFormViewModel, chargePoint: ChargePointDAO?) {
fun ChargePointForm(
viewModel: ChargePointFormViewModel,
chargePoint: ChargePointDAO?
) {
chargePoint?.let {
if (!viewModel.initialized) {
viewModel.form.updateFromDAO(it)
Expand Down Expand Up @@ -327,7 +330,9 @@ class ChargePointFormViewModel {
) {
formErrors["identity"] = "Identity already in use"
hasErrors = true
} else if (form.urlChoice == UrlChoice.Production && !form.chargePointIdentity.trim().uppercase().startsWith("MEM_")) {
} else if (form.urlChoice == UrlChoice.Production && !form.chargePointIdentity.trim().uppercase()
.startsWith("MEM_")
) {
formErrors["identity"] = "On production identity must begin with MEM_"
hasErrors = true
} else {
Expand Down
Loading

0 comments on commit 9035965

Please sign in to comment.