|
|
@ -8,6 +8,7 @@ from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
|
|
|
from tui_rsync.core.shared_kernel.components.common import UUID
|
|
|
|
from tui_rsync.core.shared_kernel.components.common import UUID
|
|
|
|
|
|
|
|
|
|
|
|
from tui_rsync.infrastructure.orm.models import BackupPlanModel, DestinationModel
|
|
|
|
from tui_rsync.infrastructure.orm.models import BackupPlanModel, DestinationModel
|
|
|
|
|
|
|
|
from ..commands import RemoveBackupBackupPlanDestinationsCommand
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BackupPlanRepository(BackupPlanRepositoryPort):
|
|
|
|
class BackupPlanRepository(BackupPlanRepositoryPort):
|
|
|
@ -30,7 +31,18 @@ class BackupPlanRepository(BackupPlanRepositoryPort):
|
|
|
|
return BackupPlanDTO.to_domain(model)
|
|
|
|
return BackupPlanDTO.to_domain(model)
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, backup_plan: BackupPlan):
|
|
|
|
def update(self, backup_plan: BackupPlan):
|
|
|
|
pass
|
|
|
|
updated_model = BackupPlanDTO.to_model(backup_plan)
|
|
|
|
|
|
|
|
model = BackupPlanModel.get_or_none(BackupPlanModel.id == updated_model.id)
|
|
|
|
|
|
|
|
remove_backup_plan_destinations_command = RemoveBackupBackupPlanDestinationsCommand(self.databaseManager)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.label = updated_model.label
|
|
|
|
|
|
|
|
model.source = updated_model.source
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remove_backup_plan_destinations_command.execute(backup_plan.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.save()
|
|
|
|
|
|
|
|
for destination in updated_model.destinations:
|
|
|
|
|
|
|
|
destination.save(force_insert=True)
|
|
|
|
|
|
|
|
|
|
|
|
def delete(self, uuid: UUID) -> bool:
|
|
|
|
def delete(self, uuid: UUID) -> bool:
|
|
|
|
deleted = BackupPlanModel.delete().where(BackupPlanModel.id == uuid.id).execute()
|
|
|
|
deleted = BackupPlanModel.delete().where(BackupPlanModel.id == uuid.id).execute()
|
|
|
|