Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d32a095
create MongoDBDataSource class
mahmoudibrahimabdulfattah May 5, 2025
607dab9
use coroutines by make suspend functions
mahmoudibrahimabdulfattah May 5, 2025
c27e432
add mongodb dependency
mahmoudibrahimabdulfattah May 5, 2025
ea9aa41
add test and implementation of mongoDBConfig
diyar214 May 6, 2025
dcee44e
Merge branch 'development' into feature/mongo-db-setup
diyar214 May 6, 2025
82c0b21
fix audit package naming
diyar214 May 7, 2025
1ec0166
change models to work with MongoDB
mahmoudibrahimabdulfattah May 7, 2025
2b1155b
change dataSource for MongoDB
mahmoudibrahimabdulfattah May 7, 2025
1a69385
fix db connection, connection string was wrong
diyar214 May 10, 2025
df6f8f4
Merge branch 'development' into feature/mongo-db-setup
diyar214 May 10, 2025
c5ad59a
remove deprecated file and update task state name
diyar214 May 10, 2025
331d8fe
delete config test
mahmoudibrahimabdulfattah May 10, 2025
0f6cccf
Merge remote-tracking branch 'origin/feature/mongo-db-setup' into fea…
mahmoudibrahimabdulfattah May 10, 2025
3212f61
create datasource test
mahmoudibrahimabdulfattah May 10, 2025
a5cd2e9
use assertThat
mahmoudibrahimabdulfattah May 11, 2025
31ae4ae
Merge branch 'development' into feature/mongo-db-setup
diyar214 May 15, 2025
147abe5
change the name of parameter in mapper functions
diyar214 May 15, 2025
967cde7
changes after merge
diyar214 May 15, 2025
899b62f
Merge branch 'feature/mongo-db-setup' of https://github.com/team-berl…
diyar214 May 15, 2025
32ba928
fix monogdb connection issue
diyar214 May 15, 2025
04304e6
replace domain modal with dto at data package
diyar214 May 15, 2025
2baa2bb
solve koin edit user dto user name
marwanqashwa May 16, 2025
9ce5438
Merge branch 'development' into feature/mongo-db-setup
diyar214 May 18, 2025
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
1 change: 1 addition & 0 deletions csv_files/audit.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"AUDITDDD_26090","1746816126090","user1234","CREATE","","PROJECT","newprojctrrr_26090"
"AUDITDDDD_91726","1746817691726","matetttt_16791","CREATE","","TASK","tasctitlett_91718"
"AUDITDD_38672","1746870738672","user1234","CREATE","","TASK","testtaskanddbaftermergedddddd_38667"
"AUDITDD_38672","1746870738672","user1234","CREATE","","TASK","testtaskanddbaftermergedddddd_38667"
"AUDITD_32769","1747065232769","user1234","CREATE","","TASK","refactorcc_32751"
"AUDITDDDD_14350","1747065314357","user1234","UPDATE","","TASK","refactorcc_32751"
"AUDITDDDD_33128","1747065333128","user1234","DELETE","","TASK","testtaskanddbaftermergedddddd_38667"
Expand Down
1 change: 1 addition & 0 deletions csv_files/task.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"tasctitlett_91718","taskmangermmmm_97132","tasc title","desc","taskmangermmmm_97132","ahmadmmmm_70365","matetttt_16791"
"refactorcc_32751","newprojctrrr_26090","refactor","","tododdd_32001","ahmadmmmm_70365","user1234"
"tasctitlett_91718","taskmangermmmm_97132","tasc title","desc","taskmangermmmm_97132","matetttt_16791","matetttt_16791"
"testtaskanddbaftermergedddddd_38667","newprojctrrr_26090","test task and db after merge","this a description for the test task after merge","tododdd_32001","ahmadmmmm_70365","user1234"
"titlett_29143","P1","titletgtrht","riothr","S1","ahmadmmmm_70365","user1234"
"titlett_29143","P1","title is add readme file","description whole app","S1","ahmadmmmm_70365","user1234"
"titlett_29143","P1","title is readme file","description whole app","S1","ahmadmmmm_70365","user1234"
2 changes: 1 addition & 1 deletion src/main/kotlin/data/dto/UserDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty

