Saturday May 30, 2009

Database Migration Derby -> MySQL

If you have started you workflow project using the build-in Derby Database from Glassfish you maybe can run into a performance problem if you manage a lot and complex of Data. This is because Derby is not so scalable in managing complex SQL statements like other Database Management Systems. In such a case you can easily migrate your workflow system form Derby to MySQL which is much more scalable.

Follow these steps to migrate data in a running system

  1. Start your Derby DB and Glassfish Server
  2. Make sure that your Workflow System is up and running
  3. Switch to the IX JEE Admin Client.
  4. Connect to the EntityPersistenceManager from your Workflow Instance
  5. Start a export using the default EQL Statement. This will export all existing Data of your workflow system into a file
    >SELECT wii FROM Entity wii



    If the export did not succeed a reason can be the HeapSize of your Glassfish Server instance. You can increase the default HeapSize from 512m to 1024m using the Glassfish Admin Console.
    Go to : Applicationserver->JVM Settings -> JVM Options
    and change -Xmx512m into -Xmx1024m

  6. Undeploy your Workflow Instance
  7. Shutdown your Derby Database
  8. Setup a new MySQL Database and create a new JDBC Connection Pool using the Glassfish Console
  9. Now you can switch the JDBC/Ressource of your Workflow System from your Derby Database to your new MySQL Database
  10. Deploy your Workflow Instance again - this will generate the necessary Tables in your new MySQL Database
  11. Optionall : after deplyoment you can setup Entity Index Fields manually if necessary  
  12. Import your Data form the Export File you generated in Step 5.

Thats it!

If the import process fails on MySQL check the following:

PacketTooBigException

If you got the Excepiton:

com.mysql.jdbc.PacketTooBigException: Packet for query is too large

you should change the max_allowed_packet setting in your MySQL server for the import process

  1.  Open your MySQL console
    >mysql -u root -p
  2. Change the max_allowed_packet setting
    >SET GLOBAL max_allowed_packet=3000000000;
  3. Restart your Glassfish Server (not the MySQL Database!)
  4. Reimport your data
  5. Restart you MySQL Server and Glassfish Server to reset the max_allowed_packet settings.

PersistenceException

If you got the Exeption:

javax.persistence.PersistenceException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'DATA' at row 1

MySQL tells you that the BLOB field is to small to store the data. This is because MySQL generates per default a SmallBlob (64K) for your Data Fields in the Entity Table. You can change the Blob type after the deplyoment of your Workflow Instance :

  1. Open your MySQL console
    >mysql -u root -p
  2. Connect to to your Database
    >USE mydatabase;
  3. Change the BLOB Type to LONGBLOB (4GB) or MEDIUMBLOB (16MB)
    >ALTER TABLE Entity CHANGE DATA DATA MEDIUMBLOB NOT NULL;

Sunday Apr 05, 2009

New Version of IX Modelers

The new version of the IX Modeler for Eclipse is now available!

The new relase 2.2.9 of the Basic module and  2.2.6 of the Integration module includes a lot of enhancements of the user interface. The management of Process and Activity properties is now extended by a new property editor concept. All properties are now managed using the "Tabbed Properties View Extension Points". This allows you to extend the IX Workflow Modeler in your Software projectes much faster as you can now use the eclipse standard extention point for tabbed properties.

The new version was tested with Eclipse 3.4.2 for Windows and Linux.

 


Wednesday Jan 21, 2009

Licensing of Imixs IX OpenSource Workflow

As we were often ask about the licensing of of the Imixs IX OpenSource Workflow which is subject to the General Public License (GPL) I want to give you today a short idea how your individual Software project is affected form this license.

