Index: openacs-4/packages/acs-kernel/acs-kernel.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/acs-kernel.info,v
diff -u -r1.111 -r1.112
--- openacs-4/packages/acs-kernel/acs-kernel.info 15 Mar 2010 00:21:16 -0000 1.111
+++ openacs-4/packages/acs-kernel/acs-kernel.info 31 Mar 2010 00:46:16 -0000 1.112
@@ -7,15 +7,15 @@
t
t
-
+
OpenACS Core Team
Routines and data models providing the foundation for OpenACS-based Web services.
2009-06-19
OpenACS
The OpenACS kernel contains the core datamodel create and drop scripts for such things as objects, groups, partiies and the supporting PL/SQL and PL/pgSQL procedures.
3
-
+
Index: openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql,v
diff -u -r1.51 -r1.52
--- openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 25 Mar 2010 17:33:52 -0000 1.51
+++ openacs-4/packages/acs-kernel/sql/oracle/apm-create.sql 31 Mar 2010 00:46:16 -0000 1.52
@@ -1822,7 +1822,8 @@
cursor cur is
select parameter_id, default_value
from apm_parameters
- where package_key = initialize_parameters.package_key;
+ where package_key = initialize_parameters.package_key
+ and scope = 'instance';
begin
-- need to initialize all params for this type
for cur_val in cur
Index: openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.6.0d7-5.6.0d8.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.6.0d7-5.6.0d8.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-kernel/sql/oracle/upgrade/upgrade-5.6.0d7-5.6.0d8.sql 31 Mar 2010 00:46:16 -0000 1.1
@@ -0,0 +1,249 @@
+
+create or replace package body apm_package
+as
+ procedure initialize_parameters (
+ package_id in apm_packages.package_id%TYPE,
+ package_key in apm_package_types.package_key%TYPE
+ )
+ is
+ v_value_id apm_parameter_values.value_id%TYPE;
+ cursor cur is
+ select parameter_id, default_value
+ from apm_parameters
+ where package_key = initialize_parameters.package_key
+ and scope = 'instance';
+ begin
+ -- need to initialize all params for this type
+ for cur_val in cur
+ loop
+ v_value_id := apm_parameter_value.new(
+ package_id => initialize_parameters.package_id,
+ parameter_id => cur_val.parameter_id,
+ attr_value => cur_val.default_value
+ );
+ end loop;
+ end initialize_parameters;
+
+ function new (
+ package_id in apm_packages.package_id%TYPE
+ default null,
+ instance_name in apm_packages.instance_name%TYPE
+ default null,
+ package_key in apm_packages.package_key%TYPE,
+ object_type in acs_objects.object_type%TYPE
+ default 'apm_package',
+ creation_date in acs_objects.creation_date%TYPE
+ default sysdate,
+ creation_user in acs_objects.creation_user%TYPE
+ default null,
+ creation_ip in acs_objects.creation_ip%TYPE
+ default null,
+ context_id in acs_objects.context_id%TYPE
+ default null
+ ) return apm_packages.package_id%TYPE
+ is
+ v_singleton_p integer;
+ v_package_type apm_package_types.package_type%TYPE;
+ v_num_instances integer;
+ v_package_id apm_packages.package_id%TYPE;
+ v_instance_name apm_packages.instance_name%TYPE;
+ begin
+ v_singleton_p := apm_package.singleton_p(
+ package_key => apm_package.new.package_key
+ );
+ v_num_instances := apm_package.num_instances(
+ package_key => apm_package.new.package_key
+ );
+
+ if v_singleton_p = 1 and v_num_instances >= 1 then
+ select package_id into v_package_id
+ from apm_packages
+ where package_key = apm_package.new.package_key;
+ return v_package_id;
+ else
+ v_package_id := acs_object.new(
+ object_id => package_id,
+ object_type => object_type,
+ creation_date => creation_date,
+ creation_user => creation_user,
+ creation_ip => creation_ip,
+ context_id => context_id
+ );
+
+ if instance_name is null then
+ v_instance_name := package_key || ' ' || v_package_id;
+ else
+ v_instance_name := instance_name;
+ end if;
+
+ insert into apm_packages
+ (package_id, package_key, instance_name)
+ values
+ (v_package_id, package_key, v_instance_name);
+
+ update acs_objects
+ set title = v_instance_name,
+ package_id = v_package_id
+ where object_id = v_package_id;
+
+ select package_type into v_package_type
+ from apm_package_types
+ where package_key = apm_package.new.package_key;
+
+ if v_package_type = 'apm_application' then
+ insert into apm_applications
+ (application_id)
+ values
+ (v_package_id);
+ else
+ insert into apm_services
+ (service_id)
+ values
+ (v_package_id);
+ end if;
+
+ initialize_parameters(
+ package_id => v_package_id,
+ package_key => apm_package.new.package_key
+ );
+ return v_package_id;
+
+ end if;
+end new;
+
+ procedure del (
+ package_id in apm_packages.package_id%TYPE
+ )
+ is
+ cursor all_values is
+ select value_id from apm_parameter_values
+ where package_id = apm_package.del.package_id;
+ cursor all_site_nodes is
+ select node_id from site_nodes
+ where object_id = apm_package.del.package_id;
+ begin
+ -- Delete all parameters.
+ for cur_val in all_values loop
+ apm_parameter_value.del(value_id => cur_val.value_id);
+ end loop;
+ delete from apm_applications where application_id = apm_package.del.package_id;
+ delete from apm_services where service_id = apm_package.del.package_id;
+ delete from apm_packages where package_id = apm_package.del.package_id;
+ -- Delete the site nodes for the objects.
+ for cur_val in all_site_nodes loop
+ site_node.del(cur_val.node_id);
+ end loop;
+ -- Delete the object.
+ acs_object.del (
+ object_id => package_id
+ );
+ end del;
+
+ function initial_install_p (
+ package_key in apm_packages.package_key%TYPE
+ ) return integer
+ is
+ v_initial_install_p integer;
+ begin
+ select 1 into v_initial_install_p
+ from apm_package_types
+ where package_key = initial_install_p.package_key
+ and initial_install_p = 't';
+ return v_initial_install_p;
+
+ exception
+ when NO_DATA_FOUND
+ then
+ return 0;
+ end initial_install_p;
+
+ function singleton_p (
+ package_key in apm_packages.package_key%TYPE
+ ) return integer
+ is
+ v_singleton_p integer;
+ begin
+ select 1 into v_singleton_p
+ from apm_package_types
+ where package_key = singleton_p.package_key
+ and singleton_p = 't';
+ return v_singleton_p;
+
+ exception
+ when NO_DATA_FOUND
+ then
+ return 0;
+ end singleton_p;
+
+ function num_instances (
+ package_key in apm_package_types.package_key%TYPE
+ ) return integer
+ is
+ v_num_instances integer;
+ begin
+ select count(*) into v_num_instances
+ from apm_packages
+ where package_key = num_instances.package_key;
+ return v_num_instances;
+
+ exception
+ when NO_DATA_FOUND
+ then
+ return 0;
+ end num_instances;
+
+ function name (
+ package_id in apm_packages.package_id%TYPE
+ ) return varchar2
+ is
+ v_result apm_packages.instance_name%TYPE;
+ begin
+ select instance_name into v_result
+ from apm_packages
+ where package_id = name.package_id;
+
+ return v_result;
+ end name;
+
+ function highest_version (
+ package_key in apm_package_types.package_key%TYPE
+ ) return apm_package_versions.version_id%TYPE
+ is
+ v_version_id apm_package_versions.version_id%TYPE;
+ begin
+ select version_id into v_version_id
+ from apm_package_version_info i
+ where apm_package_version.sortable_version_name(version_name) =
+ (select max(apm_package_version.sortable_version_name(v.version_name))
+ from apm_package_version_info v where v.package_key = highest_version.package_key)
+ and package_key = highest_version.package_key;
+ return v_version_id;
+ exception
+ when NO_DATA_FOUND
+ then
+ return 0;
+ end highest_version;
+
+ function parent_id (
+ package_id in apm_packages.package_id%TYPE
+ ) return apm_packages.package_id%TYPE
+ is
+ v_package_id apm_packages.package_id%TYPE;
+ begin
+ select sn1.object_id
+ into v_package_id
+ from site_nodes sn1
+ where sn1.node_id = (select sn2.parent_id
+ from site_nodes sn2
+ where sn2.object_id = apm_package.parent_id.package_id);
+
+ return v_package_id;
+
+ exception when NO_DATA_FOUND then
+ return -1;
+ end parent_id;
+
+end apm_package;
+/
+show errors
+
Index: openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql,v
diff -u -r1.72 -r1.73
--- openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 25 Mar 2010 00:50:24 -0000 1.72
+++ openacs-4/packages/acs-kernel/sql/postgresql/apm-create.sql 31 Mar 2010 00:46:16 -0000 1.73
@@ -1676,6 +1676,7 @@
for cur_val in select parameter_id, default_value
from apm_parameters
where package_key = ip__package_key
+ and scope = ''instance''
loop
v_value_id := apm_parameter_value__new(
null,
Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.6.0d7-5.6.0d8.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.6.0d7-5.6.0d8.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.6.0d7-5.6.0d8.sql 31 Mar 2010 00:46:16 -0000 1.1
@@ -0,0 +1,26 @@
+
+create or replace function apm_package__initialize_parameters (integer,varchar)
+returns integer as '
+declare
+ ip__package_id alias for $1;
+ ip__package_key alias for $2;
+ v_value_id apm_parameter_values.value_id%TYPE;
+ cur_val record;
+begin
+ -- need to initialize all params for this type
+ for cur_val in select parameter_id, default_value
+ from apm_parameters
+ where package_key = ip__package_key
+ and scope = ''instance''
+ loop
+ v_value_id := apm_parameter_value__new(
+ null,
+ ip__package_id,
+ cur_val.parameter_id,
+ cur_val.default_value
+ );
+ end loop;
+
+ return 0;
+end;' language 'plpgsql';
+
Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql,v
diff -u -r1.17 -r1.18
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql 10 Mar 2010 00:44:03 -0000 1.17
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-oracle.xql 31 Mar 2010 00:46:16 -0000 1.18
@@ -263,8 +263,8 @@
begin
:1 := apm.parameter_p(
- :descendent_package_key,
- :parameter_name);
+ package_key => :descendent_package_key,
+ parameter_name => :parameter_name);
end;
@@ -273,15 +273,15 @@
begin
:1 := apm.register_parameter(
- null,
- :descendent_package_key,
- :parameter_name,
- :description,
- :datatype,
- :default_value,
- :section_name,
- :min_n_values,
- :max_n_values);
+ package_key => :descendent_package_key,
+ parameter_name => :parameter_name,
+ description => :description,
+ scope => :scope,
+ datatype => :datatype,
+ default_value => :default_value,
+ section_name => :section_name,
+ min_n_values => :min_n_values,
+ max_n_values => :max_n_values);
end;
@@ -290,8 +290,8 @@
begin
:1 := apm.parameter_p(
- :new_package_key,
- :parameter_name);
+ package_key => :descendent_package_key,
+ parameter_name => :parameter_name);
end;
@@ -300,15 +300,15 @@
begin
:1 := apm.register_parameter(
- null,
- :new_package_key,
- :parameter_name,
- :description,
- :datatype,
- :default_value,
- :section_name,
- :min_n_values,
- :max_n_values);
+ package_key => :new_package_key,
+ parameter_name => :parameter_name,
+ description => :description,
+ scope => :scope,
+ datatype => :datatype,
+ default_value => :default_value,
+ section_name => :section_name,
+ min_n_values => :min_n_values,
+ max_n_values => :max_n_values);
end;
Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql 10 Mar 2010 00:44:03 -0000 1.18
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs-postgresql.xql 31 Mar 2010 00:46:16 -0000 1.19
@@ -209,7 +209,7 @@
select apm__register_parameter(null, :descendent_package_key, :parameter_name,
- :description, :datatype, :default_value,
+ :description, :scope, :datatype, :default_value,
:section_name, :min_n_values, :max_n_values)
@@ -223,7 +223,7 @@
select apm__register_parameter(null, :new_package_key, :parameter_name, :description,
- :datatype, :default_value, :section_name,
+ :scope, :datatype, :default_value, :section_name,
:min_n_values, :max_n_values)
Index: openacs-4/packages/acs-tcl/tcl/apm-install-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-install-procs.xql,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/acs-tcl/tcl/apm-install-procs.xql 10 Mar 2010 00:44:03 -0000 1.7
+++ openacs-4/packages/acs-tcl/tcl/apm-install-procs.xql 31 Mar 2010 00:46:16 -0000 1.8
@@ -94,6 +94,7 @@
select ap.*
from apm_parameters ap
where package_key = :new_package_key
+ and scope = 'instance'
@@ -102,6 +103,7 @@
select ap.*
from apm_parameters ap
where package_key = :inherited_package_key
+ and scope = 'instance'
Index: openacs-4/packages/acs-tcl/tcl/apm-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/apm-procs.xql,v
diff -u -r1.27 -r1.28
--- openacs-4/packages/acs-tcl/tcl/apm-procs.xql 25 Mar 2010 01:02:16 -0000 1.27
+++ openacs-4/packages/acs-tcl/tcl/apm-procs.xql 31 Mar 2010 00:46:16 -0000 1.28
@@ -242,7 +242,8 @@
select parameter_name, attr_value
from apm_parameters p, apm_parameter_values v, apm_packages a
- where p.parameter_id = v.parameter_id
+ where p.scope = 'instance'
+ and p.parameter_id = v.parameter_id
and a.package_id = v.package_id
and a.package_id = :package_id