#Database
spring.datasource.url=jdbc:sqlserver://${pigw_SQLDB_server}:1433;database=ItlPartnerIntegration
spring.datasource.username=${pigw_SQLDB_username}
spring.datasource.password=${pigw_SQLDB_password}
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver


#Basic Auth Credentials
basic.auth.admin.credential.username=${pigw_basic_auth_admin_username}
basic.auth.admin.credential.password=${pigw_basic_auth_admin_password}
basic.auth.admin.credential.role=ROLE_ADMIN

basic.auth.user.credential.username=${pigw_basic_auth_read_username}
basic.auth.user.credential.password=${pigw_basic_auth_read_password}
basic.auth.user.credential.role=ROLE_USER

spring.main.allow-circular-references=true
spring.mvc.pathmatch.matching-strategy=ant_path_matcher

#IBT Ordering Service 
ibt.ordering.service.basic.auth.passcode=${ibt_basic_auth_passcode}
ibt.ordering.service.getproducts.url=http://ibt-order-local-dev-helm-ibt-order-local.mns-itl-ibt-dev.svc.cluster.local/api/orderextract/v1/getProducts

#CnH Metadata Service 
cnh.metadata.service.basic.auth.passcode=${cnh_metadata_service_passcode}
cnh.metadata.service.season.url = https://cnh-metadata-local-perf.cah.apps.mnscorpdev.net/api/ip/gmcalendar/v1/getPreviousAndNexSeasonsFromCurrentSeason

#Enriched API Service - PIM
enriched.product.service.basic.auth.passcode=${pigw_pim_auth_passcode}
enriched.product.service.display.url=https://api-stage.marksandspencer.com/enrichedProduct/v1/productdisplay/stroke

#Azure File Share Details
azure.fileshare.v2.connection.string=${azure_file_share_connection_string_v2}
cnh.fileshare.v2.connection.string=${cnh_file_share_connection_string_v2}
azure.fileshare.v2.path.source=/cnh-product-full-refresh-extract/Source
azure.fileshare.v2.path.archive=/cnh-product-full-refresh-extract/Archive

configured.cleanup.weeks=8

management.endpoints.web.exposure.include=*
management.endpoint.health.enabled=true
management.endpoint.promotheus.enabled=true
management.endpoint.metrics.enabled=true

-------------------------------------------------------
package com.mns.partner.integration.extractor.controller;

import java.math.BigInteger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mns.partner.integration.extractor.exception.CloudFileUploadException;
import com.mns.partner.integration.extractor.processor.DataCleanUp;
import com.mns.partner.integration.extractor.processor.DataLoader;
import com.mns.partner.integration.extractor.processor.ExtractGenerator;

@RestController
@CrossOrigin("trustedwebsite.com") 
@RequestMapping("/api/productextractor")
public class ProductExtractorController {

	@Autowired
	DataLoader dataLoader;

	@Autowired
	ExtractGenerator extractGenerator;
	
	@Autowired
	private DataCleanUp dataCleanUp;

	@Async
	@PostMapping("/v1/loadDataFromCloud")
	public void loadDataFromCloud() {

		dataLoader.loadData();

	}

	@Async
	@PostMapping("/v1/generateExtract")
	public void generateExtract() {

		extractGenerator.startProcess();

	}

	@Async
	@PostMapping("/v1/generateExtractWithBatch/{batchId}")
	public void generateExtractUsingBatchId(@PathVariable BigInteger batchId) throws CloudFileUploadException {

		extractGenerator.startProcessUsingBatchId(batchId);

	}
	
	@Async
	@PostMapping("/v1/dataCleanUp")
	public void dataCleanUp() {

		dataCleanUp.cleanUpProcess();

	}

}

----------------------------------------
package com.mns.partner.integration.extractor.helper;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.security.InvalidKeyException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.JsonParser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.file.CloudFile;
import com.microsoft.azure.storage.file.CloudFileClient;
import com.microsoft.azure.storage.file.CloudFileDirectory;
import com.microsoft.azure.storage.file.CloudFileShare;
import com.microsoft.azure.storage.file.CopyState;
import com.microsoft.azure.storage.file.CopyStatus;
import com.mns.partner.integration.extractor.constants.Constants;
import com.mns.partner.integration.extractor.dto.extract.ProductExtract;
import com.mns.partner.integration.extractor.dto.output.Product;
import com.mns.partner.integration.extractor.exception.CloudFileLoadException;
import com.mns.partner.integration.extractor.exception.CloudFileReadException;
import com.mns.partner.integration.extractor.exception.CloudFileUploadException;
import com.mns.partner.integration.extractor.util.Utils;

@Component
public class CloudFileShareHelper {

	@Value("${azure.fileshare.v2.connection.string}")
	private String azureFileShareConnectionString;
	
	@Value("${cnh.fileshare.v2.connection.string}")
	private String cnhFileShareConnectionString;

	@Value("${azure.fileshare.v2.path.source}")
	private String sourceFileSharePath;

	@Value("${azure.fileshare.v2.path.archive}")
	private String archiveFileSharePath;

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	public CloudFile getFullExtractFileFromFileShare() throws CloudFileLoadException {

		logger.info("Full extract download from file share has started ");

		try {

			CloudFileDirectory fileDirectory = getCnHConfig(sourceFileSharePath);			

			if (fileDirectory.listFilesAndDirectories().iterator().hasNext()) {

				return (CloudFile) fileDirectory.listFilesAndDirectories().iterator().next();
			} else {
				return null;
			}

		} catch (Exception e) {

			throw new CloudFileLoadException(e);

		}

	}