Assuming that you plan to develop an individual software system using the Imixs Workflow System you have to take care about the subject of GPL. But since your software project is no workflow management system like the Imixs IX Workflow itself, there is no reason to worry about the GPL.
In contrast if you enhance or modify components of the IX Workflow Implementation or you implement a derived unit you are constrained to leave this code also under GPL.
Our goal is to avoid that someone restrict the purpose of the IX Workflow Software. Everyone is free to use the Imixs IX Workflow as free software in the manner of the Free Software Foundain (http://www.fsf.org/).

So we appreciate everybody who plan to use the IX Workflow in an individual Software Project. You be bound to inform your users and customer that the Imixs IX Workflow is fee software under GPL. This means that he will receive also the source code (of the Imixs IX Workflow) or can get it if he want it. He can change the software or use pieces of it in new free programs.
If you enhance the Imixs IX Workflow you are bound to leave this code again under GPL and share your experience with the community.

So we did not restrict you in your freedom to develop software using the IX Workflow. We also did not restrict your freedom to distribute your software or charge for service if you wish.
Free Software is about to exchange experience and knowledge, not to restrict other people in there freedom to use it.

Sunday Sep 14, 2008

New Imixs Kenai Project Page

Today we opened a new Project HomePage on Kenai

http://kenai.com/projects/ix-workflow

Kenai is a social network for connected developers. You can find and collaborate with developers of like mind and passion from around the globe.

Currently its beta but I think this is a cool thing!

http://kenai.com/

Monday Sep 01, 2008

New Version 1.6 of Imixs IX JEE Workflow

Currently we are working on the new 1.6 release of Imixs IX Workflow API and IX JEE Workflow Server. The new release will include a ReportService. This feature support a power full report function which allows you to generate dynamic reports based on running Business Processes. The Report Feature will be included into the IX REST Services so reports can be used very easy. 

Also we extend the IX Workflow Modeler with a new Report Editor that allows a Workflow Modeler to create and manage reports as *.ixr files directly in a Eclipse project.

The new functionality will expand the Imixs IX Workflow Tool with a really strong feature set! Source code of new Version 1.6 will be available on subversion repository in a pre-beta version:

https://ix-workflow.dev.java.net/source/browse/ix-workflow/

Saturday Jul 26, 2008

Building a Workflow Application - Part III

In part III of my tutorial I will explain how to build a EAR module with maven and develop a Web Frontend to test my workflow application.

If you followed the part I and part II of this tutorial you have setup an environment, created the workflow model and implemented a business loging in a EJB 3.0 session bean.

To deploy a hole JEE Web application we need now a Web Modul with the frontend and also EAR module bundeling all the components to an Enterprise Application Archive which is deployable on Glassfish.

 

Creating a WEB Module

First I create a new maven WEB module. This module will implement the web frontend and makes use of the business logic defined in the exsisting EJB Module.

As described before I add a new Module to my parent project. Choose "WAR" as the packaging Method:

 

pickture

To  get access to my business logic I modify the pom.xml and add the Workflow API and the predefined EJB module as a dependency to my pom.xml. The pom.xml file should look like the following example. In this example I added also support for MyFaces and Facelets which allows me to implement nice Web Forntend. But thise dependencies are not really necessary for a simple test:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>org.imixs.callcenter</artifactId>
<groupId>org.imixs</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.web</artifactId>
<packaging>war</packaging>
<name>org.imixs.callcenter.web</name>
<version>0.0.1-SNAPSHOT</version>
<description/>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

</plugins>
</build>

<dependencies>

<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.tomahawk</groupId>
<artifactId>tomahawk</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.api</artifactId>
<version>1.5.3</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.manik.orgunit</artifactId>
<version>0.0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.manik.model</artifactId>
<version>0.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.imixs.examples</groupId>
<artifactId>
org.imixs.callcenter.ejb
</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>


</dependencies>
</project>

Create a Backing Bean

As I use JSF to implement my WebFrontend I need now a Backing Bean which provides the necessary properties and methods for my ticket application. So first I create a new package in my maven web module under /src/man/java  and create a TicketBan class.

This class should provide a simple access to the attributes for a Ticket to be used in JSP page. There for a added a getTicket method which returns a Map object with all the attributes. If no Ticket was created before the method creates a new Ticket using the TicketService of my EJB Module.

 package org.imxis.callcenter.web.workflow;

import java.util.Map;
import javax.ejb.EJB;
import javax.faces.event.ActionEvent;
import org.imixs.workflow.ItemCollection;

public class TicketBean {

/* Ticket Services */
@EJB
org.imixs.callcenter.business.TicketService ticketService;

/* Workflow Model Service */
@EJB
org.imixs.workflow.manik.model.ModelService modelService;

private ItemCollection workitemItemCollection;

public Map getTicket() throws Exception {
if (workitemItemCollection == null)
workitemItemCollection = ticketService.createTicket();

return workitemItemCollection.getAllItems();
}

public void doStartNewProcess(ActionEvent event) throws Exception {
workitemItemCollection = ticketService.createTicket();
workitemItemCollection.replaceItemValue("$processid", new Integer(10));

}

}

So also my Backing Bean is realy simple. No I can create a JSF Page to display a Form with the Ticket. To open the form I use the doStartNewTicket method as a actionListener. This method creates an empty ticket and started with the first ProcessID of my workflow modell ID=10.

Creating a Form

So the next stepp is to create a Form to display and edit a ticket.

As I use JSF I can access each property of a Ticket during my backing bean created before. So a simple Input Field Tag looks like this:

 <h:inputText value="#{ticketBean.ticket['subject'][0]}"
id="subject_id" required="true"></h:inputText>

 As you can see I use the expression language to access the entries of my hashMap. Each entry in a ItemCollection is stored in a Vector so I use [0] expression to access the first entry in the vector.

Also you can display each property from a ticket. The following snippet shows how to display the current workflow status managed by the Workflow Manager:

<h:outputLabel 
value="#{ticketBean.ticket['txtworkflowgroup'][0]}: #{workitemBean.workitem['txtworkflowstatus'][0]}" />

Computing the Command Actions from the Model

Now I came up to the most intresting part of the Workflow System. I want a command button bar computet out of the workflow model. For each Activity I defined in my Workflow Model I what to see a command action in my Form. So the user can decide which workflow activity should be processed. In me example the user can choose to "save" a ticket or to "accept" a ticket.

Therefor I need two new methods in my Backing Bean. One method to compute the available activities and one to process the workitem.

The following code shows how I compute a ArrayList which returns the model objects for the corresponding Process Entity. The process entity can be taken form the Ticket attriubte "$processid" which is initialized during doStartNewProcess method and managed by the WokflowManager.

 	public ArrayList<Map> getActivityList() {

int processId = workitemItemCollection
.getItemValueInteger("$processid");

activityList = new ArrayList<Map>();
// Workflow-Activities
List<ItemCollection> col = modelService.findPublicActivities(processId);
for (ItemCollection aworkitem : col) {
activityList.add(aworkitem.getAllItems());
}

return activityList;
}

So I can now implement a JSF code to display commandButtons for each Activity:

 <c:forEach var="activity" items="#{ticketBean.activityList}">
<h:commandButton action="show_worklist"
actionListener="#{ticketBean.doProcess}"
value="#{activity['txtname'][0]}">
<f:param name="id" value="#{activity['numactivityid'][0]}" />
</h:commandButton>
</c:forEach>

As you can see I have full access to the Activity Entities. So I can ask for the Name of an Activity and the activityID. If a ticket goes throgth the process in each Process step the right activity buttons will be displayed. And also I am able to change the model without changing the code of my application!

Each commandButton call the method doProcess of my Ticket Bean. This Method is for process a Workflow step. We implemented some code in our EJB so the backing bean code is again realy simple:

	public void doProcess(ActionEvent event) throws Exception {
// search Activity ID from command tree
List children = event.getComponent().getChildren();
int activityID = -1;

for (int i = 0; i < children.size(); i++) {
if (children.get(i) instanceof UIParameter) {
UIParameter currentParam = (UIParameter) children.get(i);
if (currentParam.getName().equals("id")
&& currentParam.getValue() != null) {
Object oid = currentParam.getValue();
Integer intobject = new Integer(oid.toString());
activityID = intobject;

}
}
}

// add team members programatical
Vector<String> vTeam=new Vector<String>();
vTeam.add("Manfred");
vTeam.add("Eddy");
vTeam.add("Anna");
workitemItemCollection.replaceItemValue("team",vTeam);

workitemItemCollection = ticketService.processTicket(
workitemItemCollection, activityID);


}

The code first identifies the activityid provided as a param in my commandButton. Next the method adds a member list of a team to the workitem programatical. This is typical code. So you can use this team attribute in the workflow model. For example you can grant write access to the team or you can send an email to the team to notify them about a new ticket. See the IX Modeler documentation for mor informations about modeling actors.

Finally the method call the processTicket method of the TicketService EJB created in the business facade. The new attribute values are updated into the ItemCollection used by the TicketBean. So you can display the Workflow status or the workflow History with simple JSP Tags like this:

Workflow History:<h:dataTable
value="#{ticketBean.ticket['txtworkflowhistorylog']}"
var="log">
<h:column>
<h:outputText value="#{log}" />
</h:column>
</h:dataTable>

Check out the hole example from the subversion repository to see the complete JSF pages.

Creating a EAR Module

Now finally I create a new EAR module using maven. The EAR module is the deployable unit for the glassfish server. As described before I add a new Module to my parent project. 


The maven packaging method now is "EAR".

After the module is created I change the pom.xml file to advice maven to include my ejb and web module. The pom.xml defines dependencies to the IX JEE Workflow API and defines a valid Enterpirse Archive directory structure:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>org.imixs.callcenter</artifactId>
<groupId>org.imixs</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.ear</artifactId>
<packaging>ear</packaging>
<name>org.imixs.callcenter.ear</name>
<version>0.0.1-SNAPSHOT</version>
<description />
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<webModule>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.web</artifactId>
<contextRoot> /callcenter </contextRoot>
</webModule>
<ejbModule>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.ejb</artifactId>
</ejbModule>
<JarModule>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.api</artifactId>
<bundleDir>lib</bundleDir>
</JarModule>
<JarModule>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.jee.api</artifactId>
<bundleDir>lib</bundleDir>
</JarModule>
<JarModule>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.manik.model</artifactId>
<bundleDir>lib</bundleDir>
</JarModule>
</modules>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<!--
the Property glassfish.install needs to be configured in the
settings.xml file the property should point to the autodeploy
folder from glassfish domain!
-->
<echo message="About to copy EAR to autodeploydirectory..." />
<echo> EAR:
${project.build.directory}/${project.build.finalName}.ear
autodeploy directory: ${glassfish.install} </echo>
<copy
file="${project.build.directory}/${project.build.finalName}.ear"
todir="${glassfish.install}" />
<echo message="Copied EAR to autodeploy directory." />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.jee.api</artifactId>
<version>1.5.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.api</artifactId>
<version>1.5.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.imixs.examples</groupId>
<artifactId>
org.imixs.callcenter.ejb
</artifactId>
<type>ejb</type>
<version>0.0.1-SNAPSHOT</version>
</dependency>

</dependencies>
</project>

The pom.xml also includes a helpfull ant script. This ant script automatical deploys the ear to the autodepoly folder of my glassfish server. You need to define an environment variable glassfish.install in your default profile of the settings.xml.

.....
<properties>
<!-- Property Glassfish Location for auto deplyment during install -->
<glassfish.install>/opt/glassfish/domains/domain1/autodeploy</glassfish.install>
</properties>

Ok finished! Now its time to build your parent project with the maven command "run-as -> maven install".

If everything works and the build process finished succesfull you can open the sample application with the followin url:

http://localhost:8080/callcenter

Synchronizing the Workflow Model

Before I can start creating and processing a new ticket I need to upload my Workflow model created in part I of this tutorial. Therefor open the model.ixm file with Eclipse and provide the new WebService URI of the new application:

http://localhost:8080/CallcenterWorkflowModelService?wsdl

 

On the first page of the editor you can now synchronize the model:

 

 

Now you can start creating new Tickets with the web application.

Notice that you have now workflow application where a lot of fuctionallity like security, process history or email notification is managed by the IX JEE Workflow engine without write a lot of code.

If you have questions or some feedback please comment to this blog. I will update the example and extend the sample application. So look out for updates.

Building a Workflow Application - Part II

In this part of my tutorial I will explain how to implement the Business Logic using the Imixs IX Open Source Workflow components. If you followed the first part you have setup an environment and created the workflow model using the IX Workflow Modeler. The model file is part of the maven parent project and located in the /src folder.

Now I add a maven ejb modul to implement a session EJB using the IX JEE Workflow Implementation. This Implementation makes it very easy to implement business logic because I need not to care about JPA or a lot of the  EJB stuff.

Create a EJB Maven module

As I explained in Part I maven is very useful to develop jee applications. Because Maven excuses me to worry about libaries versions and the structure of a JEE component.  When you have created a Maven Parent project you can now add a new maven module to create an EJB artifact.  We provide a full tutorial how to build a multi module project with maven on our project home page. But I will explain the necessary steps here.

So select you parent project and click the menu -> new -> other - > Maven module

 

Choose a Module name and select the option "Create a simple project. The parent Project is automatically selected.

 

In the next page select Packaging "jar" to advise maven to create an EJB module.

 

After you finish Maven creates the full ejb project structure inside your parent project and creates a pom.xml file with a default configuration. Next you need to modify the pom.xml file. So open the pom.xml file with the editor. As we don't like to spent a lot of time with developing our business logic we add the IX JEE Components as dependencies to the pom file. Also two Maven plugins are to be defined here so advice maven to build a EJB artifact. So I just have to add the following plugins and dependencies to my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>org.imixs.callcenter</artifactId>
<groupId>org.imixs</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.imixs.examples</groupId>
<artifactId>org.imixs.callcenter.ejb</artifactId>
<name>org.imixs.callcenter.ejb</name>
<version>0.0.1-SNAPSHOT</version>
<description/>


<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.jee.api</artifactId>
<version>1.5.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.api</artifactId>
<version>1.5.3</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>org.imixs.workflow.manik.model</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
</project>

These build and dependency tags define the module as EJB 3.0 artifact and include the IX JEE Workflow Components.

Define a Interface

In the next step I define a Business Interface. The business interface is the part I use later in my web frontend to communicate with my backend. Therefor I add a package in the /src/main/java folder of my EJB Modul and define a simple POJO Interface like this:

package org.imixs.callcenter.business;

import java.util.List;

import org.imixs.workflow.ItemCollection;

public interface TicketService {

public ItemCollection createTicket();

public ItemCollection processTicket(ItemCollection aIssue,int activityID) throws Exception;

public List<ItemCollection> findWorkList(String project, int row, int count) ;
}

The ItemCollection Class is a generic dataobject which is defined by the IX Workflow API. If this class could not be resolved by Eclipse just try to install the new modul so maven can download the necessary parts from the internet. Select your EJB Modul Project and select the command : Run as...->maven install

You should receive a success message in the console file:


If maven was unable to download the Imixs IX Workflow artifacts check your settings.xml file for the following repository location:

<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>

The settings.xml file is located in you home directory ("document and settings/USER/.m2" on windows, home/USER/.m2/ on linux)

In some cases it can happen that Eclipse bring up a lot of compile errors. This happens if Eclipse and maven is not configured correctly. If the "run as->maven install" command is successfully you can be sure your project will be deployable. To fix Eclipse error messages please see the Maven Homepage for help. The maven integration in Eclipse Ganymede is much better as in Eclipse Europe. Also Sun NetBeans IDE have a very good Maven integration. So don't give up hope and don't stopp here if you get a compile error in eclipse ;-)

