C# Class DataMigration.CompiledXforms

Compiled xforms. This is an instance of IMethodResolver, which has compiled C# functions that actually live in the DataMigration assembly. IMethodResolvers can be external, and they don't have to be compiled (although support for scripted methods hasn't been added yet).
Inheritance: IMethodResolver, ILitmusTestResolver, IPostRowProcessorResolver
ファイルを表示 Open project: scoutmedia/DataMigration

Public Methods

Method Description
CalcCreateDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

Just generates the current datetime. Parameters are described at DataMigration.TransformMethod

CalculateActiveFlag ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

CalculateActiveFlag looks at the Subscription Status column first; if value is Life it sets ActiveFlag to true, if Cancelled, then false, if neither, it checks the expiryDate. If it's parseble and in the past, it returns false. If none of these cases apply, it returns true. Parameters are described at DataMigration.TransformMethod

CalculateExpireDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

CalculateExpireDate makes sure we can parse the expire date into a valid date, otherwise, it returns null. If user is a LIFE member, then they also get a null expire date. If the subStatus is CANCELLED, we set expire date to NOW. Technically this is unnecessary if this is an initial import; CalculateActiveFlag will set the subscription to inactive. But in the case of a subscription changing from Regular or Life to Cancelled, this is important as we rely on the offline recurring billing task to actually set the ActiveFlag to 0, and it does this by looking for expired subscriptions. Parameters are described at DataMigration.TransformMethod

DefaultToUSCountryId ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This function attempts to get a valid country id for the row, but if the data is incomplete, or we don't have a row for it, will use US. Parameters are described at DataMigration.TransformMethod

EnsureEmailIsNotInMembersTable ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool

Ensure the email does not exist in member table already. Parameters and return are described at DataMigration.LitmusTest

EnsureEmailUniqueWithinFeed ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool

Ensures the email has not been seen in the feed so far. Parameters and return are described at DataMigration.LitmusTest

EnsureEmailWasntInFirstPass ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool

Ensures that the email wasn't in there the first time we processed it.

EnsureValidEmail ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool

Ensures the email is properly formed. Parameters and return are described at DataMigration.LitmusTest

EnsureValidEmailPassThroughBlanks ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
EnsureValidSubscriptionDates ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool

The spreadsheet for BAM Magazine-only subscriptions has some rows that are messed up; there's no way we can process those rows. This litmus test in particular will try to parse out dates from three columns we have to have; they may be blank, but if they have non-blank non-date data in them, then we're hopelessly lost with processing this row.

MakeFullName ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This function combines first and last name. Parameters are described at DataMigration.TransformMethod

MemberIdFromEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This function is for the scenario where we want to create a subscription for the person, but not a row in the member table, if their email is already in the member table. We're going to look up their id from the member table, stick it in the Staging table, and therefore refrain from doing a member table insertion in post processing. Parameters are described at DataMigration.TransformMethod

OnlyPassThroughValidEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This function is for the scenario where we want to keep the row, even if it has an invalid email. If the email *is* invalid, we're going to null it out, though. Parameters are described at DataMigration.TransformMethod

PassThroughUserName ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

PassThroughUserName. It just looks for empty strings or null, and returns null, otherwise passing through the username with whitespace trimmed off both ends. Parameters are described at DataMigration.TransformMethod

ResolveLitmusTest ( String litmusTestName ) : LitmusTest

Given a Litmus Test name, returns the actual delegate method.

ResolvePostRowProcessor ( string postRowProcessorName ) : PostRowProcessor
ResolveTransformationMethod ( String xformName ) : TransformMethod

Given a transformation name, returns the actual delegate method.

UnixTimeToDateTime ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This is for making sure we only pass through valid dates or blanks. Parameters are described at DataMigration.TransformMethod

UseCreateDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

Uses the create date created earlier. Has a PreCondition that it comes after a transformMap with a destColumn of "CreateDateTime". Parameters are described at DataMigration.TransformMethod

UseLoadNum ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

Just returns the load number passed in. Parameters are described at DataMigration.TransformMethod

ValidateDateTolerateBlanks ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This is for making sure we only pass through valid dates or blanks. Parameters are described at DataMigration.TransformMethod

ValidateEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string

This function ensures that an email string exists, that it doesn't exceed our table length, and that it has an '@' sign in it. It throws BadRowExceptions if the provided email fails. Parameters are described at DataMigration.TransformMethod

Private Methods

Method Description
DateValidatorHelper ( string dateString ) : bool

Returns true for blank string, or parseable date, false otherwise. This is for detecting rows where the columns are messed up, and the dates are not where they're supposed to be.

GetDateHelper ( string expireDateString ) : DateTime?

GetDateHelper tries to parse date for you, and returns null if it can't.

ValidateEmailHelper ( string email ) : string

Helper function that checks various busines rules for emails.

Method Details

CalcCreateDate() public static method

Just generates the current datetime. Parameters are described at DataMigration.TransformMethod
public static CalcCreateDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

CalculateActiveFlag() public static method

