# ********************************************
# name dict::parent_f
# returns the parent field for given field
# for a non foreign key returns error
# ********************************************
proc dict::parent_f {field args} {
     set field_id [$field identifier]
     set relation_id [[lindex $args 0] identifier]
     set fld_par  [fld_parent $field_id $relation_id]
     if {$fld_par == 0} {
       error "no parent for non foreign key field"
      }
   set fld_par [get_fld $fld_par]
   return [list_table $fld_par [lindex [fieldClass::prefix] 0] field dict]

}
# **************************************************
# name dict::fkey_f
# checks if the field is a foreign key
# returns current values of truevalue or falsevalue
# ***************************************************

proc dict::fkey_f {fieldx} {
     set field_id [$fieldx IDENTIFIER]
     set res [fld_fk $field_id]

      # not a foreign key?
      if {$res == 0} {
         set res [falsevalue]
      } else {
         set res [truevalue]
      }
    return $res

}
proc fieldClass::prefix {} {
 return {fld identifier identifier}
}

# **************************************************
# name dict::fld_type
# returns type of field
# checks in domain if it is a user or standart type
# ***************************************************
proc dict::fld_type {c args} {
 upvar  #0 $c data
 set fld_type [$c attr TYPE]
 return $fld_type
}
# ******************************************
proc dict::mk_entity_f {field} {
  upvar #0 $field data
  return [$data(source)::mk_entity $field]
}



# ***************************************
proc dict::is_pkey {element} {
 return [$element P_KEY]
}

# *************************************
proc dict::get_field_id {element} {
 return [$element I_FIELD]
}
# *********************************************
proc dict::fld_len {field} {
 return [$field LEN]
}
# ************************************
proc dict::fld_dec {field} {
 return [$field PRECISION]
}

#***************************************
proc dict::get_name_fld {entity} {
 set name [$entity attr NAME]
 return $name
}

#************************************
# name field_dict::update
# update attr_name with value 
#************************************
proc field_dict::update {entity attr_name value} {
   _upd_fld [$entity IDENTIFIER] $attr_name $value
}  
# **************************************************
# name dict::fld_type
# returns type of field
# checks in domain if it is a user or standart type
# ***************************************************
proc dict::fld_ph_type {fieldx args} {
     set field_id [$fieldx IDENTIFIER]
     return [_ph_type $field_id]
}
proc dict::mk_domain {field} {
  set dom_id [$field I_DOMAIN]
  if {[info globals [lindex [domainClass::prefix] 0]$dom_id] == ""} {
    set domain [_get_dom $dom_id]
    return [list_table $domain [lindex [domainClass::prefix] 0] domain dict]
  }
  return [lindex [domainClass::prefix] 0]$dom_id
}
