Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/controllers/v1/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,12 @@ module.exports = class Entities extends Abstract {
createMappingCsv(req) {
return new Promise(async (resolve, reject) => {
try {
let tenantId = req.userDetails.userInformation.tenantId
// Parse CSV data from the uploaded file in the request body
let entityCSVData = await csv().fromString(req.files.entityCSV.data.toString())

// Process the entity mapping upload data using 'entitiesHelper.createMappingCsv'
let mappedEntities = await entitiesHelper.createMappingCsv(entityCSVData)
let mappedEntities = await entitiesHelper.createMappingCsv(entityCSVData, tenantId)

return resolve({
message: CONSTANTS.apiResponses.MAPPING_CSV_GENERATED,
Expand Down
4 changes: 3 additions & 1 deletion src/module/entities/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ module.exports = class UserProjectsHelper {
* @method
* @name createMappingCsv
* @param {Array<Object>} entityCSVData - Array of objects parsed from the input CSV file.
* @param {String} tenantId - Tenant ID for the user.
* @returns {Promise<Object>} Resolves with an object containing:
*/

static async createMappingCsv(entityCSVData) {
static async createMappingCsv(entityCSVData, tenantId) {
return new Promise(async (resolve, reject) => {
try {
const parentEntityIds = []
Expand All @@ -113,6 +114,7 @@ module.exports = class UserProjectsHelper {
// Filter criteria to fetch entity documents based on entity type and external ID
const filter = {
'metaInformation.externalId': value,
tenantId: tenantId,
}

const entityDocuments = await entitiesQueries.entityDocuments(filter, ['_id'])
Expand Down