EDMIService: Turn Postprocessing Steps into list
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Patterns
|
||||
Imports DigitalData.Modules.ZooFlow.State
|
||||
@@ -23,7 +24,7 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
Patterns = New Patterns2(pLogConfig)
|
||||
Helpers = New Helpers(pLogConfig, pDatabase)
|
||||
|
||||
Logger.Info("Starting Automatic Indexing")
|
||||
Logger.Info("Initializing Automatic Indexing")
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
@@ -96,18 +97,32 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
|
||||
' Now we have a SQL command which only contains vector placeholders
|
||||
' Next, we execute the command to get our result
|
||||
Dim oValue = Database.GetScalarValueWithConnection(oFinalSQLCommand, oConnectionString)
|
||||
Dim oTable = Database.GetDatatableWithConnection(oFinalSQLCommand, oConnectionString)
|
||||
|
||||
If oValue Is Nothing Then
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("SQL for Automatic Index [{0}] returned an error. Exiting.")
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Logger.Info("Value for Automatic Index [{0}] is [{1}]", pAutomaticIndex.Name, oValue.ToString)
|
||||
Dim oValues As New List(Of String)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Try
|
||||
Dim oValue As String = oRow.ItemArray(0)?.ToString()
|
||||
If oValue IsNot Nothing AndAlso oValue.Length > 0 Then
|
||||
oValues.Add(oValue)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while parsing the Result from SQL Command. Skipping.")
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
Logger.Info("Value for Automatic Index [{0}] is [{1}]", pAutomaticIndex.Name, oValues.FirstOrDefault)
|
||||
|
||||
' TODO: Return multiple values
|
||||
Return New UserAttributeValue With {
|
||||
.Values = New List(Of String) From {oValue},
|
||||
.Values = oValues,
|
||||
.Name = pAutomaticIndex.Name,
|
||||
.Id = pAutomaticIndex.Id
|
||||
}
|
||||
|
||||
@@ -9,36 +9,35 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
Public Const TYPE_VBREPLACE = "VBREPLACE"
|
||||
Public Const TYPE_REGEXPRESSION = "REG. EXPRESSION"
|
||||
|
||||
Private PostprocessingSteps As DataTable
|
||||
Private PostprocessingSteps As List(Of PostProcessingStep)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pPostProcessingSteps As DataTable)
|
||||
Public Sub New(pLogConfig As LogConfig, pPostProcessingSteps As List(Of PostProcessingStep))
|
||||
MyBase.New(pLogConfig)
|
||||
PostprocessingSteps = pPostProcessingSteps
|
||||
|
||||
Logger.Info("Starting Postprocessing of Manual Indexes")
|
||||
Logger.Info("Initializing Postprocessing of Manual Indexes")
|
||||
End Sub
|
||||
|
||||
Public Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue)
|
||||
Logger.Debug("Start of Method [ApplyManualPostprocessing]")
|
||||
Dim oAttributes = pManualAttributes
|
||||
|
||||
Try
|
||||
Logger.Debug("Start of Method [ApplyManualPostprocessing]")
|
||||
|
||||
If PostprocessingSteps Is Nothing Then
|
||||
Logger.Debug("No Postprocessing steps found. Exiting.")
|
||||
Return oAttributes
|
||||
End If
|
||||
|
||||
For Each oProcessingRow As DataRow In PostprocessingSteps.Rows
|
||||
Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")
|
||||
For Each oStep As PostProcessingStep In PostprocessingSteps
|
||||
Dim oIndexId = oStep.IndexId
|
||||
Dim oIndex As UserAttributeValue = pManualAttributes.
|
||||
Where(Function(attr) attr.Id = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")).
|
||||
Where(Function(attr) attr.Id = oStep.IndexId).
|
||||
FirstOrDefault()
|
||||
Dim oIndexPosition = pManualAttributes.IndexOf(oIndex)
|
||||
|
||||
Logger.Info("Postprocessing Index [{0}]", oIndex.Name)
|
||||
|
||||
Dim oValues = GetPostprocessingValue(oIndex.Values, oProcessingRow)
|
||||
Dim oValues = GetPostprocessingValue(oIndex.Values, oStep)
|
||||
|
||||
Logger.Info("New Value for Index [{0}] is [{1}]", oIndex.Name, String.Join(",", oValues))
|
||||
|
||||
@@ -60,18 +59,17 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow) As List(Of String)
|
||||
Public Function GetPostprocessingValue(pValues As List(Of String), pStep As PostProcessingStep) As List(Of String)
|
||||
Logger.Debug("Start of Method [GetPostprocessingValue]")
|
||||
|
||||
Dim oType = pRow.Item("TYPE")
|
||||
Dim oResult As New List(Of String)
|
||||
|
||||
Logger.Debug("Type of Postprocessing is [{0}]", oType)
|
||||
Logger.Debug("Type of Postprocessing is [{0}]", pStep.Type)
|
||||
|
||||
Select Case oType
|
||||
Select Case pStep.Type
|
||||
Case TYPE_VBREPLACE
|
||||
Dim oFindString = pRow.Item("TEXT1")
|
||||
Dim oReplaceString = pRow.Item("TEXT2")
|
||||
Dim oFindString = pStep.Text1
|
||||
Dim oReplaceString = pStep.Text2
|
||||
|
||||
Logger.Debug("Replacing [{0}] with [{1}]", oFindString, oReplaceString)
|
||||
|
||||
@@ -87,9 +85,9 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
Next
|
||||
|
||||
Case TYPE_VBSPLIT
|
||||
Dim oSeparator As String = pRow.Item("TEXT1")
|
||||
Dim oSeparator As String = pStep.Text1
|
||||
Dim oSplitIndex As Integer = 0
|
||||
Integer.TryParse(pRow.Item("TEXT2"), oSplitIndex)
|
||||
Integer.TryParse(pStep.Text1, oSplitIndex)
|
||||
|
||||
Logger.Debug("Splitting String at Separator [{0}] and Index [{1}]", oSeparator, oSplitIndex)
|
||||
|
||||
@@ -108,7 +106,7 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
|
||||
Next
|
||||
|
||||
Case Else
|
||||
Logger.Warn("Postprocessing type [{0}] is not supported!", oType)
|
||||
Logger.Warn("Postprocessing type [{0}] is not supported!", pStep.Type)
|
||||
|
||||
End Select
|
||||
|
||||
|
||||
Reference in New Issue
Block a user