2010-03-16 09:11:52 +00:00
|
|
|
;;; org-taskjuggler.el --- TaskJuggler exporter for org-mode
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
|
|
|
;;
|
|
|
|
;; Emacs Lisp Archive Entry
|
|
|
|
;; Filename: org-taskjuggler.el
|
2011-03-07 14:27:39 +00:00
|
|
|
;; Version: 7.5
|
2010-03-16 09:11:52 +00:00
|
|
|
;; Author: Christian Egli
|
|
|
|
;; Maintainer: Christian Egli
|
|
|
|
;; Keywords: org, taskjuggler, project planning
|
|
|
|
;; Description: Converts an org-mode buffer into a taskjuggler project plan
|
|
|
|
;; URL:
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;; Commentary:
|
|
|
|
;;
|
2010-03-30 09:23:41 +00:00
|
|
|
;; This library implements a TaskJuggler exporter for org-mode.
|
|
|
|
;; TaskJuggler uses a text format to define projects, tasks and
|
|
|
|
;; resources, so it is a natural fit for org-mode. It can produce all
|
|
|
|
;; sorts of reports for tasks or resources in either HTML, CSV or PDF.
|
|
|
|
;; The current version of TaskJuggler requires KDE but the next
|
|
|
|
;; version is implemented in Ruby and should therefore run on any
|
|
|
|
;; platform.
|
|
|
|
;;
|
|
|
|
;; The exporter is a bit different from other exporters, such as the
|
|
|
|
;; HTML and LaTeX exporters for example, in that it does not export
|
|
|
|
;; all the nodes of a document or strictly follow the order of the
|
|
|
|
;; nodes in the document.
|
2010-03-24 15:46:58 +00:00
|
|
|
;;
|
|
|
|
;; Instead the TaskJuggler exporter looks for a tree that defines the
|
|
|
|
;; tasks and a optionally tree that defines the resources for this
|
|
|
|
;; project. It then creates a TaskJuggler file based on these trees
|
|
|
|
;; and the attributes defined in all the nodes.
|
|
|
|
;;
|
|
|
|
;; * Installation
|
|
|
|
;;
|
|
|
|
;; Put this file into your load-path and the following line into your
|
|
|
|
;; ~/.emacs:
|
|
|
|
;;
|
|
|
|
;; (require 'org-taskjuggler)
|
2010-03-16 09:11:52 +00:00
|
|
|
;;
|
|
|
|
;; The interactive functions are similar to those of the HTML and LaTeX
|
|
|
|
;; exporters:
|
|
|
|
;;
|
|
|
|
;; M-x `org-export-as-taskjuggler'
|
|
|
|
;; M-x `org-export-as-taskjuggler-and-open'
|
|
|
|
;;
|
2010-03-24 15:46:58 +00:00
|
|
|
;; * Tasks
|
|
|
|
;;
|
2010-03-30 09:23:41 +00:00
|
|
|
;; Let's illustrate the usage with a small example. Create your tasks
|
|
|
|
;; as you usually do with org-mode. Assign efforts to each task using
|
|
|
|
;; properties (it's easiest to do this in the column view). You should
|
|
|
|
;; end up with something similar to the example by Peter Jones in
|
2010-03-24 15:46:58 +00:00
|
|
|
;; http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org.
|
|
|
|
;; Now mark the top node of your tasks with a tag named
|
|
|
|
;; "taskjuggler_project" (or whatever you customized
|
|
|
|
;; `org-export-taskjuggler-project-tag' to). You are now ready to
|
|
|
|
;; export the project plan with `org-export-as-taskjuggler-and-open'
|
|
|
|
;; which will export the project plan and open a gant chart in
|
2010-03-30 09:23:41 +00:00
|
|
|
;; TaskJugglerUI.
|
2010-03-24 15:46:58 +00:00
|
|
|
;;
|
|
|
|
;; * Resources
|
2011-03-17 08:48:19 +00:00
|
|
|
;;
|
2010-03-30 09:23:41 +00:00
|
|
|
;; Next you can define resources and assign those to work on specific
|
2010-03-24 15:46:58 +00:00
|
|
|
;; tasks. You can group your resources hierarchically. Tag the top
|
|
|
|
;; node of the resources with "taskjuggler_resource" (or whatever you
|
|
|
|
;; customized `org-export-taskjuggler-resource-tag' to). You can
|
2010-04-28 07:11:09 +00:00
|
|
|
;; optionally assign an identifier (named "resource_id") to the
|
|
|
|
;; resources (using the standard org properties commands) or you can
|
|
|
|
;; let the exporter generate identifiers automatically (the exporter
|
|
|
|
;; picks the first word of the headline as the identifier as long as
|
|
|
|
;; it is unique, see the documentation of
|
|
|
|
;; `org-taskjuggler-get-unique-id'). Using that identifier you can
|
|
|
|
;; then allocate resources to tasks. This is again done with the
|
|
|
|
;; "allocate" property on the tasks. Do this in column view or when on
|
|
|
|
;; the task type
|
2010-03-24 15:46:58 +00:00
|
|
|
;;
|
2010-04-28 07:11:09 +00:00
|
|
|
;; C-c C-x p allocate RET <resource_id> RET
|
2010-03-24 15:46:58 +00:00
|
|
|
;;
|
|
|
|
;; Once the allocations are done you can again export to TaskJuggler
|
|
|
|
;; and check in the Resource Allocation Graph which person is working
|
|
|
|
;; on what task at what time.
|
|
|
|
;;
|
|
|
|
;; * Export of properties
|
|
|
|
;;
|
|
|
|
;; The exporter also takes TODO state information into consideration,
|
|
|
|
;; i.e. if a task is marked as done it will have the corresponding
|
2010-03-30 09:23:41 +00:00
|
|
|
;; attribute in TaskJuggler ("complete 100"). Also it will export any
|
2010-03-24 15:46:58 +00:00
|
|
|
;; property on a task resource or resource node which is known to
|
|
|
|
;; TaskJuggler, such as limits, vacation, shift, booking, efficiency,
|
|
|
|
;; journalentry, rate for resources or account, start, note, duration,
|
|
|
|
;; end, journalentry, milestone, reference, responsible, scheduling,
|
|
|
|
;; etc for tasks.
|
|
|
|
;;
|
2010-03-30 09:23:41 +00:00
|
|
|
;; * Dependencies
|
2011-03-17 08:48:19 +00:00
|
|
|
;;
|
2010-03-24 15:46:58 +00:00
|
|
|
;; The exporter will handle dependencies that are defined in the tasks
|
|
|
|
;; either with the ORDERED attribute (see TODO dependencies in the Org
|
|
|
|
;; mode manual) or with the BLOCKER attribute (see org-depend.el) or
|
|
|
|
;; alternatively with a depends attribute. Both the BLOCKER and the
|
|
|
|
;; depends attribute can be either "previous-sibling" or a reference
|
2010-04-28 07:11:09 +00:00
|
|
|
;; to an identifier (named "task_id") which is defined for another
|
|
|
|
;; task in the project. BLOCKER and the depends attribute can define
|
|
|
|
;; multiple dependencies separated by either space or comma. You can
|
|
|
|
;; also specify optional attributes on the dependency by simply
|
|
|
|
;; appending it. The following examples should illustrate this:
|
2010-03-17 15:36:36 +00:00
|
|
|
;;
|
2010-04-13 14:25:40 +00:00
|
|
|
;; * Training material
|
|
|
|
;; :PROPERTIES:
|
2010-04-28 07:11:09 +00:00
|
|
|
;; :task_id: training_material
|
2010-04-13 14:25:40 +00:00
|
|
|
;; :ORDERED: t
|
|
|
|
;; :END:
|
|
|
|
;; ** Markup Guidelines
|
|
|
|
;; :PROPERTIES:
|
|
|
|
;; :Effort: 2.0
|
|
|
|
;; :END:
|
|
|
|
;; ** Workflow Guidelines
|
|
|
|
;; :PROPERTIES:
|
|
|
|
;; :Effort: 2.0
|
|
|
|
;; :END:
|
|
|
|
;; * Presentation
|
|
|
|
;; :PROPERTIES:
|
|
|
|
;; :Effort: 2.0
|
|
|
|
;; :BLOCKER: training_material { gapduration 1d } some_other_task
|
|
|
|
;; :END:
|
2011-03-17 08:48:19 +00:00
|
|
|
;;
|
2010-04-13 14:25:40 +00:00
|
|
|
;;;; * TODO
|
2010-05-27 07:36:30 +00:00
|
|
|
;; - Use SCHEDULED and DEADLINE information (not just start and end
|
|
|
|
;; properties).
|
2010-03-30 09:23:41 +00:00
|
|
|
;; - Look at org-file-properties, org-global-properties and
|
|
|
|
;; org-global-properties-fixed
|
2010-03-25 09:15:14 +00:00
|
|
|
;; - What about property inheritance and org-property-inherit-p?
|
2011-01-04 15:25:48 +00:00
|
|
|
;; - Use TYP_TODO as an way to assign resources
|
2010-03-30 08:11:13 +00:00
|
|
|
;; - Make sure multiple dependency definitions (i.e. BLOCKER on
|
2010-04-28 07:11:09 +00:00
|
|
|
;; previous-sibling and on a specific task_id) in multiple
|
2010-05-27 07:36:30 +00:00
|
|
|
;; attributes are properly exported.
|
2010-03-25 09:15:14 +00:00
|
|
|
;;
|
2010-03-16 09:11:52 +00:00
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
(require 'cl))
|
|
|
|
|
|
|
|
(require 'org)
|
|
|
|
(require 'org-exp)
|
|
|
|
|
|
|
|
;;; User variables:
|
|
|
|
|
|
|
|
(defgroup org-export-taskjuggler nil
|
|
|
|
"Options for exporting Org-mode files to TaskJuggler."
|
|
|
|
:tag "Org Export TaskJuggler"
|
|
|
|
:group 'org-export)
|
|
|
|
|
|
|
|
(defcustom org-export-taskjuggler-extension ".tjp"
|
|
|
|
"Extension of TaskJuggler files."
|
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'string)
|
|
|
|
|
2010-03-24 10:59:43 +00:00
|
|
|
(defcustom org-export-taskjuggler-project-tag "taskjuggler_project"
|
2010-03-18 09:07:38 +00:00
|
|
|
"Tag, property or todo used to find the tree containing all
|
|
|
|
the tasks for the project."
|
2010-03-16 09:11:52 +00:00
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'string)
|
|
|
|
|
2010-03-24 10:59:43 +00:00
|
|
|
(defcustom org-export-taskjuggler-resource-tag "taskjuggler_resource"
|
2010-03-18 09:07:38 +00:00
|
|
|
"Tag, property or todo used to find the tree containing all the
|
|
|
|
resources for the project."
|
2010-03-16 09:11:52 +00:00
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'string)
|
|
|
|
|
2011-03-16 16:04:58 +00:00
|
|
|
(defcustom org-export-taskjuggler-target-version 2.4
|
|
|
|
"Which version of TaskJuggler the exporter is targeting."
|
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'number)
|
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
(defcustom org-export-taskjuggler-default-project-version "1.0"
|
2010-03-18 09:07:38 +00:00
|
|
|
"Default version string for the project."
|
2010-03-16 09:11:52 +00:00
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'string)
|
|
|
|
|
2010-04-21 09:30:52 +00:00
|
|
|
(defcustom org-export-taskjuggler-default-project-duration 280
|
2010-03-18 09:07:38 +00:00
|
|
|
"Default project duration if no start and end date have been defined
|
|
|
|
in the root node of the task tree, i.e. the tree that has been marked
|
|
|
|
with `org-export-taskjuggler-project-tag'"
|
2010-03-16 09:11:52 +00:00
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type 'integer)
|
|
|
|
|
2011-03-17 08:48:19 +00:00
|
|
|
(defcustom org-export-taskjuggler-default-reports
|
2010-03-16 13:14:24 +00:00
|
|
|
'("taskreport \"Gantt Chart\" {
|
|
|
|
headline \"Project Gantt Chart\"
|
|
|
|
columns hierarchindex, name, start, end, effort, duration, completed, chart
|
2010-03-19 13:46:37 +00:00
|
|
|
timeformat \"%Y-%m-%d\"
|
|
|
|
hideresource 1
|
2010-03-24 11:01:54 +00:00
|
|
|
loadunit shortauto
|
2010-03-16 13:14:24 +00:00
|
|
|
}"
|
|
|
|
"resourcereport \"Resource Graph\" {
|
|
|
|
headline \"Resource Allocation Graph\"
|
2010-03-19 13:46:37 +00:00
|
|
|
columns no, name, utilization, freeload, chart
|
2010-03-24 11:01:54 +00:00
|
|
|
loadunit shortauto
|
2010-03-19 16:12:22 +00:00
|
|
|
sorttasks startup
|
|
|
|
hidetask ~isleaf()
|
2010-03-16 13:14:24 +00:00
|
|
|
}")
|
2010-03-18 09:07:38 +00:00
|
|
|
"Default reports for the project."
|
2010-03-16 13:14:24 +00:00
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type '(repeat (string :tag "Report")))
|
|
|
|
|
2011-03-17 08:48:19 +00:00
|
|
|
(defcustom org-export-taskjuggler-default-global-properties
|
2010-03-22 16:27:53 +00:00
|
|
|
"shift s40 \"Part time shift\" {
|
|
|
|
workinghours wed, thu, fri off
|
|
|
|
}
|
|
|
|
"
|
|
|
|
"Default global properties for the project. Here you typically
|
|
|
|
define global properties such as shifts, accounts, rates,
|
|
|
|
vacation, macros and flags. Any property that is allowed within
|
|
|
|
the TaskJuggler file can be inserted. You could for example
|
2011-03-17 08:48:19 +00:00
|
|
|
include another TaskJuggler file.
|
2010-03-22 16:27:53 +00:00
|
|
|
|
|
|
|
The global properties are inserted after the project declaration
|
|
|
|
but before any resource and task declarations."
|
|
|
|
:group 'org-export-taskjuggler
|
|
|
|
:type '(string :tag "Preamble"))
|
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
;;; Hooks
|
|
|
|
|
|
|
|
(defvar org-export-taskjuggler-final-hook nil
|
|
|
|
"Hook run at the end of TaskJuggler export, in the new buffer.")
|
|
|
|
|
|
|
|
;;; Autoload functions:
|
|
|
|
|
2010-06-08 13:13:50 +00:00
|
|
|
;; avoid compiler warning about free variable
|
|
|
|
(defvar org-export-taskjuggler-old-level)
|
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun org-export-as-taskjuggler ()
|
2010-03-18 09:07:38 +00:00
|
|
|
"Export parts of the current buffer as a TaskJuggler file.
|
|
|
|
The exporter looks for a tree with tag, property or todo that
|
|
|
|
matches `org-export-taskjuggler-project-tag' and takes this as
|
|
|
|
the tasks for this project. The first node of this tree defines
|
|
|
|
the project properties such as project name and project period.
|
|
|
|
If there is a tree with tag, property or todo that matches
|
|
|
|
`org-export-taskjuggler-resource-tag' this three is taken as
|
|
|
|
resources for the project. If no resources are specified, a
|
|
|
|
default resource is created and allocated to the project. Also
|
|
|
|
the taskjuggler project will be created with default reports as
|
|
|
|
defined in `org-export-taskjuggler-default-reports'."
|
2010-03-16 09:11:52 +00:00
|
|
|
(interactive)
|
|
|
|
|
|
|
|
(message "Exporting...")
|
2010-03-17 16:05:28 +00:00
|
|
|
(setq-default org-done-keywords org-done-keywords)
|
2010-03-16 09:11:52 +00:00
|
|
|
(let* ((tasks
|
2010-03-17 13:13:03 +00:00
|
|
|
(org-taskjuggler-resolve-dependencies
|
2011-03-17 08:48:19 +00:00
|
|
|
(org-taskjuggler-assign-task-ids
|
2011-03-16 16:04:59 +00:00
|
|
|
(org-taskjuggler-compute-task-leafiness
|
2011-03-17 08:48:19 +00:00
|
|
|
(org-map-entries
|
|
|
|
'(org-taskjuggler-components)
|
2011-03-16 16:04:59 +00:00
|
|
|
org-export-taskjuggler-project-tag nil 'archive 'comment)))))
|
2010-03-16 09:11:52 +00:00
|
|
|
(resources
|
2010-03-17 14:44:54 +00:00
|
|
|
(org-taskjuggler-assign-resource-ids
|
2011-03-17 08:48:19 +00:00
|
|
|
(org-map-entries
|
|
|
|
'(org-taskjuggler-components)
|
2010-04-07 09:49:10 +00:00
|
|
|
org-export-taskjuggler-resource-tag nil 'archive 'comment)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(filename (expand-file-name
|
|
|
|
(concat
|
|
|
|
(file-name-sans-extension
|
|
|
|
(file-name-nondirectory buffer-file-name))
|
|
|
|
org-export-taskjuggler-extension)))
|
|
|
|
(buffer (find-file-noselect filename))
|
2010-06-08 13:13:50 +00:00
|
|
|
(org-export-taskjuggler-old-level 0)
|
2010-03-16 09:11:52 +00:00
|
|
|
task resource)
|
2010-04-20 07:59:30 +00:00
|
|
|
(unless tasks
|
|
|
|
(error "No tasks specified"))
|
2010-03-16 09:11:52 +00:00
|
|
|
;; add a default resource
|
|
|
|
(unless resources
|
2011-03-17 08:48:19 +00:00
|
|
|
(setq resources
|
|
|
|
`((("resource_id" . ,(user-login-name))
|
|
|
|
("headline" . ,user-full-name)
|
2010-03-16 09:11:52 +00:00
|
|
|
("level" . 1)))))
|
2010-03-16 09:27:37 +00:00
|
|
|
;; add a default allocation to the first task if none was given
|
2010-03-16 09:11:52 +00:00
|
|
|
(unless (assoc "allocate" (car tasks))
|
2010-03-16 09:27:37 +00:00
|
|
|
(let ((task (car tasks))
|
2010-04-28 07:11:09 +00:00
|
|
|
(resource-id (cdr (assoc "resource_id" (car resources)))))
|
2010-03-16 09:27:37 +00:00
|
|
|
(setcar tasks (push (cons "allocate" resource-id) task))))
|
2010-03-16 09:11:52 +00:00
|
|
|
;; add a default start date to the first task if none was given
|
|
|
|
(unless (assoc "start" (car tasks))
|
|
|
|
(let ((task (car tasks))
|
|
|
|
(time-string (format-time-string "%Y-%m-%d")))
|
|
|
|
(setcar tasks (push (cons "start" time-string) task))))
|
|
|
|
;; add a default version if none was given
|
|
|
|
(unless (assoc "version" (car tasks))
|
|
|
|
(let ((task (car tasks))
|
|
|
|
(version org-export-taskjuggler-default-project-version))
|
|
|
|
(setcar tasks (push (cons "version" version) task))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(erase-buffer)
|
|
|
|
(org-taskjuggler-open-project (car tasks))
|
2010-03-22 16:27:53 +00:00
|
|
|
(insert org-export-taskjuggler-default-global-properties)
|
2010-03-23 15:41:05 +00:00
|
|
|
(insert "\n")
|
2010-03-16 13:14:24 +00:00
|
|
|
(dolist (resource resources)
|
2010-03-16 09:11:52 +00:00
|
|
|
(let ((level (cdr (assoc "level" resource))))
|
|
|
|
(org-taskjuggler-close-maybe level)
|
|
|
|
(org-taskjuggler-open-resource resource)
|
2010-06-08 13:13:50 +00:00
|
|
|
(setq org-export-taskjuggler-old-level level)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(org-taskjuggler-close-maybe 1)
|
2010-06-08 13:13:50 +00:00
|
|
|
(setq org-export-taskjuggler-old-level 0)
|
2010-03-16 13:14:24 +00:00
|
|
|
(dolist (task tasks)
|
2010-03-16 09:11:52 +00:00
|
|
|
(let ((level (cdr (assoc "level" task))))
|
|
|
|
(org-taskjuggler-close-maybe level)
|
|
|
|
(org-taskjuggler-open-task task)
|
2010-06-08 13:13:50 +00:00
|
|
|
(setq org-export-taskjuggler-old-level level)))
|
2010-03-16 13:14:24 +00:00
|
|
|
(org-taskjuggler-close-maybe 1)
|
2010-03-16 13:41:24 +00:00
|
|
|
(org-taskjuggler-insert-reports)
|
|
|
|
(save-buffer)
|
|
|
|
(or (org-export-push-to-kill-ring "TaskJuggler")
|
|
|
|
(message "Exporting... done"))
|
|
|
|
(current-buffer))))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun org-export-as-taskjuggler-and-open ()
|
2010-04-07 09:49:10 +00:00
|
|
|
"Export the current buffer as a TaskJuggler file and open it
|
|
|
|
with the TaskJuggler GUI."
|
2010-03-16 13:41:24 +00:00
|
|
|
(interactive)
|
2010-06-17 13:58:49 +00:00
|
|
|
(let* ((file-name (buffer-file-name (org-export-as-taskjuggler)))
|
|
|
|
(process-name "TaskJugglerUI")
|
|
|
|
(command (concat process-name " " file-name)))
|
|
|
|
(start-process-shell-command process-name nil command)))
|
2010-03-16 09:11:52 +00:00
|
|
|
|
2011-03-16 16:04:58 +00:00
|
|
|
(defun org-taskjuggler-targeting-tj3-p ()
|
|
|
|
"Return true if we are targeting TaskJuggler III."
|
2011-03-17 10:56:21 +00:00
|
|
|
(>= org-export-taskjuggler-target-version 3.0))
|
2011-03-16 16:04:58 +00:00
|
|
|
|
2010-03-17 13:13:03 +00:00
|
|
|
(defun org-taskjuggler-parent-is-ordered-p ()
|
2010-03-18 09:22:49 +00:00
|
|
|
"Return true if the parent of the current node has a property
|
|
|
|
\"ORDERED\". Return nil otherwise."
|
2010-03-17 13:13:03 +00:00
|
|
|
(save-excursion
|
|
|
|
(and (org-up-heading-safe) (org-entry-get (point) "ORDERED"))))
|
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
(defun org-taskjuggler-components ()
|
2010-03-18 09:22:49 +00:00
|
|
|
"Return an alist containing all the pertinent information for
|
|
|
|
the current node such as the headline, the level, todo state
|
|
|
|
information, all the properties, etc."
|
2010-03-16 09:11:52 +00:00
|
|
|
(let* ((props (org-entry-properties))
|
|
|
|
(components (org-heading-components))
|
2010-04-20 08:01:24 +00:00
|
|
|
(level (nth 1 components))
|
2011-03-16 16:05:02 +00:00
|
|
|
(headline
|
|
|
|
(replace-regexp-in-string
|
|
|
|
"\"" "\\\"" (nth 4 components) t t)) ; quote double quotes in headlines
|
2010-03-17 13:13:03 +00:00
|
|
|
(parent-ordered (org-taskjuggler-parent-is-ordered-p)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(push (cons "level" level) props)
|
2010-03-17 13:13:03 +00:00
|
|
|
(push (cons "headline" headline) props)
|
|
|
|
(push (cons "parent-ordered" parent-ordered) props)))
|
|
|
|
|
2010-03-17 14:44:54 +00:00
|
|
|
(defun org-taskjuggler-assign-task-ids (tasks)
|
2010-03-18 09:22:49 +00:00
|
|
|
"Given a list of tasks return the same list assigning a unique id
|
|
|
|
and the full path to each task. Taskjuggler takes hierarchical ids.
|
|
|
|
For that reason we have to make ids locally unique and we have to keep
|
|
|
|
a path to the current task."
|
2010-03-17 13:13:03 +00:00
|
|
|
(let ((previous-level 0)
|
2010-03-22 16:27:53 +00:00
|
|
|
unique-ids unique-id
|
2010-03-17 13:13:03 +00:00
|
|
|
path
|
|
|
|
task resolved-tasks tmp)
|
|
|
|
(dolist (task tasks resolved-tasks)
|
2010-03-17 14:02:01 +00:00
|
|
|
(let ((level (cdr (assoc "level" task))))
|
2010-03-17 13:13:03 +00:00
|
|
|
(cond
|
2011-03-17 08:48:19 +00:00
|
|
|
((< previous-level level)
|
2010-03-17 14:02:01 +00:00
|
|
|
(setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
|
2010-03-17 13:13:03 +00:00
|
|
|
(dotimes (tmp (- level previous-level))
|
|
|
|
(push (list unique-id) unique-ids)
|
|
|
|
(push unique-id path)))
|
2011-03-17 08:48:19 +00:00
|
|
|
((= previous-level level)
|
2010-03-17 14:02:01 +00:00
|
|
|
(setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
|
2010-03-18 21:22:30 +00:00
|
|
|
(push unique-id (car unique-ids))
|
|
|
|
(setcar path unique-id))
|
2011-03-17 08:48:19 +00:00
|
|
|
((> previous-level level)
|
2010-03-17 13:13:03 +00:00
|
|
|
(dotimes (tmp (- previous-level level))
|
|
|
|
(pop unique-ids)
|
2010-03-17 14:02:01 +00:00
|
|
|
(pop path))
|
2010-03-17 15:36:36 +00:00
|
|
|
(setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
|
2010-03-19 16:13:17 +00:00
|
|
|
(push unique-id (car unique-ids))
|
|
|
|
(setcar path unique-id)))
|
2010-03-17 13:13:03 +00:00
|
|
|
(push (cons "unique-id" unique-id) task)
|
|
|
|
(push (cons "path" (mapconcat 'identity (reverse path) ".")) task)
|
|
|
|
(setq previous-level level)
|
|
|
|
(setq resolved-tasks (append resolved-tasks (list task)))))))
|
|
|
|
|
2011-03-16 16:04:59 +00:00
|
|
|
(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."
|
2011-03-17 08:52:01 +00:00
|
|
|
(let (new-list)
|
|
|
|
(while (car tasks)
|
|
|
|
(let ((task (car tasks))
|
|
|
|
(successor (car (cdr tasks))))
|
|
|
|
(cond
|
|
|
|
;; if a task has no successors it is a leaf
|
|
|
|
((null successor)
|
|
|
|
(push (cons (cons "leaf-node" t) task) new-list))
|
|
|
|
;; if the successor has a lower level than task it is a leaf
|
|
|
|
((<= (cdr (assoc "level" successor)) (cdr (assoc "level" task)))
|
|
|
|
(push (cons (cons "leaf-node" t) task) new-list))
|
|
|
|
;; otherwise examine the rest of the tasks
|
|
|
|
(t (push task new-list))))
|
|
|
|
(setq tasks (cdr tasks)))
|
|
|
|
(nreverse new-list)))
|
2011-03-16 16:04:59 +00:00
|
|
|
|
2011-03-17 08:52:01 +00:00
|
|
|
(defun org-taskjuggler-assign-resource-ids (resources)
|
2010-03-18 09:22:49 +00:00
|
|
|
"Given a list of resources return the same list, assigning a
|
|
|
|
unique id to each resource."
|
2011-03-21 20:11:06 +00:00
|
|
|
(let (unique-ids new-list)
|
|
|
|
(dolist (resource resources new-list)
|
|
|
|
(let ((unique-id (org-taskjuggler-get-unique-id resource unique-ids)))
|
|
|
|
(push (cons "unique-id" unique-id) resource)
|
|
|
|
(push unique-id unique-ids)
|
|
|
|
(push resource new-list)))
|
|
|
|
(nreverse new-list)))
|
2010-03-17 14:44:54 +00:00
|
|
|
|
2010-03-17 13:13:03 +00:00
|
|
|
(defun org-taskjuggler-resolve-dependencies (tasks)
|
|
|
|
(let ((previous-level 0)
|
|
|
|
siblings
|
|
|
|
task resolved-tasks)
|
|
|
|
(dolist (task tasks resolved-tasks)
|
2010-03-18 21:22:30 +00:00
|
|
|
(let* ((level (cdr (assoc "level" task)))
|
|
|
|
(depends (cdr (assoc "depends" task)))
|
|
|
|
(parent-ordered (cdr (assoc "parent-ordered" task)))
|
|
|
|
(blocker (cdr (assoc "BLOCKER" task)))
|
2011-03-17 08:48:19 +00:00
|
|
|
(blocked-on-previous
|
2010-04-07 09:50:08 +00:00
|
|
|
(and blocker (string-match "previous-sibling" blocker)))
|
2010-03-18 21:22:30 +00:00
|
|
|
(dependencies
|
|
|
|
(org-taskjuggler-resolve-explicit-dependencies
|
2011-03-17 08:48:19 +00:00
|
|
|
(append
|
2010-04-07 09:50:08 +00:00
|
|
|
(and depends (org-taskjuggler-tokenize-dependencies depends))
|
2011-03-17 08:48:19 +00:00
|
|
|
(and blocker (org-taskjuggler-tokenize-dependencies blocker)))
|
2010-04-07 09:50:08 +00:00
|
|
|
tasks))
|
2010-03-18 21:22:30 +00:00
|
|
|
previous-sibling)
|
|
|
|
; update previous sibling info
|
2010-03-17 13:13:03 +00:00
|
|
|
(cond
|
2011-03-17 08:48:19 +00:00
|
|
|
((< previous-level level)
|
2010-03-17 13:13:03 +00:00
|
|
|
(dotimes (tmp (- level previous-level))
|
|
|
|
(push task siblings)))
|
|
|
|
((= previous-level level)
|
|
|
|
(setq previous-sibling (car siblings))
|
|
|
|
(setcar siblings task))
|
2011-03-17 08:48:19 +00:00
|
|
|
((> previous-level level)
|
2010-03-17 13:13:03 +00:00
|
|
|
(dotimes (tmp (- previous-level level))
|
|
|
|
(pop siblings))
|
|
|
|
(setq previous-sibling (car siblings))
|
|
|
|
(setcar siblings task)))
|
2010-03-18 21:22:30 +00:00
|
|
|
; insert a dependency on previous sibling if the parent is
|
|
|
|
; ordered or if the tasks has a BLOCKER attribute with value "previous-sibling"
|
|
|
|
(when (or (and previous-sibling parent-ordered) blocked-on-previous)
|
|
|
|
(push (format "!%s" (cdr (assoc "unique-id" previous-sibling))) dependencies))
|
|
|
|
; store dependency information
|
2011-03-17 08:48:19 +00:00
|
|
|
(when dependencies
|
2010-03-18 21:22:30 +00:00
|
|
|
(push (cons "depends" (mapconcat 'identity dependencies ", ")) task))
|
2010-03-17 13:13:03 +00:00
|
|
|
(setq previous-level level)
|
|
|
|
(setq resolved-tasks (append resolved-tasks (list task)))))))
|
|
|
|
|
2010-04-07 09:50:08 +00:00
|
|
|
(defun org-taskjuggler-tokenize-dependencies (dependencies)
|
|
|
|
"Split a dependency property value DEPENDENCIES into the
|
|
|
|
individual dependencies and return them as a list while keeping
|
|
|
|
the optional arguments (such as gapduration) for the
|
|
|
|
dependencies. A dependency will have to match `[-a-zA-Z0-9_]+'."
|
2011-03-17 08:48:19 +00:00
|
|
|
(cond
|
2010-04-07 09:50:08 +00:00
|
|
|
((string-match "^ *$" dependencies) nil)
|
|
|
|
((string-match "^[ \t]*\\([-a-zA-Z0-9_]+\\([ \t]*{[^}]+}\\)?\\)[ \t,]*" dependencies)
|
2011-03-17 08:48:19 +00:00
|
|
|
(cons
|
2010-04-07 09:50:08 +00:00
|
|
|
(substring dependencies (match-beginning 1) (match-end 1))
|
|
|
|
(org-taskjuggler-tokenize-dependencies (substring dependencies (match-end 0)))))
|
|
|
|
(t (error (format "invalid dependency id %s" dependencies)))))
|
|
|
|
|
2010-03-18 21:22:30 +00:00
|
|
|
(defun org-taskjuggler-resolve-explicit-dependencies (dependencies tasks)
|
2010-04-13 14:25:40 +00:00
|
|
|
"For each dependency in DEPENDENCIES try to find a
|
2010-04-28 07:11:09 +00:00
|
|
|
corresponding task with a matching property \"task_id\" in TASKS.
|
|
|
|
Return a list containing the resolved links for all DEPENDENCIES
|
|
|
|
where a matching tasks was found. If the dependency is
|
2010-04-13 14:25:40 +00:00
|
|
|
\"previous-sibling\" it is ignored (as this is dealt with in
|
|
|
|
`org-taskjuggler-resolve-dependencies'). If there is no matching
|
2010-04-28 07:11:09 +00:00
|
|
|
task the dependency is ignored and a warning is displayed ."
|
2010-04-07 09:50:08 +00:00
|
|
|
(unless (null dependencies)
|
2011-03-17 08:48:19 +00:00
|
|
|
(let*
|
2010-04-07 09:50:08 +00:00
|
|
|
;; the dependency might have optional attributes such as "{
|
|
|
|
;; gapduration 5d }", so only use the first string as id for the
|
|
|
|
;; dependency
|
2010-04-13 14:25:40 +00:00
|
|
|
((dependency (car dependencies))
|
|
|
|
(id (car (split-string dependency)))
|
2011-03-17 08:48:19 +00:00
|
|
|
(optional-attributes
|
2010-04-13 14:25:40 +00:00
|
|
|
(mapconcat 'identity (cdr (split-string dependency)) " "))
|
2010-04-07 09:50:08 +00:00
|
|
|
(path (org-taskjuggler-find-task-with-id id tasks)))
|
2011-03-17 08:48:19 +00:00
|
|
|
(cond
|
2010-04-07 09:50:08 +00:00
|
|
|
;; ignore previous sibling dependencies
|
|
|
|
((equal (car dependencies) "previous-sibling")
|
|
|
|
(org-taskjuggler-resolve-explicit-dependencies (cdr dependencies) tasks))
|
|
|
|
;; if the id is found in another task use its path
|
2011-03-17 08:48:19 +00:00
|
|
|
((not (null path))
|
2010-04-07 09:50:08 +00:00
|
|
|
(cons (mapconcat 'identity (list path optional-attributes) " ")
|
2011-03-17 08:48:19 +00:00
|
|
|
(org-taskjuggler-resolve-explicit-dependencies
|
2010-04-07 09:50:08 +00:00
|
|
|
(cdr dependencies) tasks)))
|
2010-04-28 07:11:09 +00:00
|
|
|
;; warn about dangling dependency but otherwise ignore it
|
2011-03-17 08:48:19 +00:00
|
|
|
(t (display-warning
|
|
|
|
'org-export-taskjuggler
|
2010-04-28 07:11:09 +00:00
|
|
|
(format "No task with matching property \"task_id\" found for id %s" id))
|
|
|
|
(org-taskjuggler-resolve-explicit-dependencies (cdr dependencies) tasks))))))
|
2010-03-18 21:22:30 +00:00
|
|
|
|
|
|
|
(defun org-taskjuggler-find-task-with-id (id tasks)
|
2010-04-07 09:50:08 +00:00
|
|
|
"Find ID in tasks. If found return the path of task. Otherwise
|
|
|
|
return nil."
|
2010-04-28 07:11:09 +00:00
|
|
|
(let ((task-id (cdr (assoc "task_id" (car tasks))))
|
2010-03-19 16:35:33 +00:00
|
|
|
(path (cdr (assoc "path" (car tasks)))))
|
2011-03-17 08:48:19 +00:00
|
|
|
(cond
|
2010-03-19 16:35:33 +00:00
|
|
|
((null tasks) nil)
|
|
|
|
((equal task-id id) path)
|
|
|
|
(t (org-taskjuggler-find-task-with-id id (cdr tasks))))))
|
2010-03-18 21:22:30 +00:00
|
|
|
|
2010-03-18 09:22:49 +00:00
|
|
|
(defun org-taskjuggler-get-unique-id (item unique-ids)
|
|
|
|
"Return a unique id for an ITEM which can be a task or a resource.
|
|
|
|
The id is derived from the headline and made unique against
|
2010-04-21 09:30:52 +00:00
|
|
|
UNIQUE-IDS. If the (downcased) first token of the headline is not
|
|
|
|
unique try to add more (downcased) tokens of the headline or
|
|
|
|
finally add more underscore characters (\"_\")."
|
2010-03-18 09:22:49 +00:00
|
|
|
(let* ((headline (cdr (assoc "headline" item)))
|
2010-03-17 13:13:03 +00:00
|
|
|
(parts (split-string headline))
|
2010-03-23 12:11:09 +00:00
|
|
|
(id (org-taskjuggler-clean-id (downcase (pop parts)))))
|
2010-03-17 13:13:03 +00:00
|
|
|
; try to add more parts of the headline to make it unique
|
2010-10-19 12:17:16 +00:00
|
|
|
(while (and (member id unique-ids) (car parts))
|
2010-03-23 12:11:09 +00:00
|
|
|
(setq id (concat id "_" (org-taskjuggler-clean-id (downcase (pop parts))))))
|
2010-03-17 13:13:03 +00:00
|
|
|
; if its still not unique add "_"
|
|
|
|
(while (member id unique-ids)
|
|
|
|
(setq id (concat id "_")))
|
2010-03-23 12:11:09 +00:00
|
|
|
id))
|
2011-03-17 08:48:19 +00:00
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
(defun org-taskjuggler-clean-id (id)
|
2010-03-18 09:22:49 +00:00
|
|
|
"Clean and return ID to make it acceptable for taskjuggler."
|
2010-03-16 09:11:52 +00:00
|
|
|
(and id (replace-regexp-in-string "[^a-zA-Z0-9_]" "_" id)))
|
|
|
|
|
|
|
|
(defun org-taskjuggler-open-project (project)
|
2010-04-28 07:14:43 +00:00
|
|
|
"Insert the beginning of a project declaration. All valid
|
2010-03-23 13:02:48 +00:00
|
|
|
attributes from the PROJECT alist are inserted. If no end date is
|
|
|
|
specified it is calculated
|
|
|
|
`org-export-taskjuggler-default-project-duration' days from now."
|
|
|
|
(let* ((unique-id (cdr (assoc "unique-id" project)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(headline (cdr (assoc "headline" project)))
|
|
|
|
(version (cdr (assoc "version" project)))
|
|
|
|
(start (cdr (assoc "start" project)))
|
2010-03-23 14:40:02 +00:00
|
|
|
(end (cdr (assoc "end" project))))
|
2011-03-17 08:48:19 +00:00
|
|
|
(insert
|
2010-03-23 14:40:02 +00:00
|
|
|
(format "project %s \"%s\" \"%s\" %s +%sd {\n }\n"
|
|
|
|
unique-id headline version start
|
|
|
|
org-export-taskjuggler-default-project-duration))))
|
2010-03-23 13:02:48 +00:00
|
|
|
|
2010-03-23 15:41:05 +00:00
|
|
|
(defun org-taskjuggler-filter-and-join (items)
|
2010-03-24 08:20:10 +00:00
|
|
|
"Filter all nil elements from ITEMS and join the remaining ones
|
|
|
|
with separator \"\n\"."
|
|
|
|
(let ((filtered-items (remq nil items)))
|
|
|
|
(and filtered-items (mapconcat 'identity filtered-items "\n"))))
|
2011-03-17 08:48:19 +00:00
|
|
|
|
2010-03-23 13:02:48 +00:00
|
|
|
(defun org-taskjuggler-get-attributes (item attributes)
|
2010-04-07 09:49:10 +00:00
|
|
|
"Return all attribute as a single formated string. ITEM is an
|
|
|
|
alist representing either a resource or a task. ATTRIBUTES is a
|
|
|
|
list of symbols. Only entries from ITEM are considered that are
|
|
|
|
listed in ATTRIBUTES."
|
2011-03-17 08:48:19 +00:00
|
|
|
(org-taskjuggler-filter-and-join
|
2010-03-23 15:41:05 +00:00
|
|
|
(mapcar
|
2011-03-17 08:48:19 +00:00
|
|
|
(lambda (attribute)
|
|
|
|
(org-taskjuggler-filter-and-join
|
2010-03-23 15:41:05 +00:00
|
|
|
(org-taskjuggler-get-attribute item attribute)))
|
|
|
|
attributes)))
|
|
|
|
|
|
|
|
(defun org-taskjuggler-get-attribute (item attribute)
|
|
|
|
"Return a list of strings containing the properly formatted
|
|
|
|
taskjuggler declaration for a given ATTRIBUTE in ITEM (an alist).
|
|
|
|
If the ATTRIBUTE is not in ITEM return nil."
|
2011-03-17 08:48:19 +00:00
|
|
|
(cond
|
2010-03-23 15:41:05 +00:00
|
|
|
((null item) nil)
|
|
|
|
((equal (symbol-name attribute) (car (car item)))
|
2010-03-30 08:11:13 +00:00
|
|
|
(cons (format "%s %s" (symbol-name attribute) (cdr (car item)))
|
2010-03-23 15:41:05 +00:00
|
|
|
(org-taskjuggler-get-attribute (cdr item) attribute)))
|
|
|
|
(t (org-taskjuggler-get-attribute (cdr item) attribute))))
|
2010-03-16 09:11:52 +00:00
|
|
|
|
|
|
|
(defun org-taskjuggler-open-resource (resource)
|
2010-04-28 07:14:43 +00:00
|
|
|
"Insert the beginning of a resource declaration. All valid
|
|
|
|
attributes from the RESOURCE alist are inserted. If the RESOURCE
|
|
|
|
defines a property \"resource_id\" it will be used as the id for
|
|
|
|
this resource. Otherwise it will use the ID property. If neither
|
|
|
|
is defined it will calculate a unique id for the resource using
|
|
|
|
`org-taskjuggler-get-unique-id'."
|
2011-03-17 08:48:19 +00:00
|
|
|
(let ((id (org-taskjuggler-clean-id
|
|
|
|
(or (cdr (assoc "resource_id" resource))
|
|
|
|
(cdr (assoc "ID" resource))
|
2010-04-28 07:11:09 +00:00
|
|
|
(cdr (assoc "unique-id" resource)))))
|
2010-03-17 15:01:23 +00:00
|
|
|
(headline (cdr (assoc "headline" resource)))
|
2010-03-23 10:09:10 +00:00
|
|
|
(attributes '(limits vacation shift booking efficiency journalentry rate)))
|
2011-03-17 08:48:19 +00:00
|
|
|
(insert
|
|
|
|
(concat
|
2010-04-28 07:11:09 +00:00
|
|
|
"resource " id " \"" headline "\" {\n "
|
2010-03-23 13:02:48 +00:00
|
|
|
(org-taskjuggler-get-attributes resource attributes) "\n"))))
|
2010-03-16 09:11:52 +00:00
|
|
|
|
|
|
|
(defun org-taskjuggler-clean-effort (effort)
|
2010-03-18 09:07:38 +00:00
|
|
|
"Translate effort strings into a format acceptable to taskjuggler,
|
2010-03-24 11:02:37 +00:00
|
|
|
i.e. REAL UNIT. If the effort string is something like 5:30 it
|
|
|
|
will be assumed to be hours and will be translated into 5.5h.
|
2010-03-18 09:07:38 +00:00
|
|
|
Otherwise if it contains something like 3.0 it is assumed to be
|
2010-04-07 09:49:10 +00:00
|
|
|
days and will be translated into 3.0d. Other formats that
|
|
|
|
taskjuggler supports (like weeks, months and years) are currently
|
|
|
|
not supported."
|
2011-03-17 08:48:19 +00:00
|
|
|
(cond
|
2010-03-16 09:11:52 +00:00
|
|
|
((null effort) effort)
|
2011-03-17 08:48:19 +00:00
|
|
|
((string-match "\\([0-9]+\\):\\([0-9]+\\)" effort)
|
2010-03-24 11:02:37 +00:00
|
|
|
(let ((hours (string-to-number (match-string 1 effort)))
|
|
|
|
(minutes (string-to-number (match-string 2 effort))))
|
|
|
|
(format "%dh" (+ hours (/ minutes 60.0)))))
|
2010-03-16 09:11:52 +00:00
|
|
|
((string-match "\\([0-9]+\\).\\([0-9]+\\)" effort) (concat effort "d"))
|
|
|
|
(t (error "Not a valid effort (%s)" effort))))
|
|
|
|
|
2010-03-23 14:40:52 +00:00
|
|
|
(defun org-taskjuggler-get-priority (priority)
|
|
|
|
"Return a priority between 1 and 1000 based on PRIORITY, an
|
|
|
|
org-mode priority string."
|
2011-03-17 08:48:19 +00:00
|
|
|
(max 1 (/ (* 1000 (- org-lowest-priority (string-to-char priority)))
|
2010-03-23 14:40:52 +00:00
|
|
|
(- org-lowest-priority org-highest-priority))))
|
|
|
|
|
2010-03-16 09:11:52 +00:00
|
|
|
(defun org-taskjuggler-open-task (task)
|
2010-03-17 16:05:28 +00:00
|
|
|
(let* ((unique-id (cdr (assoc "unique-id" task)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(headline (cdr (assoc "headline" task)))
|
2010-03-16 09:35:29 +00:00
|
|
|
(effort (org-taskjuggler-clean-effort (cdr (assoc org-effort-property task))))
|
2010-03-16 09:11:52 +00:00
|
|
|
(depends (cdr (assoc "depends" task)))
|
|
|
|
(allocate (cdr (assoc "allocate" task)))
|
2010-03-23 14:40:52 +00:00
|
|
|
(priority-raw (cdr (assoc "PRIORITY" task)))
|
|
|
|
(priority (and priority-raw (org-taskjuggler-get-priority priority-raw)))
|
2010-03-17 16:05:28 +00:00
|
|
|
(state (cdr (assoc "TODO" task)))
|
2011-03-17 08:48:19 +00:00
|
|
|
(complete (or (and (member state org-done-keywords) "100")
|
2010-03-17 16:05:28 +00:00
|
|
|
(cdr (assoc "complete" task))))
|
2010-03-17 13:13:03 +00:00
|
|
|
(parent-ordered (cdr (assoc "parent-ordered" task)))
|
2010-03-23 13:02:48 +00:00
|
|
|
(previous-sibling (cdr (assoc "previous-sibling" task)))
|
2011-03-16 16:04:59 +00:00
|
|
|
(milestone (or (cdr (assoc "milestone" task))
|
|
|
|
(and (assoc "leaf-node" task)
|
2011-03-17 08:48:19 +00:00
|
|
|
(not (or effort
|
2011-03-16 16:04:59 +00:00
|
|
|
(cdr (assoc "duration" task))
|
|
|
|
(cdr (assoc "end" task))
|
|
|
|
(cdr (assoc "period" task)))))))
|
2011-03-17 08:48:19 +00:00
|
|
|
(attributes
|
2010-03-23 13:02:48 +00:00
|
|
|
'(account start note duration endbuffer endcredit end
|
2011-03-16 16:04:59 +00:00
|
|
|
flags journalentry length maxend maxstart minend
|
|
|
|
minstart period reference responsible scheduling
|
|
|
|
startbuffer startcredit statusnote)))
|
2010-03-16 09:11:52 +00:00
|
|
|
(insert
|
2011-03-17 08:48:19 +00:00
|
|
|
(concat
|
|
|
|
"task " unique-id " \"" headline "\" {\n"
|
2010-03-17 13:13:03 +00:00
|
|
|
(if (and parent-ordered previous-sibling)
|
2010-03-23 13:02:48 +00:00
|
|
|
(format " depends %s\n" previous-sibling)
|
|
|
|
(and depends (format " depends %s\n" depends)))
|
2011-03-16 16:04:58 +00:00
|
|
|
(and allocate (format " purge %s\n allocate %s\n"
|
2011-03-21 20:11:07 +00:00
|
|
|
(or (and (org-taskjuggler-targeting-tj3-p) "allocate")
|
|
|
|
"allocations")
|
2011-03-16 16:04:58 +00:00
|
|
|
allocate))
|
2010-03-23 13:02:48 +00:00
|
|
|
(and complete (format " complete %s\n" complete))
|
|
|
|
(and effort (format " effort %s\n" effort))
|
|
|
|
(and priority (format " priority %s\n" priority))
|
2011-03-16 16:04:59 +00:00
|
|
|
(and milestone (format " milestone\n"))
|
2011-03-17 08:48:19 +00:00
|
|
|
|
2010-03-23 13:02:48 +00:00
|
|
|
(org-taskjuggler-get-attributes task attributes)
|
2010-03-16 09:11:52 +00:00
|
|
|
"\n"))))
|
|
|
|
|
|
|
|
(defun org-taskjuggler-close-maybe (level)
|
2011-03-17 08:48:19 +00:00
|
|
|
(while (> org-export-taskjuggler-old-level level)
|
2010-03-16 09:11:52 +00:00
|
|
|
(insert "}\n")
|
2010-06-08 13:13:50 +00:00
|
|
|
(setq org-export-taskjuggler-old-level (1- org-export-taskjuggler-old-level)))
|
|
|
|
(when (= org-export-taskjuggler-old-level level)
|
2010-03-16 09:11:52 +00:00
|
|
|
(insert "}\n")))
|
|
|
|
|
2010-03-16 13:14:24 +00:00
|
|
|
(defun org-taskjuggler-insert-reports ()
|
|
|
|
(let (report)
|
|
|
|
(dolist (report org-export-taskjuggler-default-reports)
|
|
|
|
(insert report "\n"))))
|
2010-03-16 09:11:52 +00:00
|
|
|
|
|
|
|
(provide 'org-taskjuggler)
|
|
|
|
|
|
|
|
;;; org-taskjuggler.el ends here
|