Implement the Interface

Next I need to implement my business interface. This is not so much code as you may think. The Imixs IX JEE Workflow encapsulates a lot of the workflow stuff and you can access a lot of powerful methods of the IX Workflow Manager.

First I implement the createTicket method. This method returns a new Ticket represented by an ItemCollection with some predefined attributes. These attributes I will later use in my Web frontend to be displayed as input fields. So I have to predefine these attributes here.

 	public ItemCollection createTicket() throws Exception {
ItemCollection itemCol=new ItemCollection();
itemCol.replaceItemValue("type","workitem");
itemCol.replaceItemValue("subject","");
itemCol.replaceItemValue("team","");
Calendar cal = Calendar.getInstance();
itemCol.replaceItemValue("deadline", cal.getTime());

return itemCol;
}

The processTicket method is also very simple. This method uses the IX WorkflowManager to process a ticket. The workflow Manager took all the work of processing a workitem as defined in the workflow model. So this is the powerfull part of the application. You need to add a WorkflowManager Instance in your code using dependency injection:

 	@EJB
org.imixs.workflow.jee.ejb.WorkflowManager wm;
ItemCollection workItem = null;

........

public ItemCollection processTicket(ItemCollection issue, int activityID)
throws Exception {

int iProcessID = issue.getItemValueInteger("$processID");
String sUniversalID = issue.getItemValueString("$uniqueid");

workItem = null;
// check if a t has been created yet?
if (!"".equals(sUniversalID))
workItem = wm.getWorkItem(sUniversalID);
// create new TeamEntity?
if (workItem == null)
workItem = wm.createWorkItem(iProcessID);
updateWorkItem(issue);

// Process workitem...
ItemCollection result = wm.processWorkItem(workItem, activityID);
return result;
}

