Revision 2e882c9f
Added by Marc Dequènes about 15 years ago
- ID 2e882c9f58d2e4ff18a1d3bcb46424bce9351127
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
object_rel.merge!(self.parameters[:relations]) if self.parameters.include?(:relations)
|
||
if self.parameters[:presentation].has_key?(:allowed_aspects)
|
||
self.parameters[:presentation][:allowed_aspects].each do |aspect|
|
||
aspect_data = self.shadow.get_aspect(aspect)
|
||
aspect_data = self.shadow.get_aspect(aspect).parameters
|
||
if aspect_data.nil?
|
||
raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect, self.handle]
|
||
end
|
||
... | ... | |
rel_list += self.class.parameters[:presentation][:associated_relations] if self.class.parameters[:presentation][:associated_relations]
|
||
|
||
aspects.each do |aspect|
|
||
aspect_data = self.class.shadow.get_aspect(aspect)
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
if defined?(aspect_data[:presentation][:associated_relations]) and aspect_data[:presentation][:associated_relations]
|
||
rel_list += aspect_data[:presentation][:associated_relations]
|
||
end
|
||
... | ... | |
def aspects
|
||
present_aspects = []
|
||
(self.class.parameters[:presentation][:allowed_aspects] || []).each do |aspect|
|
||
aspect_data = self.class.shadow.get_aspect(aspect)
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
aspect_mapping = aspect_data[:mapping]
|
||
present_aspects << aspect if self.classes & aspect_mapping[:classes] == aspect_mapping[:classes]
|
||
end
|
||
... | ... | |
end
|
||
|
||
def self.possible_attributes_for_aspect(aspect)
|
||
aspect_data = self.shadow.get_aspect(aspect)
|
||
aspect_data = self.shadow.get_aspect(aspect).parameters
|
||
self.objectclasses_attr_list(aspect_data[:mapping][:classes])
|
||
end
|
||
|
||
... | ... | |
# first pass to take aspects forced relations into account
|
||
obj_aspects = {}
|
||
aspects.each do |aspect|
|
||
aspect_data = self.class.shadow.get_aspect(aspect)
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
|
||
if defined?(aspect_data[:presentation][:associated_attributes]) and aspect_data[:presentation][:associated_attributes]
|
||
taken_attr_list = aspect_data[:presentation][:associated_attributes] & (attr_list + ignored_attrs)
|
||
... | ... | |
|
||
def self.ldap_search_string_aspects(shadow, field, op, val_list)
|
||
ldap_search_parts = val_list.split(",").collect do |val|
|
||
aspect_data = shadow.get_aspect(val)
|
||
raise PreProcessingError, _("No such aspect '%s'") % val if aspect_data.nil?
|
||
aspect = shadow.get_aspect(val)
|
||
raise PreProcessingError, _("No such aspect '%s'") % val if aspect.nil?
|
||
aspect_data = aspect.parameters
|
||
|
||
ldap_classes = aspect_data[:mapping][:classes]
|
||
|
||
... | ... | |
def add_aspect(aspect)
|
||
return unless self.class.possible_aspects.include?(aspect)
|
||
|
||
aspect_data = self.class.shadow.get_aspect(aspect)
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
add_class(*aspect_data[:mapping][:classes])
|
||
|
||
# recursive dependency enforcement
|
||
... | ... | |
def remove_aspect(aspect)
|
||
return unless self.class.possible_aspects.include?(aspect)
|
||
|
||
aspect_data = self.class.shadow.get_aspect(aspect)
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
remove_class(*aspect_data[:mapping][:classes])
|
||
end
|
||
|
||
... | ... | |
end
|
||
|
||
self.aspects.each do |aspect|
|
||
aklass = self.class.shadow.get_aspect_klass(aspect)
|
||
aklass = self.class.shadow.get_aspect(aspect)
|
||
next if aklass.nil?
|
||
|
||
case action
|
||
... | ... | |
|
||
def check_hooks_after(action)
|
||
self.aspects.each do |aspect|
|
||
aklass = self.class.shadow.get_aspect_klass(aspect)
|
||
aklass = self.class.shadow.get_aspect(aspect)
|
||
next if aklass.nil?
|
||
|
||
case action
|
lib/ldap_shadows/shadow.rb | ||
---|---|---|
EOS
|
||
|
||
@container_elements = {}
|
||
@aspects = {}
|
||
end
|
||
|
||
def set_config(shadow_def_raw)
|
||
... | ... | |
end
|
||
|
||
def add_aspect(aspect_name, aspect_def_raw)
|
||
e_type = 'aspect'
|
||
|
||
klass = add_container_element(e_type, aspect_name, aspect_def_raw)
|
||
|
||
# TODO: remove this crap
|
||
aspect_def = @config.parse_and_validate(aspect_name, e_type, aspect_def_raw)
|
||
@aspects[aspect_name.to_sym] = aspect_def
|
||
add_container_element('aspect', aspect_name, aspect_def_raw)
|
||
end
|
||
|
||
def get_aspect(aspect_name)
|
||
@aspects[aspect_name.to_sym]
|
||
end
|
||
|
||
def get_aspect_klass(aspect_name)
|
||
@container_elements['aspect'][aspect_name.to_s]
|
||
end
|
||
|
Also available in: Unified diff
[cleanup] internal rework #5