Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Matches the requirements

  • Is easy to implement

  • Simplifies operations

Let’s do it!

Expand
titleBuild a custom configuration

See Custom Fields. We take the base File Reader and add Client ID List which will be a comma delimited list of the prefixes we want to filter on:

Expand
titleWe need to modify the matching algorithm - what do we start with?

The original file reader component is deliberately simple and uses /wiki/spaces/IXB/pages/3181903910 to make it more obvious how to modify the code to meet new needs. So this is what we are starting off with. We need this function to return true when the matching criteria are met.

https://bitbucket.org/interfaceware/fromfile/src/main/MatchRules.lua

Code Block
--What file extensions do we match?
local FileExtensionMatchSet={
   txt=true,
   log=true,
   hl7=true
}

function MatchFile(FileName)
   --local JustFileName = FILfilename(FileName)
   local Extn = FILextension(FileName)
   Extn = Extn:lower()
   return FileExtensionMatchSet[Extn]
end

expand
Expand
titleStart 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:

Code Block
function IdListAPPidList()
   local IdList = component.fields()["Client Id List"]
   IdList = IdList:split(",")
   for i = 1, #IdList do
      IdList[i] = IdList[i]:trimWS()
   end
end
Expand

These are the concepts we have used:

Expand
titleWe need to get the list of prefixsMake 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

Code Block
function 
MatchFile
APPmatchPrefix(Prefix, FileName)
   local 
IdList
Part = 
component.fields()["Client Id List"]
FileName:sub(1, #Prefix)
   trace(Part, Prefix)
   
IdList
return (Part =
IdList:split(","
= Id)
end

Concepts used:

expand

Image Removed

Expand
titleNow put all the matching logic together

We write the new MatchFile function based on the functions we have written already:

Code Block
function MatchFile(FileName)
   local IdList = APPidList()
   local JustFileName = FILfilename(FileName)
   for i = 1, #IdList do
      
trace
if APPmatchPrefix(IdList[i]
) local Id = IdList[i]:trimWS() local Part = JustFileName:sub(1, #Id)
, JustFileName) then 
  
trace(Id,
 
Part)
      return 
if
true;
(Part
 
==
 
Id)
 
then
 
return
 
true
 end
   end
end
Expand
titleMake it super simple to see the status

Concepts used:

Image Removed

Expand
titleMake the logging really intuitive
Expand
titleAvoid the bottlenecks of waiting on development resources
Expand
titleDo it fast!
Expand
titleNow find the next bottleneck, fix it and rinse-repeatCommit your changes, alter the component to run on the new commit and run it!