How to build a Workflow Application

Imixs Workflow provides a workflow engine to implement human workflows. Human worflows are used in business applications when a business process is performed by different users. A ticket-system is a typical example for a workflow management system. Customers create a new ticket and the workflow system forwards the the ticket to a technical team to solve the ticket. After a member of the technical team has accepted and solved the ticket the workflow management system forwards the ticket to a quality manager to verify the solution. Finally the solution will be automatically forwarded to the customer. This is a simple example of human workflow inside a business application.

Imixs Workflow provides all the functionality to manage this kind of a business process. You can design the process with an eclipse based modeler to configure things like email notifications, security, dispatching and the process documentation.

The flowing tutorial shows how to run the Imixs Workflow engine in a Java EE 6 business application.

RUNNING IMIXS WORKFLOW IN A WEB MODULE

As the latest version 3.0.0 of Imixs Workflow supports the lightweight EJB model you can run the Imixs Workflow either in a application server like Glassfish or in a Java EE 6 web-container.
The Imixs Workflow engine is independent from a web framework but we recommend to use Java Sever Faces as JSF becomes the standard framework for Java EE web applications.
When you have started developing a new web application you can add the libraries of the Imixs Workflow engine directly into the /lib folder of your web module

  /
  +- lib/
  |  |- imixs-workflow-core.jar
  |  |- imixs-workflow-engine.jar
  |  |- imixs-workflow-faces.jar
  |  |- imixs-workflow-jax-rs.jar

If you are using Maven (which is recommended) you can simply add the following dependency into your pom.xml.

<!-- Imixs Workflow -->
		<dependency>
			<groupId>org.imixs.workflow</groupId>
			<artifactId>imixs-workflow-engine</artifactId>
			<type>jar</type>
			<version>3.0.0-SNAPSHOT</version>
		</dependency>
		
		<dependency>
			<groupId>org.imixs.workflow</groupId>
			<artifactId>imixs-workflow-jax-rs</artifactId>
			<type>jar</type>
			<version>3.0.0-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>org.imixs.workflow</groupId>
			<artifactId>imixs-workflow-faces</artifactId>
			<type>jar</type>
			<version>3.0.0-SNAPSHOT</version>
		</dependency>

Next you need to add a persistence.xml file into your web module. The persistence.xml file defines how the workitems managed by the Imixs Workflow Engine will be persisted into a database.

Add a additional file named persistence.xml into your web module :

        /
        +- WEB-INF/classes/META-INF/
        |  |- persistence.xml

The persistence.xml describes the location of you database. The following example shows a typical configuration using the Eclipselink driver provided by most JEE Application servers.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
        <persistence-unit name="org.imixs.workflow.jee.jpa" transaction-type="JTA">     
                <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>    
                <jta-data-source>jdbc/workflow-db</jta-data-source>
                <jar-file>lib/imixs-workflow-engine-3.0.0-SNAPSHOT.jar</jar-file>
                <properties>
                        <property name="eclipselink.ddl-generation"
                                value="create-tables" />
                        <property name="eclipselink.logging.level" value="INFO"/>
                </properties>                           
        </persistence-unit>
</persistence>

The jta-data-source with the name “jdbc/workflow-db” describes the jdbc connection used to store the imixs workflow data. You can configure the database resource directly in your application server. For more details about how to setup a database connection read ‘Installation and setup the Glassfish Application Server‘.

ADDING SECURITY CONFIGURATION AND WEB SERVICE

Now as the Imixs Workflow engine is part of your web module you need to configure security roles expected by the Imixs Workflow.