CalculateActiveFlag looks at the Subscription Status column first; if value is Life it sets ActiveFlag to true, if Cancelled, then false, if neither, it checks the expiryDate. If it's parseble and in the past, it returns false. If none of these cases apply, it returns true. Parameters are described at DataMigration.TransformMethod
public static CalculateActiveFlag ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

CalculateExpireDate() public static method

CalculateExpireDate makes sure we can parse the expire date into a valid date, otherwise, it returns null. If user is a LIFE member, then they also get a null expire date. If the subStatus is CANCELLED, we set expire date to NOW. Technically this is unnecessary if this is an initial import; CalculateActiveFlag will set the subscription to inactive. But in the case of a subscription changing from Regular or Life to Cancelled, this is important as we rely on the offline recurring billing task to actually set the ActiveFlag to 0, and it does this by looking for expired subscriptions. Parameters are described at DataMigration.TransformMethod
public static CalculateExpireDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

DefaultToUSCountryId() public static method

This function attempts to get a valid country id for the row, but if the data is incomplete, or we don't have a row for it, will use US. Parameters are described at DataMigration.TransformMethod
public static DefaultToUSCountryId ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

EnsureEmailIsNotInMembersTable() public static method

Ensure the email does not exist in member table already. Parameters and return are described at DataMigration.LitmusTest
public static EnsureEmailIsNotInMembersTable ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

EnsureEmailUniqueWithinFeed() public static method

Ensures the email has not been seen in the feed so far. Parameters and return are described at DataMigration.LitmusTest
public static EnsureEmailUniqueWithinFeed ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

EnsureEmailWasntInFirstPass() public static method

Ensures that the email wasn't in there the first time we processed it.
public static EnsureEmailWasntInFirstPass ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

EnsureValidEmail() public static method

Ensures the email is properly formed. Parameters and return are described at DataMigration.LitmusTest
public static EnsureValidEmail ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

EnsureValidEmailPassThroughBlanks() public static method

public static EnsureValidEmailPassThroughBlanks ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

EnsureValidSubscriptionDates() public static method

The spreadsheet for BAM Magazine-only subscriptions has some rows that are messed up; there's no way we can process those rows. This litmus test in particular will try to parse out dates from three columns we have to have; they may be blank, but if they have non-blank non-date data in them, then we're hopelessly lost with processing this row.
public static EnsureValidSubscriptionDates ( ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, IList arguments ) : bool
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
arguments IList
return bool

MakeFullName() public static method

This function combines first and last name. Parameters are described at DataMigration.TransformMethod
public static MakeFullName ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

MemberIdFromEmail() public static method

This function is for the scenario where we want to create a subscription for the person, but not a row in the member table, if their email is already in the member table. We're going to look up their id from the member table, stick it in the Staging table, and therefore refrain from doing a member table insertion in post processing. Parameters are described at DataMigration.TransformMethod
public static MemberIdFromEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

OnlyPassThroughValidEmail() public static method

This function is for the scenario where we want to keep the row, even if it has an invalid email. If the email *is* invalid, we're going to null it out, though. Parameters are described at DataMigration.TransformMethod
public static OnlyPassThroughValidEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

PassThroughUserName() public static method

PassThroughUserName. It just looks for empty strings or null, and returns null, otherwise passing through the username with whitespace trimmed off both ends. Parameters are described at DataMigration.TransformMethod
public static PassThroughUserName ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

ResolveLitmusTest() public method

Given a Litmus Test name, returns the actual delegate method.
public ResolveLitmusTest ( String litmusTestName ) : LitmusTest
litmusTestName String Litmus test name.
return LitmusTest

ResolvePostRowProcessor() public method

public ResolvePostRowProcessor ( string postRowProcessorName ) : PostRowProcessor
postRowProcessorName string
return PostRowProcessor

ResolveTransformationMethod() public method

Given a transformation name, returns the actual delegate method.
public ResolveTransformationMethod ( String xformName ) : TransformMethod
xformName String Xform name.
return TransformMethod

UnixTimeToDateTime() public static method

This is for making sure we only pass through valid dates or blanks. Parameters are described at DataMigration.TransformMethod
public static UnixTimeToDateTime ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

UseCreateDate() public static method

Uses the create date created earlier. Has a PreCondition that it comes after a transformMap with a destColumn of "CreateDateTime". Parameters are described at DataMigration.TransformMethod
public static UseCreateDate ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

UseLoadNum() public static method

Just returns the load number passed in. Parameters are described at DataMigration.TransformMethod
public static UseLoadNum ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

ValidateDateTolerateBlanks() public static method

This is for making sure we only pass through valid dates or blanks. Parameters are described at DataMigration.TransformMethod
public static ValidateDateTolerateBlanks ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string

ValidateEmail() public static method

This function ensures that an email string exists, that it doesn't exceed our table length, and that it has an '@' sign in it. It throws BadRowExceptions if the provided email fails. Parameters are described at DataMigration.TransformMethod
public static ValidateEmail ( int loadNumber, ILookup>.IDictionary lookups, IExistence>.IDictionary existenceObjects, string>.IDictionary rowInProgress, IList arguments ) : string
loadNumber int
lookups ILookup>.IDictionary
existenceObjects IExistence>.IDictionary
rowInProgress string>.IDictionary
arguments IList
return string