Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7725416
add system creation module
Viniciuspxf Sep 23, 2024
cb3c7f3
refactor SystemCreator class and SystemAggregateStorage interface
Viniciuspxf Sep 29, 2024
53e5b0e
add SystemAggregateStorage implementation to MongoSystemRepository
Viniciuspxf Sep 29, 2024
86f3d07
adjust Dockerfile to build the app-creation module
Viniciuspxf Sep 30, 2024
d5c1a11
refactor SystemDocument due to compilation error
Viniciuspxf Sep 30, 2024
5798b0b
rename init-mongo.js to mongo-init.js and bind it to the mongo container
Viniciuspxf Oct 2, 2024
f7c4ab9
add CompanySystem as Subsystem in SystemCreator
Viniciuspxf Oct 6, 2024
587715d
refactor: turn addExposedOperationsToMicroservice() and addConsumedOp…
Viniciuspxf Oct 6, 2024
d4ca833
refactor: turn addPublishChannelsToMicroservice() and addSubscribedCh…
Viniciuspxf Oct 6, 2024
8c330ef
Fix: get ObjectId value from Systems correctly
Viniciuspxf Oct 6, 2024
fbe6592
add http routes accessing SystemCreator
Viniciuspxf Oct 6, 2024
c10a582
move exceptions related to interfaces implementations to app-model mo…
Viniciuspxf Oct 9, 2024
9dc9e9b
move exceptions related to interfaces implementations to app-model mo…
Viniciuspxf Oct 9, 2024
215414b
Merge remote-tracking branch 'origin/feature/app-creation' into featu…
Viniciuspxf Oct 9, 2024
affc839
change RestEndpointsRequestDTO contract, using data classes instead o…
Viniciuspxf Oct 9, 2024
7025f76
create requestDTO and responseDTO to fix web module parse error
Viniciuspxf Oct 9, 2024
029d37f
fix /microservice and /{name}/microservice response mapping
Viniciuspxf Oct 10, 2024
05e6e59
fix serialization in app-web module
Viniciuspxf Oct 10, 2024
956dd92
fix ObjectId instantiation while converting Module to Mongo Document
Viniciuspxf Oct 10, 2024
2de1fbb
add Serializable annotation and sealed to SystemResponseDTO interface
Viniciuspxf Oct 10, 2024
e8b6a97
add SerialName to CompanySystemResponseDTO and MicroserviceResponseDTO
Viniciuspxf Oct 10, 2024
c885ecb
add unit tests to CompanySystem and Microservice creation
Viniciuspxf Oct 13, 2024
aeaf9cc
add unit tests to CompanySystem and Microservice in SystemCreator
Viniciuspxf Oct 13, 2024
9901afe
Merge remote-tracking branch 'origin/feature/app-creation' into featu…
Viniciuspxf Oct 13, 2024
5a66b65
create getExistingMicroservice method in SystemAggregateStorage and u…
Viniciuspxf Oct 13, 2024
7f74a1e
add unit tests to adding Databases, operations and message channels i…
Viniciuspxf Oct 13, 2024
4df635d
fix addMessageChannelsToMicroservice method in SystemCreator
Viniciuspxf Oct 13, 2024
f60796c
remove duplicated dependency in app-creation build.gradle.kts
Viniciuspxf Oct 15, 2024
40b784d
add tests to microservices and companySystems creation endpoints
Viniciuspxf Oct 16, 2024
bf5b222
fix /microservices and /systems endpoints paths
Viniciuspxf Oct 16, 2024
5d7da25
fix /microservices and /systems endpoints paths in ApplicationRouting…
Viniciuspxf Oct 16, 2024
369ae36
move kotlinx serialization version to gradle.properties in app-web mo…
Viniciuspxf Oct 16, 2024
a6a4818
add unit tests to MongoSystemRepository
Viniciuspxf Oct 19, 2024
55706fa
handle invalid casting in getCompanySystem and getMicroservice methods
Viniciuspxf Oct 19, 2024
399a026
fix ObjectId instantiation in Database.toDatabaseDocument() converter
Viniciuspxf Oct 19, 2024
fa21d58
Merge branch 'refs/heads/main' into feature/app-creation
Viniciuspxf Oct 19, 2024
d31100c
fix MongoSystemRepository
Viniciuspxf Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM gradle:7.4.2-jdk17 AS dependencies

WORKDIR /home/gradle/usvision

RUN mkdir app-analyses app-model app-persistence app-reports app-web \
RUN mkdir app-analyses app-model app-persistence app-reports app-web app-creation \
&& chown gradle:gradle . -R

