From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Egli Subject: [PATCH 2/5] Mark a task as a milestone if it is a leaf node and cannot be scheduled Date: Wed, 16 Mar 2011 12:04:59 +0100 Message-ID: <1300273502-12977-3-git-send-email-christian.egli@alumni.ethz.ch> References: <1300273502-12977-1-git-send-email-christian.egli@alumni.ethz.ch> Return-path: Received: from [140.186.70.92] (port=36586 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzoXU-0006Fn-Go for emacs-orgmode@gnu.org; Wed, 16 Mar 2011 07:05:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzoXN-0005f9-D9 for emacs-orgmode@gnu.org; Wed, 16 Mar 2011 07:05:10 -0400 Received: from mail.sbszh.ch ([217.162.18.84]:40941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzoXM-0005eX-Va for emacs-orgmode@gnu.org; Wed, 16 Mar 2011 07:05:09 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.sbszh.ch (Postfix) with ESMTP id DBC6786E2 for ; Wed, 16 Mar 2011 12:05:06 +0100 (CET) Received: from mail.sbszh.ch ([127.0.0.1]) by localhost (mail01.dmz.sbszh.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id okunHyFwx-ab for ; Wed, 16 Mar 2011 12:05:04 +0100 (CET) Received: from s05.sbszh.ch (s05.sbszh.ch [10.0.9.9]) by mail.sbszh.ch (Postfix) with ESMTP id D32C786E3 for ; Wed, 16 Mar 2011 12:05:02 +0100 (CET) Received: from localhost (unknown [127.0.0.1]) by localhost.sbszh.ch (Postfix) with ESMTP id A818D15C1F5 for ; Wed, 16 Mar 2011 11:05:03 +0000 (UTC) Received: from s05.sbszh.ch ([127.0.0.1]) by localhost (s05.sbszh.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12211-07 for ; Wed, 16 Mar 2011 12:05:03 +0100 (CET) Received: from wharton.sbszh.ch (w302.sbszh.ch [10.0.41.2]) by s05.sbszh.ch (Postfix) with ESMTP id 5F65215C2A8 for ; Wed, 16 Mar 2011 12:05:03 +0100 (CET) In-Reply-To: <1300273502-12977-1-git-send-email-christian.egli@alumni.ethz.ch> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * org-taskjuggler.el (org-taskjuggler-compute-task-leafiness): Compute the leafiness of a node. (org-taskjuggler-open-task, org-export-as-taskjuggler): Mark a node as a milestone if it is a leaf and has no effort. Mark a task as a milestone if it has neither an effort, a duration, an end or a period. This is needed for tj3 export as tj3 fails to compile the file if there is a leaf node with no computable end date. tj2 happily ignored the situation, but TJ3 throws an error. --- lisp/org-taskjuggler.el | 37 +++++++++++++++++++++++++++++++------ 1 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lisp/org-taskjuggler.el b/lisp/org-taskjuggler.el index ec6bb30..2d16790 100644 --- a/lisp/org-taskjuggler.el +++ b/lisp/org-taskjuggler.el @@ -263,9 +263,10 @@ defined in `org-export-taskjuggler-default-reports'." (let* ((tasks (org-taskjuggler-resolve-dependencies (org-taskjuggler-assign-task-ids - (org-map-entries - '(org-taskjuggler-components) - org-export-taskjuggler-project-tag nil 'archive 'comment)))) + (org-taskjuggler-compute-task-leafiness + (org-map-entries + '(org-taskjuggler-components) + org-export-taskjuggler-project-tag nil 'archive 'comment))))) (resources (org-taskjuggler-assign-resource-ids (org-map-entries @@ -392,6 +393,23 @@ a path to the current task." (setq previous-level level) (setq resolved-tasks (append resolved-tasks (list task))))))) +(defun org-taskjuggler-compute-task-leafiness (tasks) + "Figure out if each task is a leaf by looking at it's level, +and the level of its successor. If the successor is higher (ie +deeper), then it's not a leaf." + (cond + ((null tasks) nil) + ;; if a task has no successors it is a leaf + ((null (car (cdr tasks))) + (cons (cons (cons "leaf-node" t) (car tasks)) + (org-taskjuggler-compute-task-leafiness (cdr tasks)))) + ;; if the successor has a lower level than task it is a leaf + ((<= (cdr (assoc "level" (car (cdr tasks)))) (cdr (assoc "level" (car tasks)))) + (cons (cons (cons "leaf-node" t) (car tasks)) + (org-taskjuggler-compute-task-leafiness (cdr tasks)))) + ;; otherwise examine the rest of the tasks + (t (cons (car tasks) (org-taskjuggler-compute-task-leafiness (cdr tasks)))))) + (defun org-taskjuggler-assign-resource-ids (resources &optional unique-ids) "Given a list of resources return the same list, assigning a unique id to each resource." @@ -621,11 +639,17 @@ org-mode priority string." (cdr (assoc "complete" task)))) (parent-ordered (cdr (assoc "parent-ordered" task))) (previous-sibling (cdr (assoc "previous-sibling" task))) + (milestone (or (cdr (assoc "milestone" task)) + (and (assoc "leaf-node" task) + (not (or effort + (cdr (assoc "duration" task)) + (cdr (assoc "end" task)) + (cdr (assoc "period" task))))))) (attributes '(account start note duration endbuffer endcredit end - flags journalentry length maxend maxstart milestone - minend minstart period reference responsible - scheduling startbuffer startcredit statusnote))) + flags journalentry length maxend maxstart minend + minstart period reference responsible scheduling + startbuffer startcredit statusnote))) (insert (concat "task " unique-id " \"" headline "\" {\n" @@ -639,6 +663,7 @@ org-mode priority string." (and complete (format " complete %s\n" complete)) (and effort (format " effort %s\n" effort)) (and priority (format " priority %s\n" priority)) + (and milestone (format " milestone\n")) (org-taskjuggler-get-attributes task attributes) "\n")))) -- 1.7.1