	@SuppressWarnings("deprecation")
	public List<ProductExtract> getProductsFromFile(CloudFile fullExtractFile) throws CloudFileReadException {

		List<ProductExtract> productExtractList = new ArrayList<>();

		try {
			long fileExtractSize = fullExtractFile.getProperties().getLength();
			logger.info("Downloading text started"+fileExtractSize);
			ObjectMapper objectMapper = new ObjectMapper();
			objectMapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
			long chunkSize = 4 * 1024 * 1024L;

			if(chunkSize<fileExtractSize){
				try (ByteArrayOutputStream fileOutputStream = new ByteArrayOutputStream()) {

					for (long offset = 0L; offset <fileExtractSize; offset += chunkSize) {
						chunkSize = Math.min(fileExtractSize - offset, chunkSize);
						logger.info("offset:"+offset+" length:"+(offset + chunkSize));

						fullExtractFile.downloadRange(offset,chunkSize,fileOutputStream);
						logger.info("Sizefileoutputstream :"+fileOutputStream.size());

					}
					logger.info("Downloading completed");
					logger.info("Array as list conversion");
					productExtractList.addAll(Arrays.asList(objectMapper.readValue(fileOutputStream.toByteArray(), ProductExtract[].class)));
					logger.info("Size of productExtractList:"+productExtractList.size());
				}
				catch (IOException exception){
					logger.info("Exception:"+exception);
				}
			}
			else{
				String productExtractJson = fullExtractFile.downloadText();
				logger.info("Downloading completed");
				logger.info("Array as list conversion");
				productExtractList.addAll(Arrays.asList(objectMapper.readValue(productExtractJson, ProductExtract[].class)));
				logger.info("Size of productExtractList:"+productExtractList.size());
			}

		} catch (Exception e) {

			throw new CloudFileReadException(e);

		}

		return productExtractList;

	}

	public void moveToArchive(CloudFile sourceFile) {
		try {
			logger.info("Moving file into Archieve");
			CloudFileDirectory rootDir = getCnHConfig(archiveFileSharePath);

			CloudFile archiveCloudFile = rootDir.getFileReference(sourceFile.getName());
			archiveCloudFile.startCopy(sourceFile);

			CopyState copyState = archiveCloudFile.getCopyState();

			do {

				Thread.sleep(1000);

			} while (copyState.getStatus().equals(CopyStatus.PENDING));

			//sourceFile.delete();
		} catch (Exception e) {

			logger.error("Error while moving file", e);
			Thread.currentThread().interrupt();
		}
	}

	public CloudFile uploadToFileShare(String fileContent, String fileName, String fileType, String fileSharePath) {
		try {
			CloudFileDirectory rootDir = getConfig(fileSharePath);
			return uploadFile(fileContent, rootDir, fileName, fileType);

		} catch (Exception e) {
			CloudFileUploadException cloudFileUploadException = new CloudFileUploadException(e);
			cloudFileUploadException.logErrorMessage();
			logger.error("Error occured while uploading file to share path ", e);
		}
		return null;
	}

	private CloudFile uploadFile(String fileContent, CloudFileDirectory rootDir, String fileName, String fileType)
			throws URISyntaxException, StorageException, IOException {
		FileWriter writer = null;
		try {
			CloudFile cloudFile = rootDir.getFileReference(fileName + fileType);
			File tmpFile = new File(fileName + fileType);
			writer = new FileWriter(tmpFile);
			writer.write(fileContent);
			writer.close();
			cloudFile.uploadFromFile(tmpFile.getAbsolutePath());

			if (cloudFile.getUri() != null) {
				Files.delete(tmpFile.toPath());
				logger.info("temp file deleted ");
				logger.info("File uploaded to FileShare {}", cloudFile.getUri());
			}
			return cloudFile;
		} catch (Exception e) {
			CloudFileUploadException cloudFileUploadException = new CloudFileUploadException(e);
			cloudFileUploadException.logErrorMessage();
			logger.error("Error occured while uploading file to share path ", e);
			return null;
		} finally {
			if (writer != null)
				writer.close();
		}
	}

	private CloudFileDirectory getConfig(String shareReference)
			throws InvalidKeyException, URISyntaxException, StorageException {
		CloudStorageAccount storageAccount = CloudStorageAccount.parse(azureFileShareConnectionString);
		logger.info(
				"bloburi {} , credentials: {} , endpointsuffix: {} , fileEndpoint: {} , fileStorageUri: {}, queueuri: {} , tableUri: {}",
				storageAccount.getBlobStorageUri(), storageAccount.getCredentials(), storageAccount.getEndpointSuffix(),
				storageAccount.getFileEndpoint(), storageAccount.getFileStorageUri(),
				storageAccount.getQueueStorageUri(), storageAccount.getTableStorageUri());
		CloudFileClient fileClient = storageAccount.createCloudFileClient();
		CloudFileShare share = fileClient.getShareReference(shareReference);
		return share.getRootDirectoryReference();
	}
	
	private CloudFileDirectory getCnHConfig(String shareReference)
			throws InvalidKeyException, URISyntaxException, StorageException {
		CloudStorageAccount storageAccount = CloudStorageAccount.parse(cnhFileShareConnectionString);
		logger.info(
				"bloburi {} , credentials: {} , endpointsuffix: {} , fileEndpoint: {} , fileStorageUri: {}, queueuri: {} , tableUri: {}",
				storageAccount.getBlobStorageUri(), storageAccount.getCredentials(), storageAccount.getEndpointSuffix(),
				storageAccount.getFileEndpoint(), storageAccount.getFileStorageUri(),
				storageAccount.getQueueStorageUri(), storageAccount.getTableStorageUri());
		CloudFileClient fileClient = storageAccount.createCloudFileClient();
		CloudFileShare share = fileClient.getShareReference(shareReference);
		return share.getRootDirectoryReference();
	}

	public CloudFile pushDataToAzureFileShare(List<Product> productList, String fileNamePattern, String destinationPath)
			throws JsonProcessingException {

		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmSS");

		LocalDateTime localDateTime = LocalDateTime.now();

		String currentTimeStamp = localDateTime.format(formatter);
		String fileNameWithDate = fileNamePattern + "_" + currentTimeStamp;
		return uploadToFileShare(Utils.generateJson(productList), fileNameWithDate, Constants.JSON_FILE_TYPE,
				destinationPath);

	}

	public String getAzureFileShareConnectionString() {
		return azureFileShareConnectionString;
	}