As you can see the method is very simple. I first check if a ticket (workitem) with the same $uniqueid was created before. If so I lookup the existing ticket  otherwise I create a new workitem. I overhand the workitem to the workflowmanger to process the workitem with a defined workflow activity (activityID). The workflow manager will return a new workitem instance with updated workflow informations.
The updateWorkItem method is a typical helper method to overhand the attributes from your webfrontend to the EJB as you can not use a object reference.

 	private void updateWorkItem(ItemCollection aworkitem) throws Exception {
Iterator iter = aworkitem.getAllItems().entrySet().iterator();
while (iter.hasNext()) {

Map.Entry mapEntry = (Map.Entry) iter.next();
String sName = mapEntry.getKey().toString();
Object o = mapEntry.getValue();
workItem.replaceItemValue(sName, o);
}
}

Finally I need to implement the findWorkList method. This method should return a list of tickets to be processed by the current user. Therefor I make use of the EntiyService EJB from the IX JEE Workflow to access tickes using the EQL standard. Also I make use of a SessionConext to get the current username for which I should return the worklist.

        @Resource
SessionContext ctx;
@EJB
org.imixs.workflow.jee.ejb.EntityService entityService;
........

public List<ItemCollection> findWorkList(int row, int count) {
ArrayList<ItemCollection> workList = new ArrayList<ItemCollection>();

String name = ctx.getCallerPrincipal().getName();
String sQuery = "SELECT wi from Entity as wi JOIN wi.authorItems as t1"
+ " JOIN wi.textItems as t2 "
+ " where t1.itemName = 'namworkflowwriteaccess' and t1.itemValue = '"
+ name + "'"
+ " and t2.itemName = 'type' and t2.itemValue = 'workitem'"
+ " order by wi.created desc";

Collection<ItemCollection> col = entityService.findAllEntities(sQuery,
row, count);

for (ItemCollection aworkitem : col) {
workList.add(aworkitem);
}
return workList;
}

