Index: openacs-4/packages/categories/categories.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/categories.info,v diff -u -N -r1.21.2.3 -r1.21.2.4 --- openacs-4/packages/categories/categories.info 3 May 2020 17:39:48 -0000 1.21.2.3 +++ openacs-4/packages/categories/categories.info 10 Mar 2021 15:18:32 -0000 1.21.2.4 @@ -10,7 +10,7 @@ t categories - + timo@timohentschel.de Manage categories in category trees and let users map objects to categories. 2017-08-06 @@ -19,7 +19,7 @@ GPL 1 - + Index: openacs-4/packages/categories/sql/oracle/categories-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/oracle/categories-init.sql,v diff -u -N -r1.3 -r1.3.20.1 --- openacs-4/packages/categories/sql/oracle/categories-init.sql 8 Feb 2004 17:27:33 -0000 1.3 +++ openacs-4/packages/categories/sql/oracle/categories-init.sql 10 Mar 2021 15:18:32 -0000 1.3.20.1 @@ -38,38 +38,3 @@ -- there should be an implementation of this contract -- for apm_package, user, group and other object types - - --- this should eventually be added to acs-kernel - -create table acs_named_objects ( - object_id integer not null - constraint acs_named_objs_object_id_fk - references acs_objects(object_id) on delete cascade, - locale varchar2(5) - constraint acs_named_objs_locale_fk - references ad_locales, - object_name varchar2(200), - creation_date date default sysdate not null, - package_id integer - constraint acs_named_objs_package_id_fk - references apm_packages(package_id) on delete cascade, - constraint acs_named_objs_pk - primary key (object_id, locale) -); - -create index acs_named_objs_name_ix on acs_named_objects (substr(upper(object_name),1,1)); -create index acs_named_objs_package_ix on acs_named_objects(package_id); - -begin - acs_object_type.create_type ( - supertype => 'acs_object', - object_type => 'acs_named_object', - pretty_name => 'Named Object', - pretty_plural => 'Named Objects', - table_name => 'acs_named_objects', - id_column => 'object_id' - ); -end; -/ -show errors Index: openacs-4/packages/categories/sql/oracle/upgrade/upgrade-1.1.5d3-1.1.5d4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/oracle/upgrade/Attic/upgrade-1.1.5d3-1.1.5d4.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/sql/oracle/upgrade/upgrade-1.1.5d3-1.1.5d4.sql 10 Mar 2021 15:18:32 -0000 1.1.2.1 @@ -0,0 +1,12 @@ + +-- Cleanup of obsolete acs_named_objects table and object type is +-- optional, as there might be running systems with object types +-- depending on acs_named_object. +-- UNTESTED + +-- drop table acs_named_objects; + +-- begin +-- acs_object_type.drop_type('acs_named_object', 't'); +-- acs_object_type.drop_type('category_tree', 't'); +-- end; Index: openacs-4/packages/categories/sql/postgresql/categories-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/postgresql/categories-drop.sql,v diff -u -N -r1.8 -r1.8.2.1 --- openacs-4/packages/categories/sql/postgresql/categories-drop.sql 7 Aug 2017 23:48:05 -0000 1.8 +++ openacs-4/packages/categories/sql/postgresql/categories-drop.sql 10 Mar 2021 15:18:32 -0000 1.8.2.1 @@ -87,8 +87,6 @@ select acs_privilege__drop_privilege('category_tree_grant_permissions'); -- from categories-init -drop table acs_named_objects; -select acs_object_type__drop_type('acs_named_object', 't'); select acs_sc_contract__delete(acs_sc_contract__get_id('AcsObject')); select acs_sc_msg_type__delete(acs_sc_msg_type__get_id('AcsObject.PageUrl.InputType')); select acs_sc_msg_type__delete(acs_sc_msg_type__get_id('AcsObject.PageUrl.OutputType')); Index: openacs-4/packages/categories/sql/postgresql/categories-init.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/postgresql/categories-init.sql,v diff -u -N -r1.3 -r1.3.6.1 --- openacs-4/packages/categories/sql/postgresql/categories-init.sql 30 Mar 2013 22:50:44 -0000 1.3 +++ openacs-4/packages/categories/sql/postgresql/categories-init.sql 10 Mar 2021 15:18:32 -0000 1.3.6.1 @@ -34,40 +34,3 @@ -- there should be an implementation of this contract -- for apm_package, user, group and other object types - - --- this should eventually be added to acs-kernel - -create table acs_named_objects ( - object_id integer not null - constraint acs_named_objs_pk primary key - constraint acs_named_objs_object_id_fk - references acs_objects(object_id) on delete cascade, - object_name varchar(200), - package_id integer - constraint acs_named_objs_package_id_fk - references apm_packages(package_id) on delete cascade -); - -create index acs_named_objs_name_ix on acs_named_objects(object_name); -create index acs_named_objs_package_ix on acs_named_objects(package_id); - -CREATE OR REPLACE FUNCTION inline_0 () RETURNS integer AS $$ -BEGIN - PERFORM acs_object_type__create_type ( - 'acs_named_object', -- object_type - 'Named Object', -- pretty_name - 'Named Objects', -- pretty_plural - 'acs_object', -- supertype - 'acs_named_objects', -- table_name - 'object_id', -- id_column - null, -- name_method - 'f', - null, - null - ); - return 0; -END; -$$ LANGUAGE plpgsql; -select inline_0 (); -drop function inline_0 (); Index: openacs-4/packages/categories/sql/postgresql/upgrade/upgrade-1.1.5d3-1.1.5d4.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/sql/postgresql/upgrade/Attic/upgrade-1.1.5d3-1.1.5d4.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/categories/sql/postgresql/upgrade/upgrade-1.1.5d3-1.1.5d4.sql 10 Mar 2021 15:18:32 -0000 1.1.2.1 @@ -0,0 +1,10 @@ + +-- Cleanup of obsolete acs_named_objects table and object type is +-- optional, as there might be running systems with object types +-- depending on acs_named_object. +-- begin; + +-- drop table if exists acs_named_objects; +-- select acs_object_type__drop_type('acs_named_object', 't'); + +-- end; Index: openacs-4/packages/categories/www/doc/o.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/doc/o.adp,v diff -u -N -r1.3.2.2 -r1.3.2.3 --- openacs-4/packages/categories/www/doc/o.adp 3 Jul 2020 08:03:18 -0000 1.3.2.2 +++ openacs-4/packages/categories/www/doc/o.adp 10 Mar 2021 15:18:32 -0000 1.3.2.3 @@ -1,86 +1,15 @@ -{/doc/categories {Categories}} {Object Names and IdHandler Service Contract} -Object Names and IdHandler Service Contract +{/doc/categories {Categories}} {IdHandler Service Contract} +IdHandler Service Contract -

