From d54fa687dd7e6c0b36b5ffec9e0ecad033770ec1 Mon Sep 17 00:00:00 2001 From: alexeh Date: Thu, 19 Dec 2024 14:04:24 +0100 Subject: [PATCH] tmp: comment out import steps --- .../sourcing-data-import.service.ts | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/api/src/modules/import-data/sourcing-data/sourcing-data-import.service.ts b/api/src/modules/import-data/sourcing-data/sourcing-data-import.service.ts index 92e1cf664..0fe60fa68 100644 --- a/api/src/modules/import-data/sourcing-data/sourcing-data-import.service.ts +++ b/api/src/modules/import-data/sourcing-data/sourcing-data-import.service.ts @@ -68,7 +68,7 @@ export class SourcingDataImportService { async importSourcingData(filePath: string, taskId: string): Promise { this.logger.log(`Starting import process`); - await this.fileService.isFilePresentInFs(filePath); + //await this.fileService.isFilePresentInFs(filePath); try { const parsedXLSXDataset: SourcingRecordsSheets = await this.fileService.transformToJson(filePath, SHEETS_MAP); @@ -77,80 +77,80 @@ export class SourcingDataImportService { await this.excelValidator.validate( parsedXLSXDataset as unknown as SourcingDataSheet, ); - if (validationErrors.length) { - throw new ExcelValidationError('Validation Errors', validationErrors); - } - - //TODO: Implement transactional import. Move geocoding to first step - - await this.dbCleaner.cleanDataBeforeImport(); - - const materials: Material[] = - await this.materialService.findAllUnpaginated(); - if (!materials.length) { - throw new ServiceUnavailableException( - 'No Materials found present in the DB. Please check the LandGriffon installation manual', - ); - } + // if (validationErrors.length) { + // throw new ExcelValidationError('Validation Errors', validationErrors); + // } + // + // //TODO: Implement transactional import. Move geocoding to first step + // + // await this.dbCleaner.cleanDataBeforeImport(); + // + // const materials: Material[] = + // await this.materialService.findAllUnpaginated(); + // if (!materials.length) { + // throw new ServiceUnavailableException( + // 'No Materials found present in the DB. Please check the LandGriffon installation manual', + // ); + // } this.logger.log('Activating Indicators...'); const activeIndicators: Indicator[] = await this.indicatorService.activateIndicators( dtoMatchedData.indicators, ); - this.logger.log('Activating Materials...'); - const activeMaterials: Material[] = - await this.materialService.activateMaterials(dtoMatchedData.materials); - - await this.tasksService.updateImportTask({ - taskId, - newLogs: [ - `Activated indicators: ${activeIndicators - .map((i: Indicator) => i.name) - .join(', ')}`, - `Activated materials: ${activeMaterials - .map((i: Material) => i.hsCodeId) - .join(', ')}`, - ], - }); - - const businessUnits: BusinessUnit[] = - await this.businessUnitService.createTree(dtoMatchedData.businessUnits); - - const suppliers: Supplier[] = await this.supplierService.createTree( - dtoMatchedData.suppliers, - ); - - const { geoCodedSourcingData, errors } = - await this.geoCodingService.geoCodeLocations( - dtoMatchedData.sourcingData, - ); - if (errors.length) { - throw new GeoCodingError( - 'Import failed. There are GeoCoding errors present in the file', - errors, - ); - } - const warnings: string[] = []; - geoCodedSourcingData.forEach((elem: SourcingData) => { - if (elem.locationWarning) warnings.push(elem.locationWarning); - }); - warnings.length > 0 && - (await this.tasksService.updateImportTask({ - taskId, - newLogs: warnings, - })); - - const sourcingDataWithOrganizationalEntities: SourcingLocation[] = - await this.relateSourcingDataWithOrganizationalEntities( - suppliers, - businessUnits, - materials, - geoCodedSourcingData, - ); - - await this.sourcingLocationService.save( - sourcingDataWithOrganizationalEntities, - ); + // this.logger.log('Activating Materials...'); + // const activeMaterials: Material[] = + // await this.materialService.activateMaterials(dtoMatchedData.materials); + // + // await this.tasksService.updateImportTask({ + // taskId, + // newLogs: [ + // `Activated indicators: ${activeIndicators + // .map((i: Indicator) => i.name) + // .join(', ')}`, + // `Activated materials: ${activeMaterials + // .map((i: Material) => i.hsCodeId) + // .join(', ')}`, + // ], + // }); + // + // const businessUnits: BusinessUnit[] = + // await this.businessUnitService.createTree(dtoMatchedData.businessUnits); + // + // const suppliers: Supplier[] = await this.supplierService.createTree( + // dtoMatchedData.suppliers, + // ); + // + // const { geoCodedSourcingData, errors } = + // await this.geoCodingService.geoCodeLocations( + // dtoMatchedData.sourcingData, + // ); + // if (errors.length) { + // throw new GeoCodingError( + // 'Import failed. There are GeoCoding errors present in the file', + // errors, + // ); + // } + // const warnings: string[] = []; + // geoCodedSourcingData.forEach((elem: SourcingData) => { + // if (elem.locationWarning) warnings.push(elem.locationWarning); + // }); + // warnings.length > 0 && + // (await this.tasksService.updateImportTask({ + // taskId, + // newLogs: warnings, + // })); + // + // const sourcingDataWithOrganizationalEntities: SourcingLocation[] = + // await this.relateSourcingDataWithOrganizationalEntities( + // suppliers, + // businessUnits, + // materials, + // geoCodedSourcingData, + // ); + // + // await this.sourcingLocationService.save( + // sourcingDataWithOrganizationalEntities, + // ); this.logger.log('Generating Indicator Records...');