So thats all! You see you need not to handle with JPA or EJB patterns. Using the IX JEE Workflow makes it easy to implement a workflow component.

Deployment Descriptors

Now I need to create the deployment descriptors so my EJB module can be deployed correctly in the glassfish server.

The Descriptors are located in the maven ejb module in /src/main/resources

The first descriptor is the ejb-jar.xml which is the standard deployment descriptor.

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">

<enterprise-beans>

<!-- #### Imixs IX JEE EJBs -->
<session>
<ejb-name>ModelServiceManagerImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.ModelServiceManagerImplementation
</ejb-class>
<session-type>Stateless</session-type>
</session>
<session>
<ejb-name>WorkflowServiceManagerImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.WorkflowServiceManagerImplementation
</ejb-class>
<session-type>Stateless</session-type>
</session>
<session>
<ejb-name>ModelManagerImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.ModelManagerImplementation
</ejb-class>
<session-type>Stateless</session-type>
</session>

<session>
<ejb-name>WorkflowManagerImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.WorkflowManagerImplementation
</ejb-class>
<session-type>Stateless</session-type>
</session>
<session>
<ejb-name>EntityPersistenceManagerImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.EntityPersistenceManagerImplementation
</ejb-class>
<session-type>Stateless</session-type>
<env-entry>
<description>
Activate programmatic DISTINCT Function
(default=true)
</description>
<env-entry-name>PROGRAMMATIC_DISTINCT</env-entry-name>
<env-entry-type>java.lang.Boolean</env-entry-type>
<env-entry-value>true</env-entry-value>
</env-entry>
</session>
<session>
<ejb-name>EntityServiceImplementation</ejb-name>
<ejb-class>
org.imixs.workflow.jee.ejb.EntityServiceImplementation
</ejb-class>
<session-type>Stateless</session-type>
</session>


