Skip to content

Commit

Permalink
Merge pull request #2262 from FrancoisJRenaud/ucrGeomListWithAes-data…
Browse files Browse the repository at this point in the history
…-type-restrictions-for-aes-receiver-bug

UcrGeomListWithAes data type restrictions for aes receiver bug (+ucrReceiver and ucrGeom)
  • Loading branch information
dannyparsons authored Nov 12, 2016
2 parents 0ab8131 + 8bf9d17 commit 62c2d3a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
5 changes: 4 additions & 1 deletion instat/UcrGeomListWithAes.vb
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ Public Class UcrGeomListWithParameters
End If
If clsCurrGeom.clsAesParameters(i).strIncludedDataTypes IsNot Nothing Then
lstAesParameterUcr(i).SetIncludedDataTypes(clsCurrGeom.clsAesParameters(i).strIncludedDataTypes)
ElseIf clsCurrGeom.clsAesParameters(i).strExcludedDataTypes IsNot Nothing Then
Else lstAesParameterUcr(i).RemoveIncludedMetadataProperty("class")
End If
If clsCurrGeom.clsAesParameters(i).strExcludedDataTypes IsNot Nothing Then
lstAesParameterUcr(i).SetExcludedDataTypes(clsCurrGeom.clsAesParameters(i).strExcludedDataTypes)
Else lstAesParameterUcr(i).RemoveExcludedMetadataProperty("class")
End If
Next
Else 'If the current geom has not been populated, then an error has been made in the code
Expand Down
2 changes: 1 addition & 1 deletion instat/ucrGeom.vb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Public Class ucrGeom
'Mandatory Aesthetics
clsgeom_boxplot.AddAesParameter("y", strIncludedDataTypes:={"numeric"}, bIsMandatory:=True)
'Optional Aesthetics
clsgeom_boxplot.AddAesParameter("x")
clsgeom_boxplot.AddAesParameter("x", strIncludedDataTypes:={"numeric", "factor"})
'Warning: When x is continuous, there needs to be a grouping variable... for example cut_width(x,0.25). In our setting, a factor column can be used. If group is empty, R will send a warning message and ignore the x variable (still labels x though).
'Task: Add a warning message in the front end to explain the necessity to specify group. Give suggestions on how to proceed (use an existing factor, create a new factor column using cut_width...). To do when front-end messages will have been sorted properly.
clsgeom_boxplot.AddAesParameter("group", strIncludedDataTypes:={"factor"})
Expand Down
28 changes: 25 additions & 3 deletions instat/ucrReceiver.vb
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,22 @@ Public Class ucrReceiver
Dim strTypes(strInclude.Count - 1) As String

Array.Copy(strInclude, strTypes, strInclude.Length)
'If the two previous lines where not added, the modification of value performed on strTypes was immediately performed on strInclude, then the argument passed into the function such as clsCurrGeom.clsAesParameters(i).strIncludedDataTypes in ucrGeomListWithAes.SetParameters would have been edited (i.e. quotes would have been added to the types names in the strIncludedDataTypes of the i'th AesParameter of the current Geom...), which we don't want !
For i = 0 To strInclude.Count - 1
strTypes(i) = Chr(34) & strInclude(i) & Chr(34)
Next
AddIncludedMetadataProperty("class", strTypes)
End Sub

Public Sub SetExcludedDataTypes(strExclude As String())
Dim strTypes(strExclude.Count - 1) As String

Array.Copy(strExclude, strTypes, strExclude.Length)
'If the two previous lines where not added, the modification of value performed on strTypes was immediately performed on strInclude, then the argument passed into the function such as clsCurrGeom.clsAesParameters(i).strExcludedDataTypes in ucrGeomListWithAes.SetParameters would have been edited (i.e. quotes would have been added to the types names in the strExcludedDataTypes of the i'th AesParameter of the current Geom...), which we don't want !
For i = 0 To strExclude.Count - 1
strExclude(i) = Chr(34) & strExclude(i) & Chr(34)
strTypes(i) = Chr(34) & strTypes(i) & Chr(34)
Next
AddExcludedMetadataProperty("class", strExclude)
AddExcludedMetadataProperty("class", strTypes)
End Sub

Public Sub AddIncludedMetadataProperty(strProperty As String, strInclude As String())
Expand Down Expand Up @@ -200,12 +205,29 @@ Public Class ucrReceiver

End Sub

Public Sub RemoveExcludedMetadataProperty(strProperty As String)
Dim iIncludeIndex As Integer

iIncludeIndex = lstExcludedMetadataProperties.FindIndex(Function(x) x.Key = strProperty)
If iIncludeIndex <> -1 Then
lstExcludedMetadataProperties.RemoveAt(iIncludeIndex)
End If
If Selector IsNot Nothing Then
Selector.LoadList()
End If
End Sub
Public Sub AddExcludedMetadataProperty(strProperty As String, strExclude As String())
'Dim iIncludeIndex As Integer
Dim iExcludeIndex As Integer

Dim kvpExcludeProperty As KeyValuePair(Of String, String())

If strProperty = "class" AndAlso strExclude.Contains(Chr(34) & "factor" & Chr(34)) Then
Array.Resize(strExclude, strExclude.Length + 1)
' WARNING: This is dependent on the way the metadata is displayed by the Instat object
' If this changes in Instat object, ordered factors will not be displayed
' TODO: Make this solid - should somehow use is.factor() in R
strExclude(strExclude.Length - 1) = Chr(34) & "ordered,factor" & Chr(34)
End If
kvpExcludeProperty = New KeyValuePair(Of String, String())(strProperty, strExclude)
iExcludeIndex = lstExcludedMetadataProperties.FindIndex(Function(x) x.Key = strProperty)
If iExcludeIndex <> -1 Then
Expand Down

0 comments on commit 62c2d3a

Please sign in to comment.