+Add Files
+@context@
+
+This script will create a root folder for this instance of the
+populate package and will generate a folder tree of the given depth
+and width, with each folder containing the given number of files.
+Data is taken from a file of your choice.
+
+This script will not work unless File Storage has been installed
+and mounted under the main site with a URL of file-storage.
+
+
Index: openacs-4/contrib/packages/populate/www/add-files.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-files.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-files.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,64 @@
+ad_page_contract {
+
+ Add an arbitrary number of files to the system
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+ad_form -name add_files -html { enctype multipart/form-data } -form {
+ {new_folders_width:integer {label "Width of new folder tree?"}
+ {html { size 5 }}}
+ {new_folders_depth:integer {label "Depth of new folder tree?"}
+ {html { size 5 }}}
+ {new_files_width:integer {label "Files per folder?"}
+ {html { size 5 }}}
+ {upload_file:file {label "Data to load into each file"}}
+ {indb_p:text(radio) {label "File storage type"}
+ {options {{LOB t} {Filesystem f}}}}
+ {user_perms:text(checkbox),multiple,optional
+ {label "Permissions to assign to creation user"}
+ {options {{Read read} {Write write} {Admin admin}}}}
+ {reg_user_perms:text(checkbox),multiple,optional
+ {label "Permissions to assign to registered users"}
+ {options {{Read read} {Write write} {Admin admin}}}}
+} -validate {
+ {new_folders_width
+ { $new_folders_width > 0 }
+ "Width must be greater than zero"
+ }
+ {new_folders_depth
+ { $new_folders_depth > 0 }
+ "Depth must be greater than zero"
+ }
+ {new_files_width
+ { $new_files_width >= 0 }
+ "Files per folder must be greater than or equal to zero"
+ }
+} -on_submit {
+
+ array set file_storage [site_node::get -url "/file-storage"]
+
+ if {[catch { set root_folder_id [fs::get_root_folder -package_id $file_storage(object_id)] }]} {
+ ad_return_error "Could not find root folder" "This is probably because the file-storage package has not been installed and mounted"
+ ad_script_abort
+ }
+
+ fill_folder_tree -folder_id $root_folder_id -level 1 -max_level \
+ $new_folders_depth -width $new_folders_width -files $new_files_width \
+ -file_name "[acs_root_dir]/readme.txt" -upload_file $upload_file -indb_p $indb_p \
+ -user_perms $user_perms -reg_user_perms $reg_user_perms
+
+ ad_returnredirect "index"
+ ad_script_abort
+
+}
+
+set context {"Add files"}
+
+ad_return_template
Index: openacs-4/contrib/packages/populate/www/add-membership-groups-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-groups-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-groups-oracle.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,22 @@
+
+
+ oracle8.1.6
+
+
+
+ begin
+ :1 := composition_rel.new(
+ object_id_one => -2,
+ object_id_two => :group_id
+ );
+ end;
+
+
+
+
+
+ select user_id from cc_users where rownum <= $group_users
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/add-membership-groups-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-groups-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-groups-postgresql.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+ postgresql7.1
+
+
+
+ select composition_rel__new (-2, :group_id)
+
+
+
+
+
+ select user_id from cc_users limit $group_users
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/add-membership-groups.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-groups.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-groups.adp 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,15 @@
+
+Add Groups
+@context@
+This script will create a given number of membership_rel groups and their
+corresponding membership_rel relational segment. A composition_rel will be
+created for each group as well with "registered users" as the parent group.
+
In addition you can optionally create additional relational segments based
+on previously defined relationship types (see the "add new relationship type" page).
+
The specified number of users will be added to each new group and relational
+segment. Since these share an acs_relation only one row is actually inserted
+per user. Though a real system will normally have an uneven distribution
+of users in various groups and relational segments, for scalability testing we don't
+need to model this.
+
There are currently @current_groups@ groups in the database
+
Index: openacs-4/contrib/packages/populate/www/add-membership-groups.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-groups.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-groups.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,118 @@
+ad_page_contract {
+
+ Add an arbitrary number of groups with associated relational segments and
+ their members.
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+set creation_ip [ad_conn peeraddr]
+
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+db_1row get_group_count {}
+db_1row get_user_count {}
+
+set membership_rels [db_list_of_lists get_membership_rels {}]
+
+ad_form -name add_groups -form {
+ {new_groups:integer {label "Number of new groups to add?"}
+ {html { size 5 }}}
+ {rel_segments:text(multiselect),multiple,optional
+ {label "Relational segments to add"}
+ {options $membership_rels}}
+ {group_users:integer {label "Number of users to add to each group (max $current_users)?"}
+ {html { size 5 }}
+ {value 0}}
+} -validate {
+ {group_users
+ { $group_users <= $current_users }
+ "You can only add $current_users users to each group"
+ }
+} -on_submit {
+
+ # DRB: some notes for those not familiar with relational segments.
+
+ # A relational segment defines a subset of a group by mapping a
+ # group_id to a acs_relations rel_type. This script defines a default
+ # relational segment of rel_type membership_rel that contains all members
+ # of the group. Logically there's a 1:1 relationship between members of the
+ # group and members of the membership relational segment (think "subset") of the
+ # group. Therefore we don't need to define a new relation to map users
+ # to the membership relational segment. Though each user is visible in the
+ # group member map and relational segment member map, each occupies a single
+ # row in acs_rels. Sweet! This trick was used by aD in acs-subsite.
+
+ # Therefore each user appears once in acs_rels to map group membership and
+ # the "Group Name Members" relational segment, and once more for each optional
+ # relational segment of type other than membership_rel.
+
+ # You may think at first that sharing acs_rels rows between the group itself
+ # and membership_rels isn't general and therefore is a bad idea. What if
+ # another relational segment of membership_rel is defined that's meant to hold
+ # a subset of the groups members?
+
+ # You can't do this as the datamodel for relational segments constrains
+ # (group_id, rel_type) to be unique. Therefore our default membership_rel
+ # relational segment is the only one that can be created and we're guaranteed
+ # everything will work.
+
+ # This makes sense as the additional relational segments defined for the group
+ # are logically subsets that may or may not have a 1:1 relationship with the members
+ # of the parent group. Therefore we couldn't really "poach" the membership_rel relation
+ # that was defined for the parent group even if the unique constraint were relaxed
+ # (as aD hackers suggested might be reasonble).
+
+ # Why create the members relational segment since the group already makes
+ # use of the membership_rel that's been created for it? Well ... for one thing
+ # membership checks and permissions checking can ignore groups and only check
+ # relational segments if this is done consistently in the toolkit. Code that
+ # lists all members can be shared with code that lists all (say) students rather
+ # than be a special case script that is driven by the group rather than a subset
+ # of the group. The list goes on. Using relational segments consistently will
+ # simplify and with luck speed code ...
+
+ for { set i 1 } { $i <= $new_groups } { incr i } {
+ incr current_groups
+
+ db_transaction {
+ set group_name "Membership Group $current_groups"
+ set group_id [group::new -group_name $group_name group]
+ db_exec_plsql add_composition_rel {}
+ set rels [list membership_rel]
+ rel_segments_new $group_id membership_rel "$group_name Members"
+ foreach type_and_plural $rel_segments {
+ set type_and_plural [split $type_and_plural ":"]
+ set rel_type [lindex $type_and_plural 0]
+ lappend rels $rel_type
+ rel_segments_new $group_id $rel_type "$group_name [lindex $type_and_plural 1]"
+ }
+ } on_error {
+ ad_return_error "Error creating group \"$group_name\"" $errmsg
+ ad_script_abort
+ }
+
+ db_multirow get_users get_users {} {
+ db_transaction {
+ foreach rel $rels {
+ relation_add -member_state approved $rel $group_id $user_id
+ }
+ } on_error {
+ ad_return_error "Error adding users to group \"$group_name\"" $errmsg
+ ad_script_abort
+ }
+ }
+ }
+
+ ad_returnredirect "index"
+ ad_script_abort
+
+}
+
+set context {"Add groups"}
+
+ad_return_template
Index: openacs-4/contrib/packages/populate/www/add-membership-groups.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-groups.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-groups.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ select count(*) as current_groups from groups
+
+
+
+
+
+ select count(*) as current_users from cc_users
+
+
+
+
+
+ select o.pretty_plural, o.object_type || ':' || o.pretty_plural as type_and_plural
+ from acs_object_types o, acs_object_type_supertype_map m
+ where m.ancestor_type = 'membership_rel'
+ and o.object_type = m.object_type
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/add-membership-segment.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-membership-segment.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-membership-segment.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+ select * from acs_rel_types where rel_type = lower(:segment_name) || '_rel'
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/add-rel-type.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-rel-type.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-rel-type.adp 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,8 @@
+
+Add Relationship Type
+@context@
+This script will create a new subtype of membership_rel that can later
+be used by the "add groups" script to model sets of groups like
+those implemented by dotLRN (for instance a class group with professor, student,
+and TA subgroups).
+
Index: openacs-4/contrib/packages/populate/www/add-rel-type.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-rel-type.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-rel-type.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,43 @@
+ad_page_contract {
+
+ Add an arbitrary number of new users
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+set creation_ip [ad_conn peeraddr]
+
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+ad_form -name add_rel_type -form {
+ {rel_type:text {label "New membership_rel subtype to add?"}}
+ {pretty_name:text {label "Pretty name?"}}
+ {pretty_plural:text {label "Pretty plural?"}}
+} -validate {
+ {rel_type
+ { ![db_0or1row check_rel_type {}] }
+ "A relationship type based on this name already exists"
+ }
+} -on_submit {
+
+ db_transaction {
+
+ rel_types::new -supertype membership_rel -role_two member ${rel_type} $pretty_name $pretty_plural group 1 1 person 0 ""
+
+ } on_error {
+ ad_return_error "Creation of membership relationship type failed" $errmsg
+ ad_script_abort
+ }
+
+ ad_returnredirect "index"
+ ad_script_abort
+
+}
+
+set context {"Add membership relationship type"}
+
+ad_return_template
Index: openacs-4/contrib/packages/populate/www/add-rel-type.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-rel-type.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-rel-type.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ select 1
+ from dual
+ where exists (select 1 from acs_rel_types where rel_type = :rel_type)
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/add-subsites.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-subsites.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-subsites.adp 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,10 @@
+
+Add Subsites
+@context@
+
+The top level subsites inserted by this script will be mounted
+under the main subsite. The width parameter determines how many
+subsites will be added at each level. The depth parameter determines
+how many levels will be created.
+
+
Index: openacs-4/contrib/packages/populate/www/add-subsites.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-subsites.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-subsites.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,43 @@
+ad_page_contract {
+
+ Add an arbitrary number of new subsites
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+ad_form -name add_subsites -form {
+ {new_subsites_width:integer {label "Width of new subsite tree?"}
+ {html { size 5 }}}
+ {new_subsites_depth:integer {label "Depth of new subsite tree?"}
+ {html { size 5 }}}
+} -validate {
+ {new_subsites_width
+ { $new_subsites_width > 0 }
+ "Width must be greater than zero"
+ }
+ {new_subsites_depth
+ { $new_subsites_depth > 0 }
+ "Depth must be greater than zero"
+ }
+} -on_submit {
+
+ array set root_node [site_node::get -url "/"]
+ set context_id $root_node(package_id)
+ set parent_id $root_node(node_id)
+
+ fill_subsite_tree -parent_id $parent_id -context_id $context_id -level 1 -max_level $new_subsites_depth -width $new_subsites_width
+
+ ad_returnredirect "index"
+ ad_script_abort
+
+}
+
+set context {"Add subsites"}
+
+ad_return_template
Index: openacs-4/contrib/packages/populate/www/add-users.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-users.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-users.adp 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,6 @@
+
+Add Users
+@context@
+There are currently @current_users@ users in the database
+
+
Index: openacs-4/contrib/packages/populate/www/add-users.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-users.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-users.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,39 @@
+ad_page_contract {
+
+ Add an arbitrary number of new users
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+db_1row get_user_count {}
+
+ad_form -name add_users -form {
+ {new_users:integer {label "Number of new users to add?"}
+ {html { size 5 }}}
+} -on_submit {
+
+ for { set i 1 } { $i <= $new_users } { incr i } {
+ incr current_users
+ set email "user_${current_users}@users.users"
+ set last_name "last_${current_users}"
+ set first_names "first_${current_users}"
+ set password "test"
+ set question "foo?"
+ set answer "bar"
+ ad_user_new $email $first_names $last_name $password $question $answer
+ }
+
+ ad_returnredirect "index"
+ ad_script_abort
+
+}
+
+set context {"Add users"}
+
+ad_return_template
Index: openacs-4/contrib/packages/populate/www/add-users.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/add-users.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/add-users.xql 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+ select count(*) as current_users from cc_users
+
+
+
+
Index: openacs-4/contrib/packages/populate/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/index.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/index.adp 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,26 @@
+
+Populate
+@context@
+Create a bunch of users first. If you want to create a custom relational segments
+(as for instance dotLRN does for students, professors etc) create some appropriate
+relationship types next. Then use the "Add new membership groups" script to create
+groups, relational segments (subsets) of them, and members of the group and its
+subsets.
+
+It may also be useful to test the scalability of the site node datamodel, particularly to
+measure how the strategy of caching the information impacts start-up time. Use the
+following script to mount a large number of acs-subsite instances.
+
+We use file storage as a representative package to test the scalability of the content repository.
+This script will fail if you've not already installed and mounted file storage.
+
+After populating the database you will need to analyze all tables (Oracle) or do a
+VACUUM ANALYZE before doing any performance analysis.
Index: openacs-4/contrib/packages/populate/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/populate/www/index.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/populate/www/index.tcl 27 Jan 2003 20:23:29 -0000 1.1
@@ -0,0 +1,16 @@
+ad_page_contract {
+
+ Populate database
+
+ @author Don Baccus (dhogaza@pacifier.com)
+ @creation-date 2003-01-07
+
+}
+
+set package_id [ad_conn package_id]
+set user_id [ad_verify_and_get_user_id]
+permission::require_permission -party_id $user_id -object_id $package_id -privilege admin
+
+set context {}
+
+ad_return_template