EDMI: Implement GetAttributeValue Method

This commit is contained in:
Jonathan Jenne 2022-02-04 13:39:16 +01:00
parent e57f3309e4
commit 1f6aded64d
3 changed files with 32 additions and 5 deletions

View File

@ -1,6 +1,5 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Services.EDMIService.Methods.IDB.GetAttributeValue
Namespace Methods.IDB.GetAttributeValue
Public Class GetAttributeValueMethod
@ -16,15 +15,28 @@ Namespace Methods.IDB.GetAttributeValue
LogAndThrow("ObjectId does not exist!")
End If
Dim oValue As Object
' TODO: Implement GetAttributeValue
Dim oSQL As String = $"SELECT TERM_VALUE FROM FNIDB_GET_VARIABLE_VALUE ({pData.ObjectId}, '{pData.AttributeName}', '{pData.User.Language}')"
Dim oTable As DataTable = DatabaseIDB.GetDatatable(oSQL)
If oTable Is Nothing Then
Throw New ApplicationException($"Error while getting value for Attribute '{pData.AttributeName}'!")
End If
If oTable.Rows.Count = 0 Then
Throw New KeyNotFoundException($"Attribute '{pData.AttributeName}' is empty!")
End If
Dim oRow As DataRow = oTable.Rows.Item(0)
Dim oValue As Object = oRow.Item("TERM_VALUE")
Return New GetAttributeValueResponse(pData.ObjectId, oValue)
Catch ex As Exception
Logger.Warn("Error occurred while getting attribute value!")
Logger.Error(ex)
Return New GetAttributeValueResponse(ex)
End Try
End Function
End Class
End Namespace

View File

@ -1,5 +1,19 @@
Namespace Methods.IDB.GetAttributeValue
Imports System.Runtime.Serialization
Imports DigitalData.Modules.ZooFlow.State
Namespace Methods.IDB.GetAttributeValue
Public Class GetAttributeValueRequest
<DataMember>
Public Property ObjectId As Long
<DataMember>
Public Property AttributeName As String
''' <summary>
''' User Importing the file
''' </summary>
''' <returns></returns>
<DataMember>
Public Property User As UserState
End Class
End Namespace

View File

@ -9,6 +9,7 @@ Namespace Methods.IDB.GetAttributeValue
<DataMember>
Public Property ObjectId As Long
<DataMember>
Public Property Value As Object
Public Sub New(pObjectId As Long, pValue As Object)