GetImpExProcessingPath.ds

Review the GetImpExProcessingPath.ds referenced script files when scheduling inventory imports.

This code is provided as a sample. It isn’t a supported part of the SiteGenesis application.

Note

1/**
2 * GetImpExProcessingPath.ds
3 * Get the import processing path.
4 *
5 * @input TaskDirectoryName   : String  Task directory name
6 * @input SiteID     : String  Site ID
7 * @input FileName   : String  File name
8 * @input ImpexRoot   : Boolean  Root directory is IMPEX [default: false]
9 * @input FileExtension   : String  Processing File Extension [.processing]
10 * @input sampleLogger    : Object  Sample logger
11 * @output ImpExProcessing  : dw.io.File Import/Export processing file
12 * @output ImpExProcessingPath : String  Import/Export processing file path
13 * @output sampleLogger   : Object  Debug output for Sample logger
14 * @output sampleError    : Object  Error output for Sample logger
15 */
16importPackage(dw.system);
17importPackage(dw.io);
18importPackage(dw.util);
19// Sample Logging ImportScript
20importScript("bc_sample:library/common/libContext.ds");
21importScript("bc_sample:library/utility/exception/libsampleException.ds");
22importScript("bc_sample:library/utility/logging/libLog.ds");
23function execute(pdict : PipelineDictionary) : Number {
24 // Sample Logging var
25 var _context : String = new Context("GetImpExProcessingPath.ds");
26 var _logger : Log = Log.getLogger(pdict);
27
28 // check for mandatory pipelet input parameters
29 if(empty(pdict.TaskDirectoryName) || empty(pdict.SiteID) || empty(pdict.FileName)) {
30
31  _logger.error(_context, "Mandatory pipelet input parameters are missing or null.");
32  return PIPELET_ERROR;
33 }
34
35 // get site id
36 var siteId : String = pdict.SiteID;
37
38 // processing file extension
39 var processingFileExtension : String = pdict.FileExtension;
40
41 // impex file path
42 var impexPath : String = File.IMPEX + File.SEPARATOR + 'src' + File.SEPARATOR;
43 // IMPEX is root directory
44 var impexRoot : Boolean = empty(pdict.ImpexRoot) || (pdict.ImpexRoot == false) ? false : true;
45 _logger.debug(_context,"Impex Root: " + impexRoot + " -- Impex Root Dictionary Value: "+pdict.ImpexRoot);
46
47 var rootPath : String = impexRoot ? impexPath  +  'datafeeds' : 'datafeeds';
48
49 // site specific impex base path
50 var impexBasePath : String = rootPath + File.SEPARATOR + siteId + File.SEPARATOR;
51 _logger.debug(_context,"UNA: " + impexBasePath);
52
53 // get import processing path
54 var impexProcessingPath : String = impexBasePath + pdict.TaskDirectoryName + File.SEPARATOR + 'processing' + File.SEPARATOR + pdict.FileName;
55 if(!empty(processingFileExtension)) {
56
57  impexProcessingPath += processingFileExtension;
58 }
59
60 _logger.debug(_context,"Processing Path: " + impexProcessingPath);
61
62 var filePath = impexPath + siteId + File.SEPARATOR + pdict.TaskDirectoryName + File.SEPARATOR + 'processing' + File.SEPARATOR + pdict.FileName;
63 _logger.debug(_context,"File Path: " + filePath);
64
65 try {
66
67  pdict.ImpExProcessing  = new File(filePath);
68  pdict.ImpExProcessingPath = impexProcessingPath;
69 }
70 catch(e) {
71  var exception : sampleException = new sampleException(_context, "Error occurred while creating ImpEx processing file", e);
72  pdict.sampleError = exception;
73  return PIPELET_ERROR;
74 }
75 return PIPELET_NEXT;
76}