data class UserDto(
@BsonId val id: String,
@BsonProperty("user_name") val userName: String,
@BsonProperty("username") val userName: String,
@BsonProperty("password") val password: String,
@BsonProperty("role") val role: User.UserRole
)
32 changes: 16 additions & 16 deletions src/main/kotlin/data/mapper/AuditLogMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import com.berlin.data.dto.AuditLogDto
import com.berlin.domain.model.AuditLog

class AuditLogMapper : EntityMapper<AuditLogDto, AuditLog> {
override fun mapToDomainModel(auditLogDto: AuditLogDto): AuditLog {
override fun mapToDomainModel(from: AuditLogDto): AuditLog {
return AuditLog(
id = auditLogDto.id,
timestamp = auditLogDto.timestamp,
createdByUserId = auditLogDto.createdByUserId,
auditAction = auditLogDto.auditAction,
changesDescription = auditLogDto.changesDescription,
entityType = auditLogDto.entityType,
entityId = auditLogDto.entityId
id = from.id,
timestamp = from.timestamp,
createdByUserId = from.createdByUserId,
auditAction = from.auditAction,
changesDescription = from.changesDescription,
entityType = from.entityType,
entityId = from.entityId
)
}

override fun mapToDataModel(auditLog: AuditLog): AuditLogDto {
override fun mapToDataModel(from: AuditLog): AuditLogDto {
return AuditLogDto(
id = auditLog.id,
timestamp = auditLog.timestamp,
createdByUserId = auditLog.createdByUserId,
auditAction = auditLog.auditAction,
changesDescription = auditLog.changesDescription,
entityType = auditLog.entityType,
entityId = auditLog.entityId
id = from.id,
timestamp = from.timestamp,
createdByUserId = from.createdByUserId,
auditAction = from.auditAction,
changesDescription = from.changesDescription,
entityType = from.entityType,
entityId = from.entityId
)
}
}
24 changes: 12 additions & 12 deletions src/main/kotlin/data/mapper/ProjectMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import com.berlin.data.dto.ProjectDto
import com.berlin.domain.model.Project

class ProjectMapper : EntityMapper<ProjectDto, Project> {
override fun mapToDomainModel(projectDto: ProjectDto): Project {
override fun mapToDomainModel(from: ProjectDto): Project {
return Project(
id = projectDto.id,
title = projectDto.title,
statesId = projectDto.statesId,
description = projectDto.description,
tasksId = projectDto.tasksId
id = from.id,
title = from.title,
statesId = from.statesId,
description = from.description,
tasksId = from.tasksId
)
}

override fun mapToDataModel(project: Project): ProjectDto {
override fun mapToDataModel(from: Project): ProjectDto {
return ProjectDto(
id = project.id,
title = project.title,
statesId = project.statesId,
description = project.description,
tasksId = project.tasksId
id = from.id,
title = from.title,
statesId = from.statesId,
description = from.description,
tasksId = from.tasksId
)
}
}
32 changes: 16 additions & 16 deletions src/main/kotlin/data/mapper/TaskMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import com.berlin.data.dto.TaskDto
import com.berlin.domain.model.Task

class TaskMapper : EntityMapper<TaskDto, Task> {
override fun mapToDomainModel(taskDto: TaskDto): Task {
override fun mapToDomainModel(from: TaskDto): Task {
return Task(
id = taskDto.id,
title = taskDto.title,
projectId = taskDto.projectId,
description = taskDto.description,
stateId = taskDto.stateId,
assignedToUserId = taskDto.assignedToUserId,
createByUserId = taskDto.createByUserId
id = from.id,
title = from.title,
projectId = from.projectId,
description = from.description,
stateId = from.stateId,
assignedToUserId = from.assignedToUserId,
createByUserId = from.createByUserId
)
}

override fun mapToDataModel(task: Task): TaskDto {
override fun mapToDataModel(from: Task): TaskDto {
return TaskDto(
id = task.id,
title = task.title,
projectId = task.projectId,
description = task.description,
stateId = task.stateId,
assignedToUserId = task.assignedToUserId,
createByUserId = task.createByUserId
id = from.id,
title = from.title,
projectId = from.projectId,
description = from.description,
stateId = from.stateId,
assignedToUserId = from.assignedToUserId,
createByUserId = from.createByUserId
)
}
}
16 changes: 8 additions & 8 deletions src/main/kotlin/data/mapper/TaskStateMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import com.berlin.data.dto.TaskStateDto
import com.berlin.domain.model.TaskState

class TaskStateMapper : EntityMapper<TaskStateDto, TaskState> {
override fun mapToDomainModel(taskStateDto: TaskStateDto): TaskState {
override fun mapToDomainModel(from: TaskStateDto): TaskState {
return TaskState(
id = taskStateDto.id,
name = taskStateDto.name,
projectId = taskStateDto.projectId
id = from.id,
name = from.name,
projectId = from.projectId
)
}

override fun mapToDataModel(taskState: TaskState): TaskStateDto {
override fun mapToDataModel(from: TaskState): TaskStateDto {
return TaskStateDto(
id = taskState.id,
name = taskState.name,
projectId = taskState.projectId
id = from.id,
name = from.name,
projectId = from.projectId
)
}
}
18 changes: 9 additions & 9 deletions src/main/kotlin/data/mapper/UserMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ class UserMapper(
private val userDataSource: BaseDataSource<UserDto>,
) : EntityMapper<UserDto, User> {

override fun mapToDomainModel(userDto: UserDto): User {
override fun mapToDomainModel(from: UserDto): User {
return User(
id = userDto.id,
userName = userDto.userName,
role = userDto.role
id = from.id,
userName = from.userName,
role = from.role
)
}

override fun mapToDataModel(user: User): UserDto {
val userDto = userDataSource.getById(user.id)
override fun mapToDataModel(from: User): UserDto {
val userDto = userDataSource.getById(from.id)
?: throw UserNotFoundException("user not found")
return UserDto(
id = user.id,
userName = user.userName,
role = user.role,
id = from.id,
userName = from.userName,
role = from.role,
password = userDto.password
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/data/mongodb/config/MongoConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.bson.codecs.pojo.PojoCodecProvider
import com.mongodb.kotlin.client.coroutine.MongoCollection

class MongoConfig(
private val connectionString: String = "mongodb+srv://diyarHussein:7p53.t@GQ4F#@2c@planmate.gzyncow.mongodb.net/?retryWrites=true&w=majority&appName=PlanMate",
private val databaseName: String = "PlanMate"
private val connectionString: String = System.getenv("MONGO_URI"),
private val databaseName: String = "TaskManager",
) {

fun createMongoClient(): MongoClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package com.berlin.data.mongodb.datasource

import com.berlin.data.BaseDataSource
import com.berlin.data.dto.AuditLogDto
import com.berlin.data.mongodb.config.MongoConfig
import com.berlin.domain.model.AuditLog
import com.mongodb.client.model.Filters
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking

class MongoDBauditLogDataSource(
class MongoDBAuditLogDataSource(
private val mongoConfig: MongoConfig
) : BaseDataSource<AuditLog> {
) : BaseDataSource<AuditLogDto> {

private val client = mongoConfig.createMongoClient()
private val database = mongoConfig.getDatabase(client)
private val collection = mongoConfig.getCollection<AuditLog>(database, "audit_logs")
private val collection = mongoConfig.getCollection<AuditLogDto>(database, "audit_logs")

override fun getAll(): List<AuditLog> {
override fun getAll(): List<AuditLogDto> {
return runBlocking {
collection.find().toList()
}
}

override fun getById(id: String): AuditLog? {
override fun getById(id: String): AuditLogDto? {
return runBlocking {
collection.find(Filters.eq("_id", id)).firstOrNull()
}
}

override fun update(id: String, entity: AuditLog): Boolean {
override fun update(id: String, entity: AuditLogDto): Boolean {
return runBlocking {
collection.replaceOne(Filters.eq("_id", id), entity).wasAcknowledged()
}
Expand All @@ -40,13 +40,13 @@ class MongoDBauditLogDataSource(
}
}

override fun write(entity: AuditLog): Boolean {
override fun write(entity: AuditLogDto): Boolean {
return runBlocking {
collection.insertOne(entity).wasAcknowledged()
}
}

override fun writeAll(entities: List<AuditLog>): Boolean {
override fun writeAll(entities: List<AuditLogDto>): Boolean {
if (entities.isEmpty()) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.berlin.data.mongodb.datasource

import com.berlin.data.BaseDataSource
import com.berlin.data.dto.ProjectDto
import com.berlin.data.mongodb.config.MongoConfig
import com.berlin.domain.model.Project
import com.mongodb.client.model.Filters
Expand All @@ -10,25 +11,25 @@ import kotlinx.coroutines.runBlocking

class MongoDBProjectDataSource(
private val mongoConfig: MongoConfig
) : BaseDataSource<Project> {
) : BaseDataSource<ProjectDto> {

private val client = mongoConfig.createMongoClient()
private val database = mongoConfig.getDatabase(client)
private val collection = mongoConfig.getCollection<Project>(database, "projects")
private val collection = mongoConfig.getCollection<ProjectDto>(database, "projects")

override fun getAll(): List<Project> {
override fun getAll(): List<ProjectDto> {
return runBlocking {
collection.find().toList()
}
}

override fun getById(id: String): Project? {
override fun getById(id: String): ProjectDto? {
return runBlocking {
collection.find(Filters.eq("_id", id)).firstOrNull()
}
}

override fun update(id: String, entity: Project): Boolean {
override fun update(id: String, entity: ProjectDto): Boolean {
return runBlocking {
collection.replaceOne(Filters.eq("_id", id), entity).wasAcknowledged()
}
Expand All @@ -40,13 +41,13 @@ class MongoDBProjectDataSource(
}
}

override fun write(entity: Project): Boolean {
override fun write(entity: ProjectDto): Boolean {
return runBlocking {
collection.insertOne(entity).wasAcknowledged()
}
}

override fun writeAll(entities: List<Project>): Boolean {
override fun writeAll(entities: List<ProjectDto>): Boolean {
if (entities.isEmpty()) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.berlin.data.mongodb.datasource

import com.berlin.data.BaseDataSource
import com.berlin.data.dto.TaskStateDto
import com.berlin.data.mongodb.config.MongoConfig
import com.berlin.domain.model.TaskState
import com.mongodb.client.model.Filters
Expand All @@ -10,25 +11,25 @@ import kotlinx.coroutines.runBlocking

class MongoDBStateDataSource(
private val mongoConfig: MongoConfig
) : BaseDataSource<TaskState> {
) : BaseDataSource<TaskStateDto> {

private val client = mongoConfig.createMongoClient()
private val database = mongoConfig.getDatabase(client)
private val collection = mongoConfig.getCollection<TaskState>(database, "states")
private val collection = mongoConfig.getCollection<TaskStateDto>(database, "states")

override fun getAll(): List<TaskState> {
override fun getAll(): List<TaskStateDto> {
return runBlocking {
collection.find().toList()
}
}

override fun getById(id: String): TaskState? {
override fun getById(id: String): TaskStateDto? {
return runBlocking {
collection.find(Filters.eq("_id", id)).firstOrNull()
}
}

override fun update(id: String, entity: TaskState): Boolean {
override fun update(id: String, entity: TaskStateDto): Boolean {
return runBlocking {
collection.replaceOne(Filters.eq("_id", id), entity).wasAcknowledged()
}
Expand All @@ -40,13 +41,13 @@ class MongoDBStateDataSource(
}
}

override fun write(entity: TaskState): Boolean {
override fun write(entity: TaskStateDto): Boolean {
return runBlocking {
collection.insertOne(entity).wasAcknowledged()
}
}

override fun writeAll(entities: List<TaskState>): Boolean {
override fun writeAll(entities: List<TaskStateDto>): Boolean {
if (entities.isEmpty()) {
return false
}
Expand Down
Loading
Loading