Commit 7f17a098 authored by Richard Hult's avatar Richard Hult Committed by Richard Hult

Clean up.

2004-08-01  Richard Hult  <richard@imendio.com>

	* src/Makefile.am: Clean up.

	* Makefile.am:
	* configure.in:
	* tests/: Add back the tests and add a new test for the
	scheduler.

2004-08-01  Richard Hult  <richard@imendio.com>

	* src/planner-window.c (window_do_save_as): Use the right
	response, fixes saving.
parent 77cd19e5
2004-08-01 Richard Hult <richard@imendio.com>
* src/Makefile.am: Clean up.
* Makefile.am:
* configure.in:
* tests/: Add back the tests and add a new test for the
scheduler.
2004-08-01 Richard Hult <richard@imendio.com>
* src/planner-window.c (window_do_save_as): Use the right
response, fixes saving.
2004-07-31 Richard Hult <richard@imendio.com>
* src/Makefile.am: Put scale utils in the executable, split out
......
......@@ -14,6 +14,7 @@ SUBDIRS = \
data \
docs \
examples \
tests \
$(python_DIR) \
$(dotnet_DIR)
......
......@@ -264,6 +264,8 @@ docs/user-guide/Makefile
docs/user-guide/C/Makefile
docs/sql/Makefile
examples/Makefile
tests/Makefile
tests/files/Makefile
po/Makefile.in
data/Makefile
data/images/Makefile
......
......@@ -11,8 +11,7 @@ INCLUDES = \
-DIMAGEDIR=\""$(datadir)/pixmaps/planner"\" \
-DGLADEDIR=\""$(datadir)/planner/glade"\" \
-DMRP_VIEWDIR=\""$(libdir)/planner/views"\" \
-DMRP_PLUGINDIR=\""$(libdir)/planner/plugins"\" \
$(GNOMEUI_UNSTABLE)
-DMRP_PLUGINDIR=\""$(libdir)/planner/plugins"\"
if HAVE_PYTHON_PLUGIN
INCLUDES += $(PYTHON_INCLUDES)
......
......@@ -1325,7 +1325,7 @@ window_do_save_as (PlannerWindow *window)
GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);
......
INCLUDES = \
$(LIBMRPROJECT_CFLAGS) \
-I$(top_srcdir)
SUBDIRS = files
LDFLAGS = \
$(LIBMRPROJECT_LIBS) \
$(top_builddir)/mrproject/libmrproject.la
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/tests \
$(PLANNER_CFLAGS) $(WARN_CFLAGS) \
-DG_LOG_DOMAIN=\"Planner\" \
-DEXAMPLESDIR=\"$(top_srcdir)/tests/files\"
LDADD = \
$(top_builddir)/libplanner/libplanner-1.la \
$(PLANNER_LIBS)
noinst_LTLIBRARIES = libselfcheck.la
libselfcheck_la_SOURCES = \
self-check.c \
self-check.h
libselfcheck_la_SOURCES = \
self-check.c \
self-check.h
noinst_PROGRAMS = scheduler-test time-test calendar-test task-test
noinst_PROGRAMS = time-test calendar-test task-test
scheduler_test_SOURCES = scheduler-test.c
scheduler_test_LDFLAGS = $(top_builddir)/tests/libselfcheck.la
time_test_SOURCES = time-test.c
time_test_LDFLAGS = $(top_builddir)/tests/libselfcheck.la
......@@ -23,4 +31,4 @@ calendar_test_LDFLAGS = $(top_builddir)/tests/libselfcheck.la
task_test_SOURCES = task-test.c
task_test_LDFLAGS = $(top_builddir)/tests/libselfcheck.la
TESTS = time-test calendar-test task-test
TESTS = scheduler-test time-test calendar-test task-test
......@@ -2,22 +2,25 @@
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include "../mrproject/mrp-project.h"
#include "../mrproject/mrp-calendar.h"
#include "libplanner/mrp-project.h"
#include "libplanner/mrp-calendar.h"
#include "self-check.h"
gint
main (gint argc, gchar **argv)
{
MrpProject *project;
MrpCalendar *base, *derive, *copy;
MrpInterval *interval;
mrptime time_tue, time_sat, time_sun, time_27nov, time_28nov;
MrpDay *day_a, *day_b, *day_c, *def_1_id;
GList *l = NULL;
MrpApplication *app;
MrpProject *project;
MrpCalendar *base, *derive, *copy;
MrpInterval *interval;
mrptime time_tue, time_sat, time_sun, time_27nov, time_28nov;
MrpDay *day_a, *day_b, *day_c, *def_1_id;
GList *l = NULL;
g_type_init ();
app = mrp_application_new ();
project = mrp_project_new (NULL);
base = mrp_calendar_new ("Base", project);
......
Makefile
Makefile.in
EXTRA_DIST = test-1.planner
<?xml version="1.0"?>
<project name="Sample 1" company="Planner Community" manager="Richard Hult" phase="Implementation" project-start="20040701T000000Z" mrproject-version="2" calendar="1">
<properties>
<property name="My-Property" type="text" owner="project" label="My Property" description="Just a test"/>
<property name="cost" type="cost" owner="resource" label="Cost" description="standard cost for a resource"/>
</properties>
<properties>
<property name="My-Property" value="Testing custom properties"/>
</properties>
<phases>
<phase name="Design"/>
<phase name="Implementation"/>
<phase name="Testing"/>
</phases>
<calendars>
<day-types>
<day-type id="0" name="Working" description="A default working day"/>
<day-type id="1" name="Nonworking" description="A default non working day"/>
<day-type id="2" name="Use base" description="Use day from base calendar"/>
</day-types>
<calendar id="1" name="Default">
<default-week mon="0" tue="0" wed="0" thu="0" fri="0" sat="1" sun="1"/>
<overridden-day-types>
<overridden-day-type id="0">
<interval start="0800" end="1200"/>
<interval start="1300" end="1700"/>
</overridden-day-type>
</overridden-day-types>
<days/>
</calendar>
</calendars>
<tasks>
<task id="1" name="Project X" note="" work="1118400" start="20040701T000000Z" end="20040824T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<task id="2" name="Analysis" note="" work="115200" start="20040701T000000Z" end="20040708T104000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="3" name="Report 1" note="" work="0" start="20040708T104000Z" end="20040708T104000Z" percent-complete="0" priority="0" type="milestone" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="2" type="FS"/>
</predecessors>
</task>
<task id="4" name="Prototype" note="" work="144000" start="20040708T104000Z" end="20040715T104000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="3" type="FS"/>
</predecessors>
<task id="5" name="Design prototype" note="" work="86400" start="20040708T104000Z" end="20040713T104000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="6" name="Implementation 1" note="" work="144000" start="20040708T104000Z" end="20040714T104000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="7" name="Evaluation 1" note="" work="28800" start="20040714T104000Z" end="20040715T104000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="6" type="FS"/>
</predecessors>
</task>
<task id="8" name="Report 2" note="" work="0" start="20040715T104000Z" end="20040715T104000Z" percent-complete="0" priority="0" type="milestone" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="7" type="FS"/>
</predecessors>
</task>
</task>
<task id="9" name="Product" note="" work="820800" start="20040715T104000Z" end="20040824T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="8" type="FS"/>
</predecessors>
<task id="10" name="Summarize issues" note="" work="86400" start="20040715T104000Z" end="20040716T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="11" name="Finalize design" note="" work="144000" start="20040716T154000Z" end="20040723T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="10" type="FS"/>
</predecessors>
</task>
<task id="12" name="Implementation 2" note="" work="432000" start="20040723T154000Z" end="20040813T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="11" type="FS"/>
</predecessors>
<task id="13" name="Back-end" note="" work="432000" start="20040723T154000Z" end="20040813T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="14" name="Front-end" note="" work="432000" start="20040723T154000Z" end="20040813T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
</task>
<task id="15" name="Evaluation 2" note="" work="57600" start="20040813T154000Z" end="20040817T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="12" type="FS"/>
</predecessors>
</task>
<task id="16" name="QA" note="" work="144000" start="20040817T154000Z" end="20040824T154000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="15" type="FS"/>
</predecessors>
</task>
<task id="17" name="Report 3" note="" work="0" start="20040824T154000Z" end="20040824T154000Z" percent-complete="0" priority="0" type="milestone" scheduling="fixed-work">
<predecessors>
<predecessor id="1" predecessor-id="16" type="FS"/>
</predecessors>
</task>
</task>
</task>
</tasks>
<resource-groups/>
<resources>
<resource id="1" name="Alvaro del Castillo" short-name="ACS" type="1" units="0" email="" note="" std-rate="0">
<properties>
<property name="cost" value=""/>
</properties>
</resource>
<resource id="2" name="Richard Hult" short-name="RH" type="1" units="0" email="" note="" std-rate="0">
<properties>
<property name="cost" value=""/>
</properties>
</resource>
<resource id="3" name="Mikael Hallendal" short-name="MH" type="1" units="0" email="" note="" std-rate="0">
<properties>
<property name="cost" value=""/>
</properties>
</resource>
<resource id="4" name="Lincoln Phipps" short-name="LP" type="1" units="0" email="" note="" std-rate="0">
<properties>
<property name="cost" value=""/>
</properties>
</resource>
</resources>
<allocations>
<allocation task-id="2" resource-id="1" units="75"/>
<allocation task-id="15" resource-id="1" units="100"/>
<allocation task-id="6" resource-id="2" units="25"/>
<allocation task-id="10" resource-id="2" units="100"/>
<allocation task-id="13" resource-id="2" units="100"/>
<allocation task-id="11" resource-id="2" units="100"/>
<allocation task-id="5" resource-id="2" units="100"/>
<allocation task-id="10" resource-id="3" units="100"/>
<allocation task-id="6" resource-id="3" units="100"/>
<allocation task-id="14" resource-id="3" units="100"/>
<allocation task-id="16" resource-id="4" units="100"/>
</allocations>
</project>
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <libxml/parser.h>
#include "libplanner/mrp-project.h"
#include "self-check.h"
typedef struct {
mrptime project_start;
GHashTable *task_hash;
} ProjectData;
typedef struct {
gchar *name;
mrptime start;
mrptime finish;
gint duration;
gint work;
} TaskData;
/* Get a value for a node either carried as an attibute or as
* the content of a child.
*
* Returns xmlChar, must be xmlFreed.
*/
static gchar *
old_xml_get_value (xmlNodePtr node, const char *name)
{
gchar *val;
xmlNodePtr child;
val = (gchar *) xmlGetProp (node, name);
if (val != NULL) {
return val;
}
child = node->children;
while (child != NULL) {
if (!strcmp (child->name, name)) {
/*
* !!! Inefficient, but ...
*/
val = xmlNodeGetContent(child);
if (val != NULL) {
return val;
}
}
child = child->next;
}
return NULL;
}
/*
* Get a value for a node either carried as an attibute or as
* the content of a child.
*
* Returns a g_malloc'ed string. Caller must free.
*/
static gchar *
old_xml_get_string (xmlNodePtr node, const char *name)
{
char *ret, *val;
g_return_val_if_fail (node != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
val = old_xml_get_value (node, name);
ret = g_strdup (val);
xmlFree (val);
return ret;
}
static mrptime
old_xml_get_date (xmlNodePtr node, const char *name)
{
gchar *val;
mrptime t;
g_return_val_if_fail (node != NULL, MRP_TIME_INVALID);
g_return_val_if_fail (name != NULL, MRP_TIME_INVALID);
val = old_xml_get_value (node, name);
if (val) {
t = mrp_time_from_string (val, NULL);
xmlFree (val);
} else {
t = 0;
}
return t;
}
/* Search a child by name, if needed go down the tree to find it.
*/
static xmlNodePtr
old_xml_search_child (xmlNodePtr node, const gchar *name)
{
xmlNodePtr ret;
xmlNodePtr child;
child = node->children;
while (child != NULL) {
if (!strcmp (child->name, name))
return child;
child = child->next;
}
child = node->children;
while (child != NULL) {
ret = old_xml_search_child (child, name);
if (ret != NULL)
return ret;
child = child->next;
}
return NULL;
}
static TaskData *
read_task (xmlNodePtr node)
{
TaskData *task_data;
task_data = g_new0 (TaskData, 1);
task_data->name = old_xml_get_string (node, "name");
task_data->start = old_xml_get_date (node, "start");
task_data->finish = old_xml_get_date (node, "end");
task_data->duration = old_xml_get_date (node, "duration");
task_data->work = old_xml_get_date (node, "work");
return task_data;
}
static void
read_tasks (ProjectData *data, xmlNodePtr node)
{
xmlNodePtr task;
TaskData *task_data;
for (task = node->children; task; task = task->next) {
if (strcmp (task->name, "task") == 0){
task_data = read_task (task);
if (g_hash_table_lookup (data->task_hash, task_data->name)) {
g_print ("Duplicate name %s\n", task_data->name);
g_assert_not_reached ();
}
g_hash_table_insert (data->task_hash, task_data->name, task_data);
read_tasks (data, task);
}
}
}
static ProjectData *
read_project (const gchar *filename)
{
ProjectData *data;
xmlDocPtr doc;
xmlNodePtr tasks;
data = g_new0 (ProjectData, 1);
data->task_hash = g_hash_table_new (g_str_hash, g_str_equal);
doc = xmlParseFile (filename);
g_assert (doc != NULL);
data->project_start = old_xml_get_date (doc->children, "project-start");
tasks = old_xml_search_child (doc->children, "tasks");
read_tasks (data, tasks);
return data;
}
static void
check_project (ProjectData *data, MrpProject *project)
{
MrpTask *task;
GList *tasks, *l;
TaskData *task_data;
/* Project start. */
CHECK_INTEGER_RESULT (mrp_project_get_project_start (project), data->project_start);
tasks = mrp_project_get_all_tasks (project);
/* Sanity check. */
CHECK_INTEGER_RESULT (g_list_length (tasks), g_hash_table_size (data->task_hash));
for (l = tasks; l; l = l->next) {
task = l->data;
task_data = g_hash_table_lookup (data->task_hash, mrp_task_get_name (task));
g_assert (task_data != NULL);
/* Check start and finish. */
CHECK_INTEGER_RESULT (mrp_task_get_start (task), task_data->start);
CHECK_INTEGER_RESULT (mrp_task_get_finish (task), task_data->finish);
}
g_list_free (tasks);
}
gint
main (gint argc, gchar **argv)
{
MrpApplication *app;
const gchar *filename;
ProjectData *data;
MrpProject *project;
gchar *buf;
g_type_init ();
app = mrp_application_new ();
filename = EXAMPLESDIR "/test-1.planner";
/* Just parse the XML. */
data = read_project (filename);
/* Create a project from the same file. */
project = mrp_project_new (app);
g_assert (g_file_get_contents (filename, &buf, NULL, NULL));
g_assert (mrp_project_load_from_xml (project, buf, NULL));
g_free (buf);
/* Reschedule the project and check that the info is correct. */
mrp_project_reschedule (project);
check_project (data, project);
return EXIT_SUCCESS;
}
......@@ -2,7 +2,7 @@
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include "../mrproject/mrp-project.h"
#include "libplanner/mrp-project.h"
#include "self-check.h"
#define DAY (60*60*8)
......
......@@ -2,7 +2,7 @@
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include "../mrproject/mrp-time.h"
#include "libplanner/mrp-time.h"
#include "self-check.h"
/* Helper function to make the output look nicer */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment