Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -*-Mode: C++-*-
- // Copyright (c) 2003, 1997-2002 Ascential Software, Inc. All rights reserved.
- /*
- #######################################################################
- ##
- ## Maintenence log - insert most recent change descriptions at top
- ##
- ## Date Ecase# WHO Description.
- ## 05/04/05 73547 eaj Handle conversion failures better
- ## 04/29/05 73479 eaj Explicitly force std::llabs on linux
- ## 01/31/05 68170 xpu Redefine max() and min() on Linux.
- ## 07/22/04 30156 eaj Handle a hex value in APT_STRING_PADCHAR
- ## 03/15/04 none eaj Use osh option -string_fields for inserted
- ## field type
- ## 02/28/04 n/a xpu Moved declaration of operator+ out of
- ## the class.
- ## 01/26/04 linda Adding OS/390 support
- ## 01/21/04 43656 xpu Update output sort keys at run time.
- ## 11/21/03 n/a xpu Inserted spaces for indention.
- ## 09/26/03 39721 xpu Added a newline at the end of the file to
- ## avoid aCC 3.37 future fatal error 690.
- ## 09/04/03 39209 eaj NLS this fix since it came from 6.0
- ## 09/04/03 39209 eaj Added use of APT_STRING_PADCHAR for fixed
- ## length strings.
- ## 05/08/03 9607 xpu Removed setting dataset schemas
- ## 04/09/03 20305 eaj Added handling of + operator for ustring
- ## string mixes
- ## 04/09/03 20130 eaj Add handling of collation sequence option
- #######################################################################
- */
- #include <apt_framework/orchestrate.h>
- #include <apt_framework/record.h>
- #include <apt_framework/interface.h>
- #include <apt_framework/type/descriptor.h>
- #include <apt_framework/type/conversion.h>
- #include <apt_framework/tfmop_functions.h>
- #include <apt_util/env_flag.h>
- #include <apt_util/unicode_utils.h>
- #include <apt_util/converter_registry.h>
- #include <apt_util/lookuptable.h>
- #include <apt_util/lookupops.h>
- #include <math.h>
- #include <stdlib.h>
- #include <string.h>
- #include <map>
- #if defined(__SUN__)
- #include <sys/ddi.h>
- #endif
- // user-defined function header file
- #include "V52S0_TX_CISM_CI_REG_DATA_TF_Convert_user.h"
- #if defined(__AIX__)
- #define max __maxi64
- #define min __mini64
- #endif
- #if defined(__OSF1__)
- #define llabs labs
- #endif
- // Work around suse compiler issue with llabs, force the std package
- #if defined(__LINUX__)
- #define llabs std::llabs
- #endif
- #if defined(__OS390__) || defined(__LINUX__)
- #ifdef min
- #undef min
- #endif /* min */
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #ifdef max
- #undef max
- #endif /* max */
- #define max(a, b) ((a) < (b) ? (b) : (a))
- #endif
- #define TRX_DEFAULT_MAX_PRECISION 38
- #define TRX_DEFAULT_MAX_SCALE 10
- #define TRX_DEFAULT_CACHE_SIZE 2
- typedef APT_STD::less<APT_String> lessAPTStr;
- static APT_EnvironmentFlag sPrecision("APT_DECIMAL_INTERM_PRECISION");
- static APT_EnvironmentFlag sScale("APT_DECIMAL_INTERM_SCALE");
- static APT_EnvironmentFlag sRecordCacheSize("APT_TRANSFORM_RECORD_CACHE_SIZE");
- static APT_EnvironmentFlag sStringPadChar("APT_STRING_PADCHAR");
- static UChar sPadChar = 0;
- static int processPadCharEnv()
- {
- if (sStringPadChar)
- {
- APT_UString pc = sStringPadChar.UvalueStrHandleHex();
- if (pc.length() == 1)
- sPadChar = pc.data()[0];
- }
- return 0;
- }
- static int sDummy = processPadCharEnv();
- // Allow for addition of mixed strings and ustrings
- APT_UString operator+ (const APT_UString&, const APT_String&);
- APT_UString operator+ (const APT_String&, const APT_UString&);
- class APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert: public APT_CombinableOperator
- {
- public:
- APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert();
- ~APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert();
- protected:
- virtual APT_Status initializeFromArgs_(const APT_PropertyList &args,
- InitializeContext context);
- virtual APT_Status describeOperator();
- virtual APT_Status preRun();
- virtual APT_Status doInitialProcessing();
- virtual APT_PropertyList modifyOutputSortKeys(const APT_TransferAdapter& tAdapt,
- APT_Int32 outDs);
- virtual void processInputRecord(int inputDS);
- virtual void processRejectRecord(const APT_UString &errMsg,
- const APT_UString &warningMsg,
- int rejectDs);
- virtual APT_Status doFinalProcessing();
- virtual APT_Status writeOutputRecord();
- virtual void processEOF(int inputDS);
- virtual void postRun(APT_Status stepStatus);
- virtual APT_Status resetForNextUnit();
- // Lookup related methods
- APT_Status addTable(const APT_UString& fsetName, TableType tableType);
- // Write an output record, handles caching of multiple calls to writerecord
- void writeRecord(int outds);
- // Issue warning of failure of a conversion routine
- APT_Status issueConversionWarning(const APT_String& msg,
- const APT_String& noMoreWarnings);
- private:
- // internal macros, required for persistence mechanism
- APT_DECLARE_RTTI(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
- APT_DECLARE_PERSISTENT(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
- // input accessors
- APT_InputAccessorToDecimal input0DecimalDAY_START_OFFSET;
- APT_InputAccessorToString input0StringRETAIL_SUP_POINT,input0StringREG_DS_TYPE_FLG;
- APT_InputAccessorToTimeStamp input0TimeStampREG_DATA_START_DTTM,input0TimeStampREG_DATA_END_DTTM;
- // output accessors
- APT_OutputAccessorToInt8 output1Int8FULL_DAY_FLAG;
- APT_OutputAccessorToString output0StringCIS_LEG_ID,output1StringCIS_LEG_ID;
- APT_OutputAccessorToTimeStamp output0TimeStampSET_DTTM,output1TimeStampSET_DTTM;
- // array containing the order in which inputs are transferred.
- int tranOrder[2];
- // transfer index
- int tranIndex;
- int precision;
- int scale;
- // declare stage (global) variables.
- APT_Int8 stage0RowRejected0;
- APT_Int8 stage0NullSetVar0;
- APT_String stage0InterVar0_2;
- APT_String stage0InterVar0_3;
- APT_String stage0InterVar0_5;
- APT_String stage0InterVar0_6;
- APT_String stage0InterVar0_7;
- APT_String stage0StageVar0_svTypeFlag;
- APT_Date stage0StageVar0_svDate;
- APT_Time stage0StageVar0_svTime;
- APT_Date stage0StageVar0_svAdjustedDate;
- APT_Int32 stage0StageVar0_svSecond;
- APT_TimeStamp stage0StageVar0_svTimestamp;
- APT_Int8 stage0StageVar0_svFullDay;
- APT_String stage0StageVar0_svBreakSHIT;
- APT_FieldConversion* pConv[10];
- // buffer used for default conversions.
- char convBuf[32];
- char* pBuf;
- UChar* pUCharBuf;
- // data members for creating custom report
- APT_STD::vector<APT_CustomReportInfo> customReport;
- APT_STD::vector<APT_CustomReportInfo> customInstanceReport;
- // Reject processing information
- int maxRejectLogs;
- int rejectLogCount;
- APT_UString rejectColumn;
- // a copy of the args passed to initializeFromArgs
- APT_PropertyList stashedArgs;
- // Lookup related members
- };
- APT_IMPLEMENT_RTTI_ONEBASE(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert, APT_CombinableOperator);
- APT_IMPLEMENT_PERSISTENT(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert);
- // register operator and argument list with OSH
- #define ARG_DESC \
- "{ " \
- " otherInfo={ " \
- " inputs={ " \
- " input={ description='input data set', " \
- " multiple " \
- " } " \
- " }, " \
- " outputs={ " \
- " output={ " \
- " description='output data set', " \
- " multiple " \
- " }, " \
- " reject={ " \
- " description='reject data set', " \
- " any, " \
- " constraints={argcount= reject} " \
- " } " \
- " }, " \
- " description='Sub-Level Transform operator:' " \
- " } " \
- "} "
- APT_DEFINE_OSH_NAME(APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert, V52S0_TX_CISM_CI_REG_DATA_TF_Convert, ARG_DESC);
- APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert()
- : pBuf(0), pUCharBuf(0), maxRejectLogs(50), rejectLogCount(0), tranIndex(0),
- precision(sPrecision.valueStr().asInteger(TRX_DEFAULT_MAX_PRECISION)),
- scale(sScale.valueStr().asInteger(TRX_DEFAULT_MAX_SCALE))
- {
- // initialize stage (global) variables.
- stage0RowRejected0 = 0;
- stage0NullSetVar0 = 0;
- stage0StageVar0_svSecond = 0;
- stage0StageVar0_svFullDay = 0;
- }
- APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::~APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert()
- {
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::serialize(APT_Archive& ar, APT_UInt8)
- {
- // serialize job parameters and lookup table info
- }
- // initialize operator from arguments
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::initializeFromArgs_(const APT_PropertyList &args,
- InitializeContext context)
- {
- APT_Status status = APT_StatusOk;
- APT_Status colStatus = APT_StatusOk;
- // save the arg list to be used in describeOperator
- stashedArgs = args;
- // create lookup table array
- int nprops = args.count();
- for (int i = 0; i < nprops; i++)
- {
- const APT_Property& prop = args[i];
- if (prop.name() == (APT_UString)"maxrejectlogs" )
- {
- maxRejectLogs = prop.valueList().getProperty(APT_UString("value")).valueInt64();
- }
- else if ( prop.name() == APT_UString("reject") )
- {
- if (prop.kind() == APT_Property::eEmpty)
- continue;
- const APT_PropertyList& reject = prop.valueList();
- // Set compilation options.
- if (reject.hasProperty(APT_UString("subArgs")))
- {
- const APT_PropertyList& subArgs = reject.getProperty(APT_UString("subArgs")).valueList( );
- for (int j = 0 ; j < subArgs.count() ; j++)
- {
- const APT_Property& subProp = subArgs[j];
- if (subProp.name() == APT_UString("rejectinfo"))
- {
- rejectColumn = subProp.valueList().getProperty(APT_UString("value")).valueUString();
- }
- }
- }
- }
- else if (prop.name() == (APT_UString)"diablesharing" )
- {
- // mark the disable sharing flag
- }
- else if (prop.name() == (APT_UString)"fileset")
- {
- if (context != APT_Operator::eInitial)
- continue;
- APT_UString fname =
- prop.valueList().getProperty((APT_UString)"value").valueUString();
- APT_FileSet fs;
- APT_ParseError err;
- fs.parseFile(fname, &err);
- if (err.errorOccurred())
- {
- status = APT_StatusFailed;
- continue;
- }
- addTable(fname, eStatic);
- }
- else if (prop.name() == (APT_UString)"table")
- {
- if (context != APT_Operator::eInitial)
- continue;
- APT_UString filesetname;
- filesetname = prop.valueList().getProperty((APT_UString)"filesetname").valueUString();
- addTable(filesetname, eDynamic);
- }
- else if (updateCollationSeqFromProperty(prop, colStatus))
- {
- // We found a collation property make sure everything went ok
- if (colStatus == APT_StatusFailed)
- {
- status = APT_StatusFailed;
- }
- }
- }
- return status;
- }
- // initialize operator before serialization and parallel distribution.
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::describeOperator()
- {
- // set number of inputs/outputs.
- setInputDataSets(1);
- setOutputDataSets(2);
- // set input interface schema.
- APT_Schema* inputSchema=new APT_Schema[1];
- 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)"));
- APT_Schema droppedFds;
- int inSchema_i;
- for (inSchema_i=0;inSchema_i<viewAdaptedSchema(0).numFields(); inSchema_i++)
- {
- APT_SchemaField thisFd;
- thisFd = viewAdaptedSchema(0).field(inSchema_i);
- if(inputSchema[0].hasField_byId(thisFd.ident()))
- continue;
- else{
- droppedFds.addField(thisFd);
- }
- }
- int INPUT;
- for(INPUT=0;INPUT<1;INPUT++)
- setInputInterfaceSchema(inputSchema[INPUT],INPUT);
- delete [] inputSchema;
- // set output interface schema.
- APT_Schema* outputSchema=new APT_Schema[2];
- outputSchema[0]=APT_Schema(APT_ConvertFromString("record\n( CIS_LEG_ID: string[10];\n SET_DTTM: timestamp;\n APT_TRoutput0Rec0: *;\n)"));
- 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)"));
- int OUTPUT;
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- setOutputInterfaceSchema(outputSchema[OUTPUT],OUTPUT);
- delete [] outputSchema;
- // set view/modify adapter.
- // set transfer adapter.
- APT_TransferAdapter inTransAdapt0;
- APT_UString* dropped=new APT_UString[2];
- dropped[0]=APT_ConvertFromString("RETAIL_SUP_POINT,REG_DATA_START_DTTM,DAY_START_OFFSET");
- 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");
- if(droppedFds.numFields()>0)
- {
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- {
- sprintf(convBuf,"APT_TRinput0Rec%d",OUTPUT);
- APT_UString schVarName = (APT_UString)convBuf;
- for (inSchema_i=0;inSchema_i<droppedFds.numFields(); inSchema_i++)
- inTransAdapt0.dropFromVar(schVarName,droppedFds.field(inSchema_i).Uidentifier());
- }
- }
- APT_UString* renamedFrom=new APT_UString[2];
- APT_UString* renamedTo=new APT_UString[2];
- renamedFrom[0]=APT_ConvertFromString("REG_DATA_END_DTTM,REG_TYPE");
- renamedTo[0]=APT_ConvertFromString("REG_DATA_DTTM,CIS_LEG_TYPE");
- renamedFrom[1]=APT_ConvertFromString("REG_DATA_END_DTTM,REG_TYPE");
- renamedTo[1]=APT_ConvertFromString("REG_DATA_DTTM,CIS_LEG_TYPE");
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- {
- sprintf(convBuf,"APT_TRinput0Rec%d",OUTPUT);
- APT_UString schVarName = (APT_UString)convBuf;
- inTransAdapt0.setVarMode(schVarName, APT_TransferAdapter::eAll);
- if(!dropped[OUTPUT].isEmpty())
- inTransAdapt0.dropFromVarMulti(schVarName,dropped[OUTPUT]);
- if(!renamedFrom[OUTPUT].isEmpty()&&!renamedTo[OUTPUT].isEmpty())
- inTransAdapt0.renameFieldsInVar(schVarName,renamedFrom[OUTPUT],renamedTo[OUTPUT]);
- }
- setTransferAdapter(inTransAdapt0,0);
- delete [] dropped;
- delete [] renamedFrom;
- delete [] renamedTo;
- // declare transfer.
- for(INPUT=0;INPUT<1;INPUT++)
- {
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- {
- sprintf(convBuf,"APT_TRinput%dRec%d",INPUT,OUTPUT);
- APT_UString inSchVarName = (APT_UString)convBuf;
- sprintf(convBuf,"APT_TRoutput%dRec%d",OUTPUT,INPUT);
- APT_UString outSchVarName = (APT_UString)convBuf;
- declareTransfer(inSchVarName,outSchVarName,INPUT,OUTPUT);
- }
- }
- // set partitioner/sort insertion information.
- if(getInputSortKeys(0).count())
- {
- int i;
- for(i=0;i<2;i++)
- setOutputSortKeys(modifyOutputSortKeys(inTransAdapt0,i),i);
- }
- // set job parameters
- // Setup lookup table functionality
- setWorkingDirectory(false);
- return APT_StatusOk;
- }
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::preRun()
- {
- // read dynamic lookup table filesets
- return APT_StatusOk;
- }
- // parallel method, invoked in each partition.
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::doInitialProcessing()
- {
- APT_Status convStat = APT_StatusOk;
- // declare local variable
- APT_String localVar120;
- stage0StageVar0_svTypeFlag.setPadChar((char)sPadChar);
- stage0StageVar0_svTypeFlag.setFixedLength(1);
- pConv[0]=APT_FieldConversionRegistry::get().lookupAndParse("date_from_string[%yyyy-%mm-%dd]", NULL);
- pConv[3]=APT_FieldConversionRegistry::get().lookupAndParse("date_from_timestamp", NULL);
- pConv[9]=APT_FieldConversionRegistry::get().lookupAndParse("hours_from_time", NULL);
- pConv[5]=APT_FieldConversionRegistry::get().lookupAndParse("minutes_from_time", NULL);
- pConv[8]=APT_FieldConversionRegistry::get().lookupAndParse("month_day_from_date", NULL);
- pConv[7]=APT_FieldConversionRegistry::get().lookupAndParse("month_from_date", NULL);
- pConv[1]=APT_FieldConversionRegistry::get().lookupAndParse("time_from_string[%hh:%nn:%ss]", NULL);
- pConv[4]=APT_FieldConversionRegistry::get().lookupAndParse("time_from_timestamp", NULL);
- pConv[2]=APT_FieldConversionRegistry::get().lookupAndParse("timestamp_from_string[%yyyy-%mm-%dd %hh:%nn:%ss]", NULL);
- pConv[6]=APT_FieldConversionRegistry::get().lookupAndParse("year_from_date", NULL);
- // "initialize" code segment
- stage0InterVar0_2="A";
- stage0InterVar0_3="S";
- stage0InterVar0_5="00:00:00";
- stage0InterVar0_6="%hh:%nn:%ss";
- stage0InterVar0_7="2";
- stage0StageVar0_svTypeFlag="";
- localVar120="2001-01-01";
- convStat = pConv[0]->convert((void*)&localVar120, (void*)&stage0StageVar0_svDate, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
- localVar120="00:00:01";
- convStat = pConv[1]->convert((void*)&localVar120, (void*)&stage0StageVar0_svTime, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine time_from_string data may have been lost","No more conversion warnings will be issued");
- localVar120="2001-01-01";
- convStat = pConv[0]->convert((void*)&localVar120, (void*)&stage0StageVar0_svAdjustedDate, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
- stage0StageVar0_svSecond=0;
- localVar120="2001-01-01 00:00:01";
- convStat = pConv[2]->convert((void*)&localVar120, (void*)&stage0StageVar0_svTimestamp, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine timestamp_from_string data may have been lost","No more conversion warnings will be issued");
- stage0StageVar0_svFullDay=0;
- stage0StageVar0_svBreakSHIT="";
- // load and attach static tables
- // set up input accessor.
- APT_InputAccessorInterface** inCur=new APT_InputAccessorInterface*[1];
- int INPUT;
- for(INPUT=0;INPUT<1;INPUT++)
- inCur[INPUT]=inputAccessorInterface(INPUT);
- APT_STD::map<APT_String, APT_InputAccessorBase*>* inAcc=new APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>[1];
- inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("RETAIL_SUP_POINT", &input0StringRETAIL_SUP_POINT));
- inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DATA_START_DTTM", &input0TimeStampREG_DATA_START_DTTM));
- inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DATA_END_DTTM", &input0TimeStampREG_DATA_END_DTTM));
- inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("REG_DS_TYPE_FLG", &input0StringREG_DS_TYPE_FLG));
- inAcc[0].insert(APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::value_type("DAY_START_OFFSET", &input0DecimalDAY_START_OFFSET));
- for(INPUT=0;INPUT<1;INPUT++)
- {
- APT_STD::map<APT_String, APT_InputAccessorBase*, lessAPTStr>::iterator iter;
- for(iter = inAcc[INPUT].begin();iter!=inAcc[INPUT].end(); iter++)
- inCur[INPUT]->setupAccessor(APT_ConvertFromString(iter->first),iter->second);
- }
- delete [] inCur;
- delete [] inAcc;
- // set up output accessor.
- APT_OutputAccessorInterface** outCur=new APT_OutputAccessorInterface*[2];
- int OUTPUT;
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- outCur[OUTPUT]=outputCursor(OUTPUT);
- APT_STD::map<APT_String, APT_OutputAccessorBase*>* outAcc=new APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>[2];
- outAcc[0].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("CIS_LEG_ID", &output0StringCIS_LEG_ID));
- outAcc[0].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("SET_DTTM", &output0TimeStampSET_DTTM));
- outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("CIS_LEG_ID", &output1StringCIS_LEG_ID));
- outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("SET_DTTM", &output1TimeStampSET_DTTM));
- outAcc[1].insert(APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::value_type("FULL_DAY_FLAG", &output1Int8FULL_DAY_FLAG));
- for(OUTPUT=0;OUTPUT<2;OUTPUT++)
- {
- APT_STD::map<APT_String, APT_OutputAccessorBase*, lessAPTStr>::iterator iter;
- for(iter = outAcc[OUTPUT].begin();iter!=outAcc[OUTPUT].end(); iter++)
- outCur[OUTPUT]->setupAccessor(APT_ConvertFromString(iter->first),iter->second);
- }
- delete [] outCur;
- delete [] outAcc;
- // order in which inputs are transferred
- // set the first active input
- setActiveInput( 0);
- // send custom report.
- sendCustomReport(customReport);
- return APT_StatusOk;
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processInputRecord(int inputDS)
- {
- APT_Status convStat = APT_StatusOk;
- // handle dyamic tables
- // declare local variable
- APT_Int32 local0InterVar0_0;
- APT_String local0InterVar0_1;
- APT_Int32 local0InterVar0_4;
- APT_String localVar360;
- APT_Decimal localVar460(precision,scale);
- APT_Int8 localVar460_new;
- APT_Decimal localVar490(precision,scale);
- APT_Int16 localVar520;
- APT_Int8 localVar560;
- APT_Int8 localVar580;
- APT_Time localVar930;
- APT_Time localVar960;
- // Init the interface array indexes
- // process records.
- stage0RowRejected0=1;
- localVar360 =input0StringREG_DS_TYPE_FLG[0];
- localVar360.trimPadding(' ',APT_String::eBeginning);
- localVar360.trimPadding(' ',APT_String::eEnd);
- localVar360.compactPadding(' ');
- if(localVar360.occurrences(' '))
- {
- localVar360.trimPadding(' ',APT_String::eBeginning);
- localVar360.trimPadding(' ',APT_String::eEnd);
- localVar360.compactPadding(' ');
- }
- stage0StageVar0_svTypeFlag=localVar360;
- convStat = pConv[3]->convert((void*)&input0TimeStampREG_DATA_START_DTTM[0], (void*)&stage0StageVar0_svDate, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine date_from_timestamp data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[4]->convert((void*)&input0TimeStampREG_DATA_START_DTTM[0], (void*)&stage0StageVar0_svTime, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine time_from_timestamp data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[5]->convert((void*)&stage0StageVar0_svTime, (void*)&localVar460_new, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine minutes_from_time data may have been lost","No more conversion warnings will be issued");
- localVar460.assignFromInt32(localVar460_new);
- localVar490=localVar460-input0DecimalDAY_START_OFFSET[0];
- local0InterVar0_0=localVar490.asInteger();
- convStat = pConv[6]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar520, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine year_from_date data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[7]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar460_new, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine month_from_date data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[8]->convert((void*)&stage0StageVar0_svDate, (void*)&localVar560, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine month_day_from_date data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[9]->convert((void*)&stage0StageVar0_svTime, (void*)&localVar580, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine hours_from_time data may have been lost","No more conversion warnings will be issued");
- local0InterVar0_1=
- pxNormaliseDate(localVar520,localVar460_new,localVar560,localVar580,local0InterVar0_0,0);
- localVar360=((1>=1)?local0InterVar0_1.substring(1-1,10):APT_String(""));
- convStat = pConv[0]->convert((void*)&localVar360, (void*)&stage0StageVar0_svAdjustedDate, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine date_from_string data may have been lost","No more conversion warnings will be issued");
- if(stage0StageVar0_svTypeFlag==stage0InterVar0_2)
- {
- stage0StageVar0_svSecond=8;
- }
- else
- {
- if(stage0StageVar0_svTypeFlag==stage0InterVar0_3)
- {
- stage0StageVar0_svSecond=10;
- }
- else
- {
- stage0StageVar0_svSecond=12;
- }
- }
- convStat = pConv[7]->convert((void*)&stage0StageVar0_svAdjustedDate, (void*)&localVar460_new, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine month_from_date data may have been lost","No more conversion warnings will be issued");
- local0InterVar0_0=localVar460_new+1;
- local0InterVar0_4=input0DecimalDAY_START_OFFSET[0].asInteger();
- convStat = pConv[6]->convert((void*)&stage0StageVar0_svAdjustedDate, (void*)&localVar520, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine year_from_date data may have been lost","No more conversion warnings will be issued");
- local0InterVar0_1=pxNormaliseDate(localVar520,local0InterVar0_0,1,0,local0InterVar0_4,stage0StageVar0_svSecond);
- convStat = pConv[2]->convert((void*)&local0InterVar0_1, (void*)&stage0StageVar0_svTimestamp, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine timestamp_from_string data may have been lost","No more conversion warnings will be issued");
- convStat = pConv[4]->convert((void*)&input0TimeStampREG_DATA_END_DTTM[0], (void*)&localVar930, 0);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine time_from_timestamp data may have been lost","No more conversion warnings will be issued");
- localVar360 = (APT_String)"time_from_string[" + (APT_String)stage0InterVar0_6 + (APT_String)"]";
- convStat = APT_TOFunctions::get().convertWithParams(&stage0InterVar0_5,localVar360, (void*)&localVar960);
- if (convStat != APT_StatusOk)
- issueConversionWarning("Conversion error calling conversion routine time_from_string data may have been lost","No more conversion warnings will be issued");
- stage0StageVar0_svFullDay=localVar930==localVar960;
- sprintf(convBuf,"%u",(APT_TOFunctions::get().set_null()));
- localVar360=convBuf;
- stage0StageVar0_svBreakSHIT=APT_TOFunctions::get().substring_by_delimiter(localVar360,stage0InterVar0_7,2);
- output0StringCIS_LEG_ID[0]=input0StringRETAIL_SUP_POINT[0];
- output0TimeStampSET_DTTM[0]=stage0StageVar0_svTimestamp;
- transferAndPutRecord(0);
- stage0RowRejected0=0;
- output1StringCIS_LEG_ID[0]=input0StringRETAIL_SUP_POINT[0];
- output1TimeStampSET_DTTM[0]=stage0StageVar0_svTimestamp;
- output1Int8FULL_DAY_FLAG[0]=stage0StageVar0_svFullDay;
- transferAndPutRecord(1);
- stage0RowRejected0=0;
- // send custom instance report.
- sendCustomInstanceReport(customInstanceReport);
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::writeRecord(int outds)
- {
- // Handle output specific accessors
- }
- // parallel method, invoked in each partition.
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::doFinalProcessing()
- {
- // declare local variable
- // "finish" code segment
- // cleanup tables and caches
- return APT_StatusOk;
- }
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::writeOutputRecord()
- {
- // Handle any cached output records
- return APT_StatusOk;
- }
- APT_PropertyList APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::modifyOutputSortKeys(const APT_TransferAdapter& tAdapt,
- APT_Int32 outDs)
- {
- APT_PropertyList retKeys;
- APT_PropertyList newKeys = getInputSortKeys(0);
- int numOfKeys = newKeys.count();
- APT_FieldSelector schVar = tAdapt.getVar(outDs);
- int numOfDropFds = tAdapt.numDroppedFromVar(schVar);
- APT_UString dropFds;
- int i;
- for ( i = 0; i < numOfDropFds; i++ )
- dropFds.append(tAdapt.UdroppedVarField(schVar,i)+APT_UString(","));
- for ( i = 0; i < numOfKeys; i++ )
- {
- APT_Property prop = newKeys.getProperty(i);
- APT_UString nameOfKey = prop.valueList().getProperty(APT_UString("value")).valueUString();
- if (dropFds.occurrences(nameOfKey))
- break;
- else
- retKeys.addProperty(prop);
- }
- if ( retKeys.count() == 0 )
- retKeys.addProperty(APT_UString("unsorted"),retKeys);
- return retKeys;
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processRejectRecord(const APT_UString &errMsg,
- const APT_UString &warningMsg,
- APT_Int32 rejectDs)
- {
- // Output the log if we are not to the limit or if
- // always log (any negative value) is set
- if (rejectLogCount < maxRejectLogs ||
- maxRejectLogs < 0)
- {
- APT_TOFunctions::get().u_print_warning(errMsg);
- rejectLogCount++;
- if (rejectLogCount == maxRejectLogs)
- {
- // output a log warning that this is the last reject log you will see
- APT_TOFunctions::get().u_print_warning(warningMsg);
- }
- }
- // Set the value of the reject column
- if (rejectDs > 0)
- transferAndPutRecord(rejectDs);
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::processEOF(int inputDS)
- {
- // set next input
- if (inputDS == 0) {
- int numOfConvs;
- for(numOfConvs=0;numOfConvs<10;numOfConvs++)
- {
- if (pConv[numOfConvs])
- pConv[numOfConvs]->disOwn();
- }
- }
- advanceToNextInput();
- }
- void APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::postRun(APT_Status stepStatus)
- {
- // clear the entries in the field conversion map
- // in case there is another transform op in the flow
- APT_TOFunctions::get().clearFieldConvMap();
- }
- // Allow for addition of mixed strings and ustrings
- APT_UString operator+ (const APT_UString& lhs, const APT_String& rhstr)
- {
- const APT_UString rhs(rhstr);
- return (lhs + rhs);
- }
- APT_UString operator+ (const APT_String& lhstr, const APT_UString& rhs)
- {
- const APT_UString lhs(lhstr);
- return (lhs + rhs);
- }
- // lookup related methods
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::addTable(const APT_UString& fsetName, TableType tableType)
- {
- // handle adding a lookup tabls
- return APT_StatusOk;
- }
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::resetForNextUnit()
- {
- // handle next unit correctly in lookup case
- //Use base class implementation if no lookup used.
- APT_Operator::resetForNextUnit();
- return APT_StatusOk;
- }
- APT_Status APT_TransformOperatorImplV52S0_TX_CISM_CI_REG_DATA_TF_Convert::issueConversionWarning(const APT_String& msg,
- const APT_String& noMoreWarnings)
- {
- static APT_UInt32 warningCount = 0;
- if (warningCount <= 10)
- {
- // Issue the warning
- APT_TOFunctions::get().u_print_warning(APT_ConvertFromString(msg));
- if (warningCount == 10)
- {
- // Issue no more warnings warning
- APT_TOFunctions::get().u_print_warning(APT_ConvertFromString(noMoreWarnings));
- }
- }
- warningCount++;
- return APT_StatusOk;
- }
Add Comment
Please, Sign In to add comment