Guest User

Untitled

a guest
Nov 24th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.33 KB | None | 0 0
  1. // -*-Mode: C++-*-
  2. // Copyright (c) 2003, 1997-2002 Ascential Software, Inc. All rights reserved.
  3. /*
  4. #######################################################################
  5. ##
  6. ## Maintenence log - insert most recent change descriptions at top
  7. ##
  8. ## Date Ecase# WHO Description.
  9. ## 05/04/05 73547 eaj Handle conversion failures better
  10. ## 04/29/05 73479 eaj Explicitly force std::llabs on linux
  11. ## 01/31/05 68170 xpu Redefine max() and min() on Linux.
  12. ## 07/22/04 30156 eaj Handle a hex value in APT_STRING_PADCHAR
  13. ## 03/15/04 none eaj Use osh option -string_fields for inserted
  14. ## field type
  15. ## 02/28/04 n/a xpu Moved declaration of operator+ out of
  16. ## the class.
  17. ## 01/26/04 linda Adding OS/390 support
  18. ## 01/21/04 43656 xpu Update output sort keys at run time.
  19. ## 11/21/03 n/a xpu Inserted spaces for indention.
  20. ## 09/26/03 39721 xpu Added a newline at the end of the file to
  21. ## avoid aCC 3.37 future fatal error 690.
  22. ## 09/04/03 39209 eaj NLS this fix since it came from 6.0
  23. ## 09/04/03 39209 eaj Added use of APT_STRING_PADCHAR for fixed
  24. ## length strings.
  25. ## 05/08/03 9607 xpu Removed setting dataset schemas
  26. ## 04/09/03 20305 eaj Added handling of + operator for ustring
  27. ## string mixes
  28. ## 04/09/03 20130 eaj Add handling of collation sequence option
  29. #######################################################################
  30. */
  31.  
  32. #include <apt_framework/orchestrate.h>
  33. #include <apt_framework/record.h>
  34. #include <apt_framework/interface.h>
  35. #include <apt_framework/type/descriptor.h>
  36. #include <apt_framework/type/conversion.h>
  37. #include <apt_framework/tfmop_functions.h>
  38. #include <apt_util/env_flag.h>
  39. #include <apt_util/unicode_utils.h>
  40. #include <apt_util/converter_registry.h>
  41. #include <apt_util/lookuptable.h>
  42. #include <apt_util/lookupops.h>
  43. #include <math.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46. #include <map>
  47.  
  48. #if defined(__SUN__)
  49. #include <sys/ddi.h>
  50. #endif
  51.  
  52. // user-defined function header file
  53. #include "V52S0_TX_CISM_CI_REG_DATA_TF_Convert_user.h"
  54.  
  55. #if defined(__AIX__)
  56. #define max __maxi64
  57. #define min __mini64
  58. #endif
  59.  
  60. #if defined(__OSF1__)
  61. #define llabs labs
  62. #endif
  63.  
  64. // Work around suse compiler issue with llabs, force the std package
  65. #if defined(__LINUX__)
  66. #define llabs std::llabs
  67. #endif
  68.  
  69. #if defined(__OS390__) || defined(__LINUX__)
  70. #ifdef min
  71. #undef min
  72. #endif /* min */
  73. #define min(a, b) ((a) < (b) ? (a) : (b))
  74.  
  75. #ifdef max
  76. #undef max
  77. #endif /* max */
  78. #define max(a, b) ((a) < (b) ? (b) : (a))
  79. #endif
  80.  
  81.  
  82. #define TRX_DEFAULT_MAX_PRECISION 38
  83. #define TRX_DEFAULT_MAX_SCALE 10
  84. #define TRX_DEFAULT_CACHE_SIZE 2
  85.  
  86. typedef APT_STD::less<APT_String> lessAPTStr;
  87.  
  88. static APT_EnvironmentFlag sPrecision("APT_DECIMAL_INTERM_PRECISION");
  89. static APT_EnvironmentFlag sScale("APT_DECIMAL_INTERM_SCALE");
  90. static APT_EnvironmentFlag sRecordCacheSize("APT_TRANSFORM_RECORD_CACHE_SIZE");
  91.  
  92. static APT_EnvironmentFlag sStringPadChar("APT_STRING_PADCHAR");
  93. static UChar sPadChar = 0;
  94.  
  95. static int processPadCharEnv()
  96. {
  97. if (sStringPadChar)
  98. {
  99. APT_UString pc = sStringPadChar.UvalueStrHandleHex();
  100. if (pc.length() == 1)
  101. sPadChar = pc.data()[0];
  102. }
  103.  
  104. return 0;
  105. }
  106. static int sDummy = processPadCharEnv();
  107.  
  108. // Allow for addition of mixed strings and ustrings
  109. APT_UString operator+ (const APT_UString&, const APT_String&);
  110. APT_UString operator+ (const APT_String&, const APT_UString&);
  111.  
  112. class APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert: public APT_CombinableOperator
  113. {
  114. public:
  115. APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert();
  116. ~APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert();
  117.  
  118. protected:
  119. virtual APT_Status initializeFromArgs_(const APT_PropertyList &args,
  120. InitializeContext context);
  121. virtual APT_Status describeOperator();
  122. virtual APT_Status preRun();
  123. virtual APT_Status doInitialProcessing();
  124. virtual APT_PropertyList modifyOutputSortKeys(const APT_TransferAdapter& tAdapt,
  125. APT_Int32 outDs);
  126. virtual void processInputRecord(int inputDS);
  127. virtual void processRejectRecord(const APT_UString &errMsg,
  128. const APT_UString &warningMsg,
  129. int rejectDs);
  130. virtual APT_Status doFinalProcessing();
  131. virtual APT_Status writeOutputRecord();
  132. virtual void processEOF(int inputDS);
  133. virtual void postRun(APT_Status stepStatus);
  134. virtual APT_Status resetForNextUnit();
  135.  
  136. // Lookup related methods
  137. APT_Status addTable(const APT_UString& fsetName, TableType tableType);
  138.  
  139. // Write an output record, handles caching of multiple calls to writerecord
  140. void writeRecord(int outds);
  141.  
  142. // Issue warning of failure of a conversion routine
  143. APT_Status issueConversionWarning(const APT_String& msg,
  144. const APT_String& noMoreWarnings);
  145.  
  146. private:
  147. // internal macros, required for persistence mechanism
  148. APT_DECLARE_RTTI(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
  149. APT_DECLARE_PERSISTENT(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
  150.  
  151. // input accessors
  152. APT_InputAccessorToDecimal input0DecimalDAY_START_OFFSET;
  153. APT_InputAccessorToString input0StringRETAIL_SUP_POINT,input0StringREG_DS_TYPE_FLG;
  154. APT_InputAccessorToTimeStamp input0TimeStampREG_DATA_START_DTTM,input0TimeStampREG_DATA_END_DTTM;
  155.  
  156.  
  157. // output accessors
  158. APT_OutputAccessorToInt8 output1Int8FULL_DAY_FLAG;
  159. APT_OutputAccessorToString output0StringCIS_LEG_ID,output1StringCIS_LEG_ID;
  160. APT_OutputAccessorToTimeStamp output0TimeStampSET_DTTM,output1TimeStampSET_DTTM;
  161.  
  162.  
  163. // array containing the order in which inputs are transferred.
  164. int tranOrder[2];
  165.  
  166. // transfer index
  167. int tranIndex;
  168. int precision;
  169. int scale;
  170.  
  171. // declare stage (global) variables.
  172. APT_Int8 stage0RowRejected0;
  173. APT_Int8 stage0NullSetVar0;
  174. APT_String stage0InterVar0_2;
  175. APT_String stage0InterVar0_3;
  176. APT_String stage0InterVar0_5;
  177. APT_String stage0InterVar0_6;
  178. APT_String stage0InterVar0_7;
  179. APT_String stage0StageVar0_svTypeFlag;
  180. APT_Date stage0StageVar0_svDate;
  181. APT_Time stage0StageVar0_svTime;
  182. APT_Date stage0StageVar0_svAdjustedDate;
  183. APT_Int32 stage0StageVar0_svSecond;
  184. APT_TimeStamp stage0StageVar0_svTimestamp;
  185. APT_Int8 stage0StageVar0_svFullDay;
  186. APT_String stage0StageVar0_svBreakSHIT;
  187. APT_FieldConversion* pConv[10];
  188.  
  189.  
  190. // buffer used for default conversions.
  191. char convBuf[32];
  192. char* pBuf;
  193. UChar* pUCharBuf;
  194.  
  195. // data members for creating custom report
  196. APT_STD::vector<APT_CustomReportInfo> customReport;
  197. APT_STD::vector<APT_CustomReportInfo> customInstanceReport;
  198.  
  199. // Reject processing information
  200. int maxRejectLogs;
  201. int rejectLogCount;
  202. APT_UString rejectColumn;
  203.  
  204. // a copy of the args passed to initializeFromArgs
  205. APT_PropertyList stashedArgs;
  206.  
  207. // Lookup related members
  208.  
  209. };
  210.  
  211. APT_IMPLEMENT_RTTI_ONEBASE(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert, APT_CombinableOperator);
  212. APT_IMPLEMENT_PERSISTENT(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
  213.  
  214. // register operator and argument list with OSH
  215. #define ARG_DESC \
  216. "{ " \
  217. " otherInfo={ " \
  218. " inputs={ " \
  219. " input={ description='input data set', " \
  220. " multiple " \
  221. " } " \
  222. " }, " \
  223. " outputs={ " \
  224. " output={ " \
  225. " description='output data set', " \
  226. " multiple " \
  227. " }, " \
  228. " reject={ " \
  229. " description='reject data set', " \
  230. " any, " \
  231. " constraints={argcount= reject} " \
  232. " } " \
  233. " }, " \
  234. " description='Sub-Level Transform operator:' " \
  235. " } " \
  236. "} "
  237.  
  238. APT_DEFINE_OSH_NAME(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert, V52S0_TX_CISM_CI_REG_DATA_TF_Convert, ARG_DESC);
  239.  
  240. APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert()
  241. : pBuf(0), pUCharBuf(0), maxRejectLogs(50), rejectLogCount(0), tranIndex(0),
  242. precision(sPrecision.valueStr().asInteger(TRX_DEFAULT_MAX_PRECISION)),
  243. scale(sScale.valueStr().asInteger(TRX_DEFAULT_MAX_SCALE))
  244. {
  245. // initialize stage (global) variables.
  246. stage0RowRejected0 = 0;
  247. stage0NullSetVar0 = 0;
  248. stage0StageVar0_svSecond = 0;
  249. stage0StageVar0_svFullDay = 0;
  250.  
  251. }
  252.  
  253. APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::~APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert()
  254. {
  255. }
  256.  
  257. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::serialize(APT_Archive& ar, APT_UInt8)
  258. {
  259. // serialize job parameters and lookup table info
  260.  
  261. }
  262.  
  263. // initialize operator from arguments
  264. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::initializeFromArgs_(const APT_PropertyList &args,
  265. InitializeContext context)
  266. {
  267. APT_Status status = APT_StatusOk;
  268. APT_Status colStatus = APT_StatusOk;
  269.  
  270. // save the arg list to be used in describeOperator
  271. stashedArgs = args;
  272.  
  273. // create lookup table array
  274.  
  275.  
  276. int nprops = args.count();
  277. for (int i = 0; i < nprops; i++)
  278. {
  279. const APT_Property& prop = args[i];
  280.  
  281. if (prop.name() == (APT_UString)"maxrejectlogs" )
  282. {
  283. maxRejectLogs = prop.valueList().getProperty(APT_UString("value")).valueInt64();
  284. }
  285. else if ( prop.name() == APT_UString("reject") )
  286. {
  287. if (prop.kind() == APT_Property::eEmpty)
  288. continue;
  289.  
  290. const APT_PropertyList& reject = prop.valueList();
  291.  
  292. // Set compilation options.
  293. if (reject.hasProperty(APT_UString("subArgs")))
  294. {
  295. const APT_PropertyList& subArgs = reject.getProperty(APT_UString("subArgs")).valueList( );
  296. for (int j = 0 ; j < subArgs.count() ; j++)
  297. {
  298. const APT_Property& subProp = subArgs[j];
  299.  
  300. if (subProp.name() == APT_UString("rejectinfo"))
  301. {
  302. rejectColumn = subProp.valueList().getProperty(APT_UString("value")).valueUString();
  303. }
  304. }
  305. }
  306. }
  307. else if (prop.name() == (APT_UString)"diablesharing" )
  308. {
  309. // mark the disable sharing flag
  310.  
  311. }
  312. else if (prop.name() == (APT_UString)"fileset")
  313. {
  314. if (context != APT_Operator::eInitial)
  315. continue;
  316.  
  317. APT_UString fname =
  318. prop.valueList().getProperty((APT_UString)"value").valueUString();
  319.  
  320. APT_FileSet fs;
  321. APT_ParseError err;
  322. fs.parseFile(fname, &err);
  323. if (err.errorOccurred())
  324. {
  325. status = APT_StatusFailed;
  326. continue;
  327. }
  328.  
  329. addTable(fname, eStatic);
  330. }
  331. else if (prop.name() == (APT_UString)"table")
  332. {
  333. if (context != APT_Operator::eInitial)
  334. continue;
  335.  
  336. APT_UString filesetname;
  337. filesetname = prop.valueList().getProperty((APT_UString)"filesetname").valueUString();
  338.  
  339. addTable(filesetname, eDynamic);
  340. }
  341. else if (updateCollationSeqFromProperty(prop, colStatus))
  342. {
  343. // We found a collation property make sure everything went ok
  344. if (colStatus == APT_StatusFailed)
  345. {
  346. status = APT_StatusFailed;
  347. }
  348. }
  349. }
  350.  
  351. return status;
  352. }
  353.  
  354. // initialize operator before serialization and parallel distribution.
  355. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::describeOperator()
  356. {
  357. // set number of inputs/outputs.
  358. setInputDataSets(1);
  359. setOutputDataSets(2);
  360.  
  361. // set input interface schema.
  362. APT_Schema* inputSchema=new APT_Schema[1];
  363. inputSchema[0]=APT_Schema(APT_ConvertFromString("record\n( FILE_ID: int32;\n SOURCE_SYSTEM_CODE: string[max=10];\n ROW_NUMBER: int32;\n RETAIL_SUP_POINT: string[max=10];\n REG_TYPE: string[3];\n REG_DATA_START_DTTM: timestamp;\n REG_DATA_END_DTTM: timestamp;\n REG_DS_TYPE_FLG: string[4];\n INTV_REG_DATA: decimal[18,7];\n DATA_QUALITY: nullable string[max=1];\n DAY_START_OFFSET: decimal[4,0];\n APT_TRinput0Rec0: *;\n APT_TRinput0Rec1: *;\n)"));
  364. APT_Schema droppedFds;
  365. int inSchema_i;
  366. for (inSchema_i=0;inSchema_i<viewAdaptedSchema(0).numFields(); inSchema_i++)
  367. {
  368. APT_SchemaField thisFd;
  369. thisFd = viewAdaptedSchema(0).field(inSchema_i);
  370. if(inputSchema[0].hasField_byId(thisFd.ident()))
  371. continue;
  372. else{
  373. droppedFds.addField(thisFd);
  374. }
  375. }
  376. int INPUT;
  377. for(INPUT=0;INPUT<1;INPUT++)
  378. setInputInterfaceSchema(inputSchema[INPUT],INPUT);
  379. delete [] inputSchema;
  380.  
  381.  
  382. // set output interface schema.
  383. APT_Schema* outputSchema=new APT_Schema[2];
  384. outputSchema[0]=APT_Schema(APT_ConvertFromString("record\n( CIS_LEG_ID: string[10];\n SET_DTTM: timestamp;\n APT_TRoutput0Rec0: *;\n)"));
  385. outputSchema[1]=APT_Schema(APT_ConvertFromString("record\n( CIS_LEG_ID: string[10];\n SET_DTTM: timestamp;\n FULL_DAY_FLAG: int8;\n APT_TRoutput1Rec0: *;\n)"));
  386. int OUTPUT;
  387. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  388. setOutputInterfaceSchema(outputSchema[OUTPUT],OUTPUT);
  389. delete [] outputSchema;
  390.  
  391.  
  392. // set view/modify adapter.
  393.  
  394.  
  395. // set transfer adapter.
  396. APT_TransferAdapter inTransAdapt0;
  397. APT_UString* dropped=new APT_UString[2];
  398. dropped[0]=APT_ConvertFromString("RETAIL_SUP_POINT,REG_DATA_START_DTTM,DAY_START_OFFSET");
  399. dropped[1]=APT_ConvertFromString("FILE_ID,SOURCE_SYSTEM_CODE,ROW_NUMBER,RETAIL_SUP_POINT,REG_DATA_START_DTTM,INTV_REG_DATA,DATA_QUALITY,DAY_START_OFFSET");
  400. if(droppedFds.numFields()>0)
  401. {
  402. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  403. {
  404. sprintf(convBuf,"APT_TRinput0Rec%d",OUTPUT);
  405. APT_UString schVarName = (APT_UString)convBuf;
  406. for (inSchema_i=0;inSchema_i<droppedFds.numFields(); inSchema_i++)
  407. inTransAdapt0.dropFromVar(schVarName,droppedFds.field(inSchema_i).Uidentifier());
  408. }
  409. }
  410. APT_UString* renamedFrom=new APT_UString[2];
  411. APT_UString* renamedTo=new APT_UString[2];
  412. renamedFrom[0]=APT_ConvertFromString("REG_DATA_END_DTTM,REG_TYPE");
  413. renamedTo[0]=APT_ConvertFromString("REG_DATA_DTTM,CIS_LEG_TYPE");
  414. renamedFrom[1]=APT_ConvertFromString("REG_DATA_END_DTTM,REG_TYPE");
  415. renamedTo[1]=APT_ConvertFromString("REG_DATA_DTTM,CIS_LEG_TYPE");
  416. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  417. {
  418. sprintf(convBuf,"APT_TRinput0Rec%d",OUTPUT);
  419. APT_UString schVarName = (APT_UString)convBuf;
  420. inTransAdapt0.setVarMode(schVarName, APT_TransferAdapter::eAll);
  421. if(!dropped[OUTPUT].isEmpty())
  422. inTransAdapt0.dropFromVarMulti(schVarName,dropped[OUTPUT]);
  423. if(!renamedFrom[OUTPUT].isEmpty()&&!renamedTo[OUTPUT].isEmpty())
  424. inTransAdapt0.renameFieldsInVar(schVarName,renamedFrom[OUTPUT],renamedTo[OUTPUT]);
  425. }
  426. setTransferAdapter(inTransAdapt0,0);
  427. delete [] dropped;
  428. delete [] renamedFrom;
  429. delete [] renamedTo;
  430.  
  431.  
  432. // declare transfer.
  433. for(INPUT=0;INPUT<1;INPUT++)
  434. {
  435. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  436. {
  437. sprintf(convBuf,"APT_TRinput%dRec%d",INPUT,OUTPUT);
  438. APT_UString inSchVarName = (APT_UString)convBuf;
  439. sprintf(convBuf,"APT_TRoutput%dRec%d",OUTPUT,INPUT);
  440. APT_UString outSchVarName = (APT_UString)convBuf;
  441. declareTransfer(inSchVarName,outSchVarName,INPUT,OUTPUT);
  442. }
  443. }
  444.  
  445.  
  446. // set partitioner/sort insertion information.
  447. if(getInputSortKeys(0).count())
  448. {
  449. int i;
  450. for(i=0;i<2;i++)
  451. setOutputSortKeys(modifyOutputSortKeys(inTransAdapt0,i),i);
  452. }
  453.  
  454.  
  455. // set job parameters
  456.  
  457.  
  458. // Setup lookup table functionality
  459.  
  460.  
  461. setWorkingDirectory(false);
  462. return APT_StatusOk;
  463. }
  464.  
  465. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::preRun()
  466. {
  467. // read dynamic lookup table filesets
  468.  
  469.  
  470. return APT_StatusOk;
  471. }
  472.  
  473. // parallel method, invoked in each partition.
  474. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::doInitialProcessing()
  475. {
  476. APT_Status convStat = APT_StatusOk;
  477.  
  478. // declare local variable
  479. APT_String localVar120;
  480. stage0StageVar0_svTypeFlag.setPadChar((char)sPadChar);
  481. stage0StageVar0_svTypeFlag.setFixedLength(1);
  482. pConv[0]=APT_FieldConversionRegistry::get().lookupAndParse("date_from_string[%yyyy-%mm-%dd]", NULL);
  483. pConv[3]=APT_FieldConversionRegistry::get().lookupAndParse("date_from_timestamp", NULL);
  484. pConv[9]=APT_FieldConversionRegistry::get().lookupAndParse("hours_from_time", NULL);
  485. pConv[5]=APT_FieldConversionRegistry::get().lookupAndParse("minutes_from_time", NULL);
  486. pConv[8]=APT_FieldConversionRegistry::get().lookupAndParse("month_day_from_date", NULL);
  487. pConv[7]=APT_FieldConversionRegistry::get().lookupAndParse("month_from_date", NULL);
  488. pConv[1]=APT_FieldConversionRegistry::get().lookupAndParse("time_from_string[%hh:%nn:%ss]", NULL);
  489. pConv[4]=APT_FieldConversionRegistry::get().lookupAndParse("time_from_timestamp", NULL);
  490. pConv[2]=APT_FieldConversionRegistry::get().lookupAndParse("timestamp_from_string[%yyyy-%mm-%dd %hh:%nn:%ss]", NULL);
  491. pConv[6]=APT_FieldConversionRegistry::get().lookupAndParse("year_from_date", NULL);
  492.  
  493.  
  494. // "initialize" code segment
  495. stage0InterVar0_2="A";
  496. stage0InterVar0_3="S";
  497. stage0InterVar0_5="00:00:00";
  498. stage0InterVar0_6="%hh:%nn:%ss";
  499. stage0InterVar0_7="2";
  500. stage0StageVar0_svTypeFlag="";
  501. localVar120="2001-01-01";
  502. convStat = pConv[0]->convert((void*)&localVar120, (void*)&stage0StageVar0_svDate, 0);
  503. if (convStat != APT_StatusOk)
  504. issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
  505. localVar120="00:00:01";
  506. convStat = pConv[1]->convert((void*)&localVar120, (void*)&stage0StageVar0_svTime, 0);
  507. if (convStat != APT_StatusOk)
  508. issueConversionWarning("Conversion error calling conversion routine time_from_string data may have been lost","No more conversion warnings will be issued");
  509. localVar120="2001-01-01";
  510. convStat = pConv[0]->convert((void*)&localVar120, (void*)&stage0StageVar0_svAdjustedDate, 0);
  511. if (convStat != APT_StatusOk)
  512. issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
  513. stage0StageVar0_svSecond=0;
  514. localVar120="2001-01-01 00:00:01";
  515. convStat = pConv[2]->convert((void*)&localVar120, (void*)&stage0StageVar0_svTimestamp, 0);
  516. if (convStat != APT_StatusOk)
  517. issueConversionWarning("Conversion error calling conversion routine timestamp_from_string data may have been lost","No more conversion warnings will be issued");
  518. stage0StageVar0_svFullDay=0;
  519. stage0StageVar0_svBreakSHIT="";
  520.  
  521.  
  522. // load and attach static tables
  523.  
  524.  
  525. // set up input accessor.
  526. APT_InputAccessorInterface** inCur=new APT_InputAccessorInterface*[1];
  527. int INPUT;
  528. for(INPUT=0;INPUT<1;INPUT++)
  529. inCur[INPUT]=inputAccessorInterface(INPUT);
  530. APT_STD::map<APT_String, APT_InputAccessorBase*>* inAcc=new APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>[1];
  531. inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("RETAIL_SUP_POINT", &input0StringRETAIL_SUP_POINT));
  532. inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DATA_START_DTTM", &input0TimeStampREG_DATA_START_DTTM));
  533. inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DATA_END_DTTM", &input0TimeStampREG_DATA_END_DTTM));
  534. inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DS_TYPE_FLG", &input0StringREG_DS_TYPE_FLG));
  535. inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("DAY_START_OFFSET", &input0DecimalDAY_START_OFFSET));
  536. for(INPUT=0;INPUT<1;INPUT++)
  537. {
  538. APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::iterator iter;
  539. for(iter = inAcc[INPUT].begin();iter!=inAcc[INPUT].end(); iter++)
  540. inCur[INPUT]->setupAccessor(APT_ConvertFromString(iter->first),iter->second);
  541. }
  542. delete [] inCur;
  543. delete [] inAcc;
  544.  
  545.  
  546. // set up output accessor.
  547. APT_OutputAccessorInterface** outCur=new APT_OutputAccessorInterface*[2];
  548. int OUTPUT;
  549. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  550. outCur[OUTPUT]=outputCursor(OUTPUT);
  551. APT_STD::map<APT_String, APT_OutputAccessorBase*>* outAcc=new APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>[2];
  552. outAcc[0].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("CIS_LEG_ID", &output0StringCIS_LEG_ID));
  553. outAcc[0].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("SET_DTTM", &output0TimeStampSET_DTTM));
  554. outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("CIS_LEG_ID", &output1StringCIS_LEG_ID));
  555. outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("SET_DTTM", &output1TimeStampSET_DTTM));
  556. outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("FULL_DAY_FLAG", &output1Int8FULL_DAY_FLAG));
  557. for(OUTPUT=0;OUTPUT<2;OUTPUT++)
  558. {
  559. APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::iterator iter;
  560. for(iter = outAcc[OUTPUT].begin();iter!=outAcc[OUTPUT].end(); iter++)
  561. outCur[OUTPUT]->setupAccessor(APT_ConvertFromString(iter->first),iter->second);
  562. }
  563. delete [] outCur;
  564. delete [] outAcc;
  565.  
  566.  
  567. // order in which inputs are transferred
  568.  
  569.  
  570. // set the first active input
  571. setActiveInput( 0);
  572.  
  573.  
  574. // send custom report.
  575. sendCustomReport(customReport);
  576.  
  577. return APT_StatusOk;
  578. }
  579.  
  580. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processInputRecord(int inputDS)
  581. {
  582. APT_Status convStat = APT_StatusOk;
  583.  
  584. // handle dyamic tables
  585.  
  586.  
  587. // declare local variable
  588. APT_Int32 local0InterVar0_0;
  589. APT_String local0InterVar0_1;
  590. APT_Int32 local0InterVar0_4;
  591. APT_String localVar360;
  592. APT_Decimal localVar460(precision,scale);
  593. APT_Int8 localVar460_new;
  594. APT_Decimal localVar490(precision,scale);
  595. APT_Int16 localVar520;
  596. APT_Int8 localVar560;
  597. APT_Int8 localVar580;
  598. APT_Time localVar930;
  599. APT_Time localVar960;
  600.  
  601.  
  602. // Init the interface array indexes
  603.  
  604.  
  605. // process records.
  606. stage0RowRejected0=1;
  607. localVar360 =input0StringREG_DS_TYPE_FLG[0];
  608. localVar360.trimPadding(' ',APT_String::eBeginning);
  609. localVar360.trimPadding(' ',APT_String::eEnd);
  610. localVar360.compactPadding(' ');
  611. if(localVar360.occurrences(' '))
  612. {
  613. localVar360.trimPadding(' ',APT_String::eBeginning);
  614. localVar360.trimPadding(' ',APT_String::eEnd);
  615. localVar360.compactPadding(' ');
  616. }
  617. stage0StageVar0_svTypeFlag=localVar360;
  618. convStat = pConv[3]->convert((void*)&input0TimeStampREG_DATA_START_DTTM[0], (void*)&stage0StageVar0_svDate, 0);
  619. if (convStat != APT_StatusOk)
  620. issueConversionWarning("Conversion error calling conversion routine date_from_timestamp data may have been lost","No more conversion warnings will be issued");
  621. convStat = pConv[4]->convert((void*)&input0TimeStampREG_DATA_START_DTTM[0], (void*)&stage0StageVar0_svTime, 0);
  622. if (convStat != APT_StatusOk)
  623. issueConversionWarning("Conversion error calling conversion routine time_from_timestamp data may have been lost","No more conversion warnings will be issued");
  624. convStat = pConv[5]->convert((void*)&stage0StageVar0_svTime, (void*)&localVar460_new, 0);
  625. if (convStat != APT_StatusOk)
  626. issueConversionWarning("Conversion error calling conversion routine minutes_from_time data may have been lost","No more conversion warnings will be issued");
  627. localVar460.assignFromInt32(localVar460_new);
  628. localVar490=localVar460-input0DecimalDAY_START_OFFSET[0];
  629. local0InterVar0_0=localVar490.asInteger();
  630. convStat = pConv[6]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar520, 0);
  631. if (convStat != APT_StatusOk)
  632. issueConversionWarning("Conversion error calling conversion routine year_from_date data may have been lost","No more conversion warnings will be issued");
  633. convStat = pConv[7]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar460_new, 0);
  634. if (convStat != APT_StatusOk)
  635. issueConversionWarning("Conversion error calling conversion routine month_from_date data may have been lost","No more conversion warnings will be issued");
  636. convStat = pConv[8]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar560, 0);
  637. if (convStat != APT_StatusOk)
  638. issueConversionWarning("Conversion error calling conversion routine month_day_from_date data may have been lost","No more conversion warnings will be issued");
  639. convStat = pConv[9]->convert((void*)&stage0StageVar0_svTime, (void*)&localVar580, 0);
  640. if (convStat != APT_StatusOk)
  641. issueConversionWarning("Conversion error calling conversion routine hours_from_time data may have been lost","No more conversion warnings will be issued");
  642. local0InterVar0_1=
  643. pxNormaliseDate(localVar520,localVar460_new,localVar560,localVar580,local0InterVar0_0,0);
  644. localVar360=((1>=1)?local0InterVar0_1.substring(1-1,10):APT_String(""));
  645. convStat = pConv[0]->convert((void*)&localVar360, (void*)&stage0StageVar0_svAdjustedDate, 0);
  646. if (convStat != APT_StatusOk)
  647. issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
  648. if(stage0StageVar0_svTypeFlag==stage0InterVar0_2)
  649. {
  650. stage0StageVar0_svSecond=8;
  651. }
  652. else
  653. {
  654. if(stage0StageVar0_svTypeFlag==stage0InterVar0_3)
  655. {
  656. stage0StageVar0_svSecond=10;
  657. }
  658. else
  659. {
  660. stage0StageVar0_svSecond=12;
  661. }
  662. }
  663. convStat = pConv[7]->convert((void*)&stage0StageVar0_svAdjustedDate, (void*)&localVar460_new, 0);
  664. if (convStat != APT_StatusOk)
  665. issueConversionWarning("Conversion error calling conversion routine month_from_date data may have been lost","No more conversion warnings will be issued");
  666. local0InterVar0_0=localVar460_new+1;
  667. local0InterVar0_4=input0DecimalDAY_START_OFFSET[0].asInteger();
  668. convStat = pConv[6]->convert((void*)&stage0StageVar0_svAdjustedDate, (void*)&localVar520, 0);
  669. if (convStat != APT_StatusOk)
  670. issueConversionWarning("Conversion error calling conversion routine year_from_date data may have been lost","No more conversion warnings will be issued");
  671. local0InterVar0_1=pxNormaliseDate(localVar520,local0InterVar0_0,1,0,local0InterVar0_4,stage0StageVar0_svSecond);
  672. convStat = pConv[2]->convert((void*)&local0InterVar0_1, (void*)&stage0StageVar0_svTimestamp, 0);
  673. if (convStat != APT_StatusOk)
  674. issueConversionWarning("Conversion error calling conversion routine timestamp_from_string data may have been lost","No more conversion warnings will be issued");
  675. convStat = pConv[4]->convert((void*)&input0TimeStampREG_DATA_END_DTTM[0], (void*)&localVar930, 0);
  676. if (convStat != APT_StatusOk)
  677. issueConversionWarning("Conversion error calling conversion routine time_from_timestamp data may have been lost","No more conversion warnings will be issued");
  678. localVar360 = (APT_String)"time_from_string[" + (APT_String)stage0InterVar0_6 + (APT_String)"]";
  679. convStat = APT_TOFunctions::get().convertWithParams(&stage0InterVar0_5,localVar360, (void*)&localVar960);
  680. if (convStat != APT_StatusOk)
  681. issueConversionWarning("Conversion error calling conversion routine time_from_string data may have been lost","No more conversion warnings will be issued");
  682. stage0StageVar0_svFullDay=localVar930==localVar960;
  683. sprintf(convBuf,"%u",(APT_TOFunctions::get().set_null()));
  684. localVar360=convBuf;
  685. stage0StageVar0_svBreakSHIT=APT_TOFunctions::get().substring_by_delimiter(localVar360,stage0InterVar0_7,2);
  686. output0StringCIS_LEG_ID[0]=input0StringRETAIL_SUP_POINT[0];
  687. output0TimeStampSET_DTTM[0]=stage0StageVar0_svTimestamp;
  688. transferAndPutRecord(0);
  689. stage0RowRejected0=0;
  690. output1StringCIS_LEG_ID[0]=input0StringRETAIL_SUP_POINT[0];
  691. output1TimeStampSET_DTTM[0]=stage0StageVar0_svTimestamp;
  692. output1Int8FULL_DAY_FLAG[0]=stage0StageVar0_svFullDay;
  693. transferAndPutRecord(1);
  694. stage0RowRejected0=0;
  695.  
  696.  
  697. // send custom instance report.
  698. sendCustomInstanceReport(customInstanceReport);
  699. }
  700.  
  701. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::writeRecord(int outds)
  702. {
  703. // Handle output specific accessors
  704.  
  705.  
  706. }
  707.  
  708. // parallel method, invoked in each partition.
  709. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::doFinalProcessing()
  710. {
  711. // declare local variable
  712.  
  713.  
  714. // "finish" code segment
  715.  
  716.  
  717. // cleanup tables and caches
  718.  
  719.  
  720. return APT_StatusOk;
  721. }
  722.  
  723. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::writeOutputRecord()
  724. {
  725. // Handle any cached output records
  726.  
  727.  
  728. return APT_StatusOk;
  729. }
  730.  
  731. APT_PropertyList APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::modifyOutputSortKeys(const APT_TransferAdapter& tAdapt,
  732. APT_Int32 outDs)
  733. {
  734. APT_PropertyList retKeys;
  735. APT_PropertyList newKeys = getInputSortKeys(0);
  736. int numOfKeys = newKeys.count();
  737. APT_FieldSelector schVar = tAdapt.getVar(outDs);
  738. int numOfDropFds = tAdapt.numDroppedFromVar(schVar);
  739. APT_UString dropFds;
  740. int i;
  741. for ( i = 0; i < numOfDropFds; i++ )
  742. dropFds.append(tAdapt.UdroppedVarField(schVar,i)+APT_UString(","));
  743. for ( i = 0; i < numOfKeys; i++ )
  744. {
  745. APT_Property prop = newKeys.getProperty(i);
  746. APT_UString nameOfKey = prop.valueList().getProperty(APT_UString("value")).valueUString();
  747. if (dropFds.occurrences(nameOfKey))
  748. break;
  749. else
  750. retKeys.addProperty(prop);
  751. }
  752. if ( retKeys.count() == 0 )
  753. retKeys.addProperty(APT_UString("unsorted"),retKeys);
  754. return retKeys;
  755. }
  756.  
  757.  
  758. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processRejectRecord(const APT_UString &errMsg,
  759. const APT_UString &warningMsg,
  760. APT_Int32 rejectDs)
  761. {
  762. // Output the log if we are not to the limit or if
  763. // always log (any negative value) is set
  764. if (rejectLogCount < maxRejectLogs ||
  765. maxRejectLogs < 0)
  766. {
  767. APT_TOFunctions::get().u_print_warning(errMsg);
  768. rejectLogCount++;
  769. if (rejectLogCount == maxRejectLogs)
  770. {
  771. // output a log warning that this is the last reject log you will see
  772. APT_TOFunctions::get().u_print_warning(warningMsg);
  773. }
  774. }
  775.  
  776. // Set the value of the reject column
  777.  
  778.  
  779. if (rejectDs > 0)
  780. transferAndPutRecord(rejectDs);
  781. }
  782.  
  783. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processEOF(int inputDS)
  784. {
  785. // set next input
  786. if (inputDS == 0) {
  787. int numOfConvs;
  788. for(numOfConvs=0;numOfConvs<10;numOfConvs++)
  789. {
  790. if (pConv[numOfConvs])
  791. pConv[numOfConvs]->disOwn();
  792. }
  793. }
  794. advanceToNextInput();
  795.  
  796. }
  797.  
  798. void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::postRun(APT_Status stepStatus)
  799. {
  800. // clear the entries in the field conversion map
  801. // in case there is another transform op in the flow
  802. APT_TOFunctions::get().clearFieldConvMap();
  803. }
  804.  
  805. // Allow for addition of mixed strings and ustrings
  806. APT_UString operator+ (const APT_UString& lhs, const APT_String& rhstr)
  807. {
  808. const APT_UString rhs(rhstr);
  809. return (lhs + rhs);
  810. }
  811. APT_UString operator+ (const APT_String& lhstr, const APT_UString& rhs)
  812. {
  813. const APT_UString lhs(lhstr);
  814. return (lhs + rhs);
  815. }
  816.  
  817. // lookup related methods
  818.  
  819. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::addTable(const APT_UString& fsetName, TableType tableType)
  820. {
  821. // handle adding a lookup tabls
  822.  
  823.  
  824. return APT_StatusOk;
  825. }
  826.  
  827. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::resetForNextUnit()
  828. {
  829. // handle next unit correctly in lookup case
  830. //Use base class implementation if no lookup used.
  831. APT_Operator::resetForNextUnit();
  832.  
  833.  
  834. return APT_StatusOk;
  835. }
  836.  
  837. APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::issueConversionWarning(const APT_String& msg,
  838. const APT_String& noMoreWarnings)
  839. {
  840. static APT_UInt32 warningCount = 0;
  841.  
  842. if (warningCount <= 10)
  843. {
  844. // Issue the warning
  845. APT_TOFunctions::get().u_print_warning(APT_ConvertFromString(msg));
  846.  
  847. if (warningCount == 10)
  848. {
  849. // Issue no more warnings warning
  850. APT_TOFunctions::get().u_print_warning(APT_ConvertFromString(noMoreWarnings));
  851. }
  852. }
  853.  
  854. warningCount++;
  855.  
  856. return APT_StatusOk;
  857. }
Add Comment
Please, Sign In to add comment