	public void setAzureFileShareConnectionString(String azureFileShareConnectionString) {
		this.azureFileShareConnectionString = azureFileShareConnectionString;
	}

	public String getSourceFileSharePath() {
		return sourceFileSharePath;
	}

	public void setSourceFileSharePath(String sourceFileSharePath) {
		this.sourceFileSharePath = sourceFileSharePath;
	}
	
	public Boolean deleteFileFromCloud(String azureFileShareConnectionString, String fileSharePath,
			String fileName) {
		
		logger.info("Deleting file from cloud started {}",fileName);

		try {

			CloudStorageAccount storageAccount = CloudStorageAccount.parse(azureFileShareConnectionString);

			CloudFileClient fileClient = storageAccount.createCloudFileClient();

			CloudFileShare share = fileClient.getShareReference(fileSharePath);

			CloudFileDirectory rootDir = share.getRootDirectoryReference();

			CloudFile cloudFile;

			
				
				try {

				cloudFile = rootDir.getFileReference(fileName);
					if(cloudFile.exists())
				cloudFile.delete();
					else
						logger.info("No file exist to delete");
				
				return true;
				
				}catch(Exception e ) {
					
					logger.error("Exception While deleting the Full Extract file from Archive  {}",fileName,e);
				}

			
			
			logger.info("Deleting file from cloud ended ");

		} catch (Exception e) {

			logger.error("Error occured while deleting file from cloud ", e);

		}
		
		return false;

	}

}
--------------------------
package com.mns.partner.integration.extractor.processor;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.transaction.Transactional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.microsoft.azure.storage.file.CloudFile;
import com.mns.partner.integration.extractor.constants.AttributeType;
import com.mns.partner.integration.extractor.constants.Constants;
import com.mns.partner.integration.extractor.constants.ProcessStatus;
import com.mns.partner.integration.extractor.dao.FullExtractBatch;
import com.mns.partner.integration.extractor.dao.FullExtractProduct;
import com.mns.partner.integration.extractor.dao.FullExtractProductAttribute;
import com.mns.partner.integration.extractor.dao.FullExtractProductPhase;
import com.mns.partner.integration.extractor.dao.FullExtractProductVariant;
import com.mns.partner.integration.extractor.dao.FullExtractProductVariantPack;
import com.mns.partner.integration.extractor.dto.extract.Attribute;
import com.mns.partner.integration.extractor.dto.extract.Phase;
import com.mns.partner.integration.extractor.dto.extract.ProductExtract;
import com.mns.partner.integration.extractor.dto.extract.ProductExtractPack;
import com.mns.partner.integration.extractor.dto.extract.ProductExtractVariant;
import com.mns.partner.integration.extractor.exception.CloudFileLoadException;
import com.mns.partner.integration.extractor.exception.CloudFileReadException;
import com.mns.partner.integration.extractor.exception.DataLoadFailureException;
import com.mns.partner.integration.extractor.exception.DatabaseConnectionFailureException;
import com.mns.partner.integration.extractor.helper.CloudFileShareHelper;
import com.mns.partner.integration.extractor.repository.FullExtractBatchRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductAttributesRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductPhasesRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductVariantPacksRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductVariantsRepository;

/**
 * @author Loads data from Cloud File Share to Database
 *
 */
@Component
public class DataLoader {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	CloudFileShareHelper cloudFileShareHelper;

	@Autowired
	FullExtractBatchRepository fullExtractBatchRepository;

	@Autowired
	FullExtractProductRepository fullExtractProductRepository;

	@Autowired
	FullExtractProductAttributesRepository fullExtractProductAttributesRepository;

	@Autowired
	FullExtractProductPhasesRepository fullExtractProductPhasesRepository;

	@Autowired
	FullExtractProductVariantsRepository fullExtractProductVariantsRepository;

	@Autowired
	FullExtractProductVariantPacksRepository fullExtractProductVariantPacksRepository;

	public boolean loadData() {

		FullExtractBatch batch = new FullExtractBatch();

		try {

			CloudFile fullExtractFile = cloudFileShareHelper.getFullExtractFileFromFileShare();

			if (fullExtractFile != null) {

				logger.info("Loading Data and generating batch");
				batch = initiateDataLoad(fullExtractFile);

				List<ProductExtract> products = cloudFileShareHelper.getProductsFromFile(fullExtractFile);

				logger.info("Products to Load : {}", products.size());

				boolean status = loadProducts(batch.getBatchId(), products);

				stopDataLoad(batch, products.size(), status, null);

				cloudFileShareHelper.moveToArchive(fullExtractFile);

				return status;

			}

			return false;

		} catch (DataLoadFailureException dlfEx) {

			dlfEx.logErrorMessage();

			stopDataLoad(batch, null, false, dlfEx.getErrorMessage());

		} catch (CloudFileLoadException cflException) {

			cflException.logErrorMessage();

			stopDataLoad(batch, null, false, cflException.getErrorMessage());

		} catch (CloudFileReadException cfrException) {

			cfrException.logErrorMessage();

			stopDataLoad(batch, null, false, cfrException.getErrorMessage());

		}

		return false;

	}

	public boolean stopDataLoad(FullExtractBatch batch, Integer productCount, boolean loaded, String failureReason) {

		batch.setProductCount((productCount!=null)?BigInteger.valueOf(productCount):BigInteger.ZERO);


try {
		if (loaded) {

			batch.setFailureReason(null);
			batch.setEndTime(new Date());
			batch.setStatus(ProcessStatus.SUCCESS.name());
			batch.setDeleted(false);

		} else {
			batch.setFailureReason(failureReason);
			batch.setEndTime(new Date());
			batch.setStatus(ProcessStatus.FAILED.name());
			batch.setDeleted(false);

		}

		fullExtractBatchRepository.save(batch);
}catch(Exception e) {
	DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
	databaseConnectionFailureException.logErrorMessage();
	logger.error(Constants.DB_EXCEPTION , e);		
}
		return true;

	
	}
	

