[jbpm-commits] JBoss JBPM SVN: r2941 - in jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration: model and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Nov 15 09:22:04 EST 2008


Author: thomas.diesler at jboss.com
Date: 2008-11-15 09:22:04 -0500 (Sat, 15 Nov 2008)
New Revision: 2941

Added:
   jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/client/TokenImpl.java
   jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessImpl.java
Modified:
   jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java
   jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
Log:
WaitStateTest - ok

Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/client/TokenImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/client/TokenImpl.java	                        (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/client/TokenImpl.java	2008-11-15 14:22:04 UTC (rev 2941)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.client;
+
+import java.util.Set;
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.Process.ProcessStatus;
+import org.jbpm.api.runtime.Attachments;
+import org.jbpm.integration.model.ProcessImpl;
+
+/**
+ * An integration wrapper
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class TokenImpl implements Token
+{
+  private static final long serialVersionUID = 1L;
+
+  private org.jbpm.graph.exe.Token oldToken;
+  private ProcessImpl procImpl;
+  private Attachments att;
+  
+  public TokenImpl(ProcessImpl proc, org.jbpm.graph.exe.Token oldToken, Attachments att)
+  {
+    this.oldToken = oldToken;
+    this.procImpl = proc;
+    this.att = att;
+  }
+
+  @Override
+  public String getTokenID()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public Process getProcess()
+  {
+    return procImpl;
+  }
+
+  @Override
+  public ProcessEngine getProcessEngine()
+  {
+    return procImpl.getProcessEngine();
+  }
+
+  @Override
+  public Attachments getAttachments()
+  {
+    return att;
+  }
+
+  @Override
+  public TokenStatus getTokenStatus()
+  {
+    TokenStatus status = TokenStatus.Suspended;
+    if (oldToken.hasEnded())
+    {
+      status = TokenStatus.Destroyed;
+    }
+    return status;
+  }
+
+  @Override
+  public Set<Token> getChildTokens()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public Node getCurrentNode()
+  {
+    String nodeName = oldToken.getNode().getName();
+    return procImpl.getNode(nodeName);
+  }
+
+  @Override
+  public SequenceFlow getLastFlow()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public Token getParentToken()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public Token getRootToken()
+  {
+    throw new NotImplementedException();
+  }
+
+  @Override
+  public void signal()
+  {
+    try
+    {
+      oldToken.signal();
+    }
+    catch (RuntimeException rte)
+    {
+      procImpl.setProcessStatus(ProcessStatus.Aborted);
+      throw rte;
+    }
+  }
+}


Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/client/TokenImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java	2008-11-15 11:17:46 UTC (rev 2940)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java	2008-11-15 14:22:04 UTC (rev 2941)
@@ -23,11 +23,13 @@
 
 import javax.management.ObjectName;
 
+import org.jbpm.api.Constants;
 import org.jbpm.api.InvalidProcessException;
 import org.jbpm.api.NotImplementedException;
 import org.jbpm.api.model.Node;
 import org.jbpm.api.model.Process;
 import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.builder.ObjectNameFactory;
 import org.jbpm.graph.def.Transition;
 
 /**
@@ -52,7 +54,8 @@
   @Override
   public ObjectName getKey()
   {
-    throw new NotImplementedException();
+    long id = oldNode.getId();
+    return ObjectNameFactory.create(Constants.ID_DOMAIN + ":node=" + getName() + ",id=" + id);
   }
   
   public org.jbpm.graph.def.Node getOldNode()

Modified: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-15 11:17:46 UTC (rev 2940)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java	2008-11-15 14:22:04 UTC (rev 2941)
@@ -26,12 +26,13 @@
 
 import javax.management.ObjectName;
 
+import org.jbpm.api.Constants;
 import org.jbpm.api.InvalidProcessException;
-import org.jbpm.api.NotImplementedException;
 import org.jbpm.api.client.ProcessEngine;
 import org.jbpm.api.model.Node;
 import org.jbpm.api.model.Process;
 import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.builder.ObjectNameFactory;
 import org.jbpm.graph.node.EndState;
 import org.jbpm.graph.node.StartState;
 import org.jbpm.graph.node.State;
@@ -58,6 +59,13 @@
       throw new InvalidProcessException("ProcessDefinition name cannot be null");
   }
 
+  
+  public org.jbpm.graph.def.ProcessDefinition getOldProcessDefinition()
+  {
+    return oldProcDef;
+  }
+
+
   @Override
   public ProcessEngine getProcessEngine()
   {
@@ -67,7 +75,8 @@
   @Override
   public ObjectName getKey()
   {
-    throw new NotImplementedException();
+    long id = oldProcDef.getId();
+    return ObjectNameFactory.create(Constants.ID_DOMAIN + ":procdef=" + getName() + ",id=" + id);
   }
 
   @Override
@@ -79,7 +88,7 @@
   @Override
   public Process newInstance()
   {
-    throw new NotImplementedException();
+    return new ProcessImpl(this);
   }
   
   public void addNode(NodeImpl nodeImpl)

Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessImpl.java	                        (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessImpl.java	2008-11-15 14:22:04 UTC (rev 2941)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.model;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.client.Token;
+import org.jbpm.api.client.Token.TokenStatus;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.runtime.Attachments;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.integration.client.TokenImpl;
+
+/**
+ * An integration wrapper
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class ProcessImpl implements Process
+{
+  private static final long serialVersionUID = 1L;
+
+  private ProcessDefinitionImpl procDef;
+  private ProcessInstance oldProc;
+  private ProcessStatus procStatus = ProcessStatus.None;
+  private Token rootToken;
+  
+  public ProcessImpl(ProcessDefinitionImpl procDef)
+  {
+    this.procDef = procDef;
+  }
+
+  @Override
+  public ObjectName getKey()
+  {
+    long id = oldProc != null ? oldProc.getId() : 0;
+    return ObjectNameFactory.create(Constants.ID_DOMAIN + ":proc=" + getName() + ",id=" + id);
+  }
+  
+  @Override
+  public ProcessDefinition getProcessDefinition()
+  {
+    return procDef;
+  }
+
+  @Override
+  public ProcessEngine getProcessEngine()
+  {
+    return procDef.getProcessEngine();
+  }
+
+  @Override
+  public ProcessStatus getProcessStatus()
+  {
+    if (rootToken.getTokenStatus() == TokenStatus.Destroyed)
+      procStatus = ProcessStatus.Completed;
+    
+    return procStatus;
+  }
+
+  public void setProcessStatus(ProcessStatus procStatus)
+  {
+    this.procStatus = procStatus;
+  }
+
+  @Override
+  public Token startProcess()
+  {
+    setProcessStatus(ProcessStatus.Ready);
+    rootToken = startProcess(null);
+    return rootToken;
+  }
+
+  @Override
+  public Token startProcess(Attachments att)
+  {
+    oldProc = new ProcessInstance(procDef.getOldProcessDefinition());
+    TokenImpl token = new TokenImpl(this, oldProc.getRootToken(), att);
+    token.signal();
+    return token;
+  }
+
+  @Override
+  public String getName()
+  {
+    return procDef.getName();
+  }
+
+  @Override
+  public <T extends Node> T getNode(Class<T> clazz, String name)
+  {
+    return procDef.getNode(clazz, name);
+  }
+
+  @Override
+  public Node getNode(String name)
+  {
+    return procDef.getNode(name);
+  }
+
+  @Override
+  public List<Node> getNodes()
+  {
+    return procDef.getNodes();
+  }
+
+  @Override
+  public <T extends Node> List<T> getNodes(Class<T> clazz)
+  {
+    return procDef.getNodes(clazz);
+  }
+}


Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list