USER gradle
Expand All @@ -20,6 +20,7 @@ COPY --chown=gradle:gradle app-model/build.gradle.kts app-model/gradle
COPY --chown=gradle:gradle app-persistence/build.gradle.kts app-persistence/gradle.properties ./app-persistence/
COPY --chown=gradle:gradle app-reports/build.gradle.kts app-reports/gradle.properties ./app-reports/
COPY --chown=gradle:gradle app-web/build.gradle.kts app-web/gradle.properties ./app-web/
COPY --chown=gradle:gradle app-creation/build.gradle.kts app-creation/gradle.properties ./app-creation


# PRE-INSTALL JUST THE DEPENDENCIES -- THIS SHALL SPEEDUP FUTURE BUILDS
Expand Down
24 changes: 24 additions & 0 deletions app-creation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
val mockk_version: String by project

plugins {
`java-library`
kotlin("jvm")
kotlin("plugin.serialization")
}

group = "com.usvision.reports"
version = "0.0.1"

repositories {
mavenCentral()
}

tasks.test {
useJUnitPlatform()
}

dependencies {
implementation(project(":app-model"))
testImplementation("io.mockk:mockk:${mockk_version}")
testImplementation(kotlin("test"))
}
2 changes: 2 additions & 0 deletions app-creation/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mockk_version=1.12.3
kotlin.code.style=official
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.usvision.creation

import com.usvision.model.domain.CompanySystem
import com.usvision.model.domain.Microservice
import com.usvision.model.systemcomposite.System

interface SystemAggregateStorage {
fun getSystem(name: String): System?
fun save(microservice: Microservice): Microservice
fun save(companySystem: CompanySystem): CompanySystem
fun getCompanySystem(name: String): CompanySystem?
fun getMicroservice(name: String): Microservice?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.usvision.creation

import com.usvision.model.domain.CompanySystem
import com.usvision.model.domain.MessageChannel
import com.usvision.model.domain.Microservice
import com.usvision.model.domain.databases.Database
import com.usvision.model.domain.operations.Operation
import com.usvision.model.systemcomposite.System

typealias CompanySystemDTO = CompanySystem
typealias SystemDTO = System
typealias MicroserviceDTO = Microservice
typealias DatabaseDTO = Database

class SystemCreator(
private val systemAggregateStorage: SystemAggregateStorage
) {

fun createCompanySystem(companySystem: CompanySystemDTO, fatherSystemName: String? = null): CompanySystemDTO {
checkIfSystemAlreadyExists(companySystem.name)

fatherSystemName?.also {
val fatherSystem = systemAggregateStorage.getCompanySystem(fatherSystemName)

return@createCompanySystem fatherSystem?.let {
fatherSystem.addSubsystem(companySystem)
systemAggregateStorage.save(fatherSystem)
} ?: throw Exception("A System Of Systems with name $fatherSystemName does not exist")
}

return systemAggregateStorage.save(companySystem)
}

fun createMicroservice(microservice: MicroserviceDTO, fatherSystemName: String? = null): SystemDTO {
checkIfSystemAlreadyExists(microservice.name)

fatherSystemName?.also {
val fatherSystem = systemAggregateStorage.getCompanySystem(fatherSystemName)

return@createMicroservice fatherSystem?.let {
fatherSystem.addSubsystem(microservice)
systemAggregateStorage.save(fatherSystem)
} ?: throw Exception("A System Of Systems with name $fatherSystemName does not exist")
}

return systemAggregateStorage.save(microservice)
}

fun addNewDatabaseConnectionToMicroservice(
database: DatabaseDTO,
microserviceName: String
) = getExistingMicroservice(microserviceName).let {
it.addDatabaseConnection(database)
systemAggregateStorage.save(it)
}

fun addOperationsToMicroservice(
exposedOperations: List<Operation>,
consumedOperations: List<Operation>,
microserviceName: String
) = getExistingMicroservice(microserviceName).let {
exposedOperations.forEach {
operation -> it.exposeOperation(operation)
}

consumedOperations.forEach {
operation -> it.consumeOperation(operation)
}

systemAggregateStorage.save(it)
}

fun addMessageChannelsToMicroservice(
publishMessageChannels: List<MessageChannel>,
subscribedMessageChannels: List<MessageChannel>,
microserviceName: String
) = getExistingMicroservice(microserviceName).let {
publishMessageChannels.forEach {
operation -> it.addPublishChannel(operation)
}

subscribedMessageChannels.forEach {
operation -> it.addSubscribedChannel(operation)
}

systemAggregateStorage.save(it)
}

private fun getExistingMicroservice(
microserviceName: String
) = systemAggregateStorage.getMicroservice(microserviceName)
?: throw Exception("A Microservice with name $microserviceName does not exist")

private fun checkIfSystemAlreadyExists(name: String) {
systemAggregateStorage.getSystem(name)?.also {
throw Exception("A system with name $name already exists")
}
}
}
Loading