lib/fiona7/initializer.rb in infopark_fiona7-0.71.0.0 vs lib/fiona7/initializer.rb in infopark_fiona7-0.71.0.1

- old
+ new

@@ -4,14 +4,26 @@ 'X_Generic' => 'generic', 'X_Image' => 'image', 'X_Container' => 'publication' } + CLASSES_TITLE_MAP = { + 'X_Generic' => {'Binärdatei (Systemvorlage)' => {'lang' => 'de'}, 'Binary file (system class)' => {'lang' => 'en'}}, + 'X_Image' => {'Bilddatei (Systemvorlage)' => {'lang' => 'de'}, 'Image file (system class)' => {'lang' => 'en'}}, + 'X_Container' => {'Container (Systemvorlage)' => {'lang' => 'de'}, 'Contaienr (system class)' => {'lang' => 'en'}} + } + ATTRIBUTES_MAP = { - 'X_widget_pool' => 'linklist' + 'X_widget_pool' => 'linklist', + 'X_full_text' => 'text' } + ATTRIBUTES_TITLE_MAP = { + 'X_widget_pool' => {'Verlinkte Widgets (Systemfeld)' => {'lang' => 'de'}, 'Linked widgets (system field)' => {'lang' => 'en'}}, + 'X_full_text' => {'Hauptinhalt für die Suchmaschine (Systemfeld)' => {'lang' => 'de'}, 'Body for search engine (system field)' => {'lang' => 'en'}} + } + def initialize_system should_run = self.sanity_check return unless should_run self.classes_and_attributes @@ -34,30 +46,38 @@ attributes_present = ATTRIBUTES_MAP.all? do |name, type| attribute = RailsConnector::Attribute.find_by_name(name) any_attribute_present ||= attribute && attribute.attribute_type == type end - any_class_present && raise("Misconfiguration of attributes detected") + any_attribute_present && raise("Misconfiguration of attributes detected") return true end def classes_and_attributes CLASSES_MAP.each do |name, type| - Reactor::Cm::ObjClass.create(name, type) + obj_class = Reactor::Cm::ObjClass.create(name, type) + obj_class.set(:title, CLASSES_TITLE_MAP[name]) + obj_class.save! end ATTRIBUTES_MAP.each do |name, type| - Reactor::Cm::Attribute.create(name, type) + attribute = Reactor::Cm::Attribute.create(name, type) + attribute.set(:title, ATTRIBUTES_TITLE_MAP[name]) + if (type == 'text') + attribute.set(:isSearchableInCM, 1) + attribute.set(:isSearchableInTE, 1) + end + attribute.save! end end def set_valid_sub_obj_classes RailsConnector::ObjClass.all.each do |obj_class| valid_sub_obj_classes = read_valid_sub_obj_classes(obj_class) # empty valid_sub_obj_classes = allow all - unless valid_sub_obj_classes.empty? + unless valid_sub_obj_classes.empty? || CLASSES_MAP.keys.all? {|obj_class| valid_sub_obj_classes.include?(obj_class) } valid_sub_obj_classes += CLASSES_MAP.keys cm_class = Reactor::Cm::ObjClass.get(obj_class.name) cm_class.set(:validSubObjClasses, valid_sub_obj_classes) cm_class.save! end