	public boolean loadProducts(BigInteger extractId, List<ProductExtract> products) throws DataLoadFailureException {

		List<FullExtractProduct> finalProducts = new ArrayList<>();
		List<FullExtractProductAttribute> finalAttributes = new ArrayList<>();
		List<FullExtractProductVariant> finalVariants = new ArrayList<>();
		List<FullExtractProductPhase> finalPhases = new ArrayList<>();
		List<FullExtractProductVariantPack> finalVariantPacks = new ArrayList<>();

		for (ProductExtract productExtract : products) {

			FullExtractProduct fullExtractProduct = getFullExtractProduct(extractId, productExtract);

			List<FullExtractProductAttribute> fullExtractProductAttributes = getFullExtractProductAttributes(extractId,
					productExtract);
			List<FullExtractProductPhase> fullExtractProductPhases = getFullExtractProductPhases(extractId,
					productExtract);
			List<FullExtractProductVariant> fullExtractProductVariants = getFullExtractProductVariants(extractId,
					productExtract);

			List<FullExtractProductVariantPack> fullExtractProductVariantPacks = getFullExtractProductVariantPacks(
					extractId, productExtract);

			finalProducts.add(fullExtractProduct);
			finalAttributes.addAll(fullExtractProductAttributes);
			finalVariants.addAll(fullExtractProductVariants);
			if (!fullExtractProductPhases.isEmpty()) {
				finalPhases.addAll(fullExtractProductPhases);
			}
			if (!fullExtractProductVariantPacks.isEmpty()) {
				finalVariantPacks.addAll(fullExtractProductVariantPacks);
			}

		}

		return save(finalProducts, finalAttributes, finalVariants, finalPhases, finalVariantPacks);

	}

	@Transactional
	private boolean save(List<FullExtractProduct> finalProducts, List<FullExtractProductAttribute> finalAttributes,
			List<FullExtractProductVariant> finalVariants, List<FullExtractProductPhase> finalPhases,
			List<FullExtractProductVariantPack> finalVariantPacks) throws DataLoadFailureException {

		try {
			try {
			logger.info("Loading Data into fullExtractProduct ");

			fullExtractProductRepository.saveAll(finalProducts);

			logger.info("Loading Data into fullExtractProductAttributes ");

			fullExtractProductAttributesRepository.saveAll(finalAttributes);

			logger.info("Loading Data into fullExtractProductPhases ");

			fullExtractProductPhasesRepository.saveAll(finalPhases);

			logger.info("Loading Data into fullExtractProductVariants ");

			fullExtractProductVariantsRepository.saveAll(finalVariants);

			logger.info("Loading Data into fullExtractProductVariantPacks ");

			fullExtractProductVariantPacksRepository.saveAll(finalVariantPacks);

			logger.info("Dataload completed ");

			return true;

		} catch (Exception e) {

			throw new DataLoadFailureException(e);
		}}catch(Exception e) {
			DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
			databaseConnectionFailureException.logErrorMessage();
			logger.error(Constants.DB_EXCEPTION , e);				
		}
		return false;
	}

	private List<FullExtractProductVariantPack> getFullExtractProductVariantPacks(BigInteger batchId,
			ProductExtract productExtract) {

		List<FullExtractProductVariantPack> allVariantPacks = new ArrayList<>();

		for (ProductExtractVariant variant : productExtract.getProductVariants()) {

			if (variant.getProductPacks() != null) {

				for (ProductExtractPack productExtractPack : variant.getProductPacks()) {

					FullExtractProductVariantPack fullExtractProductVariantPack = new FullExtractProductVariantPack();

					fullExtractProductVariantPack.setVariantId(variant.getVariantId());
					fullExtractProductVariantPack.setBatchId(batchId);
					fullExtractProductVariantPack.setProductId(productExtract.getProductId());
					fullExtractProductVariantPack.setSeasonName(productExtract.getSeasonName());
					fullExtractProductVariantPack.setDepth(productExtractPack.getPackVersion().get(0).getDepth());
					fullExtractProductVariantPack
							.setGrossWeight(productExtractPack.getPackVersion().get(0).getGrossWeight());
					fullExtractProductVariantPack.setHeight(productExtractPack.getPackVersion().get(0).getHeight());
					fullExtractProductVariantPack.setPackId(productExtractPack.getPackID());
					fullExtractProductVariantPack.setTradeItemFormat(productExtractPack.getTradeItemFormat());
					fullExtractProductVariantPack.setQuantityUnits(productExtractPack.getQuantityUnits());
					fullExtractProductVariantPack
							.setUnitsOfWeight(productExtractPack.getPackVersion().get(0).getUnitsOfWeight());
					fullExtractProductVariantPack
							.setUnitsOfDimension(productExtractPack.getPackVersion().get(0).getUnitsOfDimension());
					fullExtractProductVariantPack
							.setVersion(String.valueOf(productExtractPack.getPackVersion().get(0).getVersion()));
					fullExtractProductVariantPack.setWidth(productExtractPack.getPackVersion().get(0).getWidth());

					allVariantPacks.add(fullExtractProductVariantPack);
				}
			}

		}

		return allVariantPacks;

	}

	private List<FullExtractProductVariant> getFullExtractProductVariants(BigInteger batchId,
			ProductExtract productExtract) {

		List<FullExtractProductVariant> allVariants = new ArrayList<>();

		for (ProductExtractVariant variant : productExtract.getProductVariants()) {

			FullExtractProductVariant fullExtractProductVariant = new FullExtractProductVariant();

			fullExtractProductVariant.setBatchId(batchId);
			fullExtractProductVariant.setProductId(productExtract.getProductId());
			fullExtractProductVariant.setSeasonName(productExtract.getSeasonName());
			fullExtractProductVariant.setCategory(variant.getCategory());
			fullExtractProductVariant.setGtin(variant.getGtin());
			fullExtractProductVariant.setPrimarySizeDescription(variant.getPrimarySizeDescription());
			fullExtractProductVariant.setPrimarySizeIndex(variant.getPrimarySizeIndex());
			fullExtractProductVariant.setPrimarySizeRange(variant.getPrimarySizeRange());
			fullExtractProductVariant.setSecondarySizeDescription(variant.getSecondarySizeDescription());
			fullExtractProductVariant.setSecondarySizeIndex(variant.getSecondarySizeIndex());
			fullExtractProductVariant.setSecondarySizeRange(variant.getSecondarySizeRange());
			fullExtractProductVariant.setUpc(variant.getUpc());
			fullExtractProductVariant.setVariantId(variant.getVariantId());

			allVariants.add(fullExtractProductVariant);

		}
		return allVariants;
	}

