emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: Karl Voit <devnull@Karl-Voit.at>
Cc: news1142@Karl-Voit.at, emacs-orgmode@gnu.org
Subject: Re: Process diagrams with dot and some glue using Org-mode
Date: Wed, 26 Jun 2013 17:40:09 +0100	[thread overview]
Message-ID: <87sj04keqe.fsf@ucl.ac.uk> (raw)
In-Reply-To: <2013-06-26T17-08-48@devnull.Karl-Voit.at> (Karl Voit's message of "Wed, 26 Jun 2013 17:23:03 +0200")

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

Hi Karl,

Karl Voit <devnull@Karl-Voit.at> writes:
> I was looking for a reasonable simple method to define processes and
> work-flows within Org-mode. My research did not result in anything
> existing I found useful. Therefore, I started to read about dot[1]
> and found [2].
>
> I would like to define my diagram with the following two tables: one
> for the node definitions and one for the interconnections between
> notes. The syntax should be pretty self-explanatory (or at least I
> hope so):

[...]

> The question is: is somebody with decent ELISP knowledge able to
> implement the missing method? :-)

I did something simple for generating graphs but without an adjacency
type of matrix as you have defined and without the special types of
edges.  So, quite limited with respect to what you want.  In any case,
I've attached what I played with a while ago in the hope that maybe some
of it proves useful.  What I did taxed my abilities in emacs lisp so I
won't be able to help much in adapting it to what you want...

eric
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.3-193-g334581

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: businessprocess.org --]
[-- Type: text/x-org, Size: 3897 bytes --]

* preamble
#+TITLE:     businessprocess.org
#+AUTHOR:    Eric S Fraga
#+EMAIL:     e.fraga@ucl.ac.uk
#+DATE:      2010-11-15 Mon
#+DESCRIPTION: cf. 
#+KEYWORDS: 
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:   
#+LINK_HOME: 
#+XSLT: 

* The problem

Look at [[gnus:nnmaildir%2BUCL:lists#87bp5sacnf.fsf@bunting.net.au][this email]].

* the table

#+tblname: processtable 
| Step        | Description                                                             | Next Steps  |       |
|-------------+-------------------------------------------------------------------------+-------------+-------|
| Begin       | Begin the process                                                       | Choice1     |       |
| Choice1     | Decide if we are big or small.                                          | Big         | Small |
| Big         | If we are big then do big things                                        | End         |       |
| Small       | If we are small then figure out if we are really small or possibly big. | ReallySmall | Big   |
| ReallySmall | Yes we are really small                                                 | End         |       |
| End         | The end.                                                                |             |       |
|-------------+-------------------------------------------------------------------------+-------------+-------|

* the elisp code

#+source: esf/business-process
#+begin_src emacs-lisp :results value raw :exports results
(defun esf/generate-business-process-graph (table name file)
  (let ((entries (nthcdr 2 table))
	(output (format "digraph %s {" name))
	)
    (message "Initial: %s\n" table)
    (message "Entries: %s\n" entries)
    ;; we need to do two iterations through the table, one to define
    ;; the nodes and then one to connect them.
    (setq savedentries entries)		;for second iteration
    (while entries
      (let ((entry (first entries)))
	(if (listp entry)
	    (let ((step (first entry))
		  (description (nth 1 entry)) )
	      (setq output  (format "%s\n  %s [label=\"%s\"];" output step description))
	      )
	  )
	(setq entries (cdr entries))
	)
      )
    (setq entries savedentries)
    (while entries
      (let ((entry (first entries)))
	(if (listp entry)
	    (let ((from (first entry))
		  (nextsteps (cdr (cdr entry))) )
	      (message "Nextsteps: %s\n" nextsteps)
	      (while nextsteps
		(let ((to (first nextsteps)))
		  (if to 
		      (if (not (string= to ""))
			  (setq output (format "%s\n  %s -> %s;" output from to))))
		  (setq nextsteps (cdr nextsteps))
		  )
		)
	      )
	  )
	(setq entries (cdr entries))
	)
      ) ; end while entries left
    (format "#+begin_src dot :results file :file %s :exports results
%s
}
,#+end_src\n" file output)
    )
  )
(esf/generate-business-process-graph table name file)
#+end_src

* the graph
#+call: esf/business-process(table=processtable, file="business.pdf", name="process") :results value raw

#+results: esf/business-process(table=processtable, file="business.pdf", name="process")
#+begin_src dot :results file :file business.pdf :exports results
digraph process {
  Begin [label="Begin the process"];
  Choice1 [label="Decide if we are big or small."];
  Big [label="If we are big then do big things"];
  Small [label="If we are small then figure out if we are really small or possibly big."];
  ReallySmall [label="Yes we are really small"];
  End [label="The end."];
  Begin -> Choice1;
  Choice1 -> Big;
  Choice1 -> Small;
  Big -> End;
  Small -> ReallySmall;
  Small -> Big;
  ReallySmall -> End;
}
#+end_src

#+results:
[[file:business.pdf]]


  parent reply	other threads:[~2013-06-26 17:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
2013-06-26 15:41 ` Karl Voit
2013-06-26 15:44 ` Rick Frankel
2013-06-26 17:03   ` Karl Voit
2013-06-26 18:25     ` Rick Frankel
2013-06-27  6:47       ` Karl Voit
2013-06-27 13:06         ` Rick Frankel
2013-06-27 13:56           ` Bastien
2013-06-28  9:20       ` Karl Voit
2013-06-28 15:34         ` Rick Frankel
2013-07-01 17:44           ` Karl Voit
2013-06-26 16:40 ` Eric S Fraga [this message]
2013-06-27  6:56   ` Karl Voit
2013-06-26 16:54 ` Thorsten Jolitz
2013-06-27  6:36   ` Karl Voit
2013-07-03 19:18 ` Karl Voit
2013-07-03 20:57   ` Nick Dokos
2013-07-05 16:15   ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sj04keqe.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=devnull@Karl-Voit.at \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).