Andrew:
Thanks for the feedback. I'll take a crack at the JSPs and post back.
-Lou
Andrew Jaquith <[EMAIL PROTECTED]> wrote on 09/18/2008 01:27:15 PM:
> Lou --
>
> > 1. I noticed my strings are coming out surrounded by three question
> > marks
> > (???TestWorkFlow???). I think this is related to localization so do I
> > need to add these strings to the i18n files?
>
> Yes. You need to make sure that you have i18n strings that supply the
> correct text. If you initialize a Workflow object with the String
> "TestWorkflow", JSPWiki will look for the message key "TestWorkflow".
> I am pretty sure these are in the CoreResources bundle.
>
> > 2. Is there any way for the decision maker to add a comment (fact)
> > when
> > making the decision? I don't see this so I'm guessing it will need
> > to be
> > added (maybe a new DecisionWithComments.java class?).
>
> There isn't in the UI (i.e., the workflow JSP), but the API does
> support this via Decision.addFact(Fact). This would be a nice
> enhancement, if you aren't opposed to a little recreational JSP hacking.
>
> > 3. Is there an existing way to see the workflow history or for
> > admins to
> > see histiories for all workflows? Again, I don't mind coding this - I
> > just don't want to redo something that is already there.
>
> This isn't the UI either, but the API supports this via
> WorkflowManager.getCompletedWorkflows().
> >
> >
> > Andrew Jaquith <[EMAIL PROTECTED]> wrote on 09/17/2008 11:02:45
> > PM:
> >
> >> Nice example, Louis! Thanks for doing this, and for posting it.
> >>
> >> I forgot to mention there's also a WorkflowBuilder class, with a
> >> method buildApprovalWorkflow(). This method automates a fair amount
> >> of
> >> the code needed for simple "decision" workflows. That's worth
> >> taking a
> >> look at, also. That said, your example shows the detail, which is
> >> good, and will help coders understand how it all works.
> >>
> >> Andrew
> >>
> >> On Sep 17, 2008, at 12:46 PM, [EMAIL PROTECTED] wrote:
> >>
> >>> OK, I took Andrew's suggestion and looked at UserManager. I
> >>> combined some
> >>> of that code with the javadoc example in the WorkFlow.java source
> >>> and came
> >>> up with the following very simple but working example. It sends an
> >>> email,
> >>> waits for a member of the Admins group to make a decision and then
> >>> sends
> >>> another email (I said it was very basic). It's pretty easy once you
> >>> see
> >>> it and I thought I would post in case anyone else was wondering
> >>> about
> >>> workflows.
> >>>
> >>>
> >>>
> >>> package com.lognet.wiki.plugin;
> >>>
> >>> import java.util.*;
> >>> import java.io.*;
> >>> import java.sql.*;
> >>>
> >>> import java.security.Principal;
> >>>
> >>> import com.ecyrd.jspwiki.*;
> >>>
> >>> import com.ecyrd.jspwiki.auth.user.*;
> >>> import com.ecyrd.jspwiki.workflow.*;
> >>> import com.ecyrd.jspwiki.util.MailUtil;
> >>> import com.ecyrd.jspwiki.auth.GroupPrincipal;
> >>> import com.ecyrd.jspwiki.auth.permissions.AllPermission;
> >>> import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
> >>> import com.ecyrd.jspwiki.auth.user.AbstractUserDatabase;
> >>> import com.ecyrd.jspwiki.auth.user.DuplicateUserException;
> >>> import com.ecyrd.jspwiki.auth.user.UserDatabase;
> >>> import com.ecyrd.jspwiki.auth.user.UserProfile;
> >>> import com.ecyrd.jspwiki.event.WikiEventListener;
> >>> import com.ecyrd.jspwiki.event.WikiEventManager;
> >>> import com.ecyrd.jspwiki.event.WikiSecurityEvent;
> >>> import com.ecyrd.jspwiki.filters.PageFilter;
> >>> import com.ecyrd.jspwiki.filters.SpamFilter;
> >>> import com.ecyrd.jspwiki.i18n.InternationalizationManager;
> >>> import com.ecyrd.jspwiki.rpc.RPCCallable;
> >>> import com.ecyrd.jspwiki.rpc.json.JSONRPCManager;
> >>> import com.ecyrd.jspwiki.ui.InputValidator;
> >>> import com.ecyrd.jspwiki.util.ClassUtil;
> >>>
> >>>
> >>> public class WorkFlowTestPlugin extends LNWikiAncestor //
> >>> LNWikiAncestor
> >>> is just a wrapper for WikiPlugin
> >>> {
> >>> private WikiEngine m_engine;
> >>> private WikiSession session;
> >>>
> >>>
> >>>
> >>> public String execPayload(WikiContext context, Map p) throws
> >>> Exception
> >>> {
> >>> m_engine = context.getEngine();
> >>>
> >>> Workflow workflow = new Workflow("TestWorkFlow",
> >>> context.getCurrentUser());
> >>> Step initTask = new InitTask(m_engine);
> >>> Step finishTask = new FinishTask(m_engine);
> >>> Principal actor = new GroupPrincipal("Admins");
> >>> Decision decision = new SimpleDecision(workflow,
> >>> "decision.AdminDecision", actor);
> >>> Fact aFact = new Fact( "Request Number", "123456");
> >>> decision.addFact(aFact);
> >>> initTask.addSuccessor(Outcome.STEP_COMPLETE,
> >>> decision);
> >>> decision.addSuccessor(Outcome.DECISION_APPROVE,
> >>> finishTask);
> >>> workflow.setFirstStep(initTask);
> >>> m_engine.getWorkflowManager().start(workflow);
> >>>
> >>>
> >>> return "OK";
> >>> }
> >>>
> >>> public static class InitTask extends Task
> >>> {
> >>> private final WikiEngine m_engine;
> >>>
> >>> public InitTask( WikiEngine engine )
> >>> {
> >>> super( "task.sendEmail" );
> >>> m_engine = engine;
> >>> }
> >>>
> >>> public Outcome execute() throws WikiException
> >>> {
> >>> try{
> >>> MailUtil.sendMessage( m_engine,
> >>> "[EMAIL PROTECTED]", "WFTEST", "This is an init test from the workflow");
> >>> }
> >>> catch (Exception e)
> >>> {
> >>> throw new WikiException("Could not
> >>> execute
> >>> task");
> >>> }
> >>>
> >>> return Outcome.STEP_COMPLETE;
> >>> }
> >>> }
> >>> public static class FinishTask extends Task
> >>> {
> >>> private final WikiEngine m_engine;
> >>>
> >>> public FinishTask( WikiEngine engine )
> >>> {
> >>> super( "task.sendEmail" );
> >>> m_engine = engine;
> >>> }
> >>>
> >>> public Outcome execute() throws WikiException
> >>> {
> >>> try{
> >>> MailUtil.sendMessage( m_engine,
> >>> "[EMAIL PROTECTED]", "WFTEST", "This is a finish test from the workflow");
> >>> }
> >>> catch (Exception e)
> >>> {
> >>> throw new WikiException("Could not
> >>> execute
> >>> task");
> >>> }
> >>>
> >>> return Outcome.STEP_COMPLETE;
> >>> }
> >>> }
> >>> }
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Andrew Jaquith <[EMAIL PROTECTED]>
> >>> 09/16/2008 03:20 PM
> >>> Please respond to
> >>> [email protected]
> >>>
> >>>
> >>> To
> >>> "[email protected]" <jspwiki-
> >>> [EMAIL PROTECTED]>
> >>> cc
> >>>
> >>> Subject
> >>> Re: workflows - examples?
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Louis, Bob--
> >>>
> >>> Probably the best example is in the PageManager code; we use the
> >>> workflow service to route page-save operations if approval is
> >>> required. UserManager also creates workflows if approval is required
> >>> for new wiki accounts.
> >>>
> >>> Andrew
> >>>
> >>> On Sep 16, 2008, at 13:15, Bob Paige <[EMAIL PROTECTED]> wrote:
> >>>
> >>>> I posted the same question some months ago. I hope to see an answer
> >>>> this
> >>>> time as this could be a useful feature for me.
> >>>>
> >>>> --
> >>>> Bobman
> >>>>
> >>>> On Tue, Sep 16, 2008 at 11:27 AM, <[EMAIL PROTECTED]>
> >>>> wrote:
> >>>>
> >>>>> Does anyone have any example code for setting up or using
> >>>>> workflows? I
> >>>>> see the java classes and the workflow tab, but I can't seem to
> >>>>> figure out
> >>>>> how to interact with them.
> >>>>>
> >>>
> >>
>