	private List<FullExtractProductPhase> getFullExtractProductPhases(BigInteger batchId,
			ProductExtract productExtract) {

		List<FullExtractProductPhase> allPhases = new ArrayList<>();
		if (productExtract.getPhases() != null) {
			for (Phase phase : productExtract.getPhases()) {

				FullExtractProductPhase fullExtractProductPhase = new FullExtractProductPhase();

				fullExtractProductPhase.setBatchId(batchId);
				fullExtractProductPhase.setProductId(productExtract.getProductId());
				fullExtractProductPhase.setSeasonName(productExtract.getSeasonName());
				fullExtractProductPhase.setPhaseId(phase.getPhaseId());
				fullExtractProductPhase.setMappedStatus(phase.isMappedStatus());

				allPhases.add(fullExtractProductPhase);

			}
		}

		return allPhases;

	}

	private List<FullExtractProductAttribute> getFullExtractProductAttributes(BigInteger batchId,
			ProductExtract productExtract) {

		List<FullExtractProductAttribute> allAttributes = new ArrayList<>();

		for (Attribute attribute : productExtract.getSeasonalAttributes()) {

			FullExtractProductAttribute fullExtractProductAttribute = new FullExtractProductAttribute();

			fullExtractProductAttribute.setBatchId(batchId);
			fullExtractProductAttribute.setProductId(productExtract.getProductId());
			fullExtractProductAttribute.setSeasonName(productExtract.getSeasonName());
			fullExtractProductAttribute.setAttributeType(AttributeType.SEASONAL.name());
			fullExtractProductAttribute.setAttTypeDesc(attribute.getAttTypeDesc());
			fullExtractProductAttribute.setAttDesc(attribute.getAttDesc());

			allAttributes.add(fullExtractProductAttribute);
		}

		if (productExtract.getProductAttributes() != null && !productExtract.getProductAttributes().isEmpty()) {

			for (Attribute attribute : productExtract.getProductAttributes()) {

				FullExtractProductAttribute fullExtractProductAttribute = new FullExtractProductAttribute();

				fullExtractProductAttribute.setBatchId(batchId);
				fullExtractProductAttribute.setProductId(productExtract.getProductId());
				fullExtractProductAttribute.setSeasonName(productExtract.getSeasonName());
				fullExtractProductAttribute.setAttributeType(AttributeType.FLEXIBLE.name());
				fullExtractProductAttribute.setAttTypeDesc(attribute.getAttTypeDesc());
				fullExtractProductAttribute.setAttDesc(attribute.getAttDesc());

				allAttributes.add(fullExtractProductAttribute);
			}
		}

		return allAttributes;

	}

	private FullExtractProduct getFullExtractProduct(BigInteger batchId, ProductExtract productExtract) {

		FullExtractProduct fullExtractProduct = new FullExtractProduct();

		fullExtractProduct.setColourCode(productExtract.getColourCode());
		fullExtractProduct.setColourDescription(productExtract.getColourDescription());
		fullExtractProduct.setCreationstatus(productExtract.getCreationStatus());
		fullExtractProduct.setBatchId(batchId);
		fullExtractProduct.setHierarchyLevel(productExtract.getHierarchyLevel());
		fullExtractProduct.setHierarchyValue(productExtract.getHierarchyValue());
		fullExtractProduct.setLongDesc(productExtract.getLongDesc());
		fullExtractProduct.setProductCategory(productExtract.getProductCategory());
		fullExtractProduct.setProductId(productExtract.getProductId());
		fullExtractProduct.setSeasonName(productExtract.getSeasonName());
		fullExtractProduct.setSeasonYear(productExtract.getSeasonYear());
		fullExtractProduct.setStrokeNum(productExtract.getStrokeNum());
		fullExtractProduct.setTransitMode(productExtract.getTransitMode());
		fullExtractProduct.setShortDesc(productExtract.getShortDesc());
		fullExtractProduct.setTillDesc(productExtract.getTillDesc());
		
		if(productExtract.getTaxCode()!=null) {
		 fullExtractProduct.setTaxCode(productExtract.getTaxCode());
		}
		
		return fullExtractProduct;
	}

	private FullExtractBatch initiateDataLoad(CloudFile fullExtractFile) throws DataLoadFailureException {

		try {
try{
			BigInteger fileSize = BigInteger.valueOf(fullExtractFile.getProperties().getLength());

			String fileName = fullExtractFile.getName();

			FullExtractBatch fullExtractBatch = new FullExtractBatch();
			fullExtractBatch.setStartTime(new Date());
			fullExtractBatch.setExtractFileSize(fileSize);
			fullExtractBatch.setExtractFileName(fileName);
			fullExtractBatch.setStatus(ProcessStatus.INPROGRESS.name());
			fullExtractBatch.setDeleted(false);
			return fullExtractBatchRepository.save(fullExtractBatch);

		} catch (Exception e) {

			throw new DataLoadFailureException(e);
		}}catch(Exception e) {
			DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
			databaseConnectionFailureException.logErrorMessage();
			logger.error(Constants.DB_EXCEPTION , e);				
		}
		return null;

	}

}