Object Names and IdHandler Service Contract

-

Object Names

+

IdHandler Service Contract

-When presenting a list of objects in a package not native to the -objects (i.e. permissioning, community-member, category-usage) -there has to be a fast and easy way to figure out the name of -objects. Until now, this has been done by using something like -
-acs_objects.name(object_id)
-
- -which essential means that for every object to be displayed (and -since the mentioned pages are in no means scalable and therefore -are likely to display a huge amount of objects) this pl/sql proc -will have to figure out which package-specific pl/sql proc to call -which itself will do at least one query to get the object-name. -

Obviously, this is highly undesirable since it is not scalable -at all. Therefore, a new way had to be found to get the name of an -object:

-
--------------------
--- NAMED OBJECTS --
--------------------
-
-create table acs_named_objects (
-        object_id       integer not null
-                        constraint acs_named_objs_pk primary key
-                        constraint acs_named_objs_object_id_fk
-                        references acs_objects(object_id) on delete cascade,
-        object_name     varchar2(200),
-        package_id      integer
-                        constraint acs_named_objs_package_id_fk
-                        references apm_packages(package_id) on delete cascade
-);
-
-create index acs_named_objs_name_ix on acs_named_objects (substr(upper(object_name),1,1));
-create index acs_named_objs_package_ix on acs_named_objects(package_id);
-
-begin
-        acs_object_type.create_type (
-                supertype       =>      'acs_object',
-                object_type     =>      'acs_named_object',
-                pretty_name     =>      'Named Object',
-                pretty_plural   =>      'Named Objects',
-                table_name      =>      'acs_named_objects',
-                id_column       =>      'object_id'
-        );
-end;
-/
-show errors
-
- -This means that every displayable object-type should no longer be -derived from acs_objects, but from acs_named_objects and that by -using triggers or extending the appropriate pl/sql procs, every -displayable object (certainly not acs_rels or something the like) -should have an evtry in that extension of the acs_objects table. -

In that way, when having to display a list of objects, one can -simply join the acs_named_objects table to get the names and -package_ids in an easy and - more importantly - fast and scalable -way.

-

The only shortcoming of this solution is the disregard of -internationalization, but in cases where there objects in more than -one language, it should be the triggers / pl/sql procs task to make -sure that acs_named_objects contains names in the default language -if possible.

-

IdHandler Service Contract

- Besides displaying the names of objects, some pages also want to provide links to the objects. Unfortunately, there currently is no way to do so.

