Revision f7217dcd
Added by Marc Dequènes almost 15 years ago
- ID f7217dcdffe4d0fc4711c30a59da1f76064cc40a
lib/ldap_shadows/object.rb | ||
---|---|---|
self.relations_info[rel.to_sym]
|
||
end
|
||
|
||
def organized_data(options = {})
|
||
options.symbolize_keys!
|
||
options[:expert] ||= false;
|
||
options[:skip_binary] ||= false;
|
||
def organized_data
|
||
expert_attributes = (self.class.presentation[:expert_attributes] || []) + OPERATIONAL_ATTRIBUTES
|
||
|
||
ignored_attrs = self.mapper.get_global_config[:hidden_attributes] || []
|
||
ignored_attrs += self.class.presentation[:hidden_attributes] || []
|
||
ignored_attrs += (self.class.presentation[:expert_attributes] || []) unless options[:expert]
|
||
attr_list = self.attributes.keys - ignored_attrs
|
||
|
||
aspects = self.aspects
|
||
... | ... | |
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, options))
|
||
obj_aspects[aspect].merge!(fetch_attributes_data(taken_attr_list, expert_attributes))
|
||
attr_list -= taken_attr_list
|
||
end
|
||
end
|
||
... | ... | |
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, options))
|
||
obj_aspects[aspect].merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
rel_list -= taken_rel_list
|
||
end
|
||
end
|
||
... | ... | |
end
|
||
taken_attr_list += objectclasses_attr_list(self.required_classes + (self.class.presentation[:optional_classes] || []))
|
||
end
|
||
taken_attr_list += OPERATIONAL_ATTRIBUTES if options[:expert]
|
||
taken_attr_list = taken_attr_list.uniq & attr_list
|
||
obj_info = fetch_attributes_data(taken_attr_list, options)
|
||
obj_info = fetch_attributes_data(taken_attr_list, expert_attributes)
|
||
attr_list -= taken_attr_list
|
||
|
||
# manage general relations
|
||
if self.class.presentation[:associated_relations]
|
||
taken_rel_list = self.class.presentation[:associated_relations] & rel_list
|
||
unless taken_rel_list.empty?
|
||
obj_info.merge!(fetch_relations_data(taken_rel_list, options))
|
||
obj_info.merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
rel_list -= taken_rel_list
|
||
end
|
||
end
|
||
... | ... | |
|
||
taken_attr_list = (objectclasses_attr_list(aspect_data[:mapping][:classes]) & attr_list)
|
||
obj_aspects[aspect] ||= {}
|
||
obj_aspects[aspect].merge!(fetch_attributes_data(taken_attr_list, options))
|
||
obj_aspects[aspect].merge!(fetch_attributes_data(taken_attr_list, expert_attributes))
|
||
attr_list -= taken_attr_list
|
||
|
||
break if attr_list.empty?
|
||
... | ... | |
|
||
protected
|
||
|
||
def fetch_attributes_data(attr_list, options = {})
|
||
attr_data = self.attributes.select {|key, val| attr_list.include?(key) and not (options[:skip_binary] and ActiveLdap::Base.schema.attribute(key).binary?) }
|
||
Hash[attr_data]
|
||
def fetch_attributes_data(attr_list, expert_attributes)
|
||
attr_data = self.attributes.collect do |key, val|
|
||
if attr_list.include?(key)
|
||
[key, {
|
||
:value => val,
|
||
:multiple => (val.is_a?(Array) ? val.size : 1),
|
||
:expert => expert_attributes.include?(key),
|
||
:binary => ActiveLdap::Base.schema.attribute(key).binary?
|
||
}]
|
||
else
|
||
nil
|
||
end
|
||
end
|
||
Hash[attr_data.compact]
|
||
end
|
||
|
||
def fetch_relations_data(rel_list, options = {})
|
||
def fetch_relations_data(rel_list, expert_attributes)
|
||
rel_data = rel_list.collect do |rel|
|
||
data = self.send(rel).collect{|g| g.name }
|
||
data.empty? ? nil : ["rel:" + rel, data]
|
||
if data.empty?
|
||
nil
|
||
else
|
||
["rel:" + rel, {
|
||
:value => data,
|
||
:multiple => (data.size > 1),
|
||
:expert => expert_attributes.include?("rel:" + rel),
|
||
:binary => false
|
||
}]
|
||
end
|
||
end
|
||
Hash[rel_data.compact]
|
||
end
|
Also available in: Unified diff
[evol] move display options out of object management into the display functions, and display binary field presence