[jbpm-commits] JBoss JBPM SVN: r7078 - in projects/jsf-console/branches/jsf-console-3.2-soa: jbpm4jsf/src/main/java/org/jbpm/jsf/core and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Feb 27 09:29:05 EST 2012
Author: marco.rietveld
Date: 2012-02-27 09:29:04 -0500 (Mon, 27 Feb 2012)
New Revision: 7078
Added:
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/action/UnlockActionListener.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/handler/UnlockHandler.java
Modified:
projects/jsf-console/branches/jsf-console-3.2-soa/console/src/main/webapp/app/token.xhtml
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/CoreLibrary.java
projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/tld/core.tld
Log:
JBPM-3419: unlock a token via the console.
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/console/src/main/webapp/app/token.xhtml
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/console/src/main/webapp/app/token.xhtml 2012-02-27 13:15:55 UTC (rev 7077)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/console/src/main/webapp/app/token.xhtml 2012-02-27 14:29:04 UTC (rev 7078)
@@ -149,6 +149,16 @@
<h:inputHidden value="#{id}"/>
<gs:ul>
<gs:li>
+ <ga:attribute name="rendered" value="#{token.locked}"/>
+ <h:commandLink value="Unlock">
+ <j4j:loadToken id="#{id}" target="#{token}"/>
+ <j4j:unlock value="#{token}"/>
+ <n:nav outcome="success" redirect="true" storeMessages="true"/>
+ <n:nav outcome="error" redirect="true" storeMessages="true"/>
+ </h:commandLink>
+ <h:outputText value=" this token"/>
+ </gs:li>
+ <gs:li>
<h:commandLink value="Suspend">
<ga:attribute name="rendered" value="#{! token.suspended}"/>
<j4j:loadToken id="#{id}" target="#{token}"/>
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/CoreLibrary.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/CoreLibrary.java 2012-02-27 13:15:55 UTC (rev 7077)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/CoreLibrary.java 2012-02-27 14:29:04 UTC (rev 7078)
@@ -30,6 +30,7 @@
import org.jbpm.jsf.core.handler.StartProcessHandler;
import org.jbpm.jsf.core.handler.StartTaskHandler;
import org.jbpm.jsf.core.handler.SuspendHandler;
+import org.jbpm.jsf.core.handler.UnlockHandler;
import org.jbpm.jsf.core.handler.UpdateTaskStartHandler;
import org.jbpm.jsf.core.handler.UpdateVariableHandler;
import org.jbpm.jsf.core.handler.ListTasksForActorHandler;
@@ -76,6 +77,7 @@
addTagHandler("cancel", CancelHandler.class);
addTagHandler("delete", DeleteHandler.class);
addTagHandler("suspend", SuspendHandler.class);
+ addTagHandler("unlock", UnlockHandler.class);
addTagHandler("resume", ResumeHandler.class);
addTagHandler("signal", SignalHandler.class);
Added: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/action/UnlockActionListener.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/action/UnlockActionListener.java (rev 0)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/action/UnlockActionListener.java 2012-02-27 14:29:04 UTC (rev 7078)
@@ -0,0 +1,84 @@
+package org.jbpm.jsf.core.action;
+
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.jbpm.jsf.JbpmActionListener;
+import org.jbpm.jsf.JbpmJsfContext;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+/**
+ *
+ */
+public final class UnlockActionListener implements JbpmActionListener {
+
+ private final ValueExpression valueExpression;
+
+ public UnlockActionListener(final ValueExpression valueExpression) {
+ this.valueExpression = valueExpression;
+ }
+
+ public String getName() {
+ return "unlock";
+ }
+
+ public void handleAction(JbpmJsfContext context, ActionEvent event) {
+ try {
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+ final ELContext elContext = facesContext.getELContext();
+ final Object value = valueExpression.getValue(elContext);
+ if (value == null) {
+ context.setError("Unlock failed", "The value is null");
+ return;
+ }
+ if (value instanceof TaskInstance) {
+ ((TaskInstance)value).setSignalling(false);
+ Token token = ((TaskInstance)value).getToken();
+ if( token.isLocked() ) {
+ String lockOwner = token.getLockOwner();
+ token.unlock(lockOwner);
+ }
+ else {
+ context.setError("Unlock failed", "The token is not locked.");
+ return;
+ }
+ context.addSuccessMessage("Task instance unlocked");
+ } else if (value instanceof Token) {
+ final Token token = ((Token) value);
+ if( token.isLocked() ) {
+ String lockOwner = token.getLockOwner();
+ token.unlock(lockOwner);
+ }
+ else {
+ context.setError("Unlock failed", "The token is not locked.");
+ return;
+ }
+ context.addSuccessMessage("Token unlocked");
+ } else if (value instanceof ProcessInstance) {
+ final ProcessInstance processInstance = ((ProcessInstance) value);
+ Token token = processInstance.getRootToken();
+ if( token.isLocked() ) {
+ String lockOwner = token.getLockOwner();
+ token.unlock(lockOwner);
+ }
+ else {
+ context.setError("Unlock failed", "The token is not locked.");
+ return;
+ }
+ context.addSuccessMessage("Process instance unlocked");
+ } else {
+ context.setError("Unlock failed", "The value is not a recognized type");
+ return;
+ }
+ context.getJbpmContext().getSession().flush();
+ context.selectOutcome("success");
+ } catch (Exception ex) {
+ context.setError("Unlock failed", ex);
+ return;
+ }
+ }
+}
Property changes on: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/action/UnlockActionListener.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/handler/UnlockHandler.java
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/handler/UnlockHandler.java (rev 0)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/handler/UnlockHandler.java 2012-02-27 14:29:04 UTC (rev 7078)
@@ -0,0 +1,40 @@
+package org.jbpm.jsf.core.handler;
+
+import org.jboss.gravel.common.annotation.TldAttribute;
+import org.jboss.gravel.common.annotation.TldTag;
+import org.jbpm.jsf.JbpmActionListener;
+import org.jbpm.jsf.core.action.UnlockActionListener;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+
+/**
+ *
+ */
+ at TldTag (
+ name = "unlock",
+ description = "Unlock a running token.",
+ attributes = {
+ @TldAttribute (
+ name = "value",
+ description = "The item to unlock.",
+ required = true,
+ deferredType = Object.class
+ )
+ }
+)
+public final class UnlockHandler extends AbstractHandler {
+ private final TagAttribute taskTagAttribute;
+
+ public UnlockHandler(final TagConfig config) {
+ super(config);
+ taskTagAttribute = getRequiredAttribute("value");
+ }
+
+ protected JbpmActionListener getListener(final FaceletContext ctx) {
+ return new UnlockActionListener(
+ getValueExpression(taskTagAttribute, ctx, Object.class)
+ );
+ }
+}
Property changes on: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/java/org/jbpm/jsf/core/handler/UnlockHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/tld/core.tld
===================================================================
--- projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/tld/core.tld 2012-02-27 13:15:55 UTC (rev 7077)
+++ projects/jsf-console/branches/jsf-console-3.2-soa/jbpm4jsf/src/main/tld/core.tld 2012-02-27 14:29:04 UTC (rev 7078)
@@ -1817,6 +1817,50 @@
</tag>
<tag>
+ <description><![CDATA[Unlock a running token]]></description>
+ <name>unlock</name>
+ <tag-class />
+ <tei-class />
+ <body-content>JSP</body-content>
+ <attribute>
+ <description><![CDATA[A different name to use for this action. Action names are used by some navigation handlers.]]></description>
+ <name>name</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <deferred-value>
+ <type>java.lang.String</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description><![CDATA[A boolean expression that can be used to control whether navigation will be attempted after this action completes.]]></description>
+ <name>navigate</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <deferred-value>
+ <type>boolean</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description><![CDATA[A boolean expression that, if true, will prevent this action from being run.]]></description>
+ <name>unless</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <deferred-value>
+ <type>boolean</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description><![CDATA[The item to unlock.]]></description>
+ <name>value</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <deferred-value>
+ <type>java.lang.Object</type>
+ </deferred-value>
+ </attribute>
+ </tag>
+
+ <tag>
<description><![CDATA[Update the start date of a started task.]]></description>
<name>updateTaskStart</name>
<tag-class/>
More information about the jbpm-commits
mailing list