package com.mns.partner.integration.extractor.processor;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.microsoft.azure.storage.file.CloudFile;
import com.mns.partner.integration.extractor.aop.LogExecutionTime;
import com.mns.partner.integration.extractor.constants.Constants;
import com.mns.partner.integration.extractor.constants.ProcessStatus;
import com.mns.partner.integration.extractor.dao.FullExtractBatch;
import com.mns.partner.integration.extractor.dao.FullExtractProduct;
import com.mns.partner.integration.extractor.dao.FullExtractProductAttribute;
import com.mns.partner.integration.extractor.dao.FullExtractProductVariant;
import com.mns.partner.integration.extractor.dao.FullExtractProductVariantPack;
import com.mns.partner.integration.extractor.dao.OutboundExtract;
import com.mns.partner.integration.extractor.dao.ProductExtractConfig;
import com.mns.partner.integration.extractor.dto.output.Product;
import com.mns.partner.integration.extractor.dto.pim.Attributes;
import com.mns.partner.integration.extractor.dto.pim.EnrichedProduct;
import com.mns.partner.integration.extractor.dto.response.OrderResponse;
import com.mns.partner.integration.extractor.exception.BatchNotFoundException;
import com.mns.partner.integration.extractor.exception.CloudFileUploadException;
import com.mns.partner.integration.extractor.exception.DatabaseConnectionFailureException;
import com.mns.partner.integration.extractor.helper.CloudFileShareHelper;
import com.mns.partner.integration.extractor.repository.FullExtractBatchRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductAttributesRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductPhasesRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductVariantPacksRepository;
import com.mns.partner.integration.extractor.repository.FullExtractProductVariantsRepository;
import com.mns.partner.integration.extractor.repository.OutboundExtractRepository;
import com.mns.partner.integration.extractor.repository.ProductExtractConfigRepository;
import com.mns.partner.integration.extractor.service.CnHMetaDataService;
import com.mns.partner.integration.extractor.service.EnrichedProductService;
import com.mns.partner.integration.extractor.service.IBTOrderingService;
import com.mns.partner.integration.extractor.util.Utils;

@Component
public class ExtractGenerator {

	@Autowired
	EnrichedProductService enrichedProductService;

	@Autowired
	IBTOrderingService ibtOrderingService;

	@Autowired
	CnHMetaDataService cnhMetaDataService;

	@Autowired
	OutputBuilder outputBuilder;

	@Autowired
	CloudFileShareHelper cloudFileShareHelper;

	@Autowired
	FullExtractBatchRepository fullExtractBatchRepository;

	@Autowired
	ProductExtractConfigRepository extractConfigRepository;

	@Autowired
	OutboundExtractRepository outboundExtractRepository;

	@Autowired
	FullExtractProductRepository fullExtractProductRepository;

	@Autowired
	FullExtractProductAttributesRepository fullExtractProductAttributesRepository;

	@Autowired
	FullExtractProductPhasesRepository fullExtractProductPhasesRepository;

	@Autowired
	FullExtractProductVariantsRepository fullExtractProductVariantsRepository;

	@Autowired
	FullExtractProductVariantPacksRepository fullExtractProductVariantPacksRepository;

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	public boolean startProcess() {

		try {
try {
			FullExtractBatch successfulBatch = fullExtractBatchRepository.findTopByStatusOrderByEndTimeDesc("SUCCESS");

			if (successfulBatch != null) {

				logger.info("Extract Selected {}", successfulBatch);

				startProcessUsingBatchId(successfulBatch.getBatchId());

			} else {

				throw new BatchNotFoundException();

			}

			return true;

		} catch (BatchNotFoundException bnfException) {

			bnfException.logErrorMessage();

		} catch (CloudFileUploadException cfuploadException) {

			cfuploadException.logErrorMessage();

		} catch (Exception e) {

			logger.error("Error while processing", e);
		}}catch(Exception e) {
			DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
			databaseConnectionFailureException.logErrorMessage();
			logger.error(Constants.DB_EXCEPTION , e);				
		}

		return false;
	}

	public void startProcessUsingBatchId(BigInteger batchId) throws CloudFileUploadException {
try {
		List<ProductExtractConfig> extractConfigs = extractConfigRepository
				.findByExtractTypeAndActiveFlag(Constants.PRODUCT_EXTRACT_TYPE, true);

		for (ProductExtractConfig extractConfig : extractConfigs) {

			OutboundExtract currentOutboundExtract = initialiseOutboundExtract(extractConfig.getExtractConfigId(),
					batchId);

			logger.info("Processing Extact: {}", extractConfig);

			List<String> seasons = cnhMetaDataService.getSeasons(extractConfig.getNoOfSeasonsBackward(),
					extractConfig.getNoOfSeasonsForward());

			generateOutputExtract(batchId, extractConfig, seasons, currentOutboundExtract);

			logger.info("Processing Extact Completed: {}", extractConfig);

		}
}catch(Exception e) {
	DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
	databaseConnectionFailureException.logErrorMessage();
	logger.error(Constants.DB_EXCEPTION , e);				
}
	}

	private OutboundExtract initialiseOutboundExtract(Integer extractConfigId, BigInteger batchId) {
try {
		OutboundExtract outboundExtract = new OutboundExtract();
		outboundExtract.setBatchId(batchId);
		outboundExtract.setExtractConfigId(extractConfigId);
		outboundExtract.setStartTime(new Date());
		outboundExtract.setStatus(ProcessStatus.INPROGRESS.name());

		return outboundExtractRepository.save(outboundExtract);

	}catch(Exception e) {
		DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
		databaseConnectionFailureException.logErrorMessage();
		logger.error(Constants.DB_EXCEPTION , e);				
	}
return null;
}

