Revision 5b1a6342
Added by Marc Dequènes about 15 years ago
- ID 5b1a634277e5a566517b145c19b8fe3f07ee686d
bin/shadowwalker | ||
---|---|---|
puts " - #{str}"
|
||
end
|
||
obj_klass.possible_aspects.each do |aspect|
|
||
aspect_human_name = Translator.translate_aspect_name(aspect)
|
||
list = obj_klass.possible_attributes_for_aspect(aspect)
|
||
aspect_human_name = Translator.translate_aspect_name(aspect.handle)
|
||
puts "--- Sublist of LDAP Fields for Aspect #{aspect_human_name} (#{list.size}) ---"
|
||
list.each do |field|
|
||
aspect.possible_attributes.each do |field|
|
||
str = Translator.translate_field_name(field)
|
||
str += " [#{field}]" if $program_options[:handles]
|
||
puts " - #{str}"
|
lib/ldap_shadows/elements/aspect.rb | ||
---|---|---|
end
|
||
end
|
||
end
|
||
|
||
def self.possible_attributes
|
||
ActiveLdap::Base.objectclasses_attr_list(self.parameters[:mapping][:classes])
|
||
end
|
||
end
|
||
end
|
||
end
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
if aspect.nil?
|
||
raise PreProcessingError, _("Aspect '%s' is missing for object '%s'") % [aspect_name, self.handle]
|
||
end
|
||
aspect_data = aspect.parameters
|
||
object_rel.merge!(aspect_data[:relations])
|
||
object_rel.merge!(aspect.parameters[:relations])
|
||
end
|
||
return if object_rel.empty?
|
||
|
||
... | ... | |
|
||
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).parameters
|
||
if defined?(aspect_data[:presentation][:associated_relations]) and aspect_data[:presentation][:associated_relations]
|
||
rel_list += aspect_data[:presentation][:associated_relations]
|
||
end
|
||
aspects.values.each do |aspect|
|
||
rel_list += aspect.parameters[:presentation][:associated_relations]
|
||
end
|
||
|
||
rel_list & possible_relations
|
||
... | ... | |
end
|
||
|
||
def aspects
|
||
present_aspects = []
|
||
self.class.parameters[:presentation][:allowed_aspects].each do |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]
|
||
present_aspects = {}
|
||
self.class.parameters[:presentation][:allowed_aspects].each do |aspect_name|
|
||
aspect = self.class.shadow.get_aspect(aspect_name)
|
||
aspect_mapping = aspect.parameters[:mapping]
|
||
present_aspects[aspect.handle] = aspect if self.classes & aspect_mapping[:classes] == aspect_mapping[:classes]
|
||
end
|
||
|
||
present_aspects
|
||
end
|
||
|
||
def self.possible_attributes_for_aspect(aspect)
|
||
self.objectclasses_attr_list(self.shadow.get_aspect(aspect).parameters[:mapping][:classes])
|
||
end
|
||
|
||
def info_for_relation(rel)
|
||
return nil unless self.relations.include?(rel)
|
||
|
||
... | ... | |
ActiveLdap::Base.schema.attribute(attr).operational?
|
||
end
|
||
|
||
aspects = self.aspects
|
||
rel_list = self.possible_relations
|
||
|
||
# first pass to take aspects forced relations into account
|
||
obj_aspects = {}
|
||
aspects.each do |aspect|
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
self.aspects.values.each do |aspect|
|
||
aspect_data = aspect.parameters
|
||
|
||
if defined?(aspect_data[:presentation][:associated_attributes]) and aspect_data[:presentation][:associated_attributes]
|
||
unless aspect_data[:presentation][:associated_attributes].empty?
|
||
taken_attr_list = aspect_data[:presentation][:associated_attributes] & (attr_list + ignored_attrs)
|
||
unless taken_attr_list.empty?
|
||
obj_aspects[aspect] ||= {}
|
||
obj_aspects[aspect].merge!(fetch_attributes_data(taken_attr_list, expert_attributes, admin_attributes))
|
||
obj_aspects[aspect.handle] ||= {}
|
||
obj_aspects[aspect.handle].merge!(fetch_attributes_data(taken_attr_list, expert_attributes, admin_attributes))
|
||
attr_list -= taken_attr_list
|
||
end
|
||
end
|
||
|
||
if defined?(aspect_data[:presentation][:associated_relations]) and aspect_data[:presentation][:associated_relations]
|
||
unless aspect_data[:presentation][:associated_relations].empty?
|
||
taken_rel_list = aspect_data[:presentation][:associated_relations] & rel_list
|
||
unless taken_rel_list.empty?
|
||
obj_aspects[aspect] ||= {}
|
||
obj_aspects[aspect].merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
obj_aspects[aspect.handle] ||= {}
|
||
obj_aspects[aspect.handle].merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
rel_list -= taken_rel_list
|
||
end
|
||
end
|
||
... | ... | |
|
||
# second pass to dispath the remaining attributes
|
||
unless attr_list.empty?
|
||
aspects.each do |aspect|
|
||
taken_attr_list = (self.class.possible_attributes_for_aspect(aspect) & attr_list)
|
||
obj_aspects[aspect] ||= {}
|
||
obj_aspects[aspect].merge!(fetch_attributes_data(taken_attr_list, expert_attributes, admin_attributes))
|
||
self.aspects.values.each do |aspect|
|
||
taken_attr_list = (aspect.possible_attributes & attr_list)
|
||
obj_aspects[aspect.handle] ||= {}
|
||
obj_aspects[aspect.handle].merge!(fetch_attributes_data(taken_attr_list, expert_attributes, admin_attributes))
|
||
attr_list -= taken_attr_list
|
||
|
||
break if attr_list.empty?
|
||
... | ... | |
true
|
||
end
|
||
|
||
def item_modify_aspects(op, aspect)
|
||
unless self.class.possible_aspects.include?(aspect)
|
||
raise PreProcessingError, _("No such aspect '%s' for object '%s'") % [aspect, self.class.handle]
|
||
def item_modify_aspects(op, aspect_name)
|
||
unless self.class.possible_aspects.include?(aspect_name)
|
||
raise PreProcessingError, _("No such aspect '%s' for object '%s'") % [aspect_name, self.class.handle]
|
||
end
|
||
|
||
case op
|
||
... | ... | |
raise PreProcessingError, _("The equality operator is not possible for aspects")
|
||
|
||
when '+='
|
||
return false if self.aspects.include?(aspect)
|
||
return false if self.aspects.keys.include?(aspect)
|
||
|
||
self.add_aspect(aspect)
|
||
|
||
when '-='
|
||
return false unless self.aspects.include?(aspect)
|
||
return false unless self.aspects.keys.include?(aspect)
|
||
|
||
self.remove_aspect(aspect)
|
||
|
||
... | ... | |
ldap_search_parts = val_list.split(",").collect do |val|
|
||
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]
|
||
ldap_classes = aspect.parameters[:mapping][:classes]
|
||
|
||
case op
|
||
when "="
|
||
... | ... | |
end
|
||
end
|
||
|
||
def add_aspect(aspect)
|
||
return unless self.class.possible_aspects.include?(aspect)
|
||
def add_aspect(aspect_name)
|
||
return unless self.class.possible_aspects.include?(aspect_name)
|
||
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
add_class(*aspect_data[:mapping][:classes])
|
||
aspect_mapping = self.class.shadow.get_aspect(aspect_name).parameters[:mapping]
|
||
add_class(*aspect_mapping[:classes])
|
||
|
||
# recursive dependency enforcement
|
||
aspect_data[:mapping][:depend_aspects].each do |dep_aspect|
|
||
aspect_mapping[:depend_aspects].each do |dep_aspect|
|
||
add_aspect(dep_aspect)
|
||
end
|
||
end
|
||
|
||
def remove_aspect(aspect)
|
||
return unless self.class.possible_aspects.include?(aspect)
|
||
def remove_aspect(aspect_name)
|
||
return unless self.class.possible_aspects.include?(aspect_name)
|
||
|
||
aspect_data = self.class.shadow.get_aspect(aspect).parameters
|
||
remove_class(*aspect_data[:mapping][:classes])
|
||
aspect_mapping = self.class.shadow.get_aspect(aspect_name).parameters[:mapping]
|
||
remove_class(*aspect_mapping[:classes])
|
||
end
|
||
|
||
def delete(options = {})
|
Also available in: Unified diff
[cleanup] improved a bit aspect handling