To map the Imixs Workflow roles into your web application use the security-role-ref in the web.xml.

	<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>imixsrealm</realm-name>
	</login-config>

	<security-constraint>
		<web-resource-collection>
			<web-resource-name>restricted</web-resource-name>
			<url-pattern>/pages/*</url-pattern>
			<url-pattern>/rest/*</url-pattern>
			<http-method>GET</http-method>
			<http-method>POST</http-method>
		</web-resource-collection>
		<auth-constraint>
			<role-name>org.imixs.ACCESSLEVEL.READERACCESS
			</role-name>
			<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
			</role-name>
			<role-name>org.imixs.ACCESSLEVEL.EDITORACCESS
			</role-name>
			<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS
			</role-name>
		</auth-constraint>
	</security-constraint>
	<security-constraint>
		<web-resource-collection>
			<web-resource-name>restricted</web-resource-name>
			<url-pattern>/RestService/*</url-pattern>
			<http-method>GET</http-method>
			<http-method>POST</http-method>
			<http-method>PUT</http-method>
		</web-resource-collection>
		<auth-constraint>
			<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS
			</role-name>
		</auth-constraint>
	</security-constraint>
	
	<security-role>
		<role-name>org.imixs.ACCESSLEVEL.NOACCESS
		</role-name>
	</security-role>
	<security-role>
		<role-name>org.imixs.ACCESSLEVEL.READERACCESS
		</role-name>
	</security-role>
	<security-role>
		<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS
		</role-name>
	</security-role>
	<security-role>
		<role-name>org.imixs.ACCESSLEVEL.EDITORACCESS
		</role-name>
	</security-role>
	<security-role>
		<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS
		</role-name>
	</security-role>

 

To map the roles to your user management and security groups for glassfish servers add the sun-web.xml file into your /WEB-INF folder:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">

	<context-root>/workflow</context-root>

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.NOACCESS</role-name>
		<group-name>Noaccess</group-name>
		<group-name>IMIXS-WORKFLOW-Noaccess</group-name>
	</security-role-mapping>

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.READERACCESS</role-name>
		<group-name>Reader</group-name>
		<group-name>IMIXS-WORKFLOW-Reader</group-name>
	</security-role-mapping>

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.AUTHORACCESS</role-name>
		<group-name>Author</group-name>
		<group-name>IMIXS-WORKFLOW-Author</group-name>
	</security-role-mapping>

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.EDITORACCESS</role-name>
		<group-name>Editor</group-name>
		<group-name>IMIXS-WORKFLOW-Editor</group-name>
	</security-role-mapping>

	<security-role-mapping>
		<role-name>org.imixs.ACCESSLEVEL.MANAGERACCESS</role-name>
		<group-name>Manager</group-name>
		<group-name>IMIXS-WORKFLOW-Manager</group-name>
	</security-role-mapping>
</sun-web-app>

Finally you can add the Imxis RESTfull Service interface to provide a business modeler directly from your eclipse ide using the Imixs Workflow modeler plugin. With the Imixs RESTfull Service you can access the Imixs Workflow engine from external clients.
To add the Rest Service add the following servlet description into your web.xml file:

	<!-- Imixs Rest Service -->
	<servlet>
		<servlet-name>Jersey Web Application</servlet-name>
		<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
		<init-param>
			<param-name>com.sun.jersey.config.property.packages</param-name>
			<param-value>org.imixs.workflow.jaxrs</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
		
	<servlet-mapping>
		<servlet-name>Jersey Web Application</servlet-name>
		<url-pattern>/rest/*</url-pattern>
	</servlet-mapping>

Thats it.
To build a workflow model and synchronize it with your workflow application see the Installation and setup guide of the Imixs Workflow Modeler.

IMIXS WORKFLOW AND JSF

Now the Imixs Workflow engine is part of your web application. To access the Imixs Workflow engine the imxis-faces module provides a BackingBean. You can add this BackingBean simply by extending the faces-config.xml file located in the /WEB-INF folder of you web project.

<managed-bean>
        <managed-bean-name>workflowMB</managed-bean-name>
        <managed-bean-class>org.imixs.workflow.jee.jsf.util.SimpleWorkflowController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

To create a new workitem you call the method doCreateWorkitem. This method expects an existing process-id form your previous diefined workflow model. This is an example where you create a new instance of a business process with the processID=100

<h:commandButton
        value="create new...."
        actionListener="#{workflowMB.doCreateWorkitem}"
        action="show_workitem">
        <f:param name="id"
                value="100" />
</h:commandButton>

The workflowMB allows you to bind an input value to an arbitrary property name. See the following example were an inputText value is bound to the item property ‘txtSubject’.

 <h:inputText required="true"
        value="#{workflowMB.workitem.item['txtSubject']}" id="subject_id">
 </h:inputText>

The workflow controller will automatically manage the property “txtSubject” and store the input values into the database.
Finally you can process a workitem through the Imixs Workflow by simply calling the method doProcess :

 <h:commandButton action="show_workitem"
        actionListener="#{workflowMB.doProcessWorkitem}"
        value="submit">
        <f:param name="id" value="10" />
 </h:commandButton>

You can download the full sample application from the Imixs Download center. This sample application can be used as a template to start you own business workflow project.
You will find more examples and a full installation guide at: http://www.imixs.org/jee/install.html

LUCENE SEARCH WITH IMIXS WORKFLOW

The latest snapshot release of Imixs JEE Workflow now supports Apache Lucene Search Engine. With this new fulltext search the Imixs Workflow reached a new level of a flexible and powerful workflow platform.

The Lucene search integration is provided by a new plugin which contains all the necessary functionality to access and manage a search index. Workitems are automatically added into the search index during a workflow step. A fulltext search is performed considering the fine-grained access rights for workitems managed by the Imixs Workflow Engine. This means that a search result contains only workitems which are accessible by the current user. The access level to a single workitem is fully controlled by the Imixs Workflow Manager and can be managed using the Imixs Workflow Modeler. This makes it easy to setup complex and secure business process applications and support also the flexibility of a fulltext search engine.

RELEASE 3.0 STARTED

We are now starting the next release of the Imixs Workflow 3.0

See: http://java.net/jira/browse/IMIXS_WORKFLOW-90

The general idea behind the new 3.0 release was to make use of the new EJB 3.1 container features. Because the current Imxis EntityServiceBean is in some methodes a little bit deprecated. One reason was the early implementation in the beginning of JEE5. The JPA methods are optimized for Toplink Driver which is no longer supported. So its time to make an Update!

General requirements for the new Workfow Engine

  • Replace the Entity Bean based on ItemCollection with a Map Interface
  • Use of EJB 3.1 features (JPA Map Feature)
  • Simplify the packaging (Light EJB API)
  • Optimize Scheduler Feature (persist settings in a entity)
  • No changes to the Workflow Service API – to make migration easy

Migration

A Migration is necessary as one of the main goals is to pesist no longer the ItemCollection Object but a simple portable Map Interface.
So we need a way to migrate application from Version 2.x to 3.0. As we learned in migrations from 1.x to 2.x this is not an easy work.
The goal of the new migration strategy must be a background migration.
So a tool should migrate workitems from a old datastorage into a new one running independed of a productive workflow app. This can be done by monitoring the $modified timestamp. As we know most of the data will not be changed during migration this can be done easily .

IMIXS WORKFLOW – REPORT GENERATOR FOR PDF

With the latest version of Imixs Workflow now business reports can be created in a lot of different output formats like PDF, MS Excel, MS Word or any other XSL Transformation. Read more about the Imixs Workflow REST Interface and how it works.

http://www.imixs.org/xml/restservice.html

Imixs Workflow did not only empower you in building bpm solutions based on the JEE plattform. It also gives you a flexible architecture to fulfill business requirements like compliance features, creation of business reports and securing confidential business data in a fast and easy way.

WHY ARE CHANGING THE REQUIREMENTS IN A SOFTWARE PROJECT SO OFTEN?

For several years I have developed even business applications for small, medium and large organizations. Actually, I should have learned a lot about what customers need. But like most software developers I am always surprised about endless changes during the project. You start a new software project but when you are approaching the end your customers have new ideas. Why is that? Continue reading “WHY ARE CHANGING THE REQUIREMENTS IN A SOFTWARE PROJECT SO OFTEN?”

JPA – WORKING WITH GENERIC VALUE OBJECTS

Working with generic value objects and jpa is shown by the implementation of the ImixsEntityService EJB. This service ejb is provided by the Imixs Workflow Project. It can be used to store objects independent from a specific Entity Bean. Also queries with JPQL are possible.
See: http://www.imixs.org/jee/examples/entityservice.html

IMIXS ADMIN CLIENT 2.1.1

The latest version of the Imixs Admin Client is finally released. TheImixs Admin Client is a Web Application which allows you to administrate a Imixs JEE Workflow Instance. The Admin Client can be deployed on any JEE Server independent from a workflow Application. So the Imixs Admin Client can be used to adminstrate different instances of the Imixs JEE Workflow Implemenation on the same JEE Application Server.

Downloadpage

HIDING ACTIVIES FROM USER

Today I stumbled into an issue with hidden workflow activities. Normally you can simple hide an activity to unauthorized users by adding an application specific access role to the property section ‘Visiblity and Access’. For example you can add the role ‘org.imixs.ACCESSLEVEL.MANAGERACCESS’ to allow only Managers to use this workflow activity.

But this seems not to work. The reason is that the Imixs Modeler stores the read-access restriction into the property ‘namReaders’. And this is no read-access property per default. Only the property ‘$readAccess’ will be recognized by the workflow system to protect workitems.

But the solution is quite simple. You only need to add the field name to the Imixs EntityService Bean declaration from the ejb-jar.xml descriptor:

            <ejb-name>EntityServiceBean</ejb-name>
            <ejb-class>org.imixs.workflow.jee.ejb.EntityServiceBean</ejb-class>
            <session-type>Stateless</session-type>
            <env-entry>
                <description>Additional Reader Field for Workflow Model</description>
                <env-entry-name>READ_ACCESS_FIELDS</env-entry-name>
                <env-entry-type>java.lang.String</env-entry-type>
                <env-entry-value>namreaders</env-entry-value>
            </env-entry>            
        </session>

No the property ‘namReaders’ is treated by the Imixs Workflow System as a reader field.

I think we will change the Imixs Modeler in the next release to support also the default field ‘$readAccess’. So no further configuration will be necesary here.

MYSQL AND BLOB FIELD SIZE

Using the Imixs Workflow together with mysql can lead into a problem with large data stored in a single workitem. The Database schema use by the Imixs Workflow will be generated automatically by the OR-Mapper (e.g. Toplink, Eclipslink). This is all done well. But the Data table ‘EntityData’ used by the Imixs Workflow engine contains the column ‘itemcollection’. This column will store all undstuctured data. And in some cases this data can become very large. For example when storing a attachment into a workitem the field can be serveral MB in size. The default field type in mysql is ‘BLOB’. And this fieldtype is restricted to a maximum size of 64KB. So the Imixs workflow engine can not store large workitems. This will result into a SQL Execption.

To avoid this problem the Datatype can be changed from ‘BLOB’ to ‘MEDIUMBLOB’ (=16MB) or ‘LONGBLOB’ (=4GB). This can be done with the MySQL Admin Client or from the MySQL command line.

ALTER TABLE <Tabellenname> CHANGE <columnname> <columnname> LONGBLOB;

To change the datatype for a example database ‘imixsdb’ use the following command:

ALTER TABLE ENTITYDATA CHANGE ITEMCOLLECTION ITEMCOLLECTION LONGBLOB;