Revision accc97fc
Added by Marc Dequènes about 15 years ago
- ID accc97fc6c0f1be28509ccdb5681471c097b6b6e
lib/ldap_shadows/elements/aspect.rb | ||
---|---|---|
def self.cast_relations
|
||
super
|
||
|
||
deps = self.parameters[:mapping][:depend_aspects] || []
|
||
deps = self.parameters[:mapping][:depend_aspects]
|
||
deps.each do |aspect_name|
|
||
aspect = self.shadow.get_aspect(aspect_name)
|
||
if aspect.nil?
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
|
||
object_rel = {}
|
||
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_name|
|
||
aspect = self.shadow.get_aspect(aspect_name)
|
||
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]) if aspect_data.has_key?(:relations) and aspect_data[:relations]
|
||
self.parameters[:presentation][:allowed_aspects].each do |aspect_name|
|
||
aspect = self.shadow.get_aspect(aspect_name)
|
||
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])
|
||
end
|
||
return if object_rel.empty?
|
||
|
||
... | ... | |
|
||
def human_name
|
||
attr_list = ['displayName', 'cn']
|
||
attr_list.unshift(self.class.parameters[:presentation][:name_attribute]) if self.class.parameters[:presentation].has_key?(:name_attribute)
|
||
name_attribute = self.class.parameters[:presentation][:name_attribute]
|
||
attr_list.unshift(name_attribute) unless name_attribute.nil?
|
||
attr_list.each do |attr|
|
||
if attr == 'dn'
|
||
return self.dn
|
||
... | ... | |
|
||
def human_description
|
||
attr_list = ['description']
|
||
attr_list.unshift(self.class.parameters[:presentation][:desc_attribute]) if self.class.parameters[:presentation].has_key?(:desc_attribute)
|
||
desc_attribute = self.class.parameters[:presentation][:desc_attribute]
|
||
attr_list.unshift(desc_attribute) unless desc_attribute.nil?
|
||
attr_list.each do |attr|
|
||
if self.attribute_present?(attr)
|
||
return self[attr].is_a?(Array) ? self[attr][0] : self[attr]
|
||
... | ... | |
|
||
def aspects
|
||
present_aspects = []
|
||
(self.class.parameters[:presentation][:allowed_aspects] || []).each do |aspect|
|
||
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]
|
||
... | ... | |
end
|
||
|
||
def organized_data
|
||
ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes] || []
|
||
ignored_attrs += self.class.parameters[:presentation][:hidden_attributes] || []
|
||
ignored_attrs = self.class.shadow.get_config[:presentation][:hidden_attributes]
|
||
ignored_attrs += self.class.parameters[:presentation][:hidden_attributes]
|
||
attr_list = self.nonempty_attributes - ignored_attrs
|
||
|
||
expert_attributes = (self.class.parameters[:presentation][:expert_attributes] || [])
|
||
expert_attributes = self.class.parameters[:presentation][:expert_attributes]
|
||
admin_attributes = attr_list.select do |attr|
|
||
ActiveLdap::Base.schema.attribute(attr).operational?
|
||
end
|
||
... | ... | |
taken_attr_list = attr_list
|
||
else
|
||
taken_attr_list = admin_attributes
|
||
if self.class.parameters[:presentation].has_key?(:associated_attributes)
|
||
taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
|
||
end
|
||
taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
|
||
taken_attr_list += self.class.possible_attributes
|
||
end
|
||
taken_attr_list = taken_attr_list.uniq & attr_list
|
||
... | ... | |
add_class(*aspect_data[:mapping][:classes])
|
||
|
||
# recursive dependency enforcement
|
||
depends = aspect_data[:mapping][:depend_aspects] || []
|
||
depends.each do |dep_aspect|
|
||
aspect_data[:mapping][:depend_aspects].each do |dep_aspect|
|
||
add_aspect(dep_aspect)
|
||
end
|
||
end
|
lib/ldap_shadows/shadow.rb | ||
---|---|---|
item_list[ActiveLdap::DistinguishedName.parse(item.dn)]= item
|
||
end
|
||
else
|
||
(self.get_config[:presentation][:tree_objects] || []).each do |obj_hdl|
|
||
self.get_config[:presentation][:tree_objects].each do |obj_hdl|
|
||
obj_klass = get_object(obj_hdl.downcase)
|
||
unless obj_klass
|
||
raise PreProcessingError, _("Tree object '%s' not defined") % obj_hdl
|
Also available in: Unified diff
[cleanup] simplifications thanks to default config