	public void generateOutputExtract(BigInteger extractId, ProductExtractConfig extractConfig,
			List<String> seasonNames, OutboundExtract currentOutboundExtract) throws CloudFileUploadException {

		List<FullExtractProduct> filteredProducts = new ArrayList<>();
		List<FullExtractProductAttribute> filteredProductAttributes = new ArrayList<>();
		List<FullExtractProductVariant> filteredProductVariants = new ArrayList<>();
		List<FullExtractProductVariantPack> filteredProductVariantPacks = new ArrayList<>();
		Map<String, Attributes> strokeAttributesMap = new HashMap<>();
		Map<String, Attributes> variantLevelMap = new HashMap<>();

		List<Integer> franchiseeNumbers = Utils.split(extractConfig.getFranchiseNumbers(), Constants.COMMA);

		List<Integer> orderStatusList = Utils.split(extractConfig.getOrderStatusGroup(), Constants.COMMA);

		List<OrderResponse> orderResponseList = ibtOrderingService.getProducts(franchiseeNumbers, seasonNames,
				orderStatusList);

		Map<String, Set<String>> finalSeasonProductsMap = new HashMap<>();
		Map<String, Set<String>> finalSeasonVariantsMap = new HashMap<>();

		getSeasonProductsMap(orderResponseList, finalSeasonProductsMap, finalSeasonVariantsMap);

		for (Map.Entry<String, Set<String>> seasonProducts : finalSeasonProductsMap.entrySet()) {

			filteredProducts.addAll(getFilteredProducts(extractId, seasonProducts.getKey(), seasonProducts.getValue()));
			filteredProductAttributes.addAll(
					getFilteredProductAttributes(extractId, seasonProducts.getKey(), seasonProducts.getValue()));
			filteredProductVariants.addAll(getFilteredProductVariants(extractId, seasonProducts.getKey(),
					seasonProducts.getValue(), finalSeasonVariantsMap.get(seasonProducts.getKey())));
			filteredProductVariantPacks.addAll(
					getFilteredProductVariantPacks(extractId, seasonProducts.getKey(), seasonProducts.getValue()));

		}

		Map<String, FullExtractProduct> filteredProductsMap = new HashMap<>();
		filteredProducts.forEach(x -> filteredProductsMap.put(x.getProductId() + "-" + x.getSeasonName(), x));

		Map<String, List<FullExtractProductAttribute>> filteredProductsAttributesMap = convertToAttributeMap(
				filteredProductAttributes);

		Map<String, List<FullExtractProductVariantPack>> filteredProductsVariantsPackMap = convertToMap(
				filteredProductVariantPacks);

		populateEnrichedProductServiceData(filteredProductsMap, strokeAttributesMap, variantLevelMap);

		Map<String, Product> outputDataMap = outputBuilder.buildData(filteredProductVariants,
				filteredProductsVariantsPackMap, filteredProductsAttributesMap, filteredProductsMap,
				strokeAttributesMap, variantLevelMap);

		try {

			if (!outputDataMap.isEmpty()) {

				CloudFile uploadedFile = cloudFileShareHelper.pushDataToAzureFileShare(
						new ArrayList<>(outputDataMap.values()), extractConfig.getFileNamePattern(),
						extractConfig.getDestinationPath());

				if (uploadedFile != null) {

					updateOutBoundExtractStatus(currentOutboundExtract, uploadedFile, outputDataMap.values().size());
				}

			} else {

				updateOutBoundExtractStatus(currentOutboundExtract, null, 0);

				logger.info("Nothing to push");
			}
		} catch (Exception e) {

			throw new CloudFileUploadException(e);
		}

	}

	private void updateOutBoundExtractStatus(OutboundExtract currentOutboundExtract, CloudFile uploadedFile,
			int count) {
try {
		if (uploadedFile != null) {

			currentOutboundExtract.setEndTime(new Date());
			currentOutboundExtract.setOutboundFileName(uploadedFile.getName());
			currentOutboundExtract.setOutboundFileSize(BigInteger.valueOf(uploadedFile.getProperties().getLength()));
			currentOutboundExtract.setProductCount(count);
			currentOutboundExtract.setStatus(ProcessStatus.SUCCESS.name());
			currentOutboundExtract.setOutboundFileUrl(uploadedFile.getUri().toString());

		} else {

			currentOutboundExtract.setEndTime(new Date());
			currentOutboundExtract.setOutboundFileName(null);
			currentOutboundExtract.setOutboundFileSize(null);
			currentOutboundExtract.setProductCount(0);
			currentOutboundExtract.setStatus(ProcessStatus.SUCCESS.name());
			currentOutboundExtract.setOutboundFileUrl(null);

		}
		outboundExtractRepository.save(currentOutboundExtract);
}catch(Exception e) {
	DatabaseConnectionFailureException databaseConnectionFailureException=new DatabaseConnectionFailureException(e);
	databaseConnectionFailureException.logErrorMessage();
	logger.error(Constants.DB_EXCEPTION , e);				
}
	}

	private void getSeasonProductsMap(List<OrderResponse> orderResponseList,
			Map<String, Set<String>> finalSeasonProductsMap, Map<String, Set<String>> finalSeasonVariantsMap) {

		for (OrderResponse orderResponse : orderResponseList) {

			for (Map.Entry<String, Map<String, Set<String>>> seasonProducts : orderResponse.getProductMap()
					.entrySet()) {

				if (finalSeasonProductsMap.containsKey(seasonProducts.getKey())) {

					finalSeasonProductsMap.get(seasonProducts.getKey())
							.addAll(new HashSet<>(seasonProducts.getValue().keySet()));

					Set<String> variants = new HashSet<>();

					seasonProducts.getValue().values().forEach(x -> variants.addAll(x));

					finalSeasonVariantsMap.get(seasonProducts.getKey()).addAll(variants);

				} else {

					finalSeasonProductsMap.put(seasonProducts.getKey(),
							new HashSet<>(seasonProducts.getValue().keySet()));

					Set<String> variants = new HashSet<>();

					seasonProducts.getValue().values().forEach(x -> variants.addAll(x));

					finalSeasonVariantsMap.put(seasonProducts.getKey(), variants);
				}

			}
		}

	}

	private Map<String, List<FullExtractProductVariantPack>> convertToMap(
			List<FullExtractProductVariantPack> filteredProductVariantPacks) {

		Map<String, List<FullExtractProductVariantPack>> filteredProductsVariantsPackMap = new HashMap<>();

		for (FullExtractProductVariantPack variantPack : filteredProductVariantPacks) {

			if (filteredProductsVariantsPackMap
					.containsKey(variantPack.getVariantId() + "-" + variantPack.getSeasonName())) {

				filteredProductsVariantsPackMap.get(variantPack.getVariantId() + "-" + variantPack.getSeasonName())
						.add(variantPack);

			} else {

				List<FullExtractProductVariantPack> tempList = new ArrayList<>();
				tempList.add(variantPack);
				filteredProductsVariantsPackMap.put(variantPack.getVariantId() + "-" + variantPack.getSeasonName(),
						tempList);
			}

		}

		return filteredProductsVariantsPackMap;
	}

