Feb 15

jBPM mail node

jBPM mail nodes are simple nodes designed only to send mails. This time you don’t have to implement any handler or function, jBPM libraries provide nearly all you need.

In mail info tab you can set the destination e-mail address, the subject and the mail body that is going to send. This will be useful when you know destination e-mail address, orders@mycompany.com, for instance.

If you need to send mails to workflow actors, you can set a user variable in context:

executionContext.setVariable("user", workflowActor);

and configure mail info as it follows:

jBPM mail info

jBPM address resolver will check for user e-mail address from database and send him the mail, you will have to do nothing!

This is a great node but I had some requirements that it didn’t provide to me, so I re-implemented it, adding some new methods.

You can download new implementation here.

Now I can send mails using a gmail account. To explain it in a simple way, my implementation read some extra parameters from jbpm.cfg.xml file before sending the mail.

  <string name="jbpm.mail.smtp.host" value="smtp.gmail.com" />
  <bean   name="jbpm.mail.address.resolver" class="org.jbpm.identity.mail.IdentityAddressResolver" singleton="true" />
  <string name="jbpm.mail.from.address" value="yourMail@gmail.com" />
  <string name="jbpm.mail.user" value="yourUser@gmail.com" />
  <string name="jbpm.mail.pass" value="yourPassword" />
  <string name="jbpm.mail.port" value="465" />
  <string name="jbpm.mail.smtp.socketFactory.port" value="465" />
  <string name="jbpm.mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory" />
  <string name="jbpm.mail.smtp.auth" value="true" />
  <string name="jbpm.mail.smtp.starttls.enable" value="true" />
  <string name="jbpm.mail.debug" value="true" />
  <string name="jbpm.mail.smtp.socketFactory.fallback" value="false" />
  <string name="jbpm.mail.advanced.config" value="true" />
  <string name='mail.class.name' value='FastSign.mail.Mail' />

If jbpm.mail.advanced.config is set to false it works as the original mail node. Setting it to true, activates the extra parameters. In this case, 465 is gmail port, I suppose you can change it to use other system. Note that you have to define mail.class.name with the correct package.

I hope this will be useful.

Related Posts

Feb 14

Decision node

jBPM decision nodes are very useful to create some alternative path along the workflow. The implementation of this node will choose the correct way.

Decision node example

To program these kind of nodes I prefer to develop a DecisionHandler rather than using an expression.

public class Validacion implements DecisionHandler{
....
}

Implement a decide method is mandatory:

public String decide(ExecutionContext executionContext) throws Exception;

Among this function code lines you can query database, consult session or recover variables from execution context:

executionContext.getVariable("previouslySetVariable");

This function must return a String containing the name of the transition to choose.

As the other nodes, you must configure the handler class with the node using Eclipse interface.

Decision node configuration

Related Posts

Feb 14

jBPM node

jBPM simple nodes are the most common nodes in all processes. They are used to encapsulate an action of your workflow.

The easiest way to program these kind of nodes is to develop an ActionHandler . You must do something like this:

public class Example implements ActionHandler{
.......
}

Developing ActionHandler interfaces involves to implement an execute method:

public void execute(ExecutionContext executionContext) throws Exception;

Inside this function you can add all code you need to perform the desired action. Remember that you have to send a signal to navigate to the next node at the end of execution.

executionContext.getProcessInstance().signal();

Finally, using Eclipse interface you have to link you node with you handler.

Action

At Action menu you must check Configure Action (your node must be selected). Inside Details tab you will be able to select and configure your class.

jBPM node Details

As easy as you read.

Related Posts

Feb 11

Moodle provides to developers an extensible user authentication library. You only need to extend auth_plugin_base class and place your code in a new directory inside /auth/. You can find this class inside /lib/authlib.php

This interface defines all functions you will need to develop a new authentication plug-in.

function user_login($username, $password);

This is the primary function used to login users into Moodle. You can do what you need in this function to finally return a boolean indicating the matching or mismatching of the given username and password.

funtion change_password_url();

This function must return the url where users can change the password. can_change_password() function must return true to call this one.

funtion is_internal();

Returns true if Moodle database stores user profile. For instance, LDAP plugin returns false.

function user_exists();

This function is used to check if user exists in external database.

function get_userinfo($username);

Returns an array containing all user information available.

function config_form($config, $err, $user_fields);

This function prints a form for configuring your authentication plug-in. validate_form() and process_config() functions will validate and store into database the introduced parameters.

There are other interesting functions but I have no time to explain all of them.

This interface also defines some hooks to specific Moodle pages.

Function loginpage_hook() allows to make some extra work before Moodle’s login page being printed. You can use it, for instance, to skip login form. You can check for another session in another platform to avoid users login twice.