<!-- #### Project specific EJBs -->

<session>
<ejb-name>ModelServiceBean</ejb-name>
<ejb-class>
org.imixs.workflow.manik.model.ModelServiceBean
</ejb-class>
<session-type>Stateless</session-type>
</session>


<session>
<ejb-name>TicketServiceBean</ejb-name>
<ejb-class>
org.imixs.callcenter.business.TicketServiceBean
</ejb-class>
<session-type>Stateless</session-type>
</session>

</enterprise-beans>
</ejb-jar>

If you ask yourself why you need descriptors in JEE5? This is because the annotations used by the IX JEE Workflow need to be overwritten to create unique components and need also to be defined as EJBs so the JEE Server can recognize these beans. So don't be afraid about these descriptors they are not so complex.

The second descriptor is the persitence.xml. This file is to tell the server where to store my Tickets. I need to define the datapool which I created in part I. during the setup of the server envoronment:

<persistence>
<persistence-unit name="org.imixs.workflow.jee.ejb">
<jta-data-source>jdbc/imixs_db</jta-data-source>
<properties>
<property name="toplink.ddl-generation"
value="create-tables" />
</properties>
<!-- Make sure that the library version maches the library included in ear/lib -->
<jar-file>lib/org.imixs.workflow.jee.api-1.5.7.jar</jar-file>
</persistence-unit>
</persistence>

The last descriptor is the sun-ejb-jar.xml file which defines unique JNDI Names for the ejbs and also defines the webservice endpoints:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>