	private Map<String, List<FullExtractProductAttribute>> convertToAttributeMap(
			List<FullExtractProductAttribute> filteredProductAttributes) {

		Map<String, List<FullExtractProductAttribute>> filteredProductsAttributesMap = new HashMap<>();

		for (FullExtractProductAttribute attributes : filteredProductAttributes) {

			if (filteredProductsAttributesMap
					.containsKey(attributes.getProductId() + "-" + attributes.getSeasonName())) {

				filteredProductsAttributesMap.get(attributes.getProductId() + "-" + attributes.getSeasonName())
						.add(attributes);

			} else {

				List<FullExtractProductAttribute> tempList = new ArrayList<>();
				tempList.add(attributes);
				filteredProductsAttributesMap.put(attributes.getProductId() + "-" + attributes.getSeasonName(),
						tempList);
			}

		}

		return filteredProductsAttributesMap;
	}

	public List<FullExtractProductVariantPack> getFilteredProductVariantPacks(BigInteger extractId, String seasonName,
			Set<String> products) {

		List<FullExtractProductVariantPack> extractedProductVariantPacks = fullExtractProductVariantPacksRepository
				.findByBatchIdAndSeasonName(extractId, seasonName);

		return extractedProductVariantPacks.stream().filter(x -> products.contains(x.getProductId()))
				.collect(Collectors.toList());

	}

	public List<FullExtractProductVariant> getFilteredProductVariants(BigInteger extractId, String seasonName,
			Set<String> products, Set<String> variantsSet) {

		List<FullExtractProductVariant> extractedProductVariants = fullExtractProductVariantsRepository
				.findByBatchIdAndSeasonName(extractId, seasonName);

		return extractedProductVariants.stream()
				.filter(x -> (products.contains(x.getProductId()) && variantsSet.contains(x.getVariantId())))
				.collect(Collectors.toList());

	}

	public List<FullExtractProductAttribute> getFilteredProductAttributes(BigInteger extractId, String seasonName,
			Set<String> products) {

		List<FullExtractProductAttribute> extractedProductAttributes = fullExtractProductAttributesRepository
				.findByBatchIdAndSeasonName(extractId, seasonName);

		return extractedProductAttributes.stream().filter(x -> products.contains(x.getProductId()))
				.collect(Collectors.toList());
	}

	public List<FullExtractProduct> getFilteredProducts(BigInteger extractId, String seasonName, Set<String> products) {

		List<FullExtractProduct> extractedProducts = fullExtractProductRepository.findByBatchIdAndSeasonName(extractId,
				seasonName);

		return extractedProducts.stream().filter(x -> products.contains(x.getProductId())).collect(Collectors.toList());

	}

	@LogExecutionTime
	public void populateEnrichedProductServiceData(Map<String, FullExtractProduct> filteredProductsMap,
			Map<String, Attributes> strokeAttributesMap, Map<String, Attributes> variantLevelMap) {

		for (Map.Entry<String, FullExtractProduct> entry : filteredProductsMap.entrySet()) {

			String key = entry.getValue().getHierarchyValue().substring(3, 6) + "-" + entry.getValue().getStrokeNum();

			if (!strokeAttributesMap.containsKey(key)) {

				List<EnrichedProduct> enrichedProductData = enrichedProductService.getEnrichedProductData(
						entry.getValue().getHierarchyValue().substring(3, 6), entry.getValue().getStrokeNum());

				if (enrichedProductData != null && !enrichedProductData.isEmpty()) {

					strokeAttributesMap.put(key, enrichedProductData.get(0).getAttributes());

					extractOnlineAttributesAtVariantLevel(enrichedProductData, variantLevelMap);
				}
			}

		}

	}

	private void extractOnlineAttributesAtVariantLevel(List<EnrichedProduct> enrichedProductData,
			Map<String, Attributes> variantLevelMap) {

		EnrichedProduct strokeLevelProduct = enrichedProductData.get(0);

		if (strokeLevelProduct.getChildren() != null) {

			for (EnrichedProduct colorLevelProduct : strokeLevelProduct.getChildren()) {

				if (colorLevelProduct.getChildren() != null) {

					for (EnrichedProduct sizeLevelProduct : colorLevelProduct.getChildren()) {

						String variantId = StringUtils.leftPad(sizeLevelProduct.getId(), 18, "0");
						variantLevelMap.put(variantId, sizeLevelProduct.getAttributes());

					}
				} else {

					// this is a single article, so colour level product has no children so pull the
					// attributes from color level

					String variantId = StringUtils.leftPad(colorLevelProduct.getId(), 18, "0");
					variantLevelMap.put(variantId, colorLevelProduct.getAttributes());

				}

			}
		}
	}

}


extractConfig.getDestinationPath()
 
 tblproductextractconfig
 
	@Column(name = "destinationpath")
	private String destinationPath;
 
/mnsitl-ipig-root-cate/b2boutbound/ocado/I3205_PARTNERGW_OCADO
 
/mnsitl-ipig-root-cate/b2boutbound/ocado/I3205_PARTNERGW_OCADO

/mnsitl-ipig-root-cate/b2boutbound/ocado/I3206_PARTNERGW_OCADO

/mnsitl-ipig-root-cate/b2boutbound/ocado/I3379_PARTNERGW_OCADO

/mnsitl-ipig-root-cate/b2boutbound/ocado/I3379_PARTNERGW_OCADO
 
1	Ocado Product Extract	1079,1084	1,2,3,4	PRODUCT-EXTRACT	0	1	CnH_Productextract_FullRefresh_V1	/mnsitl-ipig-root-cate/b2boutbound/ocado/I3205_PARTNERGW_OCADO	1
 
 

Differentitaite which path is used in cnh storage account and non cnh storage account

tabulate....which path is used cnh storage account and non cnh storage account

............................what is this.... think and plan  step by step and fix the issue