You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 13
Next »
This is good example how we can Eliminate bottlenecks with IguanaX. This is the problem. A large lab needs to have a file reading component which can feed files from different customers based on prefix of the file, i.e. some files start with JJ333, others XYZ etc. depending on the source.
How can we make a super streamlined component which:
Matches the requirements
Is easy to implement
Simplifies operations
Let’s do it!
Import a custom version of the file reader from git@bitbucket.org:interfaceware/file_tutorial.git
Create component from Git URL - leave the component as Editable
Copy paste the URL from here:
git@bitbucket.org:interfaceware/file_tutorial.git
This component generates some test files to make it easier to learn how to do a file reader.
Open the component in the translator with the customize link
See Customizing components to see how done if you have not done this before.
Build a custom configuration
See Custom Fields - We can add ClientList which will be a comma delimited list of the prefixes we want to filter on:
Let's extract the filename so we can look at it:
Change the matching to add in two lines:
function MatchFile(FileName)
local JustFileName = FILfilename(FileName)
trace(JustFileName);
return true;
end
Start the new MatchFile logic with getting the list of prefixes and removing white space
We’ll apply /wiki/spaces/IXB/pages/3181903910 and write this as a function:
function APPidList()
local IdList = component.fields()["ClientList"]
IdList = IdList:split(",")
for i = 1, #IdList do
IdList[i] = IdList[i]:trimWS()
end
return IdList
end
function MatchFile(FileName)
local IdList = APPidList();
return true
end
These are the concepts we have used:
Make a function which takes the ID and sees if the filename starts with it
So now we make a function to determine if the file name matches
function APPmatchPrefix(Prefix, FileName)
local Part = FileName:sub(1, #Prefix)
trace(Part, Prefix)
return (Part == Prefix)
end
Concepts used:
Now put all the matching logic together
We write the new MatchFile function based on the functions we have written already:
function MatchFile(FileName)
local IdList = APPidList()
local JustFileName = FILfilename(FileName)
for i = 1, #IdList do
if APPmatchPrefix(IdList[i], JustFileName) then
return true;
end
end
end
Concepts used:
Commit your changes, alter the component to run on the new commit and run it!