<enterprise-beans>
<!-- ### Imixs IX JEE EJBs ##### -->
<ejb>
<ejb-name>ModelManagerImplementation</ejb-name>
<jndi-name>
ejb/CallcenterModelManagerImplementation
</jndi-name>
</ejb>
<ejb>
<ejb-name>WorkflowManagerImplementation</ejb-name>
<jndi-name>
ejb/CallcenterWorkflowManagerImplementation
</jndi-name>
</ejb>
<ejb>
<ejb-name>EntityPersistenceManagerImplementation</ejb-name>
<jndi-name>
ejb/CallcenterEntityPersistenceManagerImplementation
</jndi-name>
</ejb>
<ejb>
<ejb-name>EntityServiceImplementation</ejb-name>
<jndi-name>
ejb/CallcenterEntityServiceImplementation
</jndi-name>
</ejb>
<!-- #### Imixs IX JEE Web Services ##### -->
<ejb>
<ejb-name>ModelServiceManagerImplementation</ejb-name>
<jndi-name>
ejb/CallcenterModelServiceManagerImplementation
</jndi-name>
<webservice-endpoint>
<!-- ModelServiceManagerImplementation WorkflowModelServicePort-->
<port-component-name>
WorkflowModelService
</port-component-name>
<endpoint-address-uri>
CallcenterWorkflowModelService
</endpoint-address-uri>
<login-config>
<auth-method>BASIC</auth-method>
<realm>wolf-wurst</realm>
</login-config>
</webservice-endpoint>
</ejb>
<ejb>
<ejb-name>WorkflowServiceManagerImplementation</ejb-name>
<jndi-name>
ejb/CallcenterWorkflowServiceManagerImplementation
</jndi-name>
<webservice-endpoint>
<!-- ModelServiceManagerImplementation WorkflowModelServicePort-->
<port-component-name>
WorkflowManagerService
</port-component-name>
<endpoint-address-uri>
CallcenterWorkflowManagerService
</endpoint-address-uri>
<login-config>
<auth-method>BASIC</auth-method>
<realm>imixsrealm</realm>
</login-config>
</webservice-endpoint>
</ejb>
<!-- #### Project specific EJBs ###-->
<ejb>
<ejb-name>ModelServiceBean</ejb-name>
<jndi-name>
ejb/CallcenterModelServiceBean
</jndi-name>
</ejb>
<ejb>
<ejb-name>CallcenterTicketServiceBean</ejb-name>
<jndi-name>
ejb/CallcenterTicketServiceBean
</jndi-name>
</ejb>
</enterprise-beans>
</sun-ejb-jar>

Finally you need to create a /wsdl folder in your META-INF directory and add the wsdl files for the webservices there. You can download these files directly from the org.imixs.workflow.jee.api-1.5.7.jar which is found in your local maven2 repository. Maven downloads this jar during the first maven Install process.

So finally I make a new "run as - maven install" to see if the build is sucessfull.

Now I have implemented successful a EJB Workflow Modul. In the next Part I will implement a web frontend and fit all together.

Building a Workflow Application - Part I

The following Tutorial I will explain how easy it is to build a Workflow Application using the IX Open Source Workflow Components. The Tutorial is divided into three parts:

I assume that you are familiar with Java development and also a little bit with JEE. But you need not to be a JEE expert to follow this tutorial. I use Maven to simplify the build and deployment process so you can setup a project very fast.

My goal is to develop a Callcenter application - very simplified. As this application should be workflow centric I use the IX JEE Workflow components to implement a human based workflow application. Users can create new tickets and a support team can accept these tickets and hopfully solve the tickets in a appropriate time. The business process behind the scene can be modeled using the IX Workflow Modeler and so the application is very easy to configure at runntime.

The application can be downloaded directly from the Subversion repository on our dev.java.net project homepage.

Go to the following repository location to checkout the Maven Project

https://ix-workflow.dev.java.net/source/browse/ix-workflow/examples/org.imixs.callcenter/trunk/

If you have questions or feedback please post you comments.

The Environment

To start the development it is necessary that you have installed a Glassfish Server and also the Eclipse IDE. You can also work with other IDEs like Sun NetBeans which is very cool managing Maven Projects! But as we also need to model the business process we need an Eclipse IDE as well.

As I am building a Workflow Application I also need a Database and a User Management. You can setup these parts easily using the Glassfish Web Admin Console. We support an Installation Guide on the project homepage. This guide explains how to setup a database pool  and a default user group with different roles.

After you have installed and configured the Server you continue to install the IX Workflow Modeler and the Eclipse Maven2 Plugin. Both are Eclipse Plugins which can be installed easily using the Eclipse Update Manager. To install the IX Workflow Modeler use the following Update Site:

http://www.imixs.org/org.imixs.eclipse.updatesite/

A detailed Installation Guide can be found here.

Also the Maven2 Plugin can be installed using the Eclipse Update Manager. Informations about Maven2 and Eclipse can be found here.  I also have written a Blog about how to install Maven2 in Eclipse Ganymede.

Creating a new Maven Project

As explained before I use Maven to develop this application. Maven is a build an configuration tool which makes it easy to develop JEE applications. You need not to care about libraries and configuration of artifacts. This is done by the magic of maven.

