spiderfw 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/Rakefile +7 -4
- data/VERSION +1 -1
- data/apps/admin/_init.rb +9 -0
- data/apps/admin/controllers/admin_controller.rb +12 -0
- data/apps/admin/widgets/dashboard_widget/dashboard_widget.rb +8 -0
- data/apps/app_server/app_server.rb +11 -1
- data/apps/app_server/config/options.rb +4 -0
- data/apps/app_server/controllers/app_server_controller.rb +47 -9
- data/apps/app_server/lib/app.rb +3 -1
- data/apps/app_server/lib/git_app.rb +16 -0
- data/apps/app_server/views/app_list.shtml +1 -1
- data/apps/cas_server/config/options.rb +4 -0
- data/apps/cas_server/controllers/mixins/cas_login_mixin.rb +192 -31
- data/apps/cas_server/lib/cas.rb +31 -9
- data/apps/core/auth/_init.rb +2 -2
- data/apps/core/auth/config/options.rb +6 -0
- data/apps/core/auth/controllers/login_controller.rb +1 -1
- data/apps/core/auth/controllers/mixins/auth_helper.rb +6 -1
- data/apps/core/auth/data/locale/it/LC_MESSAGES/spider_auth.mo +0 -0
- data/apps/core/auth/lib/login_authenticator.rb +12 -1
- data/apps/core/auth/lib/rbac.rb +25 -0
- data/apps/core/auth/models/group.rb +3 -8
- data/apps/core/auth/models/login_user.rb +11 -1
- data/apps/core/auth/models/mixins/rbac_provider.rb +60 -0
- data/apps/core/auth/po/it/spider_auth.po +19 -3
- data/apps/core/auth/po/spider_auth.pot +18 -2
- data/apps/core/auth/views/login.shtml +1 -0
- data/apps/core/components/_init.rb +2 -0
- data/apps/core/components/assets.rb +112 -0
- data/apps/core/components/po/it/spider_components.po +20 -6
- data/apps/core/components/po/spider_components.pot +16 -4
- data/apps/core/components/public/css/grid/1140.css +80 -0
- data/apps/core/components/public/css/grid/ie.css +43 -0
- data/apps/core/components/public/css/grid/layout.css +32 -0
- data/apps/core/components/public/css/grid/mobile.css +26 -0
- data/apps/core/components/public/css/grid/smallerscreen.css +3 -0
- data/apps/core/components/public/css/grid/typeimg.css +72 -0
- data/apps/core/components/public/js/jquery/{jquery-1.4.2.js → jquery-1.4.3.js} +1524 -881
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/button_bg.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/datepicker.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/icon_sprite.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/progress_bar.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/slider_h_bg.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/slider_handles.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/slider_v_bg.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/tab_bg.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/the_gradient.gif +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/ui-anim_basic_16x16.gif +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/css/Aristo/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/smoothness → jquery-ui-1.8.4/css/Aristo}/images/ui-icons_222222_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-icons_228ef1_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-icons_ef8c08_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-icons_ffd27a_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness → jquery-ui-1.8.4/css/Aristo}/images/ui-icons_ffffff_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css → jquery-ui-1.8.4/css/Aristo/jquery-ui.custom.css} +249 -135
- data/apps/core/components/public/js/jquery/{jquery-ui → jquery-ui-1.8.4}/development-bundle/AUTHORS.txt +2 -2
- data/apps/core/components/public/js/jquery/{jquery-ui → jquery-ui-1.8.4}/development-bundle/GPL-LICENSE.txt +0 -0
- data/apps/core/components/public/js/jquery/{jquery-ui → jquery-ui-1.8.4}/development-bundle/MIT-LICENSE.txt +1 -1
- data/apps/core/components/public/js/jquery/{jquery-ui → jquery-ui-1.8.4}/development-bundle/ui/i18n/jquery-ui-i18n.js +516 -111
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-af.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ar.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ar.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-az.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-bg.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-bg.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-bs.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ca.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ca.js} +7 -3
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-cs.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-cs.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-da.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-da.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-de.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-de.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-el.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-el.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-en-GB.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-eo.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-eo.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-es.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-es.js} +7 -3
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-et.js +23 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-eu.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-fa.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-fa.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-fi.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-fi.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-fo.js +23 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-fr-CH.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-fr.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-fr.js} +7 -3
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-he.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-he.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-hr.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-hr.js} +8 -4
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-hu.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-hu.js} +8 -4
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-hy.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-hy.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-id.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-id.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-is.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-is.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-it.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-it.js} +10 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ja.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ja.js} +5 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ko.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ko.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-lt.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-lt.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-lv.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-lv.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ms.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ms.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-nl.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-nl.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-no.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-no.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-pl.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-pl.js} +7 -3
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-pt-BR.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-pt-BR.js} +9 -5
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ro.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ro.js} +7 -3
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-ru.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ru.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sk.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sk.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sl.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sl.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sq.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sq.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sr-SR.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sr-SR.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sr.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sr.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-sv.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-sv.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-ta.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-th.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-th.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-tr.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-tr.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-uk.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-uk.js} +10 -12
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-vi.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-zh-CN.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-zh-CN.js} +6 -2
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-zh-HK.js +23 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/i18n/ui.datepicker-zh-TW.js → jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-zh-TW.js} +6 -2
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.blind.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.blind.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.bounce.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.bounce.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.clip.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.clip.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.core.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.core.js} +390 -221
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.drop.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.drop.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.explode.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.explode.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.fold.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.fold.js} +6 -6
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.effects.highlight.js +50 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.effects.pulsate.js +51 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.scale.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.scale.js} +29 -31
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.shake.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.shake.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.slide.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.slide.js} +6 -6
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/effects.transfer.js → jquery-ui-1.8.4/development-bundle/ui/jquery.effects.transfer.js} +6 -6
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.accordion.js +598 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.autocomplete.js +550 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.button.js +365 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.core.js +281 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.datepicker.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.datepicker.js} +343 -247
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.dialog.js +827 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.draggable.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.draggable.js} +107 -76
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.droppable.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.droppable.js} +48 -45
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.mouse.js +151 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.position.js +233 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.progressbar.js +94 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.resizable.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.resizable.js} +73 -61
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.selectable.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.selectable.js} +42 -33
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.slider.js +680 -0
- data/apps/core/components/public/js/jquery/{jquery-ui/development-bundle/ui/ui.sortable.js → jquery-ui-1.8.4/development-bundle/ui/jquery.ui.sortable.js} +136 -84
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.tabs.js +757 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/jquery.ui.widget.js +237 -0
- data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/version.txt +1 -0
- data/apps/core/components/public/js/jquery/patches/jquery-ui/jquery.ui.autocomplete-001.patch +17 -0
- data/apps/core/components/public/js/jquery/plugins/jquery.datalink.js +258 -0
- data/apps/core/components/public/js/jquery/plugins/jquery.json.js +178 -0
- data/apps/core/components/public/js/plugins/sortable.js +96 -72
- data/apps/core/components/public/js/spider.js +108 -50
- data/apps/core/components/public/js/utils.i18n.json +1 -0
- data/apps/core/components/public/js/utils.js +27 -0
- data/apps/core/components/widgets/admin/admin.rb +1 -1
- data/apps/core/components/widgets/admin/admin.shtml +1 -0
- data/apps/core/components/widgets/crud/crud.rb +6 -2
- data/apps/core/components/widgets/crud/crud.shtml +1 -0
- data/apps/core/components/widgets/list/list.rb +1 -1
- data/apps/core/components/widgets/list/list.shtml +2 -2
- data/apps/core/components/widgets/search_table/search_table.shtml +1 -1
- data/apps/core/components/widgets/switcher/switcher.rb +5 -1
- data/apps/core/components/widgets/table/table.rb +18 -3
- data/apps/core/components/widgets/table/table.shtml +1 -1
- data/apps/core/components/widgets/tabs/tabs.rb +0 -1
- data/apps/core/forms/_init.rb +3 -1
- data/apps/core/forms/public/ckeditor/adapters/jquery.js +6 -0
- data/apps/core/forms/public/ckeditor/ckeditor.js +137 -0
- data/apps/core/forms/public/ckeditor/images/spacer.gif +0 -0
- data/apps/core/forms/public/ckeditor/lang/_languages.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/_translationstatus.txt +60 -0
- data/apps/core/forms/public/ckeditor/lang/af.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ar.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/bg.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/bn.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/bs.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ca.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/cs.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/cy.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/da.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/de.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/el.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/en-au.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/en-ca.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/en-gb.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/en.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/eo.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/es.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/et.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/eu.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/fa.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/fi.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/fo.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/fr-ca.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/fr.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/gl.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/gu.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/he.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/hi.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/hr.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/hu.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/is.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/it.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ja.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/km.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ko.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/lt.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/lv.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/mn.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ms.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/nb.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/nl.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/no.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/pl.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/pt-br.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/pt.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ro.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/ru.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/sk.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/sl.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/sr-latn.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/sr.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/sv.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/th.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/tr.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/uk.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/vi.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/zh-cn.js +6 -0
- data/apps/core/forms/public/ckeditor/lang/zh.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/a11yhelp/lang/en.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/a11yhelp/lang/he.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/about/dialogs/about.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/autogrow/plugin.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/clipboard/dialogs/paste.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/colordialog/dialogs/colordialog.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/dialog/dialogDefinition.js +4 -0
- data/apps/core/forms/public/ckeditor/plugins/div/dialogs/div.js +8 -0
- data/apps/core/forms/public/ckeditor/plugins/find/dialogs/find.js +9 -0
- data/apps/core/forms/public/ckeditor/plugins/flash/dialogs/flash.js +9 -0
- data/apps/core/forms/public/ckeditor/plugins/flash/images/placeholder.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/button.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/checkbox.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/form.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/hiddenfield.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/radio.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/select.js +9 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/textarea.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/textfield.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/forms/images/hiddenfield.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/iframedialog/plugin.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/image/dialogs/image.js +13 -0
- data/apps/core/forms/public/ckeditor/plugins/link/dialogs/anchor.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/link/dialogs/link.js +11 -0
- data/apps/core/forms/public/ckeditor/plugins/link/images/anchor.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/liststyle/dialogs/liststyle.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/pagebreak/images/pagebreak.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/pastefromword/filter/default.js +10 -0
- data/apps/core/forms/public/ckeditor/plugins/pastetext/dialogs/pastetext.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/scayt/dialogs/options.js +8 -0
- data/apps/core/forms/public/ckeditor/plugins/scayt/dialogs/toolbar.css +6 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_address.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_div.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_p.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/dialogs/smiley.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/angel_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/angry_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/broken_heart.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/confused_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/cry_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/devil_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/embaressed_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/envelope.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/heart.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/kiss.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/lightbulb.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/omg_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/regular_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/sad_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/shades_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/teeth_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/thumbs_down.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/thumbs_up.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/tounge_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/smiley/images/wink_smile.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/specialchar/dialogs/specialchar.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/styles/styles/default.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/table/dialogs/table.js +9 -0
- data/apps/core/forms/public/ckeditor/plugins/tableresize/plugin.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/tabletools/dialogs/tableCell.js +8 -0
- data/apps/core/forms/public/ckeditor/plugins/templates/dialogs/templates.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/templates/templates/default.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/dialogs/uicolor.js +7 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/lang/en.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/lang/he.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/plugin.js +6 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/uicolor.gif +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/hue_bg.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/hue_thumb.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/picker_mask.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/picker_thumb.png +0 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/yui.css +6 -0
- data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/yui.js +76 -0
- data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/ciframe.html +49 -0
- data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +52 -0
- data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/wsc.css +6 -0
- data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/wsc.js +7 -0
- data/apps/core/forms/public/ckeditor/skins/kama/dialog.css +9 -0
- data/apps/core/forms/public/ckeditor/skins/kama/editor.css +12 -0
- data/apps/core/forms/public/ckeditor/skins/kama/icons.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/icons_rtl.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/dialog_sides.gif +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/dialog_sides.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/dialog_sides_rtl.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/mini.gif +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/noimage.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/sprites.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/sprites_ie6.png +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/images/toolbar_start.gif +0 -0
- data/apps/core/forms/public/ckeditor/skins/kama/skin.js +7 -0
- data/apps/core/forms/public/ckeditor/skins/kama/templates.css +6 -0
- data/apps/core/forms/public/ckeditor/themes/default/theme.js +8 -0
- data/apps/core/forms/public/css/form.css +3 -0
- data/apps/core/forms/public/file_input.js +1 -1
- data/apps/core/forms/public/html_area.js +55 -0
- data/apps/core/forms/public/search_select.js +46 -19
- data/apps/core/forms/public/select.js +11 -5
- data/apps/core/forms/widgets/form/form.rb +22 -6
- data/apps/core/forms/widgets/form/form.shtml +2 -0
- data/apps/core/forms/widgets/inputs/date_time/date_time.rb +6 -1
- data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +1 -0
- data/apps/core/forms/widgets/inputs/html_area/html_area.rb +51 -0
- data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +13 -0
- data/apps/core/forms/widgets/inputs/search_select/search_select.rb +8 -10
- data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +7 -7
- data/apps/core/forms/widgets/inputs/select/select.rb +15 -9
- data/apps/core/forms/widgets/inputs/select/select.shtml +1 -1
- data/apps/core/forms/widgets/inputs/time_span/time_span.rb +42 -0
- data/apps/core/forms/widgets/inputs/time_span/time_span.shtml +8 -0
- data/apps/master/_init.rb +18 -0
- data/apps/master/cmd.rb +57 -0
- data/apps/master/config/options.rb +6 -0
- data/apps/master/controllers/login_controller.rb +22 -0
- data/apps/master/controllers/master_controller.rb +261 -10
- data/apps/master/controllers/scout_controller.rb +121 -0
- data/apps/master/controllers/servant_controller.rb +16 -0
- data/apps/master/data/locale/it/LC_MESSAGES/spider_master.mo +0 -0
- data/apps/master/lib/resource.rb +7 -0
- data/apps/master/lib/resources/db_resource.rb +7 -0
- data/apps/master/lib/scout_plugin.rb +89 -0
- data/apps/master/lib/site_type.rb +24 -0
- data/apps/master/master.rb +40 -0
- data/apps/master/models/admin.rb +35 -0
- data/apps/master/models/command.rb +17 -0
- data/apps/master/models/customer.rb +20 -1
- data/apps/master/models/resource.rb +1 -0
- data/apps/master/models/scout_alert.rb +30 -0
- data/apps/master/models/scout_average.rb +23 -0
- data/apps/master/models/scout_error.rb +30 -0
- data/apps/master/models/scout_plugin_info.rb +11 -0
- data/apps/master/models/scout_plugin_instance.rb +303 -0
- data/apps/master/models/scout_plugin_trigger.rb +285 -0
- data/apps/master/models/scout_report.rb +31 -0
- data/apps/master/models/scout_report_field.rb +26 -0
- data/apps/master/models/servant.rb +82 -6
- data/apps/master/plugins/resources/apache/apache.rb +9 -0
- data/apps/master/plugins/resources/mysql/mysql.rb +45 -0
- data/apps/master/plugins/site_types/spider/spider.rb +11 -0
- data/apps/master/po/it/spider_master.po +352 -0
- data/apps/master/po/spider_master.pot +331 -0
- data/apps/master/public/css/img/web.png +0 -0
- data/apps/master/public/css/login.css +51 -0
- data/apps/master/public/css/master.css +290 -0
- data/apps/master/public/css/reset.css +23 -0
- data/apps/master/public/js/charts.js +84 -0
- data/apps/master/public/js/master.js +3 -0
- data/apps/master/templates/email/alert.html.erb +14 -0
- data/apps/master/templates/email/alert.text.erb +4 -0
- data/apps/master/views/admin.layout.shtml +14 -0
- data/apps/master/views/admin.shtml +5 -0
- data/apps/master/views/customer.shtml +37 -14
- data/apps/master/views/customers.shtml +9 -7
- data/apps/master/views/login.layout.shtml +13 -0
- data/apps/master/views/master.layout.shtml +26 -3
- data/apps/master/views/plugin_data.shtml +30 -0
- data/apps/master/views/plugin_edit.shtml +41 -0
- data/apps/master/views/plugin_instance.shtml +43 -0
- data/apps/master/views/servant.shtml +74 -0
- data/apps/master/views/servants.shtml +4 -0
- data/apps/master/views/site.shtml +3 -0
- data/apps/master/views/site_edit.shtml +17 -0
- data/apps/master/views/trigger_edit.shtml +100 -0
- data/apps/messenger/_init.rb +27 -1
- data/apps/messenger/backends/email/smtp.rb +76 -0
- data/apps/messenger/backends/sms/smstools.rb +46 -0
- data/apps/messenger/config/options.rb +28 -2
- data/apps/messenger/controllers/mixins/messenger_helper.rb +9 -5
- data/apps/messenger/lib/email_backend.rb +14 -0
- data/apps/messenger/lib/sms_backend.rb +14 -0
- data/apps/messenger/messenger.rb +32 -41
- data/apps/messenger/models/email.rb +2 -0
- data/apps/messenger/models/message.rb +37 -15
- data/apps/messenger/models/sms.rb +15 -0
- data/apps/servant/bin/spider-servant.rb +2 -1
- data/apps/servant/cmd.rb +62 -0
- data/apps/servant/controllers/servant_controller.rb +12 -0
- data/apps/servant/lib/resource.rb +3 -0
- data/apps/servant/lib/resources/db/mysql.rb +4 -0
- data/apps/servant/lib/resources/db.rb +1 -0
- data/apps/servant/lib/servant.rb +9 -3
- data/apps/worker/cmd.rb +1 -1
- data/apps/worker/models/job.rb +5 -2
- data/apps/worker/worker.rb +7 -5
- data/blueprints/install/config.ru +0 -1
- data/data/locale/it/LC_MESSAGES/spider.mo +0 -0
- data/lib/spiderfw/app.rb +77 -5
- data/lib/spiderfw/cache/template_cache.rb +15 -5
- data/lib/spiderfw/cmd/cmd.rb +2 -0
- data/lib/spiderfw/cmd/commands/app.rb +159 -0
- data/lib/spiderfw/cmd/commands/config.rb +16 -0
- data/lib/spiderfw/cmd/commands/content.rb +1 -1
- data/lib/spiderfw/cmd/commands/create.rb +13 -0
- data/lib/spiderfw/cmd/commands/model.rb +5 -1
- data/lib/spiderfw/cmd/commands/setup.rb +44 -10
- data/lib/spiderfw/cmd/commands/webserver.rb +15 -1
- data/lib/spiderfw/config/configuration.rb +19 -2
- data/lib/spiderfw/config/configuration_editor.rb +197 -0
- data/lib/spiderfw/config/options/spider.rb +48 -22
- data/lib/spiderfw/{static_content.rb → content_utils.rb} +23 -1
- data/lib/spiderfw/controller/controller.rb +8 -5
- data/lib/spiderfw/controller/controller_mixin.rb +39 -3
- data/lib/spiderfw/controller/cookies.rb +0 -3
- data/lib/spiderfw/controller/dispatcher.rb +1 -1
- data/lib/spiderfw/controller/first_responder.rb +1 -0
- data/lib/spiderfw/controller/home_controller.rb +10 -1
- data/lib/spiderfw/controller/http_controller.rb +105 -6
- data/lib/spiderfw/controller/mixins/http_mixin.rb +0 -1
- data/lib/spiderfw/controller/mixins/static_content.rb +35 -12
- data/lib/spiderfw/controller/mixins/visual.rb +125 -72
- data/lib/spiderfw/controller/request.rb +13 -1
- data/lib/spiderfw/controller/response.rb +14 -8
- data/lib/spiderfw/controller/scene.rb +5 -0
- data/lib/spiderfw/controller/session/file_session.rb +1 -1
- data/lib/spiderfw/create.rb +17 -0
- data/lib/spiderfw/home.rb +20 -8
- data/lib/spiderfw/http/adapters/mongrel.rb +24 -15
- data/lib/spiderfw/http/adapters/rack.rb +8 -3
- data/lib/spiderfw/http/adapters/webrick.rb +1 -0
- data/lib/spiderfw/http/server.rb +1 -0
- data/lib/spiderfw/i18n/cldr.rb +8 -1
- data/lib/spiderfw/i18n/i18n.rb +3 -4
- data/lib/spiderfw/i18n/javascript_parser.rb +54 -0
- data/lib/spiderfw/model/base_model.rb +550 -120
- data/lib/spiderfw/model/condition.rb +11 -2
- data/lib/spiderfw/model/data_type.rb +1 -1
- data/lib/spiderfw/model/datatypes/bool.rb +3 -1
- data/lib/spiderfw/model/datatypes/decimal.rb +4 -0
- data/lib/spiderfw/model/datatypes/password.rb +1 -0
- data/lib/spiderfw/model/datatypes/time_span.rb +26 -0
- data/lib/spiderfw/model/datatypes.rb +1 -0
- data/lib/spiderfw/model/element.rb +29 -28
- data/lib/spiderfw/model/extended_models/managed.rb +15 -0
- data/lib/spiderfw/model/identity_mapper.rb +89 -10
- data/lib/spiderfw/model/inline_model.rb +20 -2
- data/lib/spiderfw/model/integrated_element.rb +41 -0
- data/lib/spiderfw/model/mappers/db_mapper.rb +31 -27
- data/lib/spiderfw/model/mappers/hash_mapper.rb +9 -2
- data/lib/spiderfw/model/mappers/mapper.rb +105 -50
- data/lib/spiderfw/model/mappers/vfs/flat_file.rb +1 -1
- data/lib/spiderfw/model/mixins/state_machine.rb +6 -0
- data/lib/spiderfw/model/mixins/tree.rb +20 -4
- data/lib/spiderfw/model/mixins/versioned.rb +440 -67
- data/lib/spiderfw/model/model.rb +78 -17
- data/lib/spiderfw/model/model_hash.rb +2 -2
- data/lib/spiderfw/model/query.rb +17 -0
- data/lib/spiderfw/model/query_set.rb +86 -14
- data/lib/spiderfw/model/storage/base_storage.rb +1 -0
- data/lib/spiderfw/model/storage/db/adapters/mysql.rb +44 -15
- data/lib/spiderfw/model/storage/db/adapters/oracle.rb +8 -7
- data/lib/spiderfw/model/storage/db/connectors/oci8.rb +7 -1
- data/lib/spiderfw/model/storage/db/db_schema.rb +13 -0
- data/lib/spiderfw/model/storage/db/db_storage.rb +25 -5
- data/lib/spiderfw/model/unit_of_work.rb +96 -15
- data/lib/spiderfw/requires.rb +9 -1
- data/lib/spiderfw/setup/app_manager.rb +81 -0
- data/lib/spiderfw/setup/app_server_client.rb +59 -0
- data/lib/spiderfw/setup/setup_task.rb +68 -6
- data/lib/spiderfw/setup/spider_setup_wizard.rb +375 -0
- data/lib/spiderfw/site.rb +53 -0
- data/lib/spiderfw/templates/blocks/attr_if.rb +2 -2
- data/lib/spiderfw/templates/blocks/comment.rb +7 -2
- data/lib/spiderfw/templates/blocks/each.rb +1 -1
- data/lib/spiderfw/templates/blocks/html.rb +7 -0
- data/lib/spiderfw/templates/blocks/layout_assets.rb +20 -0
- data/lib/spiderfw/templates/blocks/output.rb +18 -0
- data/lib/spiderfw/templates/blocks/text.rb +17 -19
- data/lib/spiderfw/templates/blocks/widget.rb +4 -2
- data/lib/spiderfw/templates/layout.rb +269 -2
- data/lib/spiderfw/templates/template.rb +279 -46
- data/lib/spiderfw/templates/template_blocks.rb +31 -37
- data/lib/spiderfw/utils/events/event_source.rb +54 -0
- data/lib/spiderfw/utils/json.rb +39 -0
- data/lib/spiderfw/utils/logger.rb +186 -23
- data/lib/spiderfw/utils/memory.rb +30 -0
- data/lib/spiderfw/utils/monkey/date_time.rb +32 -2
- data/lib/spiderfw/utils/monkey/module.rb +16 -0
- data/lib/spiderfw/utils/monkey/object.rb +8 -0
- data/lib/spiderfw/utils/ordered_hash.rb +148 -0
- data/lib/spiderfw/utils/profiling.rb +36 -0
- data/lib/spiderfw/utils/secure_random.rb +223 -0
- data/lib/spiderfw/version.rb +1 -1
- data/lib/spiderfw/widget/widget.rb +143 -51
- data/lib/spiderfw/widget/widget_plugin.rb +13 -2
- data/lib/spiderfw.rb +117 -35
- data/spider.gemspec +1 -1
- metadata +506 -255
- data/apps/core/components/public/js/jquery/jquery-1.3.2.js +0 -4376
- data/apps/core/components/public/js/jquery/jquery-1.4.2-min.js +0 -154
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/smoothness/jquery-ui-1.7.2.custom.css +0 -406
- data/apps/core/components/public/js/jquery/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/ChangeLog.txt +0 -20
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/META.json +0 -32
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/jquery.bgiframe.js +0 -100
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/jquery.bgiframe.min.js +0 -10
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/jquery.bgiframe.pack.js +0 -10
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/bgiframe/test/index.html +0 -197
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/cookie/jquery.cookie.js +0 -97
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/cookie/jquery.cookie.min.js +0 -10
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/cookie/jquery.cookie.pack.js +0 -10
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/cookie/jquery.cookie.zip +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/jsdiff/jsdiff.js +0 -159
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/qunit/testrunner.js +0 -780
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/qunit/testsuite.css +0 -120
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/external/simulate/jquery.simulate.js +0 -152
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/jquery-1.3.2.js +0 -4376
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-icons_222222_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-icons_2e83ff_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-icons_454545_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-icons_888888_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.accordion.css +0 -9
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.all.css +0 -2
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.base.css +0 -8
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.core.css +0 -37
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.datepicker.css +0 -62
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.dialog.css +0 -13
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.progressbar.css +0 -4
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.resizable.css +0 -13
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.slider.css +0 -17
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.tabs.css +0 -11
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/base/ui.theme.css +0 -245
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/jquery-ui-1.7.2.custom.css +0 -406
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.accordion.css +0 -9
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.all.css +0 -2
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.base.css +0 -8
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.core.css +0 -37
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.datepicker.css +0 -62
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.dialog.css +0 -13
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.progressbar.css +0 -4
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.resizable.css +0 -13
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.slider.css +0 -17
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.tabs.css +0 -11
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/themes/ui-lightness/ui.theme.css +0 -247
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/effects.highlight.js +0 -48
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/effects.pulsate.js +0 -56
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/jquery-ui-1.7.2.custom.js +0 -9133
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.accordion.js +0 -477
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.core.js +0 -519
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.dialog.js +0 -671
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.progressbar.js +0 -116
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.slider.js +0 -558
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/ui/ui.tabs.js +0 -685
- data/apps/core/components/public/js/jquery/jquery-ui/development-bundle/version.txt +0 -1
- data/apps/core/components/public/js/jquery/jquery-ui/index.html +0 -367
- data/apps/core/components/public/js/jquery/jquery-ui/js/jquery-1.3.2.min.js +0 -19
- data/apps/core/components/public/js/jquery/jquery-ui/js/jquery-ui-1.7.2.custom.min.js +0 -298
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/changelog.txt +0 -27
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/jquery.autocomplete.css +0 -48
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/jquery.autocomplete.js +0 -808
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/jquery.autocomplete.min.js +0 -13
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/jquery.autocomplete.pack.js +0 -12
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/lib/jquery.ajaxQueue.js +0 -116
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/lib/jquery.bgiframe.min.js +0 -10
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/lib/jquery.js +0 -3558
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/lib/thickbox-compressed.js +0 -10
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/lib/thickbox.css +0 -163
- data/apps/core/components/public/js/jquery/plugins/jquery-autocomplete/todo +0 -166
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.js +0 -187
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.min.js +0 -1
- data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.spider.1.0.js +0 -193
- data/apps/core/forms/widgets/inputs/subform/subform.rb +0 -10
- data/apps/core/forms/widgets/inputs/subform/subform.shtml +0 -5
- data/apps/hippo/_init.rb +0 -10
- data/apps/hippo/models/mixins/hippo_struct.rb +0 -226
- data/apps/hippo/models/security_group.rb +0 -21
- data/apps/hippo/models/security_user.rb +0 -29
- data/apps/hippo/script/converti_strutture.rb +0 -335
- data/data/locale/it/LC_MESSAGES/cms.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_files.mo +0 -0
- data/data/locale/it/LC_MESSAGES/spider_images.mo +0 -0
- data/lib/spiderfw/utils/monkey/hpricot_compat.rb +0 -0
- data/lib/spiderfw/utils/setup_task.rb +0 -35
- data/lib/spiderfw/utils/test_case.rb +0 -24
- /data/apps/core/components/public/js/jquery/{jquery-ui/css/smoothness → jquery-ui-1.8.4/css/Aristo}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- /data/apps/{messenger/lib/backends/email/smtp.rb → servant/lib/commands/discovery.rb} +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spiderfw/model/mixins/state_machine'
|
2
2
|
require 'spiderfw/model/element'
|
3
|
+
require 'spiderfw/model/integrated_element'
|
3
4
|
require 'iconv'
|
4
5
|
|
5
6
|
module Spider; module Model
|
@@ -54,6 +55,7 @@ module Spider; module Model
|
|
54
55
|
include Spider::Logger
|
55
56
|
include DataTypes
|
56
57
|
include Spider::QueryFuncs
|
58
|
+
include EventSource
|
57
59
|
# include StateMachine
|
58
60
|
|
59
61
|
# The BaseModel class itself. Used when dealing with proxy objects.
|
@@ -65,6 +67,11 @@ module Spider; module Model
|
|
65
67
|
# If _parent is a model instance, which element points to this one
|
66
68
|
attr_accessor :_parent_element
|
67
69
|
|
70
|
+
# If this object is used as a superclass in class_table_inheritance, points to the current subclass
|
71
|
+
attr_accessor :_subclass_object
|
72
|
+
# This object won't be put into the identity mapper
|
73
|
+
attr_accessor :_no_identity_mapper
|
74
|
+
|
68
75
|
class <<self
|
69
76
|
# An Hash of model attributes. They can be used freely.
|
70
77
|
attr_reader :attributes
|
@@ -91,6 +98,9 @@ module Spider; module Model
|
|
91
98
|
subclass.instance_variable_set("@mapper_procs_subclass", @mapper_procs_subclass.clone) if @mapper_procs_subclass
|
92
99
|
subclass.instance_variable_set("@mapper_modules", @mapper_modules.clone) if @mapper_modules
|
93
100
|
subclass.instance_variable_set("@extended_models", @extended_models.clone) if @extended_models
|
101
|
+
em = subclass.const_set(:ElementMethods, Module.new)
|
102
|
+
subclass.send(:include, em)
|
103
|
+
super
|
94
104
|
end
|
95
105
|
|
96
106
|
def self.subclasses
|
@@ -172,6 +182,9 @@ module Spider; module Model
|
|
172
182
|
# :order attribute; if it is a Fixnum, it will mean the position in the ordering.
|
173
183
|
# :default:: (Proc or value) default value for the element. If it is a Proc, it will be passed
|
174
184
|
# the object.
|
185
|
+
# :desc:: (true or Fixnum) Use this element for the to_s string. Multiple elements
|
186
|
+
# with the :desc attribute will be joined by spaces; order may be specified if
|
187
|
+
# a Fixnum is used for the parameter
|
175
188
|
#
|
176
189
|
# Other attributes may be used by DataTypes (see #DataType::ClassMethods.take_attributes), and other code.
|
177
190
|
# See also Element.
|
@@ -179,6 +192,7 @@ module Spider; module Model
|
|
179
192
|
name = name.to_sym
|
180
193
|
@elements ||= {}
|
181
194
|
@elements_order ||= []
|
195
|
+
raise "Element called #{name} already exists in #{self}" if @elements[name]
|
182
196
|
if type.class == Class
|
183
197
|
default_attributes = case type.name
|
184
198
|
when 'String'
|
@@ -193,8 +207,8 @@ module Spider; module Model
|
|
193
207
|
# if (type.class == Class && Model.base_type(type))
|
194
208
|
# type = Model.base_type(type)
|
195
209
|
# els
|
196
|
-
if (type.class
|
197
|
-
type = create_inline_model(name, type)
|
210
|
+
if (type.class <= Hash)
|
211
|
+
type = create_inline_model(name, type, attributes)
|
198
212
|
attributes[:inline] = true
|
199
213
|
end
|
200
214
|
if (attributes[:integrated_from])
|
@@ -258,10 +272,11 @@ module Spider; module Model
|
|
258
272
|
if (create_junction)
|
259
273
|
assoc_type = first_model.const_set(assoc_type_name, Class.new(BaseModel))
|
260
274
|
assoc_type.attributes[:sub_model] = self
|
275
|
+
assoc_type.attributes[:sub_model_element] = name
|
261
276
|
assoc_type.element(attributes[:junction_id], Fixnum, :primary_key => true, :autoincrement => true, :hidden => true) if attributes[:junction_id]
|
262
|
-
assoc_type.element(self_name, self, :hidden => true, :reverse => name, :association => :choice) # FIXME: must check if reverse exists?
|
277
|
+
assoc_type.element(self_name, self, :hidden => true, :reverse => name, :association => :choice, :junction_reference => true) # FIXME: must check if reverse exists?
|
263
278
|
# FIXME! fix in case of clashes with existent elements
|
264
|
-
assoc_type.element(other_name, orig_type, :association => :choice)
|
279
|
+
assoc_type.element(other_name, orig_type, :association => :choice, :junction_reference => true)
|
265
280
|
assoc_type.integrate(other_name, :hidden => true, :no_pks => true) # FIXME: in some cases we want the integrated elements
|
266
281
|
if (proc) # to be hidden, but the integrated el instead
|
267
282
|
attributes[:extended] = true
|
@@ -278,7 +293,9 @@ module Spider; module Model
|
|
278
293
|
end
|
279
294
|
end
|
280
295
|
|
281
|
-
|
296
|
+
|
297
|
+
add_element(Element.new(name, type, attributes))
|
298
|
+
|
282
299
|
|
283
300
|
if (attributes[:add_reverse] && attributes[:add_reverse].is_a?(Symbol))
|
284
301
|
attributes[:add_reverse] = {:name => attributes[:add_reverse]}
|
@@ -331,16 +348,7 @@ module Spider; module Model
|
|
331
348
|
end
|
332
349
|
|
333
350
|
|
334
|
-
|
335
|
-
if (attributes[:element_position])
|
336
|
-
@elements_order.insert(attributes[:element_position], name)
|
337
|
-
else
|
338
|
-
@elements_order << name
|
339
|
-
end
|
340
|
-
@primary_keys ||= []
|
341
|
-
if attributes[:primary_key] && !@primary_keys.include?(@elements[name])
|
342
|
-
@primary_keys << @elements[name]
|
343
|
-
end
|
351
|
+
|
344
352
|
|
345
353
|
# class element getter
|
346
354
|
unless respond_to?(name)
|
@@ -351,18 +359,47 @@ module Spider; module Model
|
|
351
359
|
end
|
352
360
|
end
|
353
361
|
|
354
|
-
|
362
|
+
define_element_methods(name)
|
355
363
|
|
364
|
+
attr_reader "#{name}_junction" if attributes[:junction] && !attributes[:keep_junction]
|
365
|
+
|
366
|
+
if (attributes[:integrate])
|
367
|
+
integrate_params = attributes[:integrate].is_a?(Hash) ? attributes[:integrate] : {}
|
368
|
+
integrate(name, integrate_params)
|
369
|
+
end
|
370
|
+
if self.attributes[:integrated_from_elements]
|
371
|
+
self.attributes[:integrated_from_elements].each do |imod, iel|
|
372
|
+
imod.integrate_element(iel, self.elements[name]) unless imod.elements[name]
|
373
|
+
end
|
374
|
+
end
|
375
|
+
if (@subclasses)
|
376
|
+
@subclasses.each do |sub|
|
377
|
+
next if sub.elements[name] # if subclass already defined an element with this name, don't overwrite it
|
378
|
+
sub.elements[name] = @elements[name].clone
|
379
|
+
sub.elements_order << name
|
380
|
+
end
|
381
|
+
end
|
382
|
+
element_defined(@elements[name])
|
383
|
+
@elements[name].model?
|
384
|
+
return @elements[name]
|
385
|
+
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
def self.define_element_methods(name)
|
390
|
+
ivar = :"@#{ name }"
|
391
|
+
|
356
392
|
unless self.const_defined?(:ElementMethods)
|
357
393
|
em = self.const_set(:ElementMethods, Module.new)
|
358
394
|
include em
|
359
|
-
|
395
|
+
|
360
396
|
end
|
361
397
|
element_methods = self.const_get(:ElementMethods)
|
362
398
|
|
363
399
|
#instance variable getter
|
364
400
|
element_methods.send(:define_method, name) do
|
365
401
|
element = self.class.elements[name]
|
402
|
+
raise "Internal error! Element method #{name} exists, but element not found" unless element
|
366
403
|
return element.attributes[:fixed] if element.attributes[:fixed]
|
367
404
|
if (element.integrated?)
|
368
405
|
integrated = get(element.integrated_from.name)
|
@@ -375,7 +412,7 @@ module Spider; module Model
|
|
375
412
|
return val
|
376
413
|
end
|
377
414
|
|
378
|
-
# Spider.logger.debug("Element not loaded #{name} (i'm #{self.class} #{self.object_id})")
|
415
|
+
# Spider.logger.debug("Element not loaded #{name} (i'm #{self.class} #{self.object_id})")
|
379
416
|
if autoload? && primary_keys_set?
|
380
417
|
if (autoload? == :save_mode)
|
381
418
|
mapper.load_element!(self, element)
|
@@ -393,28 +430,37 @@ module Spider; module Model
|
|
393
430
|
else
|
394
431
|
val = element.attributes[:default]
|
395
432
|
end
|
433
|
+
val = element.model.new(val) if element.model? && !val.is_a?(BaseModel)
|
396
434
|
end
|
397
|
-
val.set_parent(self, name) if element.model? && val && !val._parent # FIXME!!!
|
435
|
+
val.set_parent(self, name) if element.model? && val && val.respond_to?(:parent) && !val._parent # FIXME!!!
|
398
436
|
return val
|
399
437
|
end
|
400
|
-
|
401
|
-
alias_method :"#{name}?", name if type <= Spider::DataTypes::Bool
|
438
|
+
|
439
|
+
alias_method :"#{name}?", name if self.elements[name].type <= Spider::DataTypes::Bool
|
402
440
|
|
403
441
|
#instance_variable_setter
|
404
442
|
element_methods.send(:define_method, "#{name}=") do |val|
|
405
443
|
element = self.class.elements[name]
|
444
|
+
raise "Internal error! Element method #{name}= exists, but element not found" unless element
|
406
445
|
return if element.attributes[:fixed]
|
407
446
|
was_loaded = element_loaded?(element)
|
408
447
|
#@_autoload = false unless element.primary_key?
|
409
448
|
if (element.integrated?)
|
410
449
|
integrated_obj = get(element.integrated_from)
|
411
450
|
unless integrated_obj
|
412
|
-
integrated_obj = instantiate_element(element.integrated_from.name)
|
451
|
+
integrated_obj = instantiate_element(element.integrated_from.name)
|
413
452
|
set(element.integrated_from, integrated_obj)
|
414
453
|
end
|
415
454
|
#integrated_obj.autoload = false
|
416
|
-
|
417
|
-
|
455
|
+
begin
|
456
|
+
res = integrated_obj.send("#{element.integrated_from_element}=", val)
|
457
|
+
rescue IdentityMapperException
|
458
|
+
set(element.integrated_from, Spider::Model.get(integrated_obj))
|
459
|
+
get(element.integrated_from).merge!(integrated_obj)
|
460
|
+
end
|
461
|
+
if !element.primary_key? && integrated_obj.element_modified?(name)
|
462
|
+
@modified_elements[name] = true
|
463
|
+
end
|
418
464
|
return res
|
419
465
|
end
|
420
466
|
if (val && element.model?)
|
@@ -432,38 +478,47 @@ module Spider; module Model
|
|
432
478
|
val = qs
|
433
479
|
end
|
434
480
|
else
|
435
|
-
val = element.model.
|
481
|
+
val = element.model.get(val) unless val.is_a?(BaseModel)
|
436
482
|
end
|
437
483
|
end
|
438
484
|
val = prepare_child(element.name, val)
|
439
|
-
|
485
|
+
_check(name, val)
|
440
486
|
notify_observers(name, val)
|
487
|
+
@_has_values = true
|
488
|
+
unless @_primary_keys_set
|
489
|
+
if self.class.elements[element.name].primary_key? && primary_keys_set?
|
490
|
+
@_primary_keys_set = true
|
491
|
+
if Spider::Model.identity_mapper
|
492
|
+
Spider::Model.identity_mapper.put(self, true, true)
|
493
|
+
else
|
494
|
+
Spider::Model.unit_of_work.add(self) if Spider::Model.unit_of_work
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
441
498
|
old_val = instance_variable_get(ivar)
|
442
499
|
@modified_elements[name] = true if !element.primary_key? && (!was_loaded || val != old_val)
|
443
500
|
instance_variable_set(ivar, val)
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
end
|
451
|
-
if (@subclasses)
|
452
|
-
@subclasses.each do |sub|
|
453
|
-
sub.elements[name] = @elements[name].clone
|
454
|
-
sub.elements_order << name
|
501
|
+
set_reverse(element, val) if element.model?
|
502
|
+
if val && element.model? && !self.class.attributes[:no_type_check]
|
503
|
+
klass = val.is_a?(QuerySet) ? val.model : val.class
|
504
|
+
if val && !(klass <= element.type || klass <= element.model)
|
505
|
+
raise TypeError, "Object #{val} (#{klass}) is of the wrong type for element #{element.name} in #{self.class} (expected #{element.model})"
|
506
|
+
end
|
455
507
|
end
|
508
|
+
val
|
509
|
+
#extend_element(name)
|
456
510
|
end
|
457
|
-
element_defined(@elements[name])
|
458
|
-
return @elements[name]
|
459
|
-
|
460
511
|
end
|
461
512
|
|
462
513
|
def self.add_element(el)
|
463
514
|
@elements ||= {}
|
464
515
|
@elements[el.name] = el
|
465
516
|
@elements_order ||= []
|
466
|
-
|
517
|
+
if (el.attributes[:element_position])
|
518
|
+
@elements_order.insert(el.attributes[:element_position], el.name)
|
519
|
+
else
|
520
|
+
@elements_order << el.name
|
521
|
+
end
|
467
522
|
@primary_keys ||= []
|
468
523
|
if el.attributes[:primary_key] && !@primary_keys.include?(el)
|
469
524
|
@primary_keys << el
|
@@ -475,11 +530,25 @@ module Spider; module Model
|
|
475
530
|
def self.remove_element(el)
|
476
531
|
return unless @elements
|
477
532
|
el = el.name if el.is_a?(Element)
|
533
|
+
element = @elements[el]
|
534
|
+
if self.attributes[:integrated_from_elements]
|
535
|
+
self.attributes[:integrated_from_elements].each do |mod, iel|
|
536
|
+
i = mod.elements[el]
|
537
|
+
mod.remove_element(el) if i && i.integrated? && i.integrated_from.name == iel
|
538
|
+
end
|
539
|
+
end
|
540
|
+
self.elements_array.select{ |e| e.integrated? && e.integrated_from.name == el}.each{ |e| remove_element(e) }
|
541
|
+
self.const_get(:ElementMethods).send(:remove_method, :"#{el}") rescue NameError
|
542
|
+
self.const_get(:ElementMethods).send(:remove_method, :"#{el}=") rescue NameError
|
478
543
|
@elements.delete(el)
|
479
544
|
@elements_order.delete(el)
|
480
545
|
@primary_keys.delete_if{ |pk| pk.name == el}
|
481
|
-
|
482
|
-
|
546
|
+
|
547
|
+
# if (@subclasses)
|
548
|
+
# @subclasses.each do |sub|
|
549
|
+
# sub.remove_element(el)
|
550
|
+
# end
|
551
|
+
# end
|
483
552
|
end
|
484
553
|
|
485
554
|
def self.element_defined(el)
|
@@ -513,29 +582,43 @@ module Spider; module Model
|
|
513
582
|
def self.integrate(element_name, params={})
|
514
583
|
params ||= {}
|
515
584
|
elements[element_name].attributes[:integrated_model] = true
|
516
|
-
model = elements[element_name].
|
585
|
+
model = elements[element_name].type
|
517
586
|
self.attributes[:integrated_models] ||= {}
|
518
587
|
self.attributes[:integrated_models][model] = element_name
|
519
588
|
params[:except] ||= []
|
520
589
|
model.each_element do |el|
|
521
590
|
next if params[:except].include?(el.name)
|
522
591
|
next if elements[el.name] unless params[:overwrite] # don't overwrite existing elements
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
592
|
+
integrate_element(element_name, el, params)
|
593
|
+
end
|
594
|
+
model.attributes[:integrated_from_elements] ||= []
|
595
|
+
model.attributes[:integrated_from_elements] << [self, element_name]
|
596
|
+
end
|
597
|
+
|
598
|
+
def self.integrate_element(element_name, element_element, params={})
|
599
|
+
el = element_element
|
600
|
+
integrated_attributes = {}
|
601
|
+
integrated_attributes[:primary_key] = false if params[:no_pks]
|
602
|
+
integrated_attributes[:hidden] = params[:hidden] unless (params[:hidden].nil?)
|
603
|
+
|
604
|
+
integrated_attributes[:primary_key] = false unless (params[:keep_pks])
|
605
|
+
# attributes.delete(:required)
|
606
|
+
# attributes.delete(:integrate)
|
607
|
+
# attributes.delete(:local_pk)
|
608
|
+
integrated_attributes[:local_pk] = false
|
609
|
+
integrated_attributes[:lazy] = element_name
|
610
|
+
name = params[:mapping] && params[:mapping][el.name] ? params[:mapping][el.name] : el.name
|
611
|
+
add_element(IntegratedElement.new(name, self, element_name, el.name, integrated_attributes))
|
612
|
+
define_element_methods(name)
|
613
|
+
end
|
614
|
+
|
615
|
+
def self.remove_integrate(element_name)
|
616
|
+
element = element_name.is_a?(Element) ? element_name : self.elements[element_name]
|
617
|
+
model = element.model
|
618
|
+
self.elements_array.select{ |el| el.attributes[:integrated_from] && el.attributes[:integrated_from].name == element.name }.each do |el|
|
619
|
+
self.remove_element(el)
|
538
620
|
end
|
621
|
+
model.attributes[:integrated_from_elements].reject!{ |item| item[0] == self }
|
539
622
|
end
|
540
623
|
|
541
624
|
# Sets additional attributes on the element
|
@@ -543,7 +626,7 @@ module Spider; module Model
|
|
543
626
|
# _Warning:_ for attributes which are parsed by the BaseModel during element definition,
|
544
627
|
# this will not have the desired effect; remove and redefine the element instead.
|
545
628
|
def self.element_attributes(element_name, attributes)
|
546
|
-
elements[element_name].attributes.merge
|
629
|
+
elements[element_name].attributes = elements[element_name].attributes.merge(attributes)
|
547
630
|
if attributes[:primary_key] && !@primary_keys.include?(elements[element_name])
|
548
631
|
@primary_keys << elements[element_name]
|
549
632
|
elsif !attributes[:primary_key]
|
@@ -607,17 +690,24 @@ module Spider; module Model
|
|
607
690
|
end
|
608
691
|
|
609
692
|
# Creates an inline model
|
610
|
-
def self.create_inline_model(name, hash) #:nodoc:
|
693
|
+
def self.create_inline_model(name, hash, attributes={}) #:nodoc:
|
611
694
|
model = self.const_set(Spider::Inflector.camelize(name), Class.new(InlineModel))
|
612
695
|
model.instance_eval do
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
696
|
+
if attributes[:inline_model]
|
697
|
+
attributes[:inline_model].each do |el|
|
698
|
+
element(el[0], el[1], el[2] || {})
|
699
|
+
end
|
700
|
+
else
|
701
|
+
hash.each do |key, val|
|
702
|
+
key = key.to_s if key.is_a?(Symbol)
|
703
|
+
element(:id, key.class, :primary_key => true)
|
704
|
+
if (val.class == Hash)
|
705
|
+
# TODO: allow passing of multiple values like {:element1 => 'el1', :element2 => 'el2'}
|
706
|
+
else
|
707
|
+
element(:desc, val.class, :desc => true)
|
708
|
+
end
|
709
|
+
break
|
619
710
|
end
|
620
|
-
break
|
621
711
|
end
|
622
712
|
end
|
623
713
|
model.data = hash
|
@@ -634,7 +724,7 @@ module Spider; module Model
|
|
634
724
|
if (model == superclass) # first undo table per class inheritance
|
635
725
|
@elements = {}
|
636
726
|
@elements_order = []
|
637
|
-
@extended_models.delete(model) if @extended_models
|
727
|
+
@extended_models.delete(model.superclass) if @extended_models
|
638
728
|
end
|
639
729
|
primary_keys.each{ |k| remove_element(k) } if (params[:replace_pks])
|
640
730
|
model.primary_keys.each{ |k| remove_element(k) }
|
@@ -666,9 +756,10 @@ module Spider; module Model
|
|
666
756
|
# Externalizes the superclass elements making the superclass an external integrated element.
|
667
757
|
# Parameters may be:
|
668
758
|
# * :name (symbol) name of the created element
|
669
|
-
# * :delete_cascade (bool) delete cascade the superclass instance
|
759
|
+
# * :delete_cascade (bool) delete cascade the superclass instance. True by default.
|
670
760
|
# * :no_local_pk (bool) do not define an id for this class
|
671
761
|
def self.class_table_inheritance(params={})
|
762
|
+
|
672
763
|
self.extend_model(superclass, params)
|
673
764
|
end
|
674
765
|
|
@@ -784,6 +875,25 @@ module Spider; module Model
|
|
784
875
|
self.primary_keys.select{ |k| !k.autogenerated? }.empty?
|
785
876
|
end
|
786
877
|
|
878
|
+
def self.containing_module
|
879
|
+
par = self.parent_module
|
880
|
+
while par <= BaseModel
|
881
|
+
par = par.parent_module
|
882
|
+
end
|
883
|
+
par
|
884
|
+
end
|
885
|
+
|
886
|
+
def self.get_element(el)
|
887
|
+
el = el.name if el.is_a?(Element)
|
888
|
+
el = el.to_sym
|
889
|
+
raise "No element called #{el} in #{self}" unless @elements[el]
|
890
|
+
@elements[el]
|
891
|
+
end
|
892
|
+
|
893
|
+
def self.junction?
|
894
|
+
!!self.attributes[:sub_model]
|
895
|
+
end
|
896
|
+
|
787
897
|
########################################################
|
788
898
|
# Methods returning information about the elements #
|
789
899
|
########################################################
|
@@ -906,6 +1016,7 @@ module Spider; module Model
|
|
906
1016
|
# Mixin!
|
907
1017
|
def self.get_storage(storage_string='default')
|
908
1018
|
storage_regexp = /([\w\d]+?):(.+)/
|
1019
|
+
orig_string = nil
|
909
1020
|
if (storage_string !~ storage_regexp)
|
910
1021
|
orig_string = storage_string
|
911
1022
|
storage_conf = Spider.conf.get('storages')[storage_string]
|
@@ -916,6 +1027,7 @@ module Spider; module Model
|
|
916
1027
|
end
|
917
1028
|
type, url = $1, $2
|
918
1029
|
storage = Storage.get_storage(type, url)
|
1030
|
+
storage.instance_name = orig_string
|
919
1031
|
storage.configure(storage_conf) if storage_conf
|
920
1032
|
return storage
|
921
1033
|
end
|
@@ -955,6 +1067,17 @@ module Spider; module Model
|
|
955
1067
|
return mapper
|
956
1068
|
end
|
957
1069
|
|
1070
|
+
# Syncs the schema with the storage.
|
1071
|
+
def self.sync_schema(options={})
|
1072
|
+
options = ({
|
1073
|
+
:force => false,
|
1074
|
+
:drop_fields => false,
|
1075
|
+
:update_sequences => false,
|
1076
|
+
:no_foreign_key_constraints => true
|
1077
|
+
}).merge(options)
|
1078
|
+
Spider::Model.sync_schema(self, options[:force], options)
|
1079
|
+
end
|
1080
|
+
|
958
1081
|
# Executes #self.where, and calls QuerySet#load on the result.
|
959
1082
|
# Returns nil if the result is empty, the QuerySet otherwise
|
960
1083
|
# See #self.where for parameter syntax
|
@@ -1039,15 +1162,24 @@ module Spider; module Model
|
|
1039
1162
|
@_has_values = false
|
1040
1163
|
@loaded_elements = {}
|
1041
1164
|
@modified_elements = {}
|
1042
|
-
@value_observers =
|
1043
|
-
@all_values_observers =
|
1165
|
+
@value_observers = nil
|
1166
|
+
@all_values_observers = nil
|
1044
1167
|
@_extra = {}
|
1045
1168
|
@model = self.class
|
1046
|
-
@
|
1047
|
-
@_has_values = true
|
1048
|
-
Spider::Model.unit_of_work.add(self) if (Spider::Model.unit_of_work)
|
1049
|
-
end
|
1169
|
+
@_primary_keys_set = false
|
1050
1170
|
set_values(values) if values
|
1171
|
+
# if primary_keys_set?
|
1172
|
+
# @_primary_keys_set = true
|
1173
|
+
# if Spider::Model.identity_mapper
|
1174
|
+
# Spider::Model.identity_mapper.put(self, true)
|
1175
|
+
# else
|
1176
|
+
# Spider::Model.unit_of_work.add(self) if Spider::Model.unit_of_work
|
1177
|
+
# end
|
1178
|
+
# else
|
1179
|
+
# #nil
|
1180
|
+
# end
|
1181
|
+
|
1182
|
+
|
1051
1183
|
end
|
1052
1184
|
|
1053
1185
|
# Returns an instance of the Model with #autoload set to false
|
@@ -1058,6 +1190,29 @@ module Spider; module Model
|
|
1058
1190
|
return obj
|
1059
1191
|
end
|
1060
1192
|
|
1193
|
+
def self.create(values)
|
1194
|
+
obj = self.static(values)
|
1195
|
+
obj.insert
|
1196
|
+
return obj
|
1197
|
+
end
|
1198
|
+
|
1199
|
+
def self.get(values)
|
1200
|
+
return self.new(values) unless Spider::Model.identity_mapper
|
1201
|
+
values = [values] unless values.is_a?(Hash) || values.is_a?(Array)
|
1202
|
+
if values.is_a?(Array)
|
1203
|
+
vals = {}
|
1204
|
+
self.primary_keys.each_with_index do |k, i|
|
1205
|
+
vals[k.name] = values[i]
|
1206
|
+
end
|
1207
|
+
values = vals
|
1208
|
+
end
|
1209
|
+
curr = Spider::Model.identity_mapper.get(self, values)
|
1210
|
+
return curr if curr
|
1211
|
+
obj = self.new(values)
|
1212
|
+
Spider::Model.identity_mapper.put(obj)
|
1213
|
+
obj
|
1214
|
+
end
|
1215
|
+
|
1061
1216
|
def set_values(values)
|
1062
1217
|
if (values.is_a? Hash)
|
1063
1218
|
values.keys.select{ |k|
|
@@ -1107,7 +1262,10 @@ module Spider; module Model
|
|
1107
1262
|
val.autoload = autoload?
|
1108
1263
|
end
|
1109
1264
|
end
|
1110
|
-
|
1265
|
+
val = prepare_child(name, val)
|
1266
|
+
instance_variable_set("@#{name}", val)
|
1267
|
+
set_reverse(element, val) if element.model?
|
1268
|
+
val
|
1111
1269
|
end
|
1112
1270
|
|
1113
1271
|
# Prepares an object that is being set as a child.
|
@@ -1126,7 +1284,9 @@ module Spider; module Model
|
|
1126
1284
|
}
|
1127
1285
|
obj = qs
|
1128
1286
|
elsif (!element.attributes[:keep_junction] && obj.model == element.model)
|
1287
|
+
instance_variable_set("@#{element.name}_junction", obj)
|
1129
1288
|
qs = QuerySet.new(element.type, obj.map{ |el_obj| el_obj.get(element.attributes[:junction_their_element])})
|
1289
|
+
|
1130
1290
|
obj = qs
|
1131
1291
|
end
|
1132
1292
|
end
|
@@ -1151,6 +1311,9 @@ module Spider; module Model
|
|
1151
1311
|
# FIXME: is it always ok to not set the element as modified? But otherwise sub objects
|
1152
1312
|
# are always saved (and that's definitely no good)
|
1153
1313
|
end
|
1314
|
+
if element.type == self.class.superclass && self.class.extended_models[element.type] && self.class.extended_models[element.type] == element.name
|
1315
|
+
obj._subclass_object = self
|
1316
|
+
end
|
1154
1317
|
else
|
1155
1318
|
obj = prepare_value(element, obj)
|
1156
1319
|
end
|
@@ -1178,6 +1341,17 @@ module Spider; module Model
|
|
1178
1341
|
@_parent_element = element
|
1179
1342
|
end
|
1180
1343
|
|
1344
|
+
def set_reverse(element, obj)
|
1345
|
+
return unless element.model? && obj
|
1346
|
+
if element.has_single_reverse? && (!element.attributes[:junction] || element.attributes[:keep_junction])
|
1347
|
+
unless element.multiple?
|
1348
|
+
val = obj.get_no_load(element.reverse)
|
1349
|
+
return if val && val.object_id == self.object_id
|
1350
|
+
end
|
1351
|
+
obj.set(element.reverse, self)
|
1352
|
+
end
|
1353
|
+
end
|
1354
|
+
|
1181
1355
|
|
1182
1356
|
#################################################
|
1183
1357
|
# Get and set #
|
@@ -1188,7 +1362,7 @@ module Spider; module Model
|
|
1188
1362
|
# Will call the associated getter.
|
1189
1363
|
# cat.get('favorite_food.name')
|
1190
1364
|
def get(element)
|
1191
|
-
element = element.name if
|
1365
|
+
element = element.name if element.is_a?(Element)
|
1192
1366
|
first, rest = element.to_s.split('.', 2)
|
1193
1367
|
if (rest)
|
1194
1368
|
sub_val = send(first)
|
@@ -1212,7 +1386,7 @@ module Spider; module Model
|
|
1212
1386
|
# Will call the associated setter.
|
1213
1387
|
# cat.set('favorite_food.name', 'Salmon')
|
1214
1388
|
def set(element, value, options={})
|
1215
|
-
element = element.name if
|
1389
|
+
element = element.name if element.is_a?(Element)
|
1216
1390
|
first, rest = element.to_s.split('.', 2)
|
1217
1391
|
if (rest)
|
1218
1392
|
first_val = send(first)
|
@@ -1264,7 +1438,7 @@ module Spider; module Model
|
|
1264
1438
|
|
1265
1439
|
# Prepares a value going to be set on the object. Will convert the value to the
|
1266
1440
|
# appropriate type.
|
1267
|
-
def prepare_value(element, value)
|
1441
|
+
def self.prepare_value(element, value)
|
1268
1442
|
element = self.class.elements[element] unless element.is_a?(Element)
|
1269
1443
|
if (element.type < Spider::DataType)
|
1270
1444
|
value = element.type.from_value(value) unless value.is_a?(element.type)
|
@@ -1305,8 +1479,12 @@ module Spider; module Model
|
|
1305
1479
|
value
|
1306
1480
|
end
|
1307
1481
|
|
1482
|
+
def prepare_value(element, value)
|
1483
|
+
self.class.prepare_value(element, value)
|
1484
|
+
end
|
1485
|
+
|
1308
1486
|
# Sets a value without calling the associated setter; used by the mapper.
|
1309
|
-
def set_loaded_value(element, value)
|
1487
|
+
def set_loaded_value(element, value, mark_loaded=true)
|
1310
1488
|
element_name = element.is_a?(Element) ? element.name : element
|
1311
1489
|
element = self.class.elements[element_name]
|
1312
1490
|
if (element.integrated?)
|
@@ -1315,22 +1493,24 @@ module Spider; module Model
|
|
1315
1493
|
value = prepare_child(element.name, value)
|
1316
1494
|
current = instance_variable_get("@#{element_name}")
|
1317
1495
|
current.set_parent(nil, nil) if current && current.is_a?(BaseModel)
|
1496
|
+
value.set_parent(self, element.name) if value.is_a?(BaseModel)
|
1318
1497
|
instance_variable_set("@#{element_name}", value)
|
1319
1498
|
end
|
1320
1499
|
value.loaded = true if (value.is_a?(QuerySet))
|
1321
|
-
element_loaded(element_name)
|
1500
|
+
element_loaded(element_name) if mark_loaded
|
1501
|
+
set_reverse(element, value) if element.model?
|
1322
1502
|
@modified_elements[element_name] = false
|
1323
1503
|
end
|
1324
1504
|
|
1325
1505
|
# Records that the element has been loaded.
|
1326
1506
|
def element_loaded(element_name)
|
1327
|
-
element_name =
|
1507
|
+
element_name = self.class.get_element(element_name).name
|
1328
1508
|
@loaded_elements[element_name] = true
|
1329
1509
|
end
|
1330
1510
|
|
1331
1511
|
# Returns true if the element has been loaded by the mapper.
|
1332
1512
|
def element_loaded?(element)
|
1333
|
-
element =
|
1513
|
+
element = self.class.get_element(element).name
|
1334
1514
|
return @loaded_elements[element]
|
1335
1515
|
end
|
1336
1516
|
|
@@ -1341,7 +1521,7 @@ module Spider; module Model
|
|
1341
1521
|
# Will raise a Model::FormatError when a check is not succesful.
|
1342
1522
|
# If the :check attribute is an Hash, the Hash keys will be used as messages, which will be passed
|
1343
1523
|
# to the FormatError.
|
1344
|
-
def
|
1524
|
+
def _check(name, val)
|
1345
1525
|
element = self.class.elements[name]
|
1346
1526
|
element.type.check(val) if (element.type.respond_to?(:check))
|
1347
1527
|
if (checks = element.attributes[:check])
|
@@ -1360,10 +1540,19 @@ module Spider; module Model
|
|
1360
1540
|
|
1361
1541
|
# Converts the object to the instance of a subclass for which this model is polymorphic.
|
1362
1542
|
def polymorphic_become(model)
|
1363
|
-
|
1364
|
-
|
1543
|
+
return self if self.is_a?(model)
|
1544
|
+
unless self.class.polymorphic_models && self.class.polymorphic_models[model]
|
1545
|
+
sup = model.superclass
|
1546
|
+
while sup < Spider::Model::BaseModel && !self.class.polymorphic_models[sup]
|
1547
|
+
sup = sup.superclass
|
1548
|
+
end
|
1549
|
+
raise ModelException, "#{self.class} is not polymorphic for #{model}" unless self.class.polymorphic_models[sup]
|
1550
|
+
sup_poly = polymorphic_become(sup)
|
1551
|
+
return sup_poly.polymorphic_become(model)
|
1552
|
+
end
|
1365
1553
|
el = self.class.polymorphic_models[model][:through]
|
1366
|
-
obj.
|
1554
|
+
obj = model.new(el => self)
|
1555
|
+
obj = Spider::Model.identity_mapper.get(obj) if Spider::Model.identity_mapper
|
1367
1556
|
obj.element_loaded(el)
|
1368
1557
|
return obj
|
1369
1558
|
end
|
@@ -1406,7 +1595,8 @@ module Spider; module Model
|
|
1406
1595
|
@_tmp_autoload_walk = true
|
1407
1596
|
@_autoload = a
|
1408
1597
|
if (traverse)
|
1409
|
-
self.class.elements_array.select{ |el| el.model? &&
|
1598
|
+
self.class.elements_array.select{ |el| el.model? && \
|
1599
|
+
(element_has_value?(el.name) || el.attributes[:extended_model])}.each do |el|
|
1410
1600
|
val = get(el)
|
1411
1601
|
val.autoload = a if val.respond_to?(:autoload=)
|
1412
1602
|
end
|
@@ -1475,7 +1665,8 @@ module Spider; module Model
|
|
1475
1665
|
# Returns an array of current primary key values
|
1476
1666
|
def primary_keys
|
1477
1667
|
self.class.primary_keys.map{ |k|
|
1478
|
-
|
1668
|
+
val = get(k)
|
1669
|
+
k.model? && val ? val.primary_keys : val
|
1479
1670
|
}
|
1480
1671
|
end
|
1481
1672
|
|
@@ -1498,8 +1689,7 @@ module Spider; module Model
|
|
1498
1689
|
# FIXME: should probably try to get away without this method
|
1499
1690
|
# it is the only method that relies on the mapper
|
1500
1691
|
def element_has_value?(element)
|
1501
|
-
|
1502
|
-
element = self.class.elements[element_name]
|
1692
|
+
element = self.class.get_element(element)
|
1503
1693
|
if (element.integrated?)
|
1504
1694
|
return false unless obj = instance_variable_get(:"@#{element.integrated_from.name}")
|
1505
1695
|
return obj.element_has_value?(element.integrated_from_element)
|
@@ -1508,8 +1698,9 @@ module Spider; module Model
|
|
1508
1698
|
element.attributes[:computed_from].each{ |el| return false unless element_has_value?(el) }
|
1509
1699
|
return true
|
1510
1700
|
end
|
1511
|
-
ivar =
|
1512
|
-
|
1701
|
+
ivar = nil
|
1702
|
+
ivar = instance_variable_get(:"@#{element.name}") if instance_variable_defined?(:"@#{element.name}")
|
1703
|
+
return nil == ivar ? false : true
|
1513
1704
|
# FIXME: is this needed?
|
1514
1705
|
# if (!mapper.mapped?(element)
|
1515
1706
|
# return send("#{element_name}?") if (respond_to?("#{element_name}?"))
|
@@ -1519,7 +1710,7 @@ module Spider; module Model
|
|
1519
1710
|
|
1520
1711
|
# Returns true if the element value has been modified since instantiating or loading
|
1521
1712
|
def element_modified?(element)
|
1522
|
-
element =
|
1713
|
+
element = self.class.get_element(element)
|
1523
1714
|
set_mod = @modified_elements[element.name]
|
1524
1715
|
return set_mod if set_mod
|
1525
1716
|
if (element.integrated?)
|
@@ -1534,6 +1725,7 @@ module Spider; module Model
|
|
1534
1725
|
|
1535
1726
|
# Returns true if any of elements has been modified
|
1536
1727
|
def elements_modified?(*elements)
|
1728
|
+
elements = elements[0] if elements[0].is_a?(Array)
|
1537
1729
|
elements.each{ |el| return true if element_modified?(el) }
|
1538
1730
|
return false
|
1539
1731
|
end
|
@@ -1592,18 +1784,31 @@ module Spider; module Model
|
|
1592
1784
|
return @_has_values
|
1593
1785
|
end
|
1594
1786
|
|
1595
|
-
# Sets all values of obj on the current object
|
1596
|
-
def merge!(obj)
|
1787
|
+
# Sets all values of obj on the current object
|
1788
|
+
def merge!(obj, only=nil)
|
1789
|
+
return self if obj.object_id == self.object_id
|
1597
1790
|
obj.class.elements_array.select{ |el|
|
1598
|
-
obj.element_has_value?(el) && !el.integrated? && !el.attributes[:computed_from]
|
1791
|
+
(only || obj.element_has_value?(el)) && !el.integrated? && !el.attributes[:computed_from]
|
1599
1792
|
}.each do |el|
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1793
|
+
next if only && !only.key?(el.name)
|
1794
|
+
val = obj.element_has_value?(el.name) ? obj.get_no_load(el) : nil
|
1795
|
+
our_val = self.element_has_value?(el.name) ? self.get_no_load(el) : nil
|
1796
|
+
next if our_val == val
|
1797
|
+
if el.model? && only && only[el.name].is_a?(Hash) && our_val \
|
1798
|
+
&& val.is_a?(BaseModel) && our_val.is_a?(BaseModel)
|
1799
|
+
val = our_val.merge!(val, only[el.name])
|
1800
|
+
else
|
1801
|
+
Spider.logger.warn("Element #{el.name} overwritten in #{obj.inspect}") if our_val && our_val != val
|
1603
1802
|
end
|
1604
|
-
set_loaded_value(el, val)
|
1803
|
+
set_loaded_value(el, val, false) unless val.nil? && element.multiple?
|
1804
|
+
end
|
1805
|
+
self
|
1806
|
+
end
|
1807
|
+
|
1808
|
+
def merge_hash(h)
|
1809
|
+
h.each do |k, v|
|
1810
|
+
self.set(k.to_sym, v)
|
1605
1811
|
end
|
1606
|
-
@loaded_elements.merge!(obj.loaded_elements)
|
1607
1812
|
end
|
1608
1813
|
|
1609
1814
|
# Returns a deep copy of the object
|
@@ -1615,15 +1820,23 @@ module Spider; module Model
|
|
1615
1820
|
|
1616
1821
|
# Returns a new instance with the same primary keys
|
1617
1822
|
def get_new
|
1618
|
-
obj =
|
1619
|
-
|
1823
|
+
obj = nil
|
1824
|
+
Spider::Model.no_identity_mapper do
|
1825
|
+
obj = self.class.new
|
1826
|
+
obj._no_identity_mapper = true
|
1827
|
+
self.class.primary_keys.each{ |k| obj.set(k, self.get(k)) }
|
1828
|
+
end
|
1620
1829
|
return obj
|
1621
1830
|
end
|
1622
1831
|
|
1623
1832
|
# Returns a new static instance with the same primary keys
|
1624
1833
|
def get_new_static
|
1625
|
-
obj =
|
1626
|
-
|
1834
|
+
obj = nil
|
1835
|
+
Spider::Model.no_identity_mapper do
|
1836
|
+
obj = self.class.static
|
1837
|
+
obj._no_identity_mapper = true
|
1838
|
+
self.class.primary_keys.each{ |k| obj.set(k, self.get(k)) }
|
1839
|
+
end
|
1627
1840
|
return obj
|
1628
1841
|
end
|
1629
1842
|
|
@@ -1652,16 +1865,18 @@ module Spider; module Model
|
|
1652
1865
|
# obj.observe_all_values do |instance, element_name, old_val|
|
1653
1866
|
# puts "#{element_name} for object #{instance} has changed from #{old_val} to #{instance.get(element_name) }"
|
1654
1867
|
def observe_all_values(&proc)
|
1868
|
+
@all_values_observers ||= []
|
1655
1869
|
@all_values_observers << proc
|
1656
1870
|
end
|
1657
1871
|
|
1658
1872
|
def observe_element(element_name, &proc)
|
1873
|
+
@value_observers ||= {}
|
1659
1874
|
@value_observers[element_name] ||= []
|
1660
1875
|
@value_observers[element_name] << proc
|
1661
1876
|
end
|
1662
1877
|
|
1663
1878
|
def self.observer_all_values(&proc)
|
1664
|
-
|
1879
|
+
self.all_values_observers << proc
|
1665
1880
|
end
|
1666
1881
|
|
1667
1882
|
def self.observe_element(element_name, &proc)
|
@@ -1680,9 +1895,23 @@ module Spider; module Model
|
|
1680
1895
|
|
1681
1896
|
# Calls the observers for element_name
|
1682
1897
|
def notify_observers(element_name, new_val) #:nodoc:
|
1683
|
-
|
1684
|
-
.each
|
1685
|
-
|
1898
|
+
if @value_observers && @value_observers[element_name]
|
1899
|
+
@value_observers[element_name].each{ |proc| proc.call(self, element_name, new_val) }
|
1900
|
+
end
|
1901
|
+
if @all_values_observers
|
1902
|
+
@all_values_observers.each{ |proc| proc.call(self, element_name, new_val) }
|
1903
|
+
end
|
1904
|
+
self.class.notify_observers(element_name, new_val, self)
|
1905
|
+
end
|
1906
|
+
|
1907
|
+
# Calls the observers for element_name
|
1908
|
+
def self.notify_observers(element_name, new_val, obj=nil)
|
1909
|
+
if @value_observers && @value_observers[element_name]
|
1910
|
+
@value_observers[element_name].each{ |proc| proc.call(obj, element_name, new_val) }
|
1911
|
+
end
|
1912
|
+
if @all_values_observers
|
1913
|
+
@all_values_observers.each{ |proc| proc.call(obj, element_name, new_val) }
|
1914
|
+
end
|
1686
1915
|
end
|
1687
1916
|
|
1688
1917
|
|
@@ -1708,6 +1937,7 @@ module Spider; module Model
|
|
1708
1937
|
|
1709
1938
|
# Returns the current mapper, or instantiates a new one (base on the current storage, if set)
|
1710
1939
|
def mapper
|
1940
|
+
@storage ||= nil
|
1711
1941
|
if (@storage)
|
1712
1942
|
@mapper ||= self.class.get_mapper(@storage)
|
1713
1943
|
else
|
@@ -1728,8 +1958,33 @@ module Spider; module Model
|
|
1728
1958
|
# Saves the object to the storage
|
1729
1959
|
# (see Mapper#save)
|
1730
1960
|
def save
|
1961
|
+
if @unit_of_work
|
1962
|
+
@unit_of_work.add(self)
|
1963
|
+
return
|
1964
|
+
end
|
1965
|
+
save_mode do
|
1966
|
+
before_save unless unit_of_work_available?
|
1967
|
+
if unit_of_work_available?
|
1968
|
+
Spider.current[:unit_of_work].add(self)
|
1969
|
+
if @unit_of_work
|
1970
|
+
@unit_of_work.commit
|
1971
|
+
Spider::Model.stop_unit_of_work
|
1972
|
+
if @uow_identity_mapper
|
1973
|
+
Spider.current[:identity_mapper] = nil
|
1974
|
+
@uow_identity_mapper = nil
|
1975
|
+
end
|
1976
|
+
@unit_of_work = nil
|
1977
|
+
end
|
1978
|
+
return
|
1979
|
+
else
|
1980
|
+
save!
|
1981
|
+
end
|
1982
|
+
end
|
1983
|
+
self
|
1984
|
+
end
|
1985
|
+
|
1986
|
+
def save!
|
1731
1987
|
mapper.save(self)
|
1732
|
-
reset_modified_elements
|
1733
1988
|
self
|
1734
1989
|
end
|
1735
1990
|
|
@@ -1740,11 +1995,41 @@ module Spider; module Model
|
|
1740
1995
|
self
|
1741
1996
|
end
|
1742
1997
|
|
1998
|
+
def insert
|
1999
|
+
if @unit_of_work
|
2000
|
+
@unit_of_work.add(self)
|
2001
|
+
return
|
2002
|
+
end
|
2003
|
+
save_mode do
|
2004
|
+
before_save unless unit_of_work_available?
|
2005
|
+
if unit_of_work_available?
|
2006
|
+
Spider.current[:unit_of_work].add(self, :save, :force => :insert)
|
2007
|
+
if @unit_of_work
|
2008
|
+
@unit_of_work.commit
|
2009
|
+
Spider::Model.stop_unit_of_work
|
2010
|
+
if @uow_identity_mapper
|
2011
|
+
Spider.current[:identity_mapper] = nil
|
2012
|
+
@uow_identity_mapper = nil
|
2013
|
+
end
|
2014
|
+
@unit_of_work = nil
|
2015
|
+
end
|
2016
|
+
return
|
2017
|
+
else
|
2018
|
+
insert!
|
2019
|
+
end
|
2020
|
+
end
|
2021
|
+
self
|
2022
|
+
end
|
2023
|
+
|
2024
|
+
def unit_of_work_available?
|
2025
|
+
Spider.current[:unit_of_work] && !Spider.current[:unit_of_work].running?
|
2026
|
+
end
|
2027
|
+
|
1743
2028
|
# Inserts the object in the storage
|
1744
2029
|
# Note: if the object is already present in the storage and unique indexes are enforced,
|
1745
2030
|
# this will raise an error.
|
1746
2031
|
# (See Mapper#insert).
|
1747
|
-
def insert
|
2032
|
+
def insert!
|
1748
2033
|
mapper.insert(self)
|
1749
2034
|
reset_modified_elements
|
1750
2035
|
end
|
@@ -1760,9 +2045,54 @@ module Spider; module Model
|
|
1760
2045
|
# Deletes the object from the storage
|
1761
2046
|
# (see Mapper#delete).
|
1762
2047
|
def delete
|
2048
|
+
if @unit_of_work
|
2049
|
+
@unit_of_work.add(self, :delete)
|
2050
|
+
return
|
2051
|
+
end
|
2052
|
+
before_delete unless Spider.current[:unit_of_work]
|
2053
|
+
if Spider.current[:unit_of_work]
|
2054
|
+
Spider.current[:unit_of_work].add(self, :delete)
|
2055
|
+
if @unit_of_work
|
2056
|
+
@unit_of_work.commit
|
2057
|
+
@unit_of_work.stop
|
2058
|
+
if @uow_identity_mapper
|
2059
|
+
Spider.current[:identity_mapper] = nil
|
2060
|
+
@uow_identity_mapper = nil
|
2061
|
+
end
|
2062
|
+
@unit_of_work = nil
|
2063
|
+
end
|
2064
|
+
return
|
2065
|
+
else
|
2066
|
+
delete!
|
2067
|
+
end
|
2068
|
+
end
|
2069
|
+
|
2070
|
+
def delete!
|
1763
2071
|
mapper.delete(self)
|
1764
2072
|
end
|
1765
2073
|
|
2074
|
+
def before_delete
|
2075
|
+
end
|
2076
|
+
|
2077
|
+
def before_save
|
2078
|
+
end
|
2079
|
+
|
2080
|
+
def use_unit_of_work
|
2081
|
+
had_uow = true
|
2082
|
+
unless Spider.current[:unit_of_work]
|
2083
|
+
had_wow = false
|
2084
|
+
@unit_of_work = Spider::Model.start_unit_of_work
|
2085
|
+
end
|
2086
|
+
unless Spider::Model.identity_mapper
|
2087
|
+
@uow_identity_mapper = Spider::Model::IdentityMapper.new
|
2088
|
+
Spider.current[:identity_mapper] = @uow_identity_mapper
|
2089
|
+
@uow_identity_mapper.put(self) if self.primary_keys_set?
|
2090
|
+
end
|
2091
|
+
# Spider.current[:unit_of_work].add(self)
|
2092
|
+
Spider.current[:unit_of_work]
|
2093
|
+
return had_uow
|
2094
|
+
end
|
2095
|
+
|
1766
2096
|
# Loads the object from the storage
|
1767
2097
|
# Acceptable arguments are:
|
1768
2098
|
# * a Query object, or
|
@@ -1841,15 +2171,43 @@ module Spider; module Model
|
|
1841
2171
|
end
|
1842
2172
|
end
|
1843
2173
|
end
|
1844
|
-
|
2174
|
+
raise NoMethodError, "undefined method `#{method}' for #{self.class}"
|
2175
|
+
#super
|
1845
2176
|
# end
|
1846
2177
|
end
|
1847
2178
|
|
2179
|
+
def respond_to?(symbol, include_private=false)
|
2180
|
+
return true if super
|
2181
|
+
if (self.class.attributes[:integrated_models])
|
2182
|
+
self.class.attributes[:integrated_models].each do |model, name|
|
2183
|
+
if (model.method_defined?(symbol))
|
2184
|
+
return true
|
2185
|
+
end
|
2186
|
+
end
|
2187
|
+
end
|
2188
|
+
return false
|
2189
|
+
end
|
2190
|
+
|
1848
2191
|
# Returns a descriptive string for the object.
|
1849
2192
|
# By default this method returns the value of the first String element, if any; otherwise,
|
1850
2193
|
# the string representation of the first element of any type.
|
1851
2194
|
# Descendant classes may well provide a better representation.
|
1852
2195
|
def to_s
|
2196
|
+
desc_elements = self.class.elements_array.select{ |el| el.attributes[:desc] }
|
2197
|
+
unless desc_elements.empty?
|
2198
|
+
return desc_elements.sort{ |a, b|
|
2199
|
+
ad = a.attributes[:desc]; bd = b.attributes[:desc]
|
2200
|
+
if ad == true && bd == true
|
2201
|
+
0
|
2202
|
+
elsif bd == true
|
2203
|
+
-1
|
2204
|
+
elsif ad == true
|
2205
|
+
1
|
2206
|
+
else
|
2207
|
+
ad <=> bd
|
2208
|
+
end
|
2209
|
+
}.map{ |el| self.get(el).to_s }.join(' ')
|
2210
|
+
end
|
1853
2211
|
self.class.each_element do |el|
|
1854
2212
|
if ((el.type == String || el.type == Text) && !el.primary_key?)
|
1855
2213
|
v = get(el)
|
@@ -1986,6 +2344,7 @@ module Spider; module Model
|
|
1986
2344
|
end
|
1987
2345
|
Spider::Model.with_identity_mapper do |im|
|
1988
2346
|
where.keys.each do |name|
|
2347
|
+
next unless where[name]
|
1989
2348
|
if (where[name].is_a?(Proc))
|
1990
2349
|
val = where[name].call(self, name)
|
1991
2350
|
else
|
@@ -2016,9 +2375,12 @@ module Spider; module Model
|
|
2016
2375
|
|
2017
2376
|
# Returns a yaml representation of the object. Will try to autoload all elements, unless autoload is false;
|
2018
2377
|
# foreign keys will be expressed as an array if multiple, as a single primary key value otherwise
|
2019
|
-
def to_yaml(params)
|
2378
|
+
def to_yaml(params={})
|
2020
2379
|
require 'yaml'
|
2021
|
-
|
2380
|
+
return YAML::dump(to_yaml_h(params))
|
2381
|
+
end
|
2382
|
+
|
2383
|
+
def to_yaml_h(params={})
|
2022
2384
|
h = {}
|
2023
2385
|
def obj_pks(obj, klass)
|
2024
2386
|
unless obj
|
@@ -2028,12 +2390,15 @@ module Spider; module Model
|
|
2028
2390
|
return pks[0] if pks.length == 1
|
2029
2391
|
return pks
|
2030
2392
|
end
|
2393
|
+
|
2031
2394
|
self.class.elements_array.each do |el|
|
2032
2395
|
next if params[:except] && params[:except].include?(el.name)
|
2033
2396
|
if (el.model?)
|
2034
2397
|
obj = get(el)
|
2035
|
-
if
|
2036
|
-
|
2398
|
+
if !obj
|
2399
|
+
h[el.name] = nil
|
2400
|
+
elsif (el.multiple?)
|
2401
|
+
h[el.name] = obj.map{ |o| obj_pks(o, el.model) }
|
2037
2402
|
else
|
2038
2403
|
h[el.name] = obj_pks(obj, el.model)
|
2039
2404
|
end
|
@@ -2041,7 +2406,7 @@ module Spider; module Model
|
|
2041
2406
|
h[el.name] = get(el)
|
2042
2407
|
end
|
2043
2408
|
end
|
2044
|
-
|
2409
|
+
h
|
2045
2410
|
end
|
2046
2411
|
|
2047
2412
|
def self.from_yaml(yaml)
|
@@ -2062,8 +2427,73 @@ module Spider; module Model
|
|
2062
2427
|
return obj
|
2063
2428
|
end
|
2064
2429
|
|
2065
|
-
def
|
2430
|
+
def dump_to_hash
|
2431
|
+
h = {}
|
2432
|
+
def obj_pks(obj, klass)
|
2433
|
+
unless obj
|
2434
|
+
return klass.primary_keys.length > 1 ? [] : nil
|
2435
|
+
end
|
2436
|
+
pks = obj.primary_keys
|
2437
|
+
return pks[0] if pks.length == 1
|
2438
|
+
return pks
|
2439
|
+
end
|
2440
|
+
|
2441
|
+
self.class.elements_array.each do |el|
|
2442
|
+
next unless mapper.have_references?(el) || (el.junction? && el.model.attributes[:sub_model] == self.class)
|
2443
|
+
if (el.model?)
|
2444
|
+
obj = get(el)
|
2445
|
+
if !obj
|
2446
|
+
h[el.name] = nil
|
2447
|
+
elsif (el.multiple?)
|
2448
|
+
h[el.name] = obj.map{ |o| obj_pks(o, el.model) }
|
2449
|
+
else
|
2450
|
+
h[el.name] = obj_pks(obj, el.model)
|
2451
|
+
end
|
2452
|
+
else
|
2453
|
+
val = get(el)
|
2454
|
+
if val
|
2455
|
+
case val.class.name.to_sym
|
2456
|
+
when :Date, :DateTime, :Time
|
2457
|
+
val = val.strftime
|
2458
|
+
end
|
2459
|
+
end
|
2460
|
+
h[el.name] = val
|
2461
|
+
end
|
2462
|
+
end
|
2463
|
+
h
|
2464
|
+
end
|
2465
|
+
|
2466
|
+
def dump_to_all_data_hash(options={}, h={}, seen={})
|
2467
|
+
Spider::Model.with_identity_mapper do |im|
|
2468
|
+
clname = self.class.name.to_sym
|
2469
|
+
seen[clname] ||= {}
|
2470
|
+
return if seen[clname][self.primary_keys]
|
2471
|
+
seen[clname][self.primary_keys] = true
|
2472
|
+
h[clname] ||= []
|
2473
|
+
h[clname] << self.dump_to_hash
|
2474
|
+
self.class.elements_array.each do |el|
|
2475
|
+
next unless el.model?
|
2476
|
+
next if el.model < Spider::Model::InlineModel
|
2477
|
+
next if options[:models] && !options[:models].include?(el.type)
|
2478
|
+
next if options[:except_models] && options[:except_models].include?(el.type)
|
2479
|
+
el_clname == el.type.name.to_sym
|
2480
|
+
next if options[:elements] && (options[:elements][el_clname] && !options[:elements][el_clname].include?(el.name))
|
2481
|
+
next if options[:except_elements] && (options[:except_elements][el_clname] && options[:except_elements][el_clname].include?(el.name))
|
2482
|
+
val = self.get(el)
|
2483
|
+
next unless val
|
2484
|
+
val = [val] unless val.is_a?(Enumerable)
|
2485
|
+
val.each do |v|
|
2486
|
+
v.dump_to_all_data_hash(options, h, seen)
|
2487
|
+
end
|
2488
|
+
end
|
2489
|
+
end
|
2490
|
+
h
|
2491
|
+
end
|
2492
|
+
|
2493
|
+
def self.in_transaction
|
2494
|
+
self.storage.in_transaction
|
2066
2495
|
yield
|
2496
|
+
self.storage.commit_or_continue
|
2067
2497
|
end
|
2068
2498
|
|
2069
2499
|
def self.dump_element(el)
|