Index: openacs-4/packages/logger/sql/oracle/logger-tables-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/sql/oracle/logger-tables-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/sql/oracle/logger-tables-create.sql 5 Apr 2003 10:16:16 -0000 1.1
+++ openacs-4/packages/logger/sql/oracle/logger-tables-create.sql 5 Apr 2003 13:10:13 -0000 1.2
@@ -157,6 +157,8 @@
represent an average.
';
+create sequence logger_projections_seq;
+
create table logger_measurements (
measurement_id integer
constraint logger_measurements_pk
Index: openacs-4/packages/logger/sql/oracle/logger-tables-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/sql/oracle/logger-tables-drop.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/sql/oracle/logger-tables-drop.sql 5 Apr 2003 10:16:16 -0000 1.1
+++ openacs-4/packages/logger/sql/oracle/logger-tables-drop.sql 5 Apr 2003 13:10:13 -0000 1.2
@@ -12,6 +12,8 @@
drop table logger_projections;
+drop sequence logger_projections_seq;
+
drop table logger_project_var_map;
drop table logger_variables;
Index: openacs-4/packages/logger/tcl/project-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/project-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/tcl/project-procs.xql 5 Apr 2003 10:16:42 -0000 1.1
+++ openacs-4/packages/logger/tcl/project-procs.xql 5 Apr 2003 13:10:42 -0000 1.2
@@ -32,7 +32,9 @@
-
+ select variable_id
+ from logger_project_var_map
+ where project_id = :project_id
Index: openacs-4/packages/logger/tcl/projection-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/projection-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/logger/tcl/projection-procs.tcl 5 Apr 2003 13:10:42 -0000 1.1
@@ -0,0 +1,82 @@
+ad_library {
+ Procedures in the logger::projection namespace. Those procedures
+ operate on logger projection objects.
+
+ @creation-date 5:th of April 2003
+ @author Peter Marklund (peter@collaboraid.biz)
+ @cvs-id $Id: projection-procs.tcl,v 1.1 2003/04/05 13:10:42 peterm Exp $
+}
+
+namespace eval logger::projection {}
+
+ad_proc -public logger::projection::new {
+ {-projection_id ""}
+ {-project_id:required}
+ {-variable_id:required}
+ {-start_time:required}
+ {-end_time:required}
+ {-value:required}
+} {
+ Create a new projection for a certain variable and project.
+
+ @param projection_id An optional pre-generated id for the projection.
+ @param project_id The id of the project the projection is for
+ @param variable_id The id of the variable the projection is for
+ @param start_time Marks the start of the time range the projection is for.
+ Must be on ANSI format.
+ @param end_time Marks the end of the time range the projection is for.
+ Must be on ANSI format.
+ @param value The anticipated or targeted value (a sum for
+ additive variables, an average for non-additive
+ variables).
+
+ @return The id of the created projection. Will throw an error if a projection_id
+ is provided and a projection with that id already exists in the database.
+
+ @author Peter Marklund
+} {
+ # Default projection_id to next id in a sequence
+ if { [empty_string_p $projection_id] } {
+ set projection_id [db_nextval logger_projections_seq]
+ }
+
+ db_dml insert_projection {}
+
+ return $projection_id
+}
+
+ad_proc -public logger::projection::delete {
+ {-projection_id:required}
+} {
+ Delete a projection with a certain id
+
+ @param projection_id The id of the projection to delete
+
+ @return The return value from db_dml
+
+ @author Peter Marklund
+} {
+ db_dml delete_projection {}
+}
+
+ad_proc -public logger::projection::get {
+ {-projection_id:required}
+ {-array:required}
+} {
+ Retrieve attributes of the projection with given id into an
+ array (using upvar) in the callers scope. The
+ array will contain the keys projection_id, project_id, variable_id, start_time,
+ end_time, value.
+
+ @param projection_id The id of the projection to retrieve information about
+ @param array The name of the array in the callers scope where the information will
+ be stored
+
+ @return The return value from db_1row. Throws an error if the projection doesn't exist.
+
+ @author Peter Marklund
+} {
+ upvar $array projection_array
+
+ db_1row select_projection {} -column_array projection_array
+}
Index: openacs-4/packages/logger/tcl/projection-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/projection-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/logger/tcl/projection-procs.xql 5 Apr 2003 13:10:42 -0000 1.1
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ insert into logger_projections (projection_id, project_id, variable_id, start_time, end_time, value)
+ values (:projection_id, :project_id, :variable_id, :start_time, :end_time, :value)
+
+
+
+
+
+ delete from logger_projections
+ where projection_id = :projection_id
+
+
+
+
+
+ select projection_id,
+ project_id,
+ variable_id,
+ start_time,
+ end_time,
+ value
+ from logger_projections
+ where projection_id = :projection_id
+
+
+
+
Index: openacs-4/packages/logger/tcl/variable-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/variable-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/tcl/variable-procs.tcl 5 Apr 2003 10:16:42 -0000 1.1
+++ openacs-4/packages/logger/tcl/variable-procs.tcl 5 Apr 2003 13:10:42 -0000 1.2
@@ -31,7 +31,7 @@
} {
ad_assert_arg_value_in_list type {additive non-additive}
- # Default variable_id to next id in sequence
+ # Default variable_id to next id in a sequence
if { [empty_string_p $variable_id] } {
set variable_id [db_nextval logger_variables_seq]
}
@@ -59,7 +59,7 @@
{-variable_id:required}
{-array:required}
} {
- Retrieve info about the variable with given id into an
+ Retrieve attributes of the variable with given id into an
array (using upvar) in the callers scope. The
array will contain the keys variable_id, name, unit, and type.
@@ -71,7 +71,7 @@
@author Peter Marklund
} {
- upvar $array project_array
+ upvar $array variable_array
- db_1row select_variable {} -column_array project_array
+ db_1row select_variable {} -column_array variable_array
}
Index: openacs-4/packages/logger/tcl/test/logger-test-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/test/logger-test-init.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/tcl/test/logger-test-init.tcl 5 Apr 2003 10:16:58 -0000 1.1
+++ openacs-4/packages/logger/tcl/test/logger-test-init.tcl 5 Apr 2003 13:11:09 -0000 1.2
@@ -38,6 +38,9 @@
unit EUR
type additive
}
+ set projection_start_time "2003-04-10"
+ set projection_end_time "2003-04-20"
+ set projection_value "10"
# Create a package
set package_id [apm_package_instance_new -instance_name $package_name \
@@ -50,14 +53,14 @@
# Assert that the name of the project can be retrieved
logger::project::get -project_id $project_id \
-array project_array
- aa_equals "Checking that name of project is correct" $project_array(name) $project_name
+ aa_equals "Names of projects can be retrieved after creation" $project_array(name) $project_name
# Assert that the project is mapped to the package and not mapped to any other packages
set all_projects_list [logger::package::all_projects_in_package -package_id $package_id]
set only_projects_list [logger::package::projects_only_in_package -package_id $package_id]
foreach list_var_name {all_projects_list only_projects_list} {
set list_var_value [set $list_var_name]
- aa_true "The correct project is mapped to the package ($list_var_name)" \
+ aa_true "Projects can be retrieved for package ($list_var_name)" \
[expr [llength $list_var_value] == 1 && [string equal [lindex $list_var_value 0] $project_id]]
}
@@ -86,19 +89,32 @@
-variable_id $expense_var_id
# Assert that variables are retrievable
- logger::variable::get -variable_id $hours_var_id -array hours_var
- logger::variable::get -variable_id $minutes_var_id -array minutes_var
- logger::variable::get -variable_id $expense_var_id -array expense_var
+ logger::variable::get -variable_id $hours_var_id -array hours_var_retr
+ logger::variable::get -variable_id $minutes_var_id -array minutes_var_retr
+ logger::variable::get -variable_id $expense_var_id -array expense_var_retr
+ set expected_var_names [list $hours_var(name) $minutes_var(name) $expense_var(name)]
+ set retrieved_var_names [list $hours_var_retr(name) $minutes_var_retr(name) $expense_var_retr(name)]
+ aa_true "Names of variables can be retrieved after creation" [util_sets_equal_p $expected_var_names \
+ $retrieved_var_names]
# Assert that variables are mapped to the project
set expected_var_list [list $hours_var_id $minutes_var_id $expense_var_id]
set actual_var_list [logger::project::get_variables -project_id $project_id]
- aa_true "checking that variables are mapped to project" [util_sets_equal_p $expected_var_list \
+ aa_true "Variables can be retrieved for project" [util_sets_equal_p $expected_var_list \
$actual_var_list]
- # Create projections
- # Check that the projections can be retrieved
+ # Create a projection
+ set projection_id [logger::projection::new -project_id $project_id \
+ -variable_id $hours_var_id \
+ -start_time $projection_start_time \
+ -end_time $projection_end_time \
+ -value $projection_value]
+ # Assert that projection values can be retrieved
+ logger::projection::get -projection_id $projection_id -array projection
+ aa_equals "Projection values can be retrieved after creation" $projection(value) \
+ $projection_value
+
# Create mesurements
# Check that measurements are retrievable