Project

General

Profile

« Previous | Next » 

Revision b119396d

Added by Marc Dequènes over 15 years ago

  • ID b119396da7937370af2a825fda67cea29968d225

[evol] aspects can manage their own relations now

View differences:

config/test.conf
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
hidden_attributes: ['objectClass', 'uid']
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
relations:
primaryGroup:
type: :has_many
object: group
foreign_key: gidNumber
primary_key: gidNumber
secondaryGroups:
type: :belongs_to
object: group
many: uniqueMember
foreign_key: dn
individual:
mapping:
dn_attribute: uid
......
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
hidden_attributes: ['objectClass', 'uid']
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
relations:
primaryGroup:
type: :has_many
object: group
foreign_key: gidNumber
primary_key: gidNumber
secondaryGroups:
type: :belongs_to
object: group
many: uniqueMember
foreign_key: dn
group:
mapping:
dn_attribute: cn
......
allowed_aspects: []
hidden_attributes: ['objectClass', 'uniqueMember']
expert_attributes: ['gidNumber']
associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
relations:
individualsPrimaryMembers:
type: :belongs_to
......
presentation:
associated_relations: ['primaryGroup', 'secondaryGroups']
relations:
primaryGroup:
type: :has_many
object: group
foreign_key: gidNumber
primary_key: gidNumber
secondaryGroups:
type: :belongs_to
object: group
many: uniqueMember
foreign_key: dn
shell:
mapping:
classes: ['shellUser']
test.rb
# run it _once_ when all objects are loaded
def load_relations
@object_definitions.each_pair do |obj_name, obj_def|
next unless obj_def.include?(:relations)
obj_rel = obj_def[:relations]
obj_rel = {}
obj_rel.merge!(obj_def[:relations]) if obj_def.include?(:relations)
if obj_def[:presentation].has_key?(:allowed_aspects)
obj_def[:presentation][:allowed_aspects].each do |rel|
rel_data = get_aspect(rel)
obj_rel.merge!(rel_data[:relations]) if rel_data.has_key?(:relations) and rel_data[:relations]
end
end
next if obj_rel.empty?
klass = find_klass(obj_name)

Also available in: Unified diff