So first setup a so called parent project. This project will include all the parts of the application I build during this tutorial.

Choose new project and select in the Wizzard "Maven->Maven Project"

 

Select "Create a simple Project" and skip the archetype selection.

 

Define a new Group and Artifact ID for your project and select "POM" for the Packaging (this is important to create a parent project)


Now you have the groundwork for your JEE workflow application.

Create a Workflow Model

Now as you setup your Environment you can start to create a Workflow Model. The Workflow Model is the beginning of a Workflow Project. Here you define the behavior of the Business Process for your application. In large projects it is useful to describe a business process formal using a general business modeling tool. But now I start modeling directly in the Imixs IX Workflow Modeler.

You can create you new Model file in the /src/ folder of your maven parent project. Create a new folder /workflow and create a model file "model.ixm". You can use the New Wizzard or simply create a empty file "model.ixml".
When you open this file you see the IX Workflow Editor:

 

Now I create a new Process Group called "ticket" and add three  Process Entities 

  • new Ticket
  • in process
  • closed

You will find a full description how to model a business process on the IX Modeler project Page.

After all you model can look like this:


 

You will find the model also in the subversion repository explained at the beginning. 

Now the first Part of our Tutorial is finished.

You have setup a Environment and created a new workflow model. Next we will create a Business Logic by implementing an EJB 3.0 statless session bean.

Sunday Jul 20, 2008

IX Modeler - new Version 2.2.4

The new version 2.2.4 of the Imixs IX Workflow Modeler is now released. This version includes a lot of improvements concerning the graphical modeling. Therefor the popular style has changed. The attributes of activity entities,like Mail or Access Configurations, now are displayed graphicaly. The handling of users and time objects has been improved.

 

 

 

WebService Plugin 1.3.0

Also the WebSerivce Plugin was updated to version 1.3.0. Et.al. it includes a better error handling, so connection failures will be displayed much better as in the releases before.

Also all these features are sucessfully tested in newest eclipse version Ganemede 3.4.

Sunday Jul 13, 2008

Support for Bea WebLogic 10.0

We are now also supporting Bea WebLogic Server 10.0.  Currently Bea WebLogic 10.0 did not support all the functionality as specified in the JEE spec. Particularly the Web Service implementation is not completed so if you try to deploy the Imixs IX JEE Workflow components you need some modifications.

As there are some restrictions in Bea WebLogic 10.0 concerning the Web Service Functionality you could run into problems during deployment of the IX JEE Workflow components on Bea. But it is possible to run Imixs IX Workflow on Bea 10.0.
If you like to deploy the Imixs IX JEE Workflow components on a Bea WebLogic Server 10.0 there are some things you must pay attention to.
First we recommend to remove the WebService implementations
- org.imixs.workflow.jee.ejb.ModelServiceManagerImplementation
- org.imixs.workflow.jee.ejb.WorkflowServiceManagerImplementation
from the deployment.

Then it is useful to integrate the worklfow model in a programmatic way inside you Application. We are also supporting helpful component for this.

In general you can build your ear module like described in the chapters Deployment . But as Bea WebLogic 10.0 did not support all the functionality as specified in the JEE spec you need do some modifications. We published a description about the procedure here.

Additional we are supporting a new branch of the IX JEE Workflow for Bea WebLogic. You can checkout this branch on the Subversion Repository on dev.java.net. The branch also supports the maven configuration management.

If you have questions about IX Workflow and Bea WebLogic please give us your feedback.

Saturday Jul 12, 2008

Imixs on dev.java.net

Since two months we are member of the dev.java.net community. We moved our project to dev.java.net because the Imixs IX Workflow is mainly focused on Java Technologies. So the dev.java.net is a suitable place for our project. 

As our newest subproject IX JEE Workflow is mainly developed on Glassfish Server we are also supporting a lot of deployment tips for Glassfish. So you will find now all the informations on one place.

We moved also the sources to dev.java.net which were hosted before on Sourceforge.  

Wellcome

Welcome to the Imixs Blog!

This blog is used to publish news and informations around the Imixs IX Open Source Project. The Imixs Open Source Project (imixs.org) was created to promote the development of workflow technologies based on open software standards.

Within the scope of this project, various technologies and procedures are published that allow and support the development of open, process-oriented workflow systems.

How you are involved

Make use of the products and give us your feedback. You are now a part of the project by making suggestions and further developing the code. If you wish to assume this role, we have a few steps for you to follow.

  • Please read the guidelines 
  • Load the source code
  • Contribute corrections
To become a Contributer for the subprojects join our dev.java.net project site: https://ix-workflow.dev.java.net/