add overwrite when update spaces with spacesModel

This commit is contained in:
faris Aljohari
2025-03-06 11:13:14 +03:00
parent 6864e000b8
commit 61692c70d1
2 changed files with 39 additions and 8 deletions

View File

@ -449,6 +449,9 @@ export class SpaceService {
try {
await queryRunner.connect();
await queryRunner.startTransaction();
const project = await this.spaceModelService.validateProject(
params.projectUuid,
);
const space =
await this.validationService.validateSpaceWithinCommunityAndProject(
@ -483,9 +486,15 @@ export class SpaceService {
queryRunner,
);
} else if (hasDependencies) {
throw new HttpException(
`Space cannot be linked to a model because it has existing dependencies (devices, subspaces, or product allocations).`,
HttpStatus.BAD_REQUEST,
await this.spaceModelService.overwriteSpace(
space,
project,
queryRunner,
);
await this.spaceModelService.linkToSpace(
space,
spaceModel,
queryRunner,
);
}
}