global mand_table
global opt_table
global num_opt_table_types
global num_mand_tables
global num_opt_tables
set tcl_path [ GuidoGetParamBufferValue [ GuidoExecServer GetTCLPath { } ] tclPath ]
source "$tcl_path/geology_db_mapper.tcl"
proc getDatabaseHandle {sessionType} {
set buffer [GuidoExecServer LegacyGetCurrentDatabaseHandle [subst {sessionType = "GeologyDatabase"}]]
return [GuidoGetParamBufferValue $buffer DatabaseHandle]
}
proc DB_MAX_TABFL_FN {} {
set buffer [GuidoExecServer acQuireGet_DB_MAX_TABFL {}]
return [GuidoGetParamBufferValue $buffer "DB_MAX_TABFL"]
}
set DB_MAX_TABFL [DB_MAX_TABFL_FN]
set dbType GeologyDatabase
set databaseHandle [getDatabaseHandle $dbType]
set unrequiredField {}
set num_unrequired_fields 0
set tableStructuresParam [GuidoExecServer "GetDatabaseTableStructures" {}]
set numTableTypes [GuidoGetParamBufferValue $tableStructuresParam num_table_types]
for {set idx 0} {$idx < $numTableTypes} {incr idx} {
set table_type "[GuidoGetParamBufferValue $tableStructuresParam table($idx).type]"
set table($table_type).num_mand_fields "[GuidoGetParamBufferValue $tableStructuresParam table($idx).num_mand_fields]"
upvar 0 table($table_type).num_mand_fields num_mand_fields
for {set jdx 0} {$jdx < $num_mand_fields} {incr jdx} {
set table($table_type).field($jdx).name "[GuidoGetParamBufferValue $tableStructuresParam table($idx).field($jdx).name]"
if {"[GuidoGetParamBufferValue $tableStructuresParam table($idx).field($jdx).required]" == "false"} {
set unrequired($num_unrequired_fields).name "[GuidoGetParamBufferValue $tableStructuresParam table($idx).field($jdx).name]"
lappend unrequiredField "[GuidoGetParamBufferValue $tableStructuresParam table($idx).field($jdx).name]"
incr num_unrequired_fields
}
}
}
proc databaseTypeCheck { obj type value} {
if {"$type" == "$value"} {
$obj setInputAllowed true
return 1
} else {
$obj setInputAllowed false
return 0
}
}
proc getTableMapping { node } {
set nodeLabel "[$node getLabelMLTKey]"
if {[$node isLeaf] ||
"$nodeLabel" == "Optional Fields"} {
set parent [$node getParent]
return [getTableMapping $parent]
} else {
set parent [$node getParent]
set parentLabel "[$parent getLabelMLTKey]"
return "[$node getCurrentValue]"
}
}
proc setTableMapping { node tablename validateName } {
set currentMapping "[getTableMapping $node]"
if {"$currentMapping" != "$tablename"} {
set changeMapping "true"
set count [$node getChildCount]
for {set idx 0} {$idx < $count} {incr idx} {
set child [$node getChildAt $idx]
if {[$child isLeaf]} {
if {"[$child getCurrentValue]" != ""} {
if {"[$child getCurrentValue]" != "[getNodeSurpacName $child]"} {
GuidoMessage message DB_CANNOT_CHANGE_TABLE_MAPPING "$tablename" "$currentMapping"
set changeMapping "false"
return 0
}
}
}
}
if {"$changeMapping" == "true"} {
$node setCurrentValue "$tablename"
$node setLabelNoMlt "[getNodeSurpacName $node] -> $tablename"
$node setMenuEnabled true
}
} elseif {"[getNodeSurpacName $node]" == "$tablename"} {
$node setCurrentValue "$tablename"
$node setLabelNoMlt "[getNodeSurpacName $node] -> $tablename"
$node setMenuEnabled false
}
return 1
}
proc getNodeSurpacName { node } {
set label "[$node getLabelMLTKey]"
set idx [string first " -> " $label]
if {$idx != -1} {
incr idx -1
return "[string range $label 0 $idx]"
} else {
return "$label"
}
}
proc getNodeaQuireName { node } {
set label "[$node getLabelMLTKey]"
set idx [string first " -> " $label]
if {$idx != -1} {
incr idx 4
return "[string range $label $idx [string length $label] ]"
} else {
return ""
}
}
proc getFieldMapping { node } {
if {[$node isLeaf]} {
set surpacName "[$node getLabelMLTKey]"
set parent [$node getParent]
set parentLabel "[$parent getLabelMLTKey]"
set pparent [$parent getParent]
return "[$node getCurrentValue]"
} else {
return "no mapping"
}
}
proc setFieldMapping { node tableName fieldName validateName } {
set parent [$node getParent]
set tableMapped [getTableMapping $parent]
set surpacTableName "[getNodeSurpacName $parent]"
if {"$surpacTableName" == "Optional Fields"} {
set parent [$parent getParent]
set surpacTableName "[getNodeSurpacName $parent]"
}
set surpacFieldName "[getNodeSurpacName $node]"
set return_code 1
if {"$tableMapped" != "$tableName"} {
set return_code [setTableMapping $parent "$tableName" true]
}
if {$return_code == 1} {
set nodeSurpacName "[getNodeSurpacName $node]"
if {"$fieldName" == ""} {
$node setCurrentValue ""
$node setLabelNoMlt "$nodeSurpacName"
} elseif {"[getFieldMapping $node]" != "$fieldName"} {
$node setCurrentValue "$fieldName"
$node setLabelNoMlt "$nodeSurpacName -> $fieldName"
$node setMenuEnabled true
} elseif {"$nodeSurpacName" == "$fieldName"} {
$node setCurrentValue "$fieldName"
$node setLabelNoMlt "$nodeSurpacName -> $fieldName"
$node setMenuEnabled true
}
return 1
} else {
GuidoMessage message DB_CANNOT_MAP_FIELD "$fieldName" "$tableMapped"
return 0
}
}
proc getSurpacFieldName { tableNode dbName } {
set count [$tableNode getChildCount]
for {set idx 0} {$idx < $count} {incr idx} {
set child [$tableNode getChildAt $idx]
if {[$child isLeaf]} {
if {"[getFieldMapping $child]" == "$dbName"} {
return "[getNodeSurpacName $child]"
}
} elseif {"[$child getLabelMLTKey]" == "Optional Fields"} {
return "[getSurpacFieldName $child $dbName]"
}
}
return ""
}
proc getNodeType { node } {
set tableMapped "[getTableMapping $node]"
set parent [$node getParent]
set folderName "[$parent getCurrentValue]"
if {[$node isLeaf]} {
if {"[$node getCurrentValue]" == ""} {
return "calculated"
} elseif {"$folderName" == "$tableMapped" ||
"$folderName" == "Optional Fields"} {
return "field"
} else {
return "unknown"
}
} else {
return "unknown"
}
}
proc getNodeHandle { node name nodeType } {
set idx [string first "-> " $name]
if {$idx == 0} {
set acQuireName [string tolower [string range $name 3 [string length $name]]]
set comp [string compare "[string tolower [getNodeaQuireName $node]]" $acQuireName]
} else {
set comp [string compare [string tolower [getNodeSurpacName $node]] [string tolower $name]]
}
if {"$comp" == "0"} {
if {"$nodeType" == "leaf" && [$node isLeaf]} {
return $node
} elseif {"$nodeType" == "branch" && ![$node isLeaf]} {
return $node
}
}
if {![$node isLeaf]} {
set childCount [$node getChildCount]
for {set idx 0} {$idx < $childCount} {incr idx} {
set child [$node getChildAt $idx]
set n [getNodeHandle $child $name $nodeType]
if {$n != 0} {
return $n
}
}
}
return 0
}
proc setNodeInformation { node } {
set selectionType "[getNodeType $node]"
if {"$selectionType" == "field"} {
} elseif {"$selectionType" == "calculated"} {
set fieldName "[$node getLabelMLTKey]"
set tableMapped "[getTableMapping $node]"
set parent [$node getParent]
set pparent [$parent getParent]
set surpacTableName "[getNodeSurpacName $pparent]"
set saveCalcFunction "true"
if {"$fieldName" == "hole_path" ||
"$fieldName" == "x_from" ||
"$fieldName" == "y_from" ||
"$fieldName" == "z_from" ||
"$fieldName" == "x_to" ||
"$fieldName" == "y_to" ||
"$fieldName" == "y_to" ||
"$fieldName" == "x" ||
"$fieldName" == "y" ||
"$fieldName" == "z"} {
set surpacTableName "[getNodeSurpacName $parent]"
}
if {"$saveCalcFunction" == "true"} {
}
}
}
proc saveSelectedNodeInfo { tree } {
set currentNodeSelected [$tree getSelectedNode]
if {"$currentNodeSelected" != ""} {
if {[$currentNodeSelected isLeaf]} {
setNodeInformation $currentNodeSelected
}
}
return 1
}
GuidoPopupMenu removeMappingMenu {
GuidoMenuItem removeMappingItem {
-label "Remove mapping"
}
}
GuidoPopupMenu removeMappingMenu2 {
GuidoMenuItem removeMappingItem2 {
-label "Remove mapping"
}
GuidoMenuItem renameItem {
-label "Rename"
}
}
proc createTableStructure { table_type surpac_table_name db_table_name } {
global dbType
GuidoTreeBranch "table($surpac_table_name)" {
-label_no_mlt "$surpac_table_name"
-default $db_table_name
global "table($table_type).num_mand_fields"
upvar 0 table($table_type).num_mand_fields num_mand_fields
for {set idx 0} {$idx < $num_mand_fields} {incr idx} {
global "table($table_type).field($idx).name"
upvar 0 table($table_type).field($idx).name field_name
set fieldParams [GuidoExecServer "GetFieldInformation" [subst {DatabaseType = $dbType DbTableName = "$db_table_name" SurpacTableName = "$surpac_table_name" DbFieldName = "$field_name" SurpacFieldName = "$field_name" } ]]
if {[GuidoGetParamBufferValue $fieldParams status] != -1} {
if {"[GuidoGetParamBufferValue $fieldParams mandatoryCalculated]" == "true"} {
continue
}
}
if {$table_type == "DB_DISCRETE_SAMPLE_TABLE" ||
$table_type == "DB_COLLAR_TABLE" ||
"[isUnrequiredField $field_name]" == "false"} {
GuidoTreeLeaf "field($surpac_table_name)$idx" {
-label_no_mlt "$field_name"
-default "$field_name"
-menu_enabled false
}
}
}
GuidoTreeBranch "opt_fields($surpac_table_name)" {
-label "Optional Fields"
-default "Optional Fields"
}
}
upvar 0 "table($surpac_table_name)" branch_node
set disable_table_menu true
global num_opt_table_types
for {set idx 0} {$idx < $num_opt_table_types} {incr idx} {
global "opt_table_types($idx).type"
upvar 0 opt_table_types($idx).type opt_type
if {"$opt_type" == "$table_type"} {
set disable_table_menu false
break
}
}
if {"$disable_table_menu" == "true"} {
$branch_node setMenuEnabled false
}
return $branch_node
}
proc fieldCount { tableNode } {
set surpacTableName "[getNodeSurpacName $tableNode]"
set fieldParams [GuidoExecServer acQuireFieldCount [subst {table = $surpacTableName} ]]
set count "[GuidoGetParamBufferValue $fieldParams number]"
if {$count == "0"} {
set parent [$tableNode getParent]
if {[$parent getLabelMLTKey] == "Interval Tables"} {
set count 9
} elseif {[$parent getLabelMLTKey] == "Point Tables"} {
set count 5
}
}
set children [$tableNode getChildCount]
for {set idx 0} {$idx < $children} {incr idx} {
set child [$tableNode getChildAt $idx]
if {![$child isLeaf]} {
set children [$child getChildCount]
for {set idx 0} {$idx < $children} {incr idx} {
set gchild [$child getChildAt $idx]
set surpacName "[getNodeSurpacName $gchild]"
if {[string first "*" $surpacName] != -1} {
incr count
}
}
} else {
set surpacName "[getNodeSurpacName $child]"
if {[string first "*" $surpacName] != -1} {
incr count
}
}
}
return $count
}
proc addField { node tablename surpacFieldName dbFieldName validateName } {
set tableMapped "[getTableMapping $node]"
set parent [$node getParent]
if {"$validateName" == "true"} {
set surpacFieldName [string tolower $surpacFieldName]
regsub -all {[^A-z0-9\_\-\%]} $surpacFieldName _ surpacFieldName
}
if {"$tableMapped" == "$tablename" ||
"[getNodeSurpacName $parent]" == "$tablename"} {
if {"$dbFieldName" == ""} {
set mapping "$surpacFieldName"
} elseif {"$surpacFieldName" != "$dbFieldName"} {
set mapping "$surpacFieldName -> $dbFieldName"
} else {
set mapping "$dbFieldName"
}
set leafName "$tablename-$surpacFieldName"
GuidoTreeLeaf "$leafName" {
-label_no_mlt "$mapping"
-default "$dbFieldName"
}
upvar 0 "$leafName" field
$node addChild $field
return "$surpacFieldName"
} else {
GuidoMessage message DB_CANNOT_ADD_FIELD "$surpacFieldName" "$tableMapped"
return 0
}
return "$surpacFieldName"
}
proc getTableNodeByTableType { table_type } {
global num_mand_tables
for {set idx 0} {$idx < $num_mand_tables} {incr idx} {
global mand_table($idx).type ttype
upvar 0 mand_table($idx).type ttype
if {"$table_type" == "$ttype"} {
global mand_table($idx).node_handle
upvar 0 mand_table($idx).node_handle nhandle
return $nhandle
}
}
global num_opt_tables
for {set idx 0} {$idx < $num_opt_tables} {incr idx} {
global opt_table($idx).type opt_table_type
upvar 0 opt_table($idx).type opt_table_type
if {"$table_type" == "$opt_table_type"} {
global opt_table($idx).node_handle
upvar 0 opt_table($idx).node_handle nhandle
return $nhandle
}
}
return 0
}
proc getOptTableNodeByTableType { table_type } {
global num_opt_table_types
for {set idx 0} {$idx < $num_opt_table_types} {incr idx} {
global opt_table_types($idx).type
upvar 0 opt_table_types($idx).type opt_types
if {"$table_type" == "$opt_types"} {
global opt_table_types($idx).node_handle
upvar 0 opt_table_types($idx).node_handle nhandle
return $nhandle
}
}
return 0
}
proc getOptTableTypeByNodeName { node_name } {
global num_opt_table_types
for {set idx 0} {$idx < $num_opt_table_types} {incr idx} {
global opt_table_types($idx).name
upvar 0 opt_table_types($idx).name opt_type_name
if {"$node_name" == "$opt_type_name"} {
global opt_table_types($idx).type
upvar 0 opt_table_types($idx).type optable_type
return $optable_type
}
}
return DB_UNKNOWN_TABLE
}
proc addOptionalFields { tree } {
global dbType
$tree setRefreshEnabled false
set mappingParams [GuidoExecServer "acQuireDatabaseMappings" {}]
set databaseName "[GuidoGetParamBufferValue $mappingParams DatabaseName]"
set numTables [GuidoGetParamBufferValue $mappingParams NumTables]
for {set idx 0} {$idx < $numTables} {incr idx} {
set tableName "[GuidoGetParamBufferValue $mappingParams TableName($idx)]"
set tableType [GuidoGetParamBufferValue $mappingParams TableType($idx)]
set acQuireTableName "[GuidoGetParamBufferValue $mappingParams DbName($idx)]"
set numFields [GuidoGetParamBufferValue $mappingParams NumFields($idx)]
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes" && $tableType == "DB_DISCRETE_SAMPLE_TABLE"} {
continue;
}
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import samples" && $tableType != "DB_DISCRETE_SAMPLE_TABLE"} {
continue;
}
set node [getTableNodeByTableType $tableType]
if {$node == 0} {
set node [getOptTableNodeByTableType $tableType]
if {$node != 0} {
set newnode [createTableStructure $tableType $tableName $tableName]
$newnode setLabelNoMlt $tableName
$node addChild $newnode
set node $newnode
}
}
if {$node != 0} {
set optNode [getNodeHandle $node "Optional Fields" "branch"]
for {set idx2 0} {$idx2 < $numFields} {incr idx2} {
set fieldName "[GuidoGetParamBufferValue $mappingParams Table($idx)_FieldName($idx2)]"
set databaseName "[GuidoGetParamBufferValue $mappingParams Table($idx)_DbName($idx2)]"
set fieldNode [getNodeHandle $node $fieldName "leaf"]
if {$fieldNode == 0} {
addField $optNode $tableName $fieldName $fieldName false
}
}
}
}
$tree setRefreshEnabled true
return 1
}
proc getDatabaseMappings { realDatabaseStructure tree } {
global dbType
$tree setRefreshEnabled false
set mappingParams [GuidoExecServer "acQuireDatabaseMappings" {}]
set databaseName "[GuidoGetParamBufferValue $mappingParams DatabaseName]"
set numTables [GuidoGetParamBufferValue $mappingParams NumTables]
for {set idx 0} {$idx < $numTables} {incr idx} {
set tableName "[GuidoGetParamBufferValue $mappingParams TableName($idx)]"
set tableType [GuidoGetParamBufferValue $mappingParams TableType($idx)]
set acQuireTableName "[GuidoGetParamBufferValue $mappingParams DbName($idx)]"
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes" && $tableType == "DB_DISCRETE_SAMPLE_TABLE"} {
continue;
}
if { [string tolower [ GuidoSSIOption get "current function name"]] != "acquire import drillholes" && $tableType != "DB_DISCRETE_SAMPLE_TABLE"} {
continue;
}
set numFields [GuidoGetParamBufferValue $mappingParams NumFields($idx)]
set rootNode [$tree getRootNode]
set node [getNodeHandle $rootNode $tableName "branch"]
set acQuireRootNode [$realDatabaseStructure  getRootNode]
set realNode [getNodeHandle $acQuireRootNode $acQuireTableName "branch"]
if {"$realNode" != "0"} {
for {set idx2 0} {$idx2 < $numFields} {incr idx2} {
set fieldName "[GuidoGetParamBufferValue $mappingParams Table($idx)_FieldName($idx2)]"
set acQuireFieldName "[GuidoGetParamBufferValue $mappingParams Table($idx)_DbName($idx2)]"
set fieldNode [getNodeHandle $node $fieldName "leaf"]
set leafNode [getNodeHandle $realNode $acQuireFieldName "leaf"]
if {"$leafNode" != "0"} {
setFieldMapping $fieldNode $acQuireTableName $acQuireFieldName false
}
}
}
}
$tree setRefreshEnabled true
return 1
}
proc DragDropped {event tree} {
global removeMappingMenu2
if {[$tree getLastDropNode] == ""} {
return
}
set dropNode [$tree getLastDropNode]
set data [$event getData]
if {[$dropNode isLeaf]} {
if {[$data isLeaf]} {
set dropNodeParent [$dropNode getParent]
set dropNodePParent [$dropNodeParent getParent]
set table [$data getParent]
set tablename [$table getLabelMLTKey]
set mapName [$data getLabelMLTKey]
set rcode [setFieldMapping $dropNode $tablename $mapName true]
if {$rcode == 1} {
set fName [$data getLabelMLTKey]
$dropNode setLabelNoMlt "[getNodeSurpacName $dropNode] -> $fName"
$dropNode setMenuEnabled true
}
} else {
GuidoMessage message "Cannot map field name because data is not a table field"
}
} else {
set folderName "[$dropNode getLabelMLTKey]"
if {"$folderName" == "Mandatory Tables" ||
"$folderName" == "Optional Tables" ||
"$folderName" == "Surpac Database"} {
return
}
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes"} {
if {"$folderName" == "Discrete Tables"} {
return;
}
} else {
set parent [$dropNode getParent]
set parentName "[$parent getLabelMLTKey]"
if {![$data isLeaf] && "$folderName" != "Discrete Tables" && "$parentName" != "Discrete Tables"} {
return;
}
}
set parent [$dropNode getParent]
set parentName "[$parent getLabelMLTKey]"
if {![$data isLeaf]} {
set tableName "[$data getLabelMLTKey]"
set tNode 0
set tableType [getOptTableTypeByNodeName $folderName]
if {"$tableType" != "DB_UNKNOWN_TABLE"} {
set validParam [GuidoExecServer "ValidTableFieldName" [subst {dbname = "$tableName"}]]
if {"[GuidoGetParamBufferValue $validParam validName]" == "false"} {
GuidoMessage message DB_CANNOT_MAP_INVALID_TBL_NAME "$tableName"
} else {
set useName [string tolower $tableName]
set buffer [GuidoExecServer DatabaseTableBrowser {isEditable = "false" DatabaseHandle = "GEOLOGY"}]
for {set jdx 1} {1} {incr jdx} {
set exists 0
for {set idx 0} {1} {incr idx} {
if {[catch {
set name [GuidoGetParamBufferValue $buffer TableName($idx)]
if {$name == $useName} {
set exists 1
break
}
} err]} {
break;
}
}
if {$exists == 0} {
if {[getNodeHandle [$tree getRootNode] $useName "branch"] == 0 &&
[getNodeHandle [$tree getRootNode] $useName* "branch"] == 0} {
break
}
}
set useName [string tolower $tableName]$jdx
}
set tNode [createTableStructure $tableType $tableName $tableName]
$tNode setLabelNoMlt $tableName
$dropNode addChild $tNode
$tNode setLabelNoMlt "[string tolower $useName]* -> $tableName"
$tNode setMenuEnabled true
$tNode setMenu $removeMappingMenu2
}
} elseif {"$folderName" != "Optional Fields" &&
"$folderName" != "Optional Tables"} {
set currentMapping "[getNodeaQuireName $dropNode]"
if {"$currentMapping" != "$tableName" && $currentMapping != ""} {
GuidoMessage message DB_CANNOT_CHANGE_TABLE_MAPPING "$tableName" "$currentMapping"
} else {
setTableMapping $dropNode $tableName true
set tNode $dropNode
}
}
if {$tNode != 0} {
set children [$data getChildCount]
set optNode [getNodeHandle $tNode "Optional Fields" "branch"]
if {$optNode != 0} {
for {set idx 0} {$idx < $children} {incr idx} {
set child [$data getChildAt $idx]
if {[$child isLeaf]} {
set fName "[$child getLabelMLTKey]"
set fNode [getNodeHandle $tNode $fName "leaf"]
if {$fNode == 0} {
if {"$fName" == "HOLEID"} {
set fNode [getNodeHandle $tNode "hole_id" "leaf"]
} elseif {"$fName" == "East"} {
set fNode [getNodeHandle $tNode "x" "leaf"]
} elseif {"$fName" == "North"} {
set fNode [getNodeHandle $tNode "y" "leaf"]
} elseif {"$fName" == "RL"} {
set fNode [getNodeHandle $tNode "z" "leaf"]
} elseif {"$fName" == "Depth"} {
set fNode [getNodeHandle $tNode "max_depth" "leaf"]
} elseif {"$fName" == "From"} {
set fNode [getNodeHandle $tNode "depth_from" "leaf"]
} elseif {"$fName" == "To"} {
set fNode [getNodeHandle $tNode "depth_to" "leaf"]
} elseif {"$fName" == "SAMPLEID"} {
set fNode [getNodeHandle $tNode "sampid" "leaf"]
if {$fNode == 0} {
set fNode [getNodeHandle $tNode "samp_id" "leaf"]
}
}
}
if {$fNode != 0} {
set rcode [setFieldMapping $fNode $tableName $fName true]
if {$rcode == 1} {
$fNode setLabelNoMlt "[getNodeSurpacName $fNode] -> $fName"
$fNode setMenuEnabled true
}
} else {
set fNode [getNodeHandle $tNode "-> $fName" "leaf"]
if {$fNode == 0} {
global DB_MAX_TABFL
if {[fieldCount $tNode] >= $DB_MAX_TABFL} {
GuidoMessage warning DB_AQUIRE_TOO_MANY_FIELDS $fName [getNodeSurpacName $tNode] $DB_MAX_TABFL
} else {
set sName "[addField $optNode $tableName $fName $fName true]"
set fNode [getNodeHandle $optNode $sName "leaf"]
$fNode setLabelNoMlt "$sName* -> $fName"
$fNode setMenuEnabled true
$fNode setMenu $removeMappingMenu2
}
}
}
}
}
}
}
} else {
if {"$folderName" == "Optional Fields"} {
set fName [$data getLabelMLTKey]
set fNode [getNodeHandle $dropNode "-> $fName" "leaf"]
if {$fNode == 0} {
set fNode [getNodeHandle $dropNode $fName "leaf"]
if {$fNode == 0} {
global DB_MAX_TABFL
if {[fieldCount $parent] >= $DB_MAX_TABFL} {
GuidoMessage warning DB_AQUIRE_TOO_MANY_FIELDS $fName [getNodeSurpacName $parent] $DB_MAX_TABFL
} else {
set table [$data getParent]
set tableName "[$table getLabelMLTKey]"
set return_code [setTableMapping $parent "$tableName" true]
if {$return_code == 1} {
set sName "[addField $dropNode [getNodeSurpacName $parent] $fName $fName true]"
set fNode [getNodeHandle $dropNode $sName "leaf"]
$fNode setLabelNoMlt "$sName* -> $fName"
$fNode setMenu $removeMappingMenu2
$fNode setMenuEnabled true
} else {
set table [$dropNode getParent]
set tableName "[getNodeaQuireName $table]"
GuidoMessage message DB_CANNOT_MAP_FIELD "$fName" "$tableName"
}
}
} else {
set table [$data getParent]
set tableName "[$table getLabelMLTKey]"
set return_code [setTableMapping $parent "$tableName" true]
if {$return_code == 1} {
$fNode setLabelNoMlt "[getNodeSurpacName $fNode] -> $fName"
$fNode setMenuEnabled true
} else {
GuidoMessage message DB_CANNOT_MAP_FIELD "$fName" "$tableName"
}
}
}
}
}
}
}
proc isUnrequiredField { node_name } {
global num_unrequired_fields
for {set idx 0} {$idx < $num_unrequired_fields} {incr idx} {
global unrequired($idx).name
upvar 0 unrequired($idx).name unreq_fld
if {"$node_name" == "$unreq_fld"} {
return true
}
}
return false
}
proc removeMapping { tree } {
set selectedNode [$tree getSelectedNode]
set surpacName "[getNodeSurpacName $selectedNode]"
$selectedNode setLabelNoMlt "$surpacName"
$selectedNode setCurrentValue $surpacName
if {[string first "*" $surpacName] != -1} {
set parent [$selectedNode getParent]
$parent removeChild $selectedNode
}
if {![$selectedNode isLeaf]} {
set count [$selectedNode getChildCount]
for {set idx 0} {$idx < $count} {incr idx} {
set child [$selectedNode getChildAt $idx]
if {![$child isLeaf]} {
if {"[$child getCurrentValue]" == "Optional Fields"} {
set count2 [$child getChildCount]
for {set idx2 0} {$idx2 < $count2} {incr idx2} {
set child2 [$child getChildAt $idx2]
if {[$child2 isLeaf]} {
set surpacName "[getNodeSurpacName $child2]"
$child2 setLabelNoMlt "$surpacName"
$child2 setCurrentValue $surpacName
$child2 setMenuEnabled true
if {[string first "*" $surpacName] != -1} {
$child removeChild $child2
incr count2 -1
incr idx2 -1
}
}
}
}
} else {
set surpacName "[getNodeSurpacName $child]"
$child setLabelNoMlt "$surpacName"
$child setCurrentValue $surpacName
$child setMenuEnabled true
if {[string first "*" $surpacName] != -1} {
$selectedNode removeChild $child
incr count -1
incr idx -1
}
}
}
}
}
global busy
set busy 0
proc unBusy {} {
global busy
set busy 0
}
proc connect {connected realDatabaseStructure ddbStructure} {
global busy
if {$busy == 0} {
set busy 1
set buffer [GuidoExecServer acQuireConnect {}]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 0} {
$connected setCurrentValue true
$realDatabaseStructure installTreeLoader acQuireDatabaseBrowser
getDatabaseMappings $realDatabaseStructure $ddbStructure
}
}
}
global overWriteSel
set overWriteSel false
proc overwriteAction { formHandle formStatus } {
if {"$formStatus" == "yes"} {
global overWriteSel
set overWriteSel true
$formHandle hide
$formHandle destroy
} elseif {"$formStatus" == "no"} {
global overWriteSel
set overWriteSel false
$formHandle hide
$formHandle destroy
} else {
$formHandle setStatus $formStatus
}
}
proc overwrite { fileName } {
GuidoForm overwriteForm {
-help_id 203
-label "Verify creation of file"
-tip MSC_SAVE_OVERWRITE_FILE_TIP
-layout BoxLayout Y_AXIS
GuidoPanel Main_Panel {
-layout BoxLayout Y_AXIS
-border etched true
GuidoPanel Spacing_Panel {
-layout BoxLayout X_AXIS
GuidoLabel spacer1 {
-width 0.5
}
GuidoLabel Warning_Label {
-icon "icons/Warning.gif"
}
GuidoLabel spacer2 {
-width 0.5
}
GuidoPanel Warning_Panel {
-layout BoxLayout Y_AXIS
GuidoLabel spacer3 {
-height 0.5
}
GuidoLabel Overwrite_Label {
-label "You are about to overwrite the file:"
}
}
}
GuidoPanel Filename_Panel {
-layout FlowLayout
GuidoLabel Filename_Label {
-label "BLANK_LINE"
-font_style bold
}
GuidoLabel spacer3 {
-height 0.7
}
}
GuidoLabel Continue_Label {
-label "Select YES to overwrite the file or NO to cancel this operation."
}
GuidoLabel spacer4 {
-height 0.2
}
}
GuidoPanel overwriteButtonPanel {
-layout BorderLayout
GuidoPanel b0 {
-position Center
GuidoLabel spacer4 {
-height 1.2
}
}
GuidoPanel b1 {
-layout FlowLayout left
-position West
GuidoButton helpButton {
-caption " "
-icon "icons/16/help.png"
-action valueChanged {[overwriteAction $overwriteForm "help"] }
}
}
GuidoPanel b2 {
-layout FlowLayout left
-position East
GuidoButton okButton {
-caption "Yes"
-height 1
-display_length 10
-icon "icons/16/activate.png"
-action valueChanged {[overwriteAction $overwriteForm "yes"]}
}
GuidoButton cancelButton {
-caption "No"
-height 1
-display_length 10
-icon "icons/cancel.png"
-action valueChanged {[overwriteAction $overwriteForm "no"]}
}
}
}
}
$Filename_Label setCurrentValue $fileName
$overwriteForm show modal
return 1
}
proc saveSelections {selection} {
global overWriteSel
global busy
if {$busy == 0} {
set busy 1
set buffer [GuidoExecServer acQuireSelectionFileExists [subst {file = $selection}]]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 1} {
set fileName [GuidoGetParamBufferValue $buffer file]
overwrite $fileName
if {$overWriteSel == "true"} {
GuidoExecServer acQuireSaveSelections [subst {file = $selection}]
}
} else {
GuidoExecServer acQuireSaveSelections [subst {file = $selection}]
}
}
}
proc loadSelections {connected selection realDatabaseStructure ddbStructure} {
global busy
if {$busy == 0} {
set busy 1
set buffer [GuidoExecServer acQuireLoadSelections [subst {file = $selection}]]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 0} {
$connected setCurrentValue true
$realDatabaseStructure installTreeLoader acQuireDatabaseBrowser
getDatabaseMappings $realDatabaseStructure $ddbStructure
}
}
}
proc getNodeHandleMapped { node name nodeType } {
set comp [string compare [string tolower [getNodeaQuireName $node]] [string tolower "$name"]]
if {"$comp" == "0"} {
if {"$nodeType" == "leaf" && [$node isLeaf]} {
return $node
} elseif {"$nodeType" == "branch" && ![$node isLeaf]} {
return $node
}
}
if {![$node isLeaf]} {
set childCount [$node getChildCount]
for {set idx 0} {$idx < $childCount} {incr idx} {
set child [$node getChildAt $idx]
set n [getNodeHandleMapped $child $name $nodeType]
if {$n != 0} {
return $n
}
}
}
return 0
}
proc getAliases {tree acQuireTree} {
global busy
if {$busy == 0} {
set busy 1
set buffer [GuidoExecServer acQuireGetAliases {}]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 0} {
set acQuireRootNode [$acQuireTree getRootNode]
set rootNode [$tree getRootNode]
set numAliases [GuidoGetParamBufferValue $buffer numAliases]
for {set idx 0} {$idx < $numAliases} {incr idx} {
set alias "[GuidoGetParamBufferValue $buffer Alias($idx)]"
set acQuireTableName "[string range $alias 0 [expr [string first "." $alias] - 1]]"
set acQuireFieldName "[string range $alias [expr [string first "." $alias] + 1] [expr [string first "<" $alias] - 1]]"
set surpacFieldName "[string range $alias [expr [string first ">" $alias] + 1] [string length $alias]]"
set tableNode [getNodeHandle $acQuireRootNode $acQuireTableName "branch"]
if {$tableNode != 0} {
set fieldNode [getNodeHandle $tableNode $acQuireFieldName "leaf"]
if {$fieldNode != 0} {
set acQuireFieldName [$fieldNode getCurrentValue]
set node [getNodeHandleMapped $rootNode $acQuireTableName "branch"]
if {$node != 0} {
set leafNode [getNodeHandle $node $surpacFieldName "leaf"]
if {$leafNode != 0} {
$leafNode setLabelNoMlt "[getNodeSurpacName $leafNode] -> $acQuireFieldName"
$leafNode setMenuEnabled true
}
} else {
set node [getNodeHandle $rootNode $acQuireTableName "branch"]
if {$node != 0} {
set leafNode [getNodeHandle $node $surpacFieldName "leaf"]
if {$leafNode != 0} {
$node setLabelNoMlt "[getNodeSurpacName $node] -> $acQuireTableName"
$node setMenuEnabled true
$leafNode setLabelNoMlt "[getNodeSurpacName $leafNode] -> $acQuireFieldName"
$leafNode setMenuEnabled true
}
}
}
}
}
}
}
}
}
GuidoTree ddbStructure {
-action dropTarget {[DragDropped GUIDO_EVENT $ddbStructure]}
-branch_menu $removeMappingMenu
-editable false
-leaf_menu $removeMappingMenu
-label "Surpac Database"
}
proc renameNodeAction { formHandle formStatus field } {
global ddbStructure
if {"$formStatus" == "rename"} {
set selectedNode [$ddbStructure getSelectedNode]
set newName "[$field getCurrentValue]"
set dbName "[$selectedNode getCurrentValue]"
set mapping "$newName* -> $dbName"
$selectedNode setLabelNoMlt "$mapping"
$formHandle hide
$formHandle destroy
} elseif {"$formStatus" == "cancel"} {
$formHandle hide
$formHandle destroy
} else {
$formHandle setStatus $formStatus
}
}
proc renameNode { } {
GuidoForm renameNodeForm {
-help_id 778
-label "Rename a field or table"
-layout BoxLayout Y_AXIS
GuidoPanel outerRenameNodePanel {
-layout CentreLineLayout
-border etched true
GuidoField newNameFld {
-default ""
-display_length 15
-format none
-label "New name"
-max_length 36
-null false
}
}
GuidoPanel renameButtonPanel {
-layout FlowLayout Left
GuidoButton helpButton {
-caption " "
-icon "icons/16/help.png"
-action valueChanged {[renameNodeAction $renameNodeForm "help" "$newNameFld"] }
}
GuidoButton renameButton {
-caption "Rename"
-display_length 10
-icon "icons/16/edit.png"
-action valueChanged {[renameNodeAction $renameNodeForm "rename" "$newNameFld"]}
}
GuidoButton cancelButton {
-caption "Cancel"
-display_length 10
-icon "icons/cancel.png"
-action valueChanged {[renameNodeAction $renameNodeForm "cancel" "$newNameFld"]}
}
}
GuidoFiller f {
-height 0.5
}
}
$renameNodeForm show modal
return 1
}
proc init { ddbScroll realDatabaseStructure} {
global ddbStructure
set dbType GeologyDatabase
set databaseHandle [getDatabaseHandle $dbType]
global removeMappingItem
$removeMappingItem setActionCallback mouseReleased {[removeMapping $ddbStructure]}
global removeMappingItem2
$removeMappingItem2 setActionCallback mouseReleased {[removeMapping $ddbStructure]}
global renameItem
$renameItem setActionCallback mouseReleased {[renameNode]}
$realDatabaseStructure installTreeLoader acQuireDatabaseBrowser
$realDatabaseStructure setEditable false
set second "[[$realDatabaseStructure getRootNode] getChildCount]"
global num_mand_tables
global num_opt_table_types
global opt_table
global opt_table_type
global mand_table
global num_opt_tables
if {$num_mand_tables != 0 || $num_opt_tables != 0 || $num_opt_table_types != 0} {
set root_node [$ddbStructure getRootNode]
if {$num_mand_tables > 0} {
GuidoTreeBranch mandatory_tables {
-label "Mandatory Tables"
-default "Mandatory Tables"
-menu_enabled false
}
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes"} {
$root_node addChild $mandatory_tables
for {set idx 0} {$idx < $num_mand_tables} {incr idx} {
global mand_table($idx).type
upvar 0 mand_table($idx).type ttype
global mand_table($idx).name tname
upvar 0 mand_table($idx).name tname
set mtable [createTableStructure $ttype $tname $tname]
$mandatory_tables addChild $mtable
global mand_table($idx).node_handle
set mand_table($idx).node_handle $mtable
}
}
}
if {$num_opt_tables > 0 || $num_opt_table_types > 0} {
GuidoTreeBranch optional_tables {
-label "Optional Tables"
-default "Optional Tables"
-menu_enabled false
}
$root_node addChild $optional_tables
for {set idx 0} {$idx < $num_opt_table_types} {incr idx} {
global opt_table_types($idx).name opt_table_types_name
upvar 0 opt_table_types($idx).name opt_table_types_name
if { [string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes" && $opt_table_types_name != "Discrete Tables" ||
[string tolower [ GuidoSSIOption get "current function name"]] != "acquire import drillholes" && $opt_table_types_name == "Discrete Tables"} {
GuidoTreeBranch opt_table_types_$idx {
-label "$opt_table_types_name"
-default "DB_OPTIONAL_TABLE_TYPE"
-menu_enabled false
}
upvar 0 opt_table_types_$idx table
$optional_tables addChild $table
global opt_table_types($idx).node_handle
set opt_table_types($idx).node_handle $table
}
}
}
addOptionalFields $ddbStructure
$ddbScroll add [$ddbStructure getObject]
set num_child [$root_node getChildCount]
incr num_child -1
set last_node [$root_node getChildAt $num_child]
$ddbStructure scrollPathToVisible $last_node
}
if {$second} {
getDatabaseMappings $realDatabaseStructure $ddbStructure
}
}
proc writeNode {node level form tableNumIn fieldNumIn} {
upvar 1 $tableNumIn tableNum
upvar 1 $fieldNumIn fieldNum
set indentIt 1
if {"[$node getCurrentValue]" == "Mandatory Tables" ||
"[$node getCurrentValue]" == "Optional Tables" ||
"[$node getCurrentValue]" == "Optional Fields" ||
"[$node getCurrentValue]" == "DB_OPTIONAL_TABLE_TYPE"} {
set indentIt 0
} else {
if {$level == 1} {
incr tableNum
$form writeOutputField "table($tableNum).surpacName" [getNodeSurpacName $node]
set label "[$node getLabelMLTKey]"
set idx [string first " -> " $label]
if {$idx != -1} {
$form writeOutputField "table($tableNum).acQuireName" [$node getCurrentValue]
} else {
$form writeOutputField "table($tableNum).acQuireName" ""
}
set fieldNum 0
} elseif {$level == 2} {
$form writeOutputField "table($tableNum).surpacFieldName($fieldNum)" [getNodeSurpacName $node]
set label "[$node getLabelMLTKey]"
set idx [string first " -> " $label]
if {$idx != -1} {
$form writeOutputField "table($tableNum).acQuireFieldName($fieldNum)" [$node getCurrentValue]
} else {
$form writeOutputField "table($tableNum).acQuireFieldName($fieldNum)" ""
}
}
}
if {![$node isLeaf]} {
set children [$node getChildCount]
for {set idx 0} {$idx < $children} {incr idx} {
set child [$node getChildAt $idx]
if {$indentIt == 1} {
incr level
}
writeNode $child $level $form tableNum fieldNum
incr fieldNum
if {$indentIt == 1} {
incr level -1
}
}
}
}
global legacyPreprocess
set legacyPreprocess 0
proc saveMappings {form ddbStructure} {
global legacyPreprocess
global filename
global load_type
global hole_path
global report_format
global maximum_errors
global selection
global connected
global realDatabaseStructure
set send 0
if {$legacyPreprocess == "0" && [$form getStatus] == "apply"} {
initialize $form $filename $report_format $selection $load_type $hole_path $maximum_errors
set send 1
if {[$selection getCurrentValue] != ""} {
loadSelections $connected [$selection getCurrentValue] $realDatabaseStructure $ddbStructure
}
set idx 0
set surpacName "[$form readInputField table($idx).surpacName]"
set acQuireName "[$form readInputField table($idx).acQuireName]"
while {$surpacName != ""} {
set node [getNodeHandle [$ddbStructure getRootNode] $surpacName "branch"]
if {$node != 0 && $acQuireName != ""} {
set jdx 0
set surpacFieldName "[$form readInputField table($idx).surpacFieldName($jdx)]"
set acQuireFieldName "[$form readInputField table($idx).acQuireFieldName($jdx)]"
while {$surpacFieldName != ""} {
set fieldNode [getNodeHandle $node $surpacFieldName "leaf"]
if {$fieldNode != 0 && $acQuireFieldName != ""} {
setFieldMapping $fieldNode $acQuireName $acQuireFieldName false
}
incr jdx
set surpacFieldName "[$form readInputField table($idx).surpacFieldName($jdx)]"
set acQuireFieldName "[$form readInputField table($idx).acQuireFieldName($jdx)]"
}
}
incr idx
set surpacName "[$form readInputField table($idx).surpacName]"
set acQuireName "[$form readInputField table($idx).acQuireName]"
}
}
if {[string compare [$form getStatus] "legacy preprocess apply"] == 0} {
set send 1
}
if {$send == 1} {
$form preprocessInit
set buffer [GuidoExecServer acQuireConnectionStatus {}]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 0} {
set tableNum -1
set fieldNum 0
writeNode [$ddbStructure getRootNode] 0 $form tableNum fieldNum
$form writeOutputField "load_type" [$load_type getCurrentValue]
if {[string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes"} {
$form writeOutputField "hole_path" [$hole_path getCurrentValue]
}
$form writeOutputField "filename" [$filename getCurrentValue]
$form writeOutputField "report_format" [$report_format getCurrentValue]
$form writeOutputField "maximum_errors" [$maximum_errors getCurrentValue]
$form writeOutputField "selection" [$selection getCurrentValue]
$form finishedWritingFields
}
}
if {[string compare [$form getStatus] "legacy preprocess apply"] == 0} {
set legacyPreprocess 1
}
}
proc initialize {form filename report_format selection load_type hole_path maximum_errors} {
$filename setCurrentValue "[$form readInputField filename]"
$report_format setCurrentValue "[$form readInputField report_format]"
$selection setCurrentValue "[$form readInputField selection]"
$load_type setCurrentValue "[$form readInputField load_type]"
$hole_path setCurrentValue "[$form readInputField hole_path]"
if {"[$form readInputField maximum_errors]" != ""} {
$maximum_errors setCurrentValue "[$form readInputField maximum_errors]"
}
set buffer [GuidoExecServer acQuireConnectionStatus {quiet = true}]
set status [GuidoGetParamBufferValue $buffer status]
if {$status == 0} {
global connected
$connected setCurrentValue true
}
}
if {[string tolower [ GuidoSSIOption get "current function name"]] == "acquire import samples"} {
GuidoComboBox hole_path {
-display_length 13
-format none
-label "Hole path"
-max_length 8
-tip DB_ACQUIRE_HOLE_PATH
-value_in linear curved vertical
-default curved
-null false
}
}
GuidoForm acquire {
-default_buttons
if {[string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes"} {
-label "acQuire Import Drillholes"
} else {
-label "acQuire Import Samples"
}
-tip FRM_ACQUIRE_1
-layout BoxLayout Y_AXIS
GuidoPanel top {
-layout CentreLineLayout
-label Setup
-border etched true
GuidoLabel connectLabel {
-label "Connect to acQuire and select data"
-height 1.1
}
GuidoPanel buttons {
-layout BoxLayout X_AXIS
GuidoField connected {
-default "false"
-visible false
}
GuidoButton connectButton {
-action focusGained {[unBusy]}
-caption "Connect"
-height 1
-width 7
}
}
GuidoFiller filler {
-height 0.5
}
GuidoFiller filler {
-height 0.5
}
GuidoPanel buttons {
-layout BoxLayout X_AXIS
GuidoLabel selectionLabel {
-label "acQuire selection file"
-height 1.1
}
}
GuidoPanel buttons {
-layout BoxLayout X_AXIS
GuidoFileBrowserField selection {
-display_length 20
-format none
-max_length 256
-null true
-file_mask *.sel
-tip "DB_ACQUIRE_SELECTION"
}
GuidoFiller filler {
-width 0.3
}
GuidoButton loadSelections {
-dependency {"[ $selection getCurrentValue]" != ""}
-action focusGained {[unBusy]}
-caption "Load"
-height 1
}
GuidoFiller filler {
-width 0.3
}
GuidoButton saveSelections {
-dependency {"[ $selection getCurrentValue]" != "" && "[$connected getCurrentValue]" != "false"}
-action valueChanged {[saveSelections [$selection getCurrentValue]]}
-action focusGained {[unBusy]}
-caption "Save"
-height 1
}
}
}
GuidoPanel middle {
-layout BoxLayout Y_AXIS
-label "Data Selector"
-border etched true
GuidoSplitPane spane {
-divider_location 39%
-expandable true
GuidoPanel leftTreeViewPanel {
-layout BoxLayout Y_AXIS
GuidoScrollPane realDatabaseScroll {
-height 16
-width 25
GuidoTree realDatabaseStructure {
-enable_action dragSourceGestureRecognized
-label "Database Structure"
-no_mlt
-database_handle $databaseHandle
}
}
}
GuidoPanel rightTreeViewPanel {
-layout BoxLayout Y_AXIS
GuidoScrollPane ddbScroll {
-height 16
-width 39
}
GuidoLabel asterisk {
-label "FRM_ACQUIRE_2"
}
}
}
}
GuidoPanel bottom {
-layout CentreLineLayout
-label Parameters
-border etched true
GuidoComboBox load_type {
-display_length 13
-format none
-label "Load Type"
-max_length 13
-tip DB_ACQUIRE_LOAD_TYPE
-value_in Insert Update Insert/Update
-default Insert/Update
-null false
}
if {[string tolower [ GuidoSSIOption get "current function name"]] == "acquire import drillholes"} {
GuidoComboBox hole_path {
-display_length 13
-format none
-label "Hole path"
-max_length 8
-tip DB_ACQUIRE_HOLE_PATH
-value_in linear curved vertical
-default curved
-null false
}
}
GuidoField maximum_errors {
-display_length 2
-format integer
-label "Maximum errors allowed during load"
-max_length 5
-null false
-tip DB_ACQUIRE_MAXIMUM_ERRORS
-translate none
-default "50"
}
GuidoFileBrowserField filename {
-display_length 23.6
-extension false
-file_access write
-file_mask reports|*.log
-format none
-label REPORT_FILE_NAME
-max_length 256
-tip REPORT_FILE_NAME_TIP
-translate lower
}
GuidoComboBox report_format {
-display_length 21
-format none
-label Format
-max_length 40
-null false
-value_in ".not - Surpac Note File" ".csv - Comma Separated (Spreadsheet)" ".htm - Hypertext Markup Language (Web)" ".html - Hypertext Markup Language (Web)" ".rtf - Rich Text Format (Microsoft Word)" ".pdf - Adobe Acrobat" ".ps - Postscript" ".log - Surpac log file"
}
}
$connectButton setActionCallback valueChanged {[connect $connected $realDatabaseStructure $ddbStructure]}
$loadSelections setActionCallback valueChanged {[loadSelections $connected [$selection getCurrentValue] $realDatabaseStructure $ddbStructure]}
init $ddbScroll $realDatabaseStructure
-action stateChanged {[saveMappings $acquire $ddbStructure]}
$acquire legacyProcessValues false
-action initial {[initialize $acquire $filename $report_format $selection $load_type $hole_path $maximum_errors]}
}
