namespace eval ::xo::db::sql {}
::nsf::object::alloc ::xo::db::Class ::xo::db::sql::apm {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object
set :abstract_p f
set :auto_save false
set :name_method {}
set :object_type ::xo::db::sql::apm
set :security_inherit_p t
set :sql_package_name apm
set :supertype acs_object
set :with_table true}
::xo::db::sql::apm proc set_global_value {{-dbn {}} -package_key:required -parameter_name:required -attr_value:required} {
foreach var [list PACKAGE_KEY PARAMETER_NAME ATTR_VALUE] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__set_global_value($_PACKAGE_KEY, $_PARAMETER_NAME, $_ATTR_VALUE)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc unregister_parameter {{-dbn {}} -parameter_id} {
foreach var [list PARAMETER_ID] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__unregister_parameter($_PARAMETER_ID)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc unregister_service {{-dbn {}} -package_key:required {-cascade_p f}} {
foreach var [list PACKAGE_KEY CASCADE_P] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__unregister_service($_PACKAGE_KEY, $_CASCADE_P)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc update_parameter {{-dbn {}} -parameter_id:required -parameter_name -description {-datatype string} -default_value -section_name {-min_n_values 1} {-max_n_values 1}} {
foreach var [list PARAMETER_ID PARAMETER_NAME DESCRIPTION DATATYPE DEFAULT_VALUE SECTION_NAME MIN_N_VALUES MAX_N_VALUES] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__update_parameter($_PARAMETER_ID, $_PARAMETER_NAME, $_DESCRIPTION, $_DATATYPE, $_DEFAULT_VALUE, $_SECTION_NAME, $_MIN_N_VALUES, $_MAX_N_VALUES)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc unregister_application {{-dbn {}} -package_key:required {-cascade_p f}} {
foreach var [list PACKAGE_KEY CASCADE_P] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__unregister_application($_PACKAGE_KEY, $_CASCADE_P)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc unregister_package {{-dbn {}} -package_key:required {-cascade_p t}} {
foreach var [list PACKAGE_KEY CASCADE_P] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__unregister_package($_PACKAGE_KEY, $_CASCADE_P)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc register_p {{-dbn {}} -package_key:required} {
foreach var [list PACKAGE_KEY] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__register_p($_PACKAGE_KEY)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc register_parameter {{-dbn {}} -parameter_id -package_key:required -parameter_name:required -description -scope:required {-datatype string} -default_value -section_name {-min_n_values 1} {-max_n_values 1}} {
foreach var [list PARAMETER_ID PACKAGE_KEY PARAMETER_NAME DESCRIPTION SCOPE DATATYPE DEFAULT_VALUE SECTION_NAME MIN_N_VALUES MAX_N_VALUES] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__register_parameter($_PARAMETER_ID, $_PACKAGE_KEY, $_PARAMETER_NAME, $_DESCRIPTION, $_SCOPE, $_DATATYPE, $_DEFAULT_VALUE, $_SECTION_NAME, $_MIN_N_VALUES, $_MAX_N_VALUES)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc register_service {{-dbn {}} -package_key:required -pretty_name:required -pretty_plural:required -package_uri:required {-initial_install_p f} {-singleton_p f} {-implements_subsite_p f} {-inherit_templates_p f} -spec_file_path -spec_file_mtime} {
foreach var [list PACKAGE_KEY PRETTY_NAME PRETTY_PLURAL PACKAGE_URI INITIAL_INSTALL_P SINGLETON_P IMPLEMENTS_SUBSITE_P INHERIT_TEMPLATES_P SPEC_FILE_PATH SPEC_FILE_MTIME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__register_service($_PACKAGE_KEY, $_PRETTY_NAME, $_PRETTY_PLURAL, $_PACKAGE_URI, $_INITIAL_INSTALL_P, $_SINGLETON_P, $_IMPLEMENTS_SUBSITE_P, $_INHERIT_TEMPLATES_P, $_SPEC_FILE_PATH, $_SPEC_FILE_MTIME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc update_package {{-dbn {}} -package_key:required -pretty_name -pretty_plural -package_uri -package_type -initial_install_p -singleton_p {-implements_subsite_p f} {-inherit_templates_p f} -spec_file_path -spec_file_mtime} {
foreach var [list PACKAGE_KEY PRETTY_NAME PRETTY_PLURAL PACKAGE_URI PACKAGE_TYPE INITIAL_INSTALL_P SINGLETON_P IMPLEMENTS_SUBSITE_P INHERIT_TEMPLATES_P SPEC_FILE_PATH SPEC_FILE_MTIME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__update_package($_PACKAGE_KEY, $_PRETTY_NAME, $_PRETTY_PLURAL, $_PACKAGE_URI, $_PACKAGE_TYPE, $_INITIAL_INSTALL_P, $_SINGLETON_P, $_IMPLEMENTS_SUBSITE_P, $_INHERIT_TEMPLATES_P, $_SPEC_FILE_PATH, $_SPEC_FILE_MTIME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc set_value {{-dbn {}} -package_id:required -parameter_name:required -attr_value:required} {
foreach var [list PACKAGE_ID PARAMETER_NAME ATTR_VALUE] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__set_value($_PACKAGE_ID, $_PARAMETER_NAME, $_ATTR_VALUE)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc register_package {{-dbn {}} -package_key:required -pretty_name:required -pretty_plural:required -package_uri:required -package_type:required {-initial_install_p f} {-singleton_p f} {-implements_subsite_p f} {-inherit_templates_p f} -spec_file_path -spec_file_mtime} {
foreach var [list PACKAGE_KEY PRETTY_NAME PRETTY_PLURAL PACKAGE_URI PACKAGE_TYPE INITIAL_INSTALL_P SINGLETON_P IMPLEMENTS_SUBSITE_P INHERIT_TEMPLATES_P SPEC_FILE_PATH SPEC_FILE_MTIME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__register_package($_PACKAGE_KEY, $_PRETTY_NAME, $_PRETTY_PLURAL, $_PACKAGE_URI, $_PACKAGE_TYPE, $_INITIAL_INSTALL_P, $_SINGLETON_P, $_IMPLEMENTS_SUBSITE_P, $_INHERIT_TEMPLATES_P, $_SPEC_FILE_PATH, $_SPEC_FILE_MTIME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc parameter_p {{-dbn {}} -package_key:required -parameter_name:required} {
foreach var [list PACKAGE_KEY PARAMETER_NAME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__parameter_p($_PACKAGE_KEY, $_PARAMETER_NAME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc register_application {{-dbn {}} -package_key:required -pretty_name:required -pretty_plural:required -package_uri:required {-initial_install_p f} {-singleton_p f} {-implements_subsite_p f} {-inherit_templates_p f} -spec_file_path -spec_file_mtime} {
foreach var [list PACKAGE_KEY PRETTY_NAME PRETTY_PLURAL PACKAGE_URI INITIAL_INSTALL_P SINGLETON_P IMPLEMENTS_SUBSITE_P INHERIT_TEMPLATES_P SPEC_FILE_PATH SPEC_FILE_MTIME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__register_application($_PACKAGE_KEY, $_PRETTY_NAME, $_PRETTY_PLURAL, $_PACKAGE_URI, $_INITIAL_INSTALL_P, $_SINGLETON_P, $_IMPLEMENTS_SUBSITE_P, $_INHERIT_TEMPLATES_P, $_SPEC_FILE_PATH, $_SPEC_FILE_MTIME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc id_for_name {{-dbn {}} -package_key:required -parameter_name:required} {
foreach var [list PACKAGE_KEY PARAMETER_NAME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__id_for_name($_PACKAGE_KEY, $_PARAMETER_NAME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}
::xo::db::sql::apm proc get_value {{-dbn {}} -package_id:required -parameter_name:required} {
foreach var [list PACKAGE_ID PARAMETER_NAME] {
set varname [string tolower $var]
if {[info exists $varname]} {
set $var [set $varname]
set _$var :$var
} else {
set _$var null
}
}
set sql "
select apm__get_value($_PACKAGE_ID, $_PARAMETER_NAME)
"
db_with_handle -dbn $dbn db {
return [ ns_set value [ns_pg_bind 0or1row $db $sql] 0 ]
}
}