Commit 2a3da3d6 authored by Richard Hult's avatar Richard Hult Committed by Richard Hult

Add short name for resources. Fixes bug #132345, based on patch from

2004-03-15  Richard Hult  <richard@imendio.com>

	* Add short name for resources. Fixes bug #132345, based on patch
	from Lincoln Phipps. Also fix a few memory leaks while at it.
parent fb37166e
2004-03-15 Richard Hult <richard@imendio.com>
* Add short name for resources. Fixes bug #132345, based on patch
from Lincoln Phipps. Also fix a few memory leaks while at it.
2004-03-15 Richard Hult <richard@imendio.com>
* src/planner-gantt-print.c (planner_gantt_print_data_new): Patch
......
......@@ -78,6 +78,7 @@ Note: A mistake in the format design led to this suboptimality. A
<!ELEMENT resource (properties?)>
<!ATTLIST resource id CDATA #REQUIRED
name CDATA #REQUIRED
short-name CDATA #IMPLIED
email CDATA #IMPLIED
type (1|2) #REQUIRED
group CDATA #IMPLIED
......
......@@ -61,7 +61,7 @@
<widget class="GtkTable" id="table1">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
......@@ -110,8 +110,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -135,8 +135,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -160,8 +160,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -185,8 +185,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -201,8 +201,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -217,8 +217,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -239,8 +239,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -261,8 +261,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -288,6 +288,53 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_short_name">
<property name="visible">True</property>
<property name="label" translatable="yes">_Short name:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">entry_name</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_short_name">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Optional - overrides resource name in Gantt view.</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
......
......@@ -116,7 +116,7 @@
<widget class="GtkTable" id="table1">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
......@@ -165,8 +165,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -209,8 +209,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
......@@ -233,8 +233,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
......@@ -249,12 +249,60 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label105">
<property name="visible">True</property>
<property name="label" translatable="yes">_Short name:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">name_entry</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="short_name_entry">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Optional - overrides resource name in gantt view.</property>
<property name="can_focus">True</property>
<property name="has_focus">False</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -182,6 +182,8 @@ TH.res-hdr { }
margin-left: 10px;
}
TD.res-short-name { }
TD.res-type { }
TD.res-email { }
......
......@@ -32,6 +32,7 @@
<table class="resources" cellspacing="1" cellpadding="2" border="1">
<tr class="resources-hdr">
<th align="left" class="res-hdr">Name</th>
<th align="left" class="res-hdr">Short name</th>
<th align="left" class="res-hdr">Type</th>
<th align="left" class="res-hdr">Email</th>
<th align="left" class="res-hdr">Tasks</th>
......@@ -108,6 +109,11 @@
<a name="res-{@id}"><xsl:value-of select="@name"/></a>
</span>
</td>
<td class="res-short-name">
<span class="res-short-name">
<xsl:value-of select="@short-name"/>
</span>
</td>
<td class="res-type">
<xsl:choose>
<xsl:when test="@type = 1">Worker</xsl:when>
......
EXTRA_DIST = README database.sql
EXTRA_DIST = README database.sql database-0.7.sql upgrade-0.6.x-0.7.sql
......@@ -4,11 +4,11 @@ postgres SQL database.
A very brief getting started howto (change username etc to use...):
* Init database:
* Init database (WARNING: This is usually already done on a working system):
initdb -D /tmp/test-db
* Start server:
* Start server (WARNING: This is usually already done on a working system):
postmaster -D /tmp/test-db
......@@ -24,12 +24,26 @@ A very brief getting started howto (change username etc to use...):
echo 'CREATE GROUP planner WITH USER rhult;' | psql -e -U rhult -d plannerdb
* Create tables:
* Create tables from new. This depends upon the schema that you are up to
in your code. Look in libplanner/dtd and identify the highest DTD version
shown. This corresponds to the SQL file in this directory.
e.g.
cat database.sql | psql -e -U rhult -d plannerdb
or e.g.
cat database-0.7.sql | psql -e -U rhult -d plannerdb
* Update Tables (in existing database). If you already have a database then
just update this to the new schema. Use the appropriate update file based
on your old and new schema,
e.g.
cat update-0.6.x-0.7.sql | psql -e -U rhult -d plannerdb
* Drop database and group to start over:
dropdb plannerdb
echo 'DROP GROUP planner;' | psql -e -U rhult -d plannerdb
dropdb plannerdb
-- $Id$
-- Planner Database Schema
-- Daniel Lundin <daniel@codefactory.se>
-- Richard Hult <richard@imendio.com>
-- Copyright 2003 CodeFactory AB
--
-- Project
--
CREATE TABLE project (
proj_id serial,
name text NOT NULL,
company text,
manager text,
proj_start date NOT NULL DEFAULT CURRENT_TIMESTAMP,
cal_id integer,
phase text,
default_group_id integer,
revision integer,
last_user text NOT NULL DEFAULT (user),
PRIMARY KEY (proj_id)
);
GRANT select,insert,update,delete ON project TO GROUP planner;
GRANT select,update ON project_proj_id_seq TO GROUP planner;
--
-- Phases
--
CREATE TABLE phase (
phase_id serial,
proj_id integer,
name text NOT NULL,
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (phase_id)
);
GRANT select,insert,update,delete ON phase TO GROUP planner;
GRANT select,update ON phase_phase_id_seq TO GROUP planner;
--
-- Day Types
--
CREATE TABLE daytype (
dtype_id serial,
proj_id integer,
name text,
descr text,
is_work boolean NOT NULL DEFAULT FALSE,
is_nonwork boolean NOT NULL DEFAULT FALSE,
UNIQUE (proj_id, name),
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (dtype_id)
);
GRANT select,insert,update,delete ON daytype TO GROUP planner;
GRANT select,update ON daytype_dtype_id_seq TO GROUP planner;
--
-- Calendar
--
CREATE TABLE calendar (
cal_id serial,
proj_id integer,
parent_cid integer,
name text,
day_mon integer DEFAULT NULL,
day_tue integer DEFAULT NULL,
day_wed integer DEFAULT NULL,
day_thu integer DEFAULT NULL,
day_fri integer DEFAULT NULL,
day_sat integer DEFAULT NULL,
day_sun integer DEFAULT NULL,
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (day_mon) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_tue) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_wed) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_thu) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_fri) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_sat) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (day_sun) REFERENCES daytype (dtype_id)
ON DELETE SET DEFAULT ON UPDATE CASCADE
DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (parent_cid) REFERENCES calendar (cal_id)
ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY (cal_id)
);
GRANT select,insert,update,delete ON calendar TO GROUP planner;
GRANT select,update ON calendar_cal_id_seq TO GROUP planner;
ALTER TABLE project ADD CONSTRAINT project_cal_id
FOREIGN KEY (cal_id) REFERENCES calendar (cal_id)
ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;
--
-- Day
--
CREATE TABLE day (
day_id serial,
cal_id integer,
dtype_id integer,
date date,
FOREIGN KEY (dtype_id) REFERENCES daytype (dtype_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (cal_id) REFERENCES calendar (cal_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (day_id)
);
GRANT select,insert,update,delete ON day TO GROUP planner;
--
-- Day (working) Interval
--
CREATE TABLE day_interval (
cal_id integer,
dtype_id integer,
start_time time with time zone,
end_time time with time zone,
FOREIGN KEY (dtype_id) REFERENCES daytype (dtype_id)
ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE,
FOREIGN KEY (cal_id) REFERENCES calendar (cal_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (dtype_id, cal_id, start_time, end_time)
);
GRANT select,insert,update,delete ON day_interval TO GROUP planner;
--
-- Task
--
CREATE TABLE task (
task_id serial,
parent_id integer,
proj_id integer,
name text NOT NULL,
note text,
start timestamp with time zone,
finish timestamp with time zone,
work integer DEFAULT 0,
duration integer DEFAULT 0,
percent_complete integer DEFAULT 0,
is_milestone boolean NOT NULL DEFAULT FALSE,
is_fixed_work boolean NOT NULL DEFAULT TRUE,
constraint_type text NOT NULL DEFAULT 'ASAP',
constraint_time timestamp with time zone,
CHECK (constraint_type = 'ASAP' OR constraint_type = 'MSO' OR constraint_type = 'FNLT' OR constraint_type = 'SNET'),
CHECK (percent_complete > -1 AND percent_complete < 101),
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (parent_id) REFERENCES task (task_id)
ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY (task_id)
);
GRANT select,insert,update,delete ON task TO GROUP planner;
GRANT select,update ON task_task_id_seq TO GROUP planner;
-- FIXME: Add triggers to handle different types of tasks/milestones
--
-- Predecessor (tasks)
--
CREATE TABLE predecessor (
task_id integer NOT NULL,
pred_task_id integer NOT NULL,
pred_id serial,
type text NOT NULL DEFAULT 'FS',
lag integer DEFAULT 0,
CHECK (type = 'FS' OR type = 'FF' OR type = 'SS' OR type = 'SF'),
UNIQUE (pred_id),
FOREIGN KEY (task_id) REFERENCES task (task_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (pred_task_id) REFERENCES task (task_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (task_id, pred_task_id)
);
GRANT select,insert,update,delete ON predecessor TO GROUP planner;
GRANT select,update ON predecessor_pred_id_seq TO GROUP planner;
--
-- Property types
--
CREATE TABLE property_type (
proptype_id serial,
proj_id integer,
name text NOT NULL,
label text NOT NULL,
type text NOT NULL DEFAULT 'text',
owner text NOT NULL DEFAULT 'project',
descr text,
CHECK (type = 'date' OR type = 'duration' OR type = 'float'
OR type = 'int' OR type = 'text' OR type = 'text-list'
OR type = 'cost'),
CHECK (owner = 'project' OR owner = 'task' OR owner = 'resource'),
UNIQUE (proj_id, name),
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (proptype_id)
);
GRANT select,insert,update,delete ON property_type TO GROUP planner;
GRANT select,update ON property_type_proptype_id_seq TO GROUP planner;
--
-- Properties
--
CREATE TABLE property (
prop_id serial,
proptype_id integer NOT NULL,
value text,
FOREIGN KEY (proptype_id) REFERENCES property_type (proptype_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (prop_id)
);
GRANT select,insert,update,delete ON property TO GROUP planner;
GRANT select,update ON property_prop_id_seq TO GROUP planner;
--
-- Project properties
--
CREATE TABLE project_to_property (
proj_id integer,
prop_id integer,
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (prop_id) REFERENCES property (prop_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (proj_id, prop_id)
);
GRANT select,insert,update,delete ON project_to_property TO GROUP planner;
--
-- Task properties
--
CREATE TABLE task_to_property (
prop_id integer,
task_id integer,
FOREIGN KEY (task_id) REFERENCES task (task_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (prop_id) REFERENCES property (prop_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (task_id, prop_id)
);
GRANT select,insert,update,delete ON task_to_property TO GROUP planner;
--
-- Resource Group
--
CREATE TABLE resource_group (
group_id serial,
proj_id integer,
name text NOT NULL,
admin_name text,
admin_phone text,
admin_email text,
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (group_id)
);
GRANT select,insert,update,delete ON resource_group TO GROUP planner;
GRANT select,update ON resource_group_group_id_seq TO GROUP planner;
--
-- Resource
--
CREATE TABLE resource (
res_id serial,
proj_id integer,
group_id integer,
name text,
short_name text,
email text,
note text,
is_worker boolean NOT NULL DEFAULT TRUE,
units real NOT NULL DEFAULT 1.0,
std_rate real NOT NULL DEFAULT 0.0,
ovt_rate real NOT NULL DEFAULT 0.0,
cal_id integer,
FOREIGN KEY (proj_id) REFERENCES project (proj_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (group_id) REFERENCES resource_group (group_id)
ON DELETE SET NULL ON UPDATE CASCADE,
FOREIGN KEY (cal_id) REFERENCES calendar (cal_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (res_id)
);
GRANT select,insert,update,delete ON resource TO GROUP planner;
GRANT select,update ON resource_res_id_seq TO GROUP planner;
--
-- Resource properties
--
CREATE TABLE resource_to_property (
prop_id integer,
res_id integer,
FOREIGN KEY (res_id) REFERENCES resource (res_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (prop_id) REFERENCES property (prop_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (res_id, prop_id)
);
GRANT select,insert,update,delete ON resource_to_property TO GROUP planner;
--
-- Allocations (of resources)
--
CREATE TABLE allocation (
task_id integer,
res_id integer,
units real NOT NULL DEFAULT 1.0,
FOREIGN KEY (res_id) REFERENCES resource (res_id)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (task_id) REFERENCES task (task_id)
ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (res_id, task_id)
);
GRANT select,insert,update,delete ON allocation TO GROUP planner;
-- Planner Database Schema Upgrade from 0.6.x to 0.7
-- Lincoln Phipps <lincoln.phipps@openmutual.net>
-- Copyright 2004 Lincoln Phipps
--
-- Resource Schema Changes from 0.6.x to 0.7
--
ALTER TABLE resource ADD COLUMN short_name text
......@@ -346,7 +346,7 @@ old_xml_read_resource (MrpParser *parser, xmlNodePtr tree)
xmlNodePtr child;
gint id;
gint type;
gchar *name, *email;
gchar *name, *short_name, *email;
gint gid;
gint units;
gfloat std_rate; /*, ovt_rate;*/
......@@ -362,6 +362,7 @@ old_xml_read_resource (MrpParser *parser, xmlNodePtr tree)
id = old_xml_get_int (tree, "id");
name = old_xml_get_string (tree, "name");
short_name = old_xml_get_string (tree, "short-name");
gid = old_xml_get_int (tree, "group");
type = old_xml_get_int (tree, "type");
units = old_xml_get_int (tree, "units");
......@@ -370,6 +371,10 @@ old_xml_read_resource (MrpParser *parser, xmlNodePtr tree)
email = old_xml_get_string (tree, "email");
calendar_id = old_xml_get_int (tree, "calendar");
if (short_name == NULL) {
short_name = g_strdup ("");
}
if (email == NULL) {
email = g_strdup ("");