def try_to_link(text)
text = text.slice(2..text.length-3)
if text =~ /^http:.+/
return generate_url_link (text)
end
if text =~ /\A([^@\s]+)@(nmh.org|nmff.org|northwestern.edu)\Z/i
return generate_mailto_link (text)
end
@dw_object = DwObject.find_by_path(text)
if !@dw_object
split_text = text.split(/[^a-zA-Z0-9\-_]/)
case split_text.length
when 3
@dw_object = DwObject.find_by_path('EDW/'+text)
when 2
@dw_object = DwObject.find_by_path('EDW/'+text)
if session[:contextobject] == 'SchemaType' && !@dw_object
theSchemaType = SchemaType.find(session[:contextid])
path_text = 'EDW/' + theSchemaType.schema_type_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
elsif session[:contextobject] == 'Schema' && !@dw_object
theSchema = Schema.find(session[:contextid])
path_text = 'EDW/' + theSchema.schema_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
elsif session[:contextobject] == 'Table' && !@dw_object
theTable = Table.find(session[:contextid])
path_text = 'EDW/' + theTable.Schema.schema_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
end
when 1
@dw_object = DwObject.find_by_path('EDW/'+text)
if session[:contextobject] == 'SchemaType' && !@dw_object
theSchema = Schema.find(session[:contextid])
path_text = 'EDW/' + theSchemaType.schema_type_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
elsif session[:contextobject] == 'Schema' && !@dw_object
theSchema = Schema.find(session[:contextid])
path_text = 'EDW/' + theSchema.schema_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
elsif session[:contextobject] == 'Table' && !@dw_object
theTable = Table.find(session[:contextid])
path_text = 'EDW/' + theTable.Schema.schema_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
@dw_object = DwObject.find_by_path(path_text + '/' + theTable.table_nm + '/' + text) if !@dw_object
elsif !@dw_object && session[:contextobject] == 'Column'
theColumn = Column.find(session[:contextid])
path_text = 'EDW/' + theColumn.Table.Schema.schema_nm + '/' + theColumn.Table.table_nm
@dw_object = DwObject.find_by_path(path_text + '/' + text)
@dw_object = DwObject.find_by_path(path_text) if !@dw_object
end
end
end
return generate_object_link (@dw_object, text) if @dw_object
else return text
end