I hope these lines will help you.

Related Posts

Feb 10

This is a usual question of all beginners.

ownerid, userid and groupid are set to wiki_pages table to differentiate them when any combination of groupmode or studentmode is set.

userid is a foreign key to Moodle users table. It contains the user id who edited that wiki page version.

If the current wiki is a separated groups or a visible groups activity. groupid is set to distinguish a page called “Moodle”between the several course groups.

ownerid is used to set a property relationship between the user and a wiki page. This is needed when any student mode is set and we allow users to edit pages belonging to other people.

Related Posts

Feb 10

This is a mini how-to oriented to new NWiki developers who usually use incorrect SQL queries to access to wiki pages.

wiki_pages table has one primary key: id. If you have it, you can invoke dmllib.php functions such get_record

	$page = get_record('wiki_pages', 'id', $pageid);

Several problems appear when you don’t have this id. Then you must use wiki API. There are great magic functions that recover wiki pages data from database.

If you are developing new features you must take into account that wiki_pages table has an enormous unique key:

  • pagename
  • version
  • dfwiki
  • groupid
  • userid
  • ownerid

In a normal situation you will have a pagename and a wiki id or a coursemodule id. Then, you must get coursemodule description using Moodle API.

  • get_coursemodule_from_id( $modulename, $cmid, $courseid);
  • get_coursemodule_from_instance($modulename, $instance, $courseid=0) ;

Using these functions you will be able to look up for the groupmode of this activity instance. At this point you will know the groupmode and stundentmode combination that is set up.

Calling get_record/s with the correct fields will return the desired wiki/s.

Related Posts

Feb 06

moodle

Moodle HQ ask us two years ago to modify our DFWiki to replace default Moodle wiki. We were really excited about this opportunity. We knew that we would have to work hard, but we accepted the propousal.

We debugged our code, ewiki migration scripts were written and backups were tested one million times. But Moodle1.6 didn’t included NWiki.

Then Moodle.com send us a large TO-DO list for Moodle 1.7. There were several security issues to fix and some requirements to implements. We didn’t finish at time, all these tasks plus roles and XMLDB integration were too much.

You will get into core in Moodle 1.8. They forgot about us…

Moodle community was eager for our wiki, so somebody opened a issue in Moodle tracker to be put to the vote. NWiki got a plenty of votes. It’s the second most popular item of the site, but we still waiting…

During the last two weeks, it seemed to be some activity around this topic. Moodle.com was revising and testing our wiki. A Moodle new site was created to put NWiki to the test, but they also installed another wiki, OU Wiki. OU from Open University and Wiki to cheat community.

OU

I installed this module one year ago and it was crashing all time. Reading Martin’s words, I thought that it have been improved and finished so I’ve been testing it few hours. What kind of wiki is it? An WYSIWYG editor with version control is not a wiki… What kind of joke is this.

Yesterday, Martin Dougiamas post this at Using Moodle forum. He said he can decide between NWiki and OU “Wiki”… I say you can decide between to please your community or to please your company. NWiki has thousands of users but, it’s box populi that Moodle.com and Open University work together to improve this CMS. It’s normal that they (OU) want to program the application core, they spent £5 million in their online learning environment!!!!

Wikis testing course include also a pair of choices. One for user-friendly experience and the other for developer-friendly code. What’s happening with the other voting, it does not count. Of course not! It was not an official voting…

I thing that comparing NWiki and OU “Wiki” is too difficult. Ours has a lot of features so it’s less easy to use. Ours has a lot of features so it has more code to read. OU’s has very/too simple so has less code (8 times less code) and is extremely easy to work with.

“It has a lot of fancy features……the code still reflects the fact that it was built by a team of students…” said Martin talking about our wiki. What’s up with you, mr. MD? Fancy features? Do you know what’s I+D+I? It’s a great work, users have technical or teaching problems and we find solutions. We are very pleased to create useful features, Moodle community said that, not me. There always is somebody that love and use these fancy features in their learning environments. Which are Moodle learning improvements of las two years? Do you really want to put social constructionist pedagogy into practice. You need a forum and a wiki. You have the first one, but you what’s up with ewiki? Everybody hates it and you are doing nothing to solve this problem.

You don’t like our code? I’m totally agree with you, it could be much better, but it works. It has some little bugs and PHP warnings but we always fix them as fast as we can. Is OU “Wiki” free of bugs? I crashed it in a minute. Can you crash ours or ewiki as fast as me?

This is a post to claim the right of our software and to work all my pent up anger down. We have nothing to worry about, Moodle huge community supports us. We will win. Otherwise, DFWiki will strike back….

Remember that you can vote for NWiki here, you only need to create an account. Thanks a lot for you time and support.

Related Posts