First, we need to know that package_id of the package -responsible for the object. This information is currently -impossible to get since we would need to go up the context -hierarchy until we finally get hold of an apm_package object. But -lets assume we get this information by using the new -acs_named_objects table, then we would need to figure out the url -to that package instance. This can be done, but again by calling a -highly unefficient pl/sql proc. But even then we would need the +responsible for the object, then we would need to figure out the url +to that package instance. This can be done, but then we would need the local url to the page being able to display a certain object. Since a package may have more than one type of objects (i.e. file folders, files, file versions), we can not simply store additional @@ -90,8 +19,7 @@ at all during display-time, but doing so at the time the user actually wants to see an object. The links would simply direct to /o/$object_id, which is a global virtual-url-handling page that -will figure out the package instance url (by using -acs_named_objects and the pl/sql proc) and then relying upon a +will figure out the package instance url and then relying upon a Service Contract to get the local url - that means every package holding displayable objects should implement this interface for its objects:

Index: openacs-4/packages/categories/www/doc/o.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/www/doc/o.html,v diff -u -N -r1.1.1.1.22.2 -r1.1.1.1.22.3 --- openacs-4/packages/categories/www/doc/o.html 3 Jul 2020 08:03:18 -0000 1.1.1.1.22.2 +++ openacs-4/packages/categories/www/doc/o.html 10 Mar 2021 15:18:32 -0000 1.1.1.1.22.3 @@ -1,106 +1,28 @@ - Object Names and IdHandler Service Contract + IdHandler Service Contract -

Object Names and IdHandler Service Contract

+

IdHandler Service Contract

-
-

Object Names

- -When presenting a list of objects in a package not native to the -objects (i.e. permissioning, community-member, category-usage) -there has to be a fast and easy way to figure out the name of -objects. Until now, this has been done by using something like -
-acs_objects.name(object_id)
-
-which essential means that for every object to be displayed -(and since the mentioned pages are in no means scalable and -therefore are likely to display a huge amount of objects) -this pl/sql proc will have to figure out which package-specific -pl/sql proc to call which itself will do at least one query -to get the object-name. -

-Obviously, this is highly undesirable since it is not scalable -at all. Therefore, a new way had to be found to get the name -of an object: -

--------------------
--- NAMED OBJECTS --
--------------------
-
-create table acs_named_objects (
-	object_id	integer not null
-			constraint acs_named_objs_pk primary key
-			constraint acs_named_objs_object_id_fk
-			references acs_objects(object_id) on delete cascade,
-	object_name	varchar2(200),
-	package_id	integer
-			constraint acs_named_objs_package_id_fk
-			references apm_packages(package_id) on delete cascade
-);
-
-create index acs_named_objs_name_ix on acs_named_objects (substr(upper(object_name),1,1));
-create index acs_named_objs_package_ix on acs_named_objects(package_id);
-
-begin
-        acs_object_type.create_type (
-                supertype       =>      'acs_object',
-                object_type     =>      'acs_named_object',
-                pretty_name     =>      'Named Object',
-                pretty_plural   =>      'Named Objects',
-                table_name      =>      'acs_named_objects',
-                id_column       =>      'object_id'
-        );
-end;
-/
-show errors
-
- -This means that every displayable object-type should no longer be -derived from acs_objects, but from acs_named_objects and that -by using triggers or extending the appropriate pl/sql procs, -every displayable object (certainly not acs_rels or something the -like) should have an evtry in that extension of the acs_objects table. -

-In that way, when having to display a list of objects, one can simply -join the acs_named_objects table to get the names and package_ids -in an easy and - more importantly - fast and scalable way. -

-The only shortcoming of this solution is the disregard of -internationalization, but in cases where there objects in more -than one language, it should be the triggers / pl/sql procs task -to make sure that acs_named_objects contains names in the -default language if possible. - - -

IdHandler Service Contract

- Besides displaying the names of objects, some pages also want to provide links to the objects. Unfortunately, there currently is no way to do so.

-First, we need to know that package_id of the package -responsible for the object. This information is currently impossible -to get since we would need to go up the context hierarchy until we -finally get hold of an apm_package object. But lets assume we -get this information by using the new acs_named_objects -table, then we would need to figure out the url to that -package instance. This can be done, but again by calling a -highly unefficient pl/sql proc. But even then we would need the -local url to the page being able to display a certain object. -Since a package may have more than one type of objects (i.e. file folders, -files, file versions), we can not simply store additional -package information about which page to call to display an object. +First, we need to know that package_id of the package responsible for +the object, then we would need to figure out the url to that package +instance. This can be done, but even then we would need the local url +to the page being able to display a certain object. Since a package +may have more than one type of objects (i.e. file folders, files, file +versions), we can not simply store additional package information +about which page to call to display an object.

The solution to this kind of problem is by not resolving the url at all during display-time, but doing so at the time the user actually wants to see an object. The links would simply direct to /o/$object_id, which is a global virtual-url-handling page -that will figure out the package instance url (by using -acs_named_objects and the pl/sql proc) and then relying +that will figure out the package instance url and then relying upon a Service Contract to get the local url - that means every package holding displayable objects should implement this interface for its objects: