Return-Path: <_www@dev.magnolia.info> Received: from dev.magnolia.info ([213.173.174.20] verified) by mail.obinary.com (CommuniGate Pro SMTP 5.1.10) with ESMTP id 14543641 for svn-list@magnolia.info; Sat, 19 Jul 2008 12:56:16 +0200 Received: by dev.magnolia.info (Postfix, from userid 70) id D66056A2466; Sat, 19 Jul 2008 12:56:16 +0200 (CEST) MIME-Version: 1.0 X-Mailer: SVN::Notify 2.70: http://search.cpan.org/dist/SVN-Notify/ From: svn@magnolia.info Errors-To: svn@magnolia.info To: svn-list@magnolia.info Subject: [16923] upgrading to our latest code Reply-To: dev-list@magnolia.info Content-Type: text/html; charset=UTF-8 Message-Id: <20080719105616.D66056A2466@dev.magnolia.info> Date: Sat, 19 Jul 2008 12:56:16 +0200 (CEST) Content-Transfer-Encoding: quoted-printable
upgrading to our latest code
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/pom.xml 2008-07-18 19:52:16=
UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/pom.xml 2008-07-19 10:56:15 UTC (rev 16923)
@@ -1,21 +1,17 @@
-<project=20
- xmlns=3D"http://maven.apache.org/POM/4.0.0"=20
- xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"=20
- xsi:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://=
maven.apache.org/maven-v4_0_0.xsd"
->
-
- <parent>
+<project xmlns=3D"http://maven.apache.org/POM/4.0.0&q=
uot; xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" xs=
i:schemaLocation=3D"http://maven.apache.org/POM/4.0.0 http://maven.a=
pache.org/maven-v4_0_0.xsd">
+ <properties>
+ <!--openwfe.version>1.7.2pre11</openwfe.version-->
+ </properties>
+ <parent>
<artifactId>magnolia-project</arti=
factId>
<groupId>info.magnolia</groupId&g=
t;
- <version>3.1-SNAPSHOT</version>
+ <version>3.0-6596-rev3-SNAPSHOT</version>
<relativePath>../pom.xml</relative=
Path>
</parent>
-
<modelVersion>4.0.0</modelVersion>=
;
<artifactId>magnolia-module-workflow&l=
t;/artifactId>
<name>magnolia-module-workflow</nam=
e>
- <version>3.1-SNAPSHOT</version>
-
+ <version>3.0-6596-rev3-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId=
>
@@ -25,7 +21,7 @@
<dependency>
<groupId>info.magnolia</groupId=
>
<artifactId>magnolia-core</arti=
factId>
- <version>3.1-SNAPSHOT</version>
+ <version>3.0-rc3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId=
>
@@ -39,7 +35,7 @@
<dependency>
<groupId>info.magnolia</groupId=
>
<artifactId>magnolia-module-admini=
nterface</artifactId>
- <version>3.1-SNAPSHOT</version>
+ <version>3.0-6596-rev3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
@@ -63,33 +59,25 @@
<dependency>
<groupId>info.magnolia</groupId=
>
<artifactId>magnolia-exchange-simp=
le</artifactId>
- <version>3.1-SNAPSHOT</version>
+ <version>3.0-6596-rev3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>info.magnolia</groupId=
>
<artifactId>magnolia-gui</artif=
actId>
- <version>3.1-SNAPSHOT</version>
+ <version>3.0-6596-rev3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</arti=
factId>
</dependency>
=20
- <!--
<dependency>
- <groupId>org.jruby</groupId>
- <artifactId>jruby-complete</artifactId>
- <version>1.1-SNAPSHOT</version>
- </dependency>
- -->
- <dependency>
<groupId>org.openwfe</groupId>=
;
<artifactId>openwferu</artifact=
Id>
- <version>0.9.16-SNAPSHOT</version>
+ <version>0.9.19-SNAPSHOT</version>
</dependency>
=20
</dependencies>
-
<distributionManagement>
<site>
<id>magnolia</id>
@@ -100,7 +88,7 @@
=20
<repositories>
<repository>
- <!-- where JRuby and OpenWFEru are -->
+ <!-- where OpenWFEru is -->
<id>maven.openwfe.org.snapshots<=
/id>
<url>http://maven.openwfe.org/snap=
shots</url>
<snapshots>
@@ -108,4 +96,5 @@
</snapshots>
</repository>
</repositories>
+
</project>
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/java/info/magnolia=
/module/workflow/WorkflowModule.java 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/java/info/magnolia/module/workflow/Work=
flowModule.java 2008-07-19 10:56:15 UTC (rev 16923)
@@ -20,6 +20,7 @@
import info.magnolia.cms.util.NodeDataUtil;
import info.magnolia.commands.CommandsManager;
import info.magnolia.context.Context;
+import info.magnolia.context.MgnlContext;
import info.magnolia.module.admininterface.Abst=
ractAdminModule;
=20
import java.util.HashMap;
@@ -85,6 +86,10 @@
if (path !=3D null)
launchitem.put(Context.ATTRIBUTE_P=
ATH, path);
=20
+ //String uuid =3D getUuid(repository, path);
+ //if (uuid !=3D null)
+ // launchitem.put(Context.ATTRIBUTE_UUID, uuid);
+
launchitem.put(WorkflowConstants.ATT_WO=
RKFLOW, flowName);
=20
return launchFlow(launchitem);
@@ -165,6 +170,11 @@
//
// WORKLIST METHODS
=20
+ public List getUserInbox () {
+
+ return getInbox("user", MgnlContext.getUser().getName(=
));
+ }
+
public List getUserInbox (String name) {
=20
return getInbox("user", name=
);
@@ -190,6 +200,16 @@
Object.class);
}
=20
+ public List getWorkitems () {
+
+ return (List) JavaEmbedUtils.invokeMethod
+ (this.rubyRuntime,=20
+ this.worklist,=20
+ "get_workitems",
+ new Object[] {},
+ Object.class);
+ }
+
/**
* Returns the path of the content object =
associated with the workitem
* (wi identified by its fei - FlowExpress=
ionId).
@@ -313,6 +333,31 @@
//
// PRIVATE METHODS
=20
+ /*
+ private String getUuid (String repository, String path) {
+
+ if (repository =3D=3D null) return null;
+
+ try {
+
+ Content c =3D ContentRepository.getHierarchyManager(reposito=
ry)
+ .getContent(path);
+
+ return c.getUUID();
+ }
+ catch (Throwable t) {
+
+ log.info
+ ("getUuid() "+
+ "failed to find UUID for path '"+path+
+ "' in repository '"+repository+"'\n"=
;+
+ "("+t.getMessage()+")");
+
+ return null;
+ }
+ }
+ */
+
private void registerCacheUrl() {
=20
Content node =3D ContentUtil
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflow=
er/engine.rb 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/resources/workflower/engine.rb 2008-07-=
19 10:56:15 UTC (rev 16923)
@@ -26,579 +26,560 @@
require 'openwfe/expool/errorjournal'
=20
require 'openwfe/storage/yamlcustom'
- # very important, else the to_yaml() function serializes=
too much...
+ # very important, else the to_yaml() function serializes to=
o much...
=20
require 'workflower/worklist'
=20
=20
module Workflower
=20
- #
- # Some constants.
- # Their names are new, their values are old.
+ #
+ # Some constants.
+ # Their names are new, their values are old.
=20
- EXPRESSION_WORKSPACE =3D 'Expressions'
+ EXPRESSION_WORKSPACE =3D 'Expressions'
=20
+ #
+ # The JCR based OpenWFEru engine.
+ #
+ class JcrPersistedEngine < OpenWFE::Engine
+
#
- # The JCR based OpenWFEru engine.
+ # A dedicated Magnlia launch flow method.
+ # It accepts as Hash[Map] as a launchitem.
#
- class JcrPersistedEngine < OpenWFE::Engine
+ # To make things simple, it returns the flow expression i=
d
+ # of the root of the process newly launched as a string.
+ #
+ def launch_flow (hash)
=20
- #
- # A dedicated Magnlia launch flow method.
- # It accepts as Hash[Map] as a launchitem.
- #
- # To make things simple, it returns the flow expression id
- # of the root of the process newly launched as a string.
- #
- def launch_flow (hash)
+ li =3D OpenWFE::LaunchItem.new
=20
- li =3D OpenWFE::LaunchItem.new
+ li.workflow_definition_url =3D hash[WfConstants::WFD_UR=
L]
=20
- li.workflow_definition_url =3D hash[WfConstants:=
:WFD_URL]
+ linfo { "launch_flow() for '#{li.workflow_definiti=
on_url}'" }
=20
- linfo { "launch_flow() for '#{li.workflow_d=
efinition_url}'" }
+ hash.remove WfConstants::WFD_URL
=20
- hash.remove WfConstants::WFD_URL
+ li.attributes =3D {}
+ hash.each { |k, v| li.attributes[k] =3D v }
=20
- li.attributes =3D {}
- hash.each { |k, v| li.attributes[k] =3D v }
+ fei =3D launch li
=20
- fei =3D launch li
+ fei.to_s
+ end
=20
- fei.to_s
- end
+ #
+ # As the name implies.
+ #
+ def cancel_flow (sid)
=20
- #
- # As the name implies.
- #
- def cancel_flow (sid)
+ linfo { "cancel_flow() for '#{sid}'" }
=20
- linfo { "cancel_flow() for '#{sid}'" }
+ wfid =3D if sid.match("^.fei ")
+ OpenWFE::FlowExpressionId.from_s(sid).wfid
+ else
+ sid
+ end
=20
- wfid =3D if sid.match("^.fei ")
- OpenWFE::FlowExpressionId.from_s(sid).wfid
- else
- sid
- end
+ cancel_process sid
+ end
=20
- cancel_process sid
- end
+ protected
=20
- protected
+ #
+ # Uses a JCR based expression storage
+ #
+ def build_expression_storage
=20
- #
- # Uses a JCR based expression storage
- #
- def build_expression_storage
+ @application_context[:expression_cache_size] =3D 1000
=20
- @application_context[:expression_cache_size]=
=3D 1000
+ init_service(
+ OpenWFE::S_EXPRESSION_STORAGE,=20
+ OpenWFE::CacheExpressionStorage)
+ =20
+ init_service(
+ OpenWFE::S_EXPRESSION_STORAGE + ".1",
+ JcrExpressionStorage)
+ end
=20
- init_service(
- S_EXPRESSION_STORAGE,=20
- OpenWFE::CacheExpressionStorage)
- =20
- init_service(
- S_EXPRESSION_STORAGE + ".1",
- JcrExpressionStorage)
- end
+ #
+ # Uses a JCR based error journal
+ #
+ def build_error_journal
=20
- #
- # Uses a JCR based error journal
- #
- def build_error_journal
+ init_service OpenWFE::S_ERROR_JOURNAL, JcrErrorJourna=
l
+ #init_service OpenWFE::S_ERROR_JOURNAL, OpenWFE::YamlErrorJourna=
l
+ end
+ end
=20
- init_service S_ERROR_JOURNAL, JcrErrorJourna=
l
- #init_service S_ERROR_JOURNAL, OpenWFE::YamlErrorJournal
- end
- end
+ #
+ # Using HttpClient to get https document instead of openssl.rb
+ #
+ class OpenWFE::ExpressionPool
=20
- #
- # Using HttpClient to get https document instead of openssl.rb
- #
- class OpenWFE::ExpressionPool
+ alias :original_read_uri :read_uri
=20
- alias :original_read_uri :read_uri
+ def read_uri (uri)
=20
- def read_uri (uri)
+ suri =3D uri.to_s
=20
- suri =3D uri.to_s
+ if suri.match("^magnolia:")
=20
- if suri.match("^magnolia:")
+ JCRFlowUtil.getFlowDefAsString suri[11..-1]
=20
- JCRFlowUtil.getFlowDefAsString suri[11..-1]
+ elsif suri.match("^https:")
=20
- elsif suri.match("^https:")
+ hc =3D HttpClient.new
+ gm =3D GetMethod.new uri
+ hc.executeMethod gm
=20
- hc =3D HttpClient.new
- gm =3D GetMethod.new uri
- hc.executeMethod gm
+ gm.getResponseBodyAsString
=20
- gm.getResponseBodyAsString
+ else
=20
- else
-
- original_read_uri uri
- end
- end
+ original_read_uri uri
+ end
end
+ end
=20
- #
- # Stores the workflow expressions (atomic pieces of workflow instanc=
es)
- # in a JCR repository).
- #
- class JcrExpressionStorage
- include MonitorMixin
- include OpenWFE::ServiceMixin
- include OpenWFE::OwfeServiceLocator
- include OpenWFE::ExpressionStorageBase
+ #
+ # Stores the workflow expressions (atomic pieces of workflow instances=
)
+ # in a JCR repository).
+ #
+ class JcrExpressionStorage
+ include MonitorMixin
+ include OpenWFE::ServiceMixin
+ include OpenWFE::OwfeServiceLocator
+ include OpenWFE::ExpressionStorageBase
=20
=20
- ENGINE_ENV =3D '/engine_environment'
- EXPRESSIONS_QUERY =3D '//*[@ID]'
+ ENGINE_ENV =3D '/engine_environment'
+ EXPRESSIONS_QUERY =3D '//*[@ID]'
=20
=20
- def initialize (service_name, application_context)
+ def initialize (service_name, application_context)
=20
- super()
- #
- # this call, is very important as this class includes
- # the MonitorMixin.
+ super()
+ #
+ # this call, is very important as this class includes
+ # the MonitorMixin.
=20
- service_init service_name, application_context
+ service_init service_name, application_context
=20
- @hm =3D ContentRepository.getHierarchyManager(EX=
PRESSION_WORKSPACE)
+ @hm =3D ContentRepository.getHierarchyManager(EXPRESSIO=
N_WORKSPACE)
=20
- raise "failed to get HierarchyManager '#{EX=
PRESSION_WORKSPACE}'" \
- unless @hm
+ raise "failed to get HierarchyManager '#{EXPRESSIO=
N_WORKSPACE}'" \
+ unless @hm
=20
- observe_expool
+ observe_expool
=20
- linfo { "initialize() expression storage re=
ady" }
- end
+ linfo { "initialize() expression storage ready&quo=
t; }
+ end
=20
- def []=3D (fei, fe)
+ def []=3D (fei, fe)
=20
- ldebug { "[]=3D storing #{fei.to_s}" }
+ ldebug { "[]=3D storing #{fei.to_s}" }
=20
- synchronize do
+ synchronize do
=20
- c =3D locate_expression fei, true
+ c =3D locate_expression fei, true
=20
- vf =3D c.getJCRNode.getSession.getValueFacto=
ry
+ vf =3D c.getJCRNode.getSession.getValueFactory
=20
- c.createNodeData(
- WfConstants::NODEDATA_ID, vf.createValue(fei.to_s))
- c.createNodeData(
- WfConstants::NODEDATA_WFID, vf.createValue(fei.wfid)=
)
- c.createNodeData(
- WfConstants::NODEDATA_EXPCLASS, vf.createValue(fe.cl=
ass.name))
+ c.createNodeData(
+ WfConstants::NODEDATA_ID, vf.createValue(fei.to_s))
+ c.createNodeData(
+ WfConstants::NODEDATA_WFID, vf.createValue(fei.wfid))
+ c.createNodeData(
+ WfConstants::NODEDATA_EXPCLASS, vf.createValue(fe.class.name))
=20
- c.createNodeData(
- WfConstants::NODEDATA_VALUE, vf.createValue(YAML.dum=
p(fe)))
+ c.createNodeData(
+ WfConstants::NODEDATA_VALUE, vf.createValue(YAML.dump(fe)))
=20
- @hm.save
- end
- end
+ @hm.save
+ end
+ end
=20
- def [] (fei)
- synchronize do
+ def [] (fei)
+ synchronize do
=20
- cExpression =3D locate_expression fei
+ cExpression =3D locate_expression fei
=20
- return nil unless cExpression
+ return nil unless cExpression
=20
- load_expression cExpression
- end
- end
+ load_expression cExpression
+ end
+ end
=20
- def delete (fei)
- synchronize do
+ def delete (fei)
+ synchronize do
=20
- cExpression =3D locate_expression fei
+ cExpression =3D locate_expression fei
=20
- if cExpression
+ if cExpression
=20
- cExpression.delete
- @hm.save
- end
- end
+ cExpression.delete
+ @hm.save
end
+ end
+ end
=20
- #
- # Returns the size of this expression storage (returns the count
- # of expressions stored).
- #
- def size
+ #
+ # Returns the size of this expression storage (returns the count
+ # of expressions stored).
+ #
+ def size
=20
- query_for_expression(EXPRESSIONS_QUERY).size + 1
- # plus one for the engive environment expression
- end
+ query_for_expression(EXPRESSIONS_QUERY).size + 1
+ # plus one for the engive environment expression
+ end
=20
- alias :length :size
+ alias :length :size
=20
- def each (wfid_prefix=3Dnil, &block)
+ #
+ # The 0.9.17 method for expstorage implementations. Replaces each an=
d
+ # each_of_kind.
+ #
+ def find_expressions (options=3D{})
=20
- #query_string =3D if wfid_prefix
- # "//*[@ID and starts-with(local-name(), '#{wfid_pre=
fix}')]"
- #else
- # EXPRESSIONS_QUERY
- #end
- #
- # the current JCR impl doesn't support starts-with() grr=
rr....
- #
- query_string =3D EXPRESSIONS_QUERY
+ ic =3D options[:include_classes]
=20
- c =3D query_for_expressions(query_string)
+ qs =3D if ic
=20
- ldebug { "each() will consider #{c.size} ex=
pressions" }
+ classes =3D get_expression_map.get_expression_classes=
ic
=20
- c.each do |content|
+ s =3D classes.collect { |expclass|
+ "@expressionClass=3D'#{expclass.to_s}'"
+ }.join(" or ")
=20
- #ldebug { "each() considering #{content=
.getHandle}" }
- #ldebug { "each() considering #{content.getName}&qu=
ot; }
+ "//*[#{s}]"
+ else
=20
- next if wfid_prefix \
- and (not content.getName.match("^"+wfid_pr=
efix))
- #
- # grrrr...
+ EXPRESSIONS_QUERY
+ end
=20
- fexp =3D load_expression content
- block.call fexp.fei, fexp
- end
- end
+ linfo { "find_expressions() qs is >#{qs}<&qu=
ot; }
=20
- #
- # a minimalistic implementation : will load all the nodes...
- #
- def each_of_kind (kind, &block)
+ c =3D query_for_expressions qs
=20
- classes =3D get_expression_map.get_expression_cl=
asses kind
+ c.inject([]) do |r, content|
=20
- qs =3D classes.collect { |expclass|
- "@expressionClass=3D'#{expclass.to_s}'"
- }.join(" or ")
+ linfo { "each_of_kind() considering #{content.ge=
tHandle}" }
+ #ldebug { "each_of_kind() considering #{content.getName}&qu=
ot; }
=20
- qs =3D "//*[#{qs}]"
+ fexp =3D load_expression content
=20
- linfo { "each_of_kind() qs is >#{qs}<=
" }
+ r << fexp if does_match?(options, fexp)
=20
- c =3D query_for_expressions qs
+ r
+ end
+ end
=20
- c.each do |content|
+ #
+ # A 0.9.17 method, getting quicker to the heart of a process definit=
ion.
+ #
+ # (not yet proven...)
+ #
+ def fetch_root (wfid)
=20
- ldebug { "each_of_kind() considering #{=
content.getHandle}" }
- ldebug { "each_of_kind() considering #{content.getN=
ame}" }
+ qs =3D \
+ "//*["+
+ "@expressionClass=3D'OpenWFE::DefineExpression' and "+
+ "@wfid=3D'#{wfid}'"+
+ "]"
=20
- fexp =3D load_expression content
- block.call fexp.fei, fexp
- end
- end
+ linfo { "fetch_root() qs is >#{qs}<" }
=20
- #
- # A 0.9.17 method, getting quicker to the heart of a process def=
inition.
- #
- # (not yet proven...)
- #
- def fetch_root (wfid)
+ c =3D query_for_expressions qs
=20
- qs =3D \
- "//*["+
- "@expressionClass=3D'OpenWFE::DefineExpression' and=
"+
- "@wfid=3D'#{wfid}'"+
- "]"
+ return nil if c.size < 1
=20
- linfo { "fetch_root() qs is >#{qs}<&q=
uot; }
+ exps =3D c.collect do |content|
=20
- c =3D query_for_expressions qs
+ load_expression content
+ end
=20
- return nil if c.size < 1
+ exps.sort { |a, b| a.fei.expid <=3D> b.fei.expid =
}[0]
+ end
=20
- exps =3D c.collect do |content|
+ protected
=20
- load_expression content
- end
+ #
+ # Returns an array of Content instances matching the query_string
+ #
+ def query_for_expressions (query_string)
=20
- exps.sort { |a, b| a.fei.expid <=3D> b.fei=
.expid }[0]
- end
+ qr =3D MgnlContext.getQueryManager(EXPRESSION_WORKSPA=
CE)\
+ .createQuery(query_string, Query::XPATH).execute
=20
- protected
+ qr.getContent(WfConstants::NODENAME_EXPRESSION)
+ end
=20
- #
- # Returns an array of Content instances matching the query_s=
tring
- #
- def query_for_expressions (query_string)
+ #
+ # Returns the Content instance where the expression has to be / is
+ # located.
+ #
+ def locate_expression (fei, create_if_missing=3Dfalse)
=20
- qr =3D MgnlContext.getQueryManager(EXPRESSIO=
N_WORKSPACE)\
- .createQuery(query_string, Query::XPATH).execute
+ path =3D determine_path(fei)
=20
- qr.getContent(WfConstants::NODENAME_EXPRESSI=
ON)
- end
+ if @hm.isExist(path)
=20
- #
- # Returns the Content instance where the expression has to b=
e / is
- # located.
- #
- def locate_expression (fei, create_if_missing=3Dfalse)
+ @hm.getContent path
=20
- path =3D determine_path(fei)
+ elsif create_if_missing
=20
- if @hm.isExist(path)
+ ContentUtil.createPath @hm, path, ItemType::EXPRESS=
ION
=20
- @hm.getContent path
+ else
=20
- elsif create_if_missing
+ nil
+ end
+ end
=20
- ContentUtil.createPath @hm, path, ItemTy=
pe::EXPRESSION
+ def determine_path (fei)
=20
- else
+ return ENGINE_ENV if fei.workflow_instance_id =3D=3D =
'0'
+ #
+ # the environment common to all the process instances
+ # in the process engine
=20
- nil
- end
- end
+ wfid =3D fei.parent_workflow_instance_id
=20
- def determine_path (fei)
+ a_wfid =3D get_wfid_generator.split_wfid(wfid)
=20
- return ENGINE_ENV if fei.workflow_instance_i=
d =3D=3D '0'
- #
- # the environment common to all the process instance=
s
- # in the process engine
+ path =3D '/'
+ path << a_wfid[-2]
+ path << '/'
+ path << a_wfid[-1]
+ path << '/'
+ path << fei.workflow_instance_id
+ path << '__'
+ path << OpenWFE.ensure_for_filename(fei.wfname)
+ path << '__'
+ path << fei.expression_id
+ path << '_'
+ path << fei.expression_name
=20
- wfid =3D fei.parent_workflow_instance_id
+ path
+ end
=20
- a_wfid =3D get_wfid_generator.split_wfid(wfi=
d)
+ #
+ # Loads the engine environment expression.
+ #
+ #def load_engine_env
+ # return nil unless @hm.isExist(ENGINE_ENV)
+ # load_expression(@hm.getContent(ENGINE_ENV))
+ #end
=20
- path =3D '/'
- path << a_wfid[-2]
- path << '/'
- path << a_wfid[-1]
- path << '/'
- path << fei.workflow_instance_id
- path << '__'
- path << OpenWFE.ensure_for_filename(fei.wfname)
- path << '__'
- path << fei.expression_id
- path << '_'
- path << fei.expression_name
+ def load_expression (content)
=20
- path
- end
+ s =3D content.getNodeData(WfConstants::NODEDATA_VALUE=
).getString
+ expression =3D YAML.load(s)
=20
- #
- # Loads the engine environment expression.
- #
- #def load_engine_env
- # return nil unless @hm.isExist(ENGINE_ENV)
- # load_expression(@hm.getContent(ENGINE_ENV))
- #end
+ #return nil unless expression
=20
- def load_expression (content)
+ expression.application_context =3D @application_conte=
xt
=20
- s =3D content.getNodeData(WfConstants::NODED=
ATA_VALUE).getString
- expression =3D YAML.load(s)
+ expression
+ end
+ end
=20
- #return nil unless expression
+ #
+ # A perf version of the JcrPersistedEngine, uses a cache and a=20
+ # threaded version of the JcrExpressionStorage.
+ #
+ class CachedJcrPersistedEngine < JcrPersistedEngine
=20
- expression.application_context =3D @applicat=
ion_context
+ protected
=20
- expression
- end
- end
+ def build_expression_storage
=20
- #
- # A perf version of the JcrPersistedEngine, uses a cache and a=20
- # threaded version of the JcrExpressionStorage.
- #
- class CachedJcrPersistedEngine < JcrPersistedEngine
+ @application_context[:expression_cache_size] ||=3D 77=
7
=20
- protected
+ init_service(
+ OpenWFE::S_EXPRESSION_STORAGE,
+ OpenWFE::CacheExpressionStorage)
=20
- def build_expression_storage
+ init_service(
+ OpenWFE::S_EXPRESSION_STORAGE + ".1",
+ ThreadedJcrExpressionStorage)
+ end
+ end
=20
- @application_context[:expression_cache_size]=
||=3D 777
+ #
+ # A threaded version of the JcrExpressionStorage.
+ # For performance.
+ #
+ class ThreadedJcrExpressionStorage < JcrExpressionStorage
+ include OpenWFE::ThreadedStorageMixin
=20
- init_service(
- S_EXPRESSION_STORAGE,
- CacheExpressionStorage)
+ def initialize (service_name, application_context)
=20
- init_service(
- S_EXPRESSION_STORAGE + ".1",
- ThreadedJcrExpressionStorage)
- end
- end
+ super
=20
- #
- # A threaded version of the JcrExpressionStorage.
- # For performance.
- #
- class ThreadedJcrExpressionStorage < JcrExpressionStorage
- include OpenWFE::ThreadedStorageMixin
-
- def initialize (service_name, application_context)
-
- super
-
- start_processing_thread()
- end
+ start_queue()
end
+ end
=20
- #
- # Keeping track of potential workflow troubles in the JCR.
- #
- # For now, workflow errors go into the Expressions workspace.
- #
- class JcrErrorJournal < OpenWFE::ErrorJournal
+ #
+ # Keeping track of potential workflow troubles in the JCR.
+ #
+ # For now, workflow errors go into the Expressions workspace.
+ #
+ class JcrErrorJournal < OpenWFE::ErrorJournal
=20
- EJOURNAL_PATH =3D '/error_journal'
+ EJOURNAL_PATH =3D '/error_journal'
=20
- def initialize (service_name, application_context)
+ def initialize (service_name, application_context)
=20
- super
+ super
=20
- @hm =3D ContentRepository.getHierarchyManager(EX=
PRESSION_WORKSPACE)
+ @hm =3D ContentRepository.getHierarchyManager(EXPRESSIO=
N_WORKSPACE)
=20
- raise "failed to get HierarchyManager '#{EX=
PRESSION_WORKSPACE}'" \
- unless @hm
+ raise "failed to get HierarchyManager '#{EXPRESSIO=
N_WORKSPACE}'" \
+ unless @hm
=20
- @mutex =3D Mutex.new
- end
+ @mutex =3D Mutex.new
+ end
=20
- #
- # Returns a list (older error first) of the errors for a process
- # instance identified by its fei or wfid.
- #
- def get_error_log (wfid)
+ #
+ # Returns a list (older error first) of the errors for a process
+ # instance identified by its fei or wfid.
+ #
+ def get_error_log (wfid)
=20
- #wfid =3D to_wfid(wfid)
+ #wfid =3D to_wfid(wfid)
=20
- c =3D locate_content(wfid)
+ c =3D locate_content(wfid)
=20
- return [] unless c
+ return [] unless c
=20
- h =3D {}
+ h =3D {}
=20
- c.getNodeDataCollection.each do |d|
+ c.getNodeDataCollection.each do |d|
=20
- index =3D Integer(d.getName)
- error =3D YAML.load(d.getString)
+ index =3D Integer(d.getName)
+ error =3D YAML.load(d.getString)
=20
- h[index] =3D error
- end
+ h[index] =3D error
+ end
=20
- # making sure we return the errors in the origin=
al order
- # (order of occurrence)
+ # making sure we return the errors in the original orde=
r
+ # (order of occurrence)
=20
- h.keys.sort.collect { |k| h[k] }
- end
+ h.keys.sort.collect { |k| h[k] }
+ end
=20
- def remove_error_log (wfid)
+ def remove_error_log (wfid)
=20
- @mutex.synchronize do
+ @mutex.synchronize do
=20
- c =3D locate_content(wfid)
+ c =3D locate_content(wfid)
=20
- return unless c
+ return unless c
=20
- c.delete
- @hm.save
- end
- end
+ c.delete
+ @hm.save
+ end
+ end
=20
- def remove_errors (wfid, errors)
+ def remove_errors (wfid, errors)
=20
- errors =3D Array(errors)
+ errors =3D Array(errors)
=20
- @mutex.synchronize do
+ @mutex.synchronize do
=20
- c =3D locate_content wfid, false
+ c =3D locate_content wfid, false
=20
- return unless c
+ return unless c
=20
- c.getNodeDataCollection.each do |cerror|
+ c.getNodeDataCollection.each do |cerror|
=20
- error =3D YAML.load(cerror.getString)
- cerror.delete if errors.include?(error)
- end
- end
+ error =3D YAML.load(cerror.getString)
+ cerror.delete if errors.include?(error)
end
+ end
+ end
=20
- #
- # Returns a hash wfid --> error list
- #
- def get_error_logs
+ #
+ # Returns a hash wfid --> error list
+ #
+ def get_error_logs
=20
- journal =3D @hm.getQueryManager.createQuery(
- 'error_journal/*/*', Query::XPATH).execute
- journal =3D journal.getContent(
- WfConstants::NODENAME_WORKFLOW_ERRORS)
+ journal =3D @hm.getQueryManager.createQuery(
+ 'error_journal/*/*', Query::XPATH).execute
+ journal =3D journal.getContent(
+ WfConstants::NODENAME_WORKFLOW_ERRORS)
=20
- ldebug { "get_error_logs() found #{journal.=
size} error journals" }
+ ldebug { "get_error_logs() found #{journal.size} e=
rror journals" }
=20
- result =3D {}
+ result =3D {}
=20
- journal.each do |n|
+ journal.each do |n|
=20
- wfid =3D n.getName
- errors =3D get_error_log wfid
+ wfid =3D n.getName
+ errors =3D get_error_log wfid
=20
- result[wfid] =3D errors
- end
+ result[wfid] =3D errors
+ end
=20
- result
- end
+ result
+ end
=20
- protected
+ protected
=20
- def locate_content (wfid, create_if_missing=3Dfa=
lse)
+ def locate_content (wfid, create_if_missing=3Dfalse)
=20
- wfid =3D wfid.parent_workflow_instance_id \
- if wfid.is_a?(OpenWFE::FlowExpressionId)
+ wfid =3D wfid.parent_workflow_instance_id \
+ if wfid.is_a?(OpenWFE::FlowExpressionId)
=20
- a_wfid =3D get_wfid_generator.split_wfid(wfi=
d)
+ a_wfid =3D get_wfid_generator.split_wfid(wfid)
=20
- path =3D ''
- path << EJOURNAL_PATH
- path << '/'
- path << a_wfid[-1]
- path << '/'
- path << wfid
+ path =3D ''
+ path << EJOURNAL_PATH
+ path << '/'
+ path << a_wfid[-1]
+ path << '/'
+ path << wfid
=20
- if @hm.isExist(path)
+ if @hm.isExist(path)
=20
- @hm.getContent path
+ @hm.getContent path
=20
- elsif create_if_missing
+ elsif create_if_missing
=20
- ContentUtil.createPath(
- @hm,=20
- path,=20
- ItemType.new(WfConstants::NODENAME_WORKFLOW_ERRO=
RS))
+ ContentUtil.createPath(
+ @hm,=20
+ path,=20
+ ItemType.new(WfConstants::NODENAME_WORKFLOW_ERRORS))
=20
- else
+ else
=20
- nil
- end
- end
+ nil
+ end
+ end
=20
- #
- # Will dump the error into the JCR as a YAML string.
- #
- def record_error (error)
+ #
+ # Will dump the error into the JCR as a YAML string.
+ #
+ def record_error (error)
=20
- @mutex.synchronize do
+ @mutex.synchronize do
=20
- c =3D locate_content(error.wfid, true)
+ c =3D locate_content(error.wfid, true)
=20
- #i =3D c.getNodeDataCollection.size
- i =3D Integer(Time.now.to_f * 1000)
+ #i =3D c.getNodeDataCollection.size
+ i =3D Integer(Time.now.to_f * 1000)
=20
- vf =3D c.getJCRNode.getSession.getValueF=
actory
- c.createNodeData(i.to_s, vf.createValue(YAML.dump(er=
ror)))
+ vf =3D c.getJCRNode.getSession.getValueFactory
+ c.createNodeData(i.to_s, vf.createValue(YAML.dump(error)))
=20
- @hm.save
+ @hm.save
=20
- ldebug { "record_error() for #{erro=
r.wfid}" }
- end
- end
- end
+ ldebug { "record_error() for #{error.wfid}&quo=
t; }
+ end
+ end
+ end
end
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflow=
er/logging.rb 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/resources/workflower/logging.rb 2008-07=
-19 10:56:15 UTC (rev 16923)
@@ -10,29 +10,38 @@
=20
module Workflower
=20
+ #
+ # Wrapping an sl4j logger inside a Ruby envelope.
+ #
+ class Logger
+
+ def initialize (logpath)
+
+ @slogger =3D Factory.getLogger(logpath)
+
+ @slogger.info " -ooo- Logger ready to log"
+ end
+
#
- # Wrapping an sl4j logger inside a Ruby envelope.
+ # warn is a Kernel method in ruby... Doesn't work via met=
hod_messing
+ # have to code it in hard.
#
- class Logger
+ def warn (&block)
=20
- def initialize (logpath)
+ @slogger.warn block.call
+ end
=20
- @slogger =3D Factory.getLogger(logpath)
+ def method_missing (m, *args, &block)
=20
- @slogger.info " -ooo- Logger ready to log=
"
- end
+ return if (m =3D=3D :debug) and (not @slogger.isDebugEn=
abled)
+ # slight optimization
=20
- def method_missing (m, *args, &block)
+ message =3D block.call
+ # string concatenation only occurs here,
+ # hence the optimization
=20
- return if (m =3D=3D :debug) and (not @slogger.is=
DebugEnabled)
- # slight optimization
-
- message =3D block.call
- # string concatenation only occurs here,
- # hence the optimization
-
- @slogger.send m, message
- end
+ @slogger.send m, message
end
+ end
=20
end
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflow=
er/participants.rb 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/resources/workflower/participants.rb 20=
08-07-19 10:56:15 UTC (rev 16923)
@@ -14,72 +14,78 @@
=20
module Workflower
=20
- #
- # This participant stores the workitem it receives in the=20
- # JCR repo.
- #
- class MgnlParticipant
- include OpenWFE::LocalParticipant
+ #
+ # This participant stores the workitem it receives in the=20
+ # JCR repo.
+ #
+ class MgnlParticipant
+ include OpenWFE::LocalParticipant
=20
- #def initialize
- # super()
- #end
+ #def initialize
+ # super()
+ #end
=20
- def consume (workitem)
+ def consume (workitem)
=20
- get_worklist.store workitem
+ get_worklist.store workitem
=20
- # do not reply to engine
- # workitem is now stored in the JCR worklist, job done.
- end
+ # do not reply to engine
+ # workitem is now stored in the JCR worklist, job done.
+ end
=20
- def cancel (cancelitem)
+ def cancel (cancelitem)
=20
- # remove workitem from JCR worklist...
+ # remove workitem from JCR worklist...
=20
- get_worklist.remove cancelitem.fei
- end
+ linfo { "cancel() removing workitem for #{cancelit=
em.fei.to_s}" }
+
+ get_worklist.remove cancelitem.fei
end
+ end
=20
- #
- # This participant triggers Magnolia commands.
- #
- class MgnlCommandParticipant
- include OpenWFE::LocalParticipant
+ #
+ # This participant triggers Magnolia commands.
+ #
+ class MgnlCommandParticipant
+ include OpenWFE::LocalParticipant
=20
- #def initialize
- # super()
- #end
+ #def initialize
+ # super()
+ #end
=20
- def consume (workitem)
+ def consume (workitem)
=20
- command_name =3D workitem.participant_name[8..-1=
]
+ command_name =3D workitem.participant_name[8..-1]
=20
- command =3D CommandsManager.getInstance.getComma=
nd(command_name)
+ command =3D CommandsManager.getInstance.getCommand(comm=
and_name)
=20
- unless command
- lerror { "consume() no command named '#{command_nam=
e}'" }
- return
- end
+ unless command
+ lerror { "consume() no command named '#{command_name}'"=
; }
+ return
+ end
=20
- linfo { "consume() command class is #{comma=
nd.getClass.getName}" }
+ linfo do=20
+ "consume() command '#{command_name}' "+
+ "class is #{command.getClass.getName}"
+ end
=20
- context =3D MgnlContext.getSystemContext
- context =3D WorkItemContext.new context, workitem.toMap
+ context =3D MgnlContext.getSystemContext
+ context =3D WorkItemContext.new context, workitem.toMap
=20
- MgnlContext.setInstance context
- # I hate this one, a full blown command pattern and that=
...
+ MgnlContext.setInstance context
+ # I hate this one, a full blown command pattern and that...
=20
- command.execute context
- =20
- # in fine...
+ result =3D command.execute context
+ workitem.attributes['command_result'] =3D result
=20
- reply_to_engine workitem
- end
+ # in fine...
=20
- def cancel (cancelitem)
+ reply_to_engine workitem
+ end
=20
- # nothing to do...
- end
+ def cancel (cancelitem)
+
+ # nothing to do...
end
+ end
end
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflow=
er/startup.rb 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/resources/workflower/startup.rb 2008-07=
-19 10:56:15 UTC (rev 16923)
@@ -12,7 +12,7 @@
=20
=20
S_WORKLIST =3D 'worklist'
- # the name of the worklist service
+ # the name of the worklist service
=20
=20
#
@@ -32,10 +32,10 @@
$engine.register_participant "user-.*&quo=
t;, MgnlParticipant.new
$engine.register_participant "group-.*&qu=
ot;, MgnlParticipant.new
$engine.register_participant "role-.*&quo=
t;, MgnlParticipant.new
- # human participants
+ # human participants
=20
$engine.register_participant "command-.*&=
quot;, MgnlCommandParticipant.new
- # magnolia commands
+ # magnolia commands
=20
$worklist =3D Worklist.new(S_WORKLIST, ac)
=20
@@ -45,23 +45,23 @@
# Opening the service locator to add the get_w=
orklist lookup method.
#
module OpenWFE::OwfeServiceLocator
- def get_worklist
- @application_context[S_WORKLIST]
- end
+ def get_worklist
+ @application_context[S_WORKLIST]
+ end
end
=20
#
# for grabbing the workflow engine very easily=
from the Ruby runtime
#
def get_workflow_engine
- $engine
+ $engine
end
=20
#
# for grabbing the worklist instance very easi=
ly from the Ruby runtime
#
def get_worklist
- $worklist
+ $worklist
end
=20
=20
@@ -72,8 +72,8 @@
# Hooks can, for example, add specific partici=
pant to the workflow engine
#
begin
- require 'workflower/hooks'
+ require 'workflower/hooks'
rescue LoadError
- # no hooks
+ # no hooks
end
=20
--- modules/community/magnolia-module-workflow/branc=
hes/magnolia-module-workflow-openwfe-ruby-3.0/src/main/resources/workflow=
er/worklist.rb 2008-07-18 19:52:16 UTC (rev 16922)
+++ modules/community/magnolia-module-workflow/branches/magnolia-module-w=
orkflow-openwfe-ruby-3.0/src/main/resources/workflower/worklist.rb 2008-0=
7-19 10:56:15 UTC (rev 16923)
@@ -13,8 +13,8 @@
#MgnlContext =3D Java::info.magnolia.context.M=
gnlContext
#Query =3D Java::info.magnolia.cms.core.search=
.Query
#WfConstants =3D Java::info.magnolia.module.wo=
rkflow.WorkflowConstants
- #
- # they are all already loaded in engine.rb
+ #
+ # they are all already loaded in engine.rb
=20
require 'thread'
require 'yaml'
@@ -26,319 +26,338 @@
#
class OpenWFE::InFlowItem
=20
- #
- # Turns the workitem into a Map (hash).
- #
- def toMap
+ #
+ # Turns the workitem into a Map (hash).
+ #
+ def toMap
=20
- m =3D HashMap.new
+ m =3D HashMap.new
=20
- @attributes.each do |k, v|=20
+ @attributes.each do |k, v|=20
=20
- v.each { |kk, vv| m[kk] =3D vv } if k =3D=3D 'pa=
rams'
- # flattening...
+ v.each { |kk, vv| m[kk] =3D vv } if k =3D=3D 'params'
+ # flattening...
=20
- m[k] =3D v
- end
+ m[k] =3D v
+ end
=20
- m[WfConstants::ATT_ID] =3D fei.to_s
- m[WfConstants::ATT_WORKFLOW] =3D fei.workflow_definition_name
- m[WfConstants::ATT_LAST_MODIFIED] =3D @last_modified
+ m[WfConstants::ATT_ID] =3D fei.to_s
+ m[WfConstants::ATT_WFID] =3D fei.wfid
+ m[WfConstants::ATT_WI_ID] =3D fei.workflow_instance_id + "__&qu=
ot; + fei.expression_id
+ m[WfConstants::ATT_WORKFLOW] =3D fei.workflow_definition_name
+ m[WfConstants::ATT_LAST_MODIFIED] =3D @last_modified
=20
- m
- end
+ m
+ end
end
=20
=20
module Workflower
=20
- WORKLIST_WORKSPACE =3D 'Store'
+ WORKLIST_WORKSPACE =3D 'Store'
=20
+ #
+ # Methods formerly gathered in the JCRWorkItemAPI java class...
+ #
+ class Worklist
+ include OpenWFE::ServiceMixin
+ include OpenWFE::OwfeServiceLocator
+
+ def initialize (service_name, application_context)
+
+ service_init service_name, application_context
+
+ @hm =3D ContentRepository.getHierarchyManager(WORKLIST_WORKSPACE)
+
+ raise "failed to get HierarchyManager '#{WORKLIST_WORKSPACE}'=
" \
+ unless @hm
+
+ @mutex =3D Mutex.new
+ end
+
#
- # Methods formerly gathered in the JCRWorkItemAPI java c=
lass...
+ # Stores a workitem in the JCR repo.
#
- class Worklist
- include OpenWFE::ServiceMixin
- include OpenWFE::OwfeServiceLocator
+ def store (workitem)
=20
- def initialize (service_name, application_context)
+ @mutex.synchronize do
=20
- service_init service_name, application_context
+ workitem.touch
=20
- @hm =3D ContentRepository.getHierarchyManager(WO=
RKLIST_WORKSPACE)
-
- raise "failed to get HierarchyManager '#{WORKLIST_WORKS=
PACE}'" \
- unless @hm
-
- @mutex =3D Mutex.new
+ path =3D determine_path workitem.fei
+ begin
+ c =3D @hm.getContent path
+ c.delete if c
+ # erases previous versions of the workitem...
+ rescue Exception =3D> e
+ ldebug { "store() #{path} did not exist" }
end
=20
- #
- # Stores a workitem in the JCR repo.
- #
- def store (workitem)
+ c =3D ContentUtil.createPath(@hm, path, ItemType::WOR=
KITEM)
=20
- @mutex.synchronize do
+ workitem.attributes[WfConstants::ATT_WORKITEM_PATH] =3D=
path
+ # as a convenience, store the path in the=20
+ # workitem attributes as well
=20
- workitem.touch
+ vf =3D c.getJCRNode.getSession.getValueFactory
=20
- path =3D determine_path workitem.fei
- begin
- c =3D @hm.getContent path
- c.delete if c
- # erases previous versions of the workitem...
- rescue Exception =3D> e
- ldebug { "store() #{path} did not exist" }
- end
+ c.createNodeData(
+ WfConstants::NODEDATA_ID,=20
+ vf.createValue(workitem.fei.to_s))
+ c.createNodeData(
+ WfConstants::NODEDATA_WFID,
+ vf.createValue(workitem.fei.wfid))
+ c.createNodeData(
+ WfConstants::NODEDATA_PATH,
+ vf.createValue(workitem.path))
+ c.createNodeData(
+ WfConstants::NODEDATA_PARTICIPANT,=20
+ vf.createValue(workitem.participant_name))
=20
- c =3D ContentUtil.createPath(@hm, path, Item=
Type::WORKITEM)
+ assign_to =3D workitem\
+ .attributes[WfConstants::ATTRIBUTE_ASSIGN_TO]
=20
- workitem.attributes[WfConstants::ATT_WORKITE=
M_PATH] =3D path
- # as a convenience, store the path in the=20
- # workitem attributes as well
+ c.createNodeData(
+ WfConstants::ATTRIBUTE_ASSIGN_TO,
+ vf.createValue(assign_to)) if assign_to
=20
- vf =3D c.getJCRNode.getSession.getValueFacto=
ry
+ #
+ # for now, dump the workitem as yaml stuff...
=20
- c.createNodeData(
- WfConstants::NODEDATA_ID,=20
- vf.createValue(workitem.fei.to_s))
- c.createNodeData(
- WfConstants::NODEDATA_WFID,
- vf.createValue(workitem.fei.wfid))
- c.createNodeData(
- WfConstants::NODEDATA_PATH,
- vf.createValue(workitem.path))
- c.createNodeData(
- WfConstants::NODEDATA_PARTICIPANT,=20
- vf.createValue(workitem.participant_name))
+ # TODO : use an XPATH-friendlier encoding scheme
=20
- assign_to =3D workitem\
- .attributes[WfConstants::ATTRIBUTE_ASSIGN_TO]
+ c.createNodeData(
+ WfConstants::NODEDATA_VALUE,
+ vf.createValue(YAML.dump(workitem)))
=20
- c.createNodeData(
- WfConstants::ATTRIBUTE_ASSIGN_TO,
- vf.createValue(assign_to)) if assign_to
+ @hm.save
=20
- #
- # for now, dump the workitem as yaml stuff...
+ linfo { "store() saved workitem at #{path}"=
}
+ end
+ end
=20
- # TODO : use an XPATH-friendlier encoding sc=
heme
+ #
+ # Removes the workitem from the worklist and proceeds it to the engi=
ne
+ #
+ # This method has to be called, not the one from the engine.
+ #
+ def proceed_flow (sfei, action, comment)
=20
- c.createNodeData(
- WfConstants::NODEDATA_VALUE,
- vf.createValue(YAML.dump(workitem)))
+ linfo { "proceed_flow() for '#{sfei}'" }
=20
- @hm.save
+ fei =3D OpenWFE::FlowExpressionId.from_s sfei
+ wi =3D get_worklist.fetch fei
=20
- linfo { "store() saved workitem at #{pa=
th}" }
- end
- end
+ raise "no workitem found for '#{sfei}'" unles=
s wi
=20
- #
- # Removes the workitem from the worklist and proceeds it to the =
engine
- #
- # This method has to be called, not the one from the engine.
- #
- def proceed_flow (sfei, action, comment)
+ get_worklist.remove fei
+ # removes workitem from JCR storage
=20
- linfo { "proceed_flow() for '#{sfei}'"=
}
+ wi.touch=20
+ # setting last_modified to now
=20
- fei =3D OpenWFE::FlowExpressionId.from_s sfei
- wi =3D get_worklist.fetch fei
+ wi.attributes.delete Context::ATTRIBUTE_EXCEPTION
+ wi.attributes.delete Context::ATTRIBUTE_MESSAGE
=20
- raise "no workitem found for '#{sfei}'"=
; unless wi
+ wi.attributes[WfConstants::ATTRIBUTE_ACTION] =3D \
+ action
+ wi.attributes[WfConstants::ATTRIBUTE_USERNAME] =3D \
+ MgnlContext.getUser.getName
=20
- get_worklist.remove fei
- # removes workitem from JCR storage
+ wi.attributes[Context::ATTRIBUTE_COMMENT] =3D comment \
+ if comment and comment !=3D ''
=20
- wi.touch=20
- # setting last_modified to now
+ get_engine.proceed wi
+ end
=20
- wi.attributes.delete Context::ATTRIBUTE_EXCEPTIO=
N
- wi.attributes.delete Context::ATTRIBUTE_MESSAGE
+ def remove (fei)
=20
- wi.attributes[WfConstants::ATTRIBUTE_ACTION] =3D=
\
- action
- wi.attributes[WfConstants::ATTRIBUTE_USERNAME] =3D \
- MgnlContext.getUser.getName
+ @mutex.synchronize do
=20
- wi.attributes[Context::ATTRIBUTE_COMMENT] =3D co=
mment \
- if comment and comment !=3D ''
+ begin
=20
- get_engine.proceed wi
- end
+ c =3D fetch_content fei
=20
- def remove (fei)
+ c.delete
+ @hm.save
=20
- @mutex.synchronize do
+ ldebug { "remove() removed workitem #{fei}&qu=
ot; }
=20
- c =3D fetch_content fei
- c.delete
- @hm.save
- end
+ rescue Exception =3D> e
=20
- ldebug { "store() removed workitem #{fei}&=
quot; }
+ linfo { "remove() can't remove 'missing' worki=
tem #{fei}" }
end
+ end
+ end
=20
- #
- # Returns the workitem with the given fei
- #
- def fetch (fei)
+ #
+ # Returns the workitem with the given fei
+ #
+ def fetch (fei)
=20
- fei =3D OpenWFE::FlowExpressionId.from_s(fei) if=
fei.is_a?(String)
+ fei =3D OpenWFE::FlowExpressionId.from_s(fei) if fei.is=
_a?(String)
=20
- fetch_from_content(fetch_content(fei))
- end
+ fetch_from_content(fetch_content(fei))
+ end
=20
- def get_user_inbox (username)
+ def get_user_inbox (username)
=20
- current_user =3D MgnlContext.getUser
+ current_user =3D MgnlContext.getUser
=20
- s =3D '//*[(@assignTo=3D"'+username+'"=
) or '+
- '(@participant=3D"user-'+username+'" and not(@=
assignTo))'
+ s =3D '//*[(@assignTo=3D"'+username+'") or '+
+ '(@participant=3D"user-'+username+'" and not(@assignTo=
))'
=20
- current_user.getGroups.each do |groupname|
- s << ' or (@participant=3D"group-'+groupname+=
'")'
- end
- current_user.getRoles.each do |rolename|
- s << ' or (@participant=3D"role-'+rolename+'&=
quot;)'
- end
- s << ']'
+ current_user.getGroups.each do |groupname|
+ s << ' or (@participant=3D"group-'+groupname+'")=
'
+ end
+ current_user.getRoles.each do |rolename|
+ s << ' or (@participant=3D"role-'+rolename+'")'
+ end
+ s << ']'
=20
- query s
- end
+ query s
+ end
=20
- def get_group_inbox (groupname)
+ def get_group_inbox (groupname)
=20
- query '//*[@participant=3D"group-'+groupnam=
e+'"]'
- end
+ query '//*[@participant=3D"group-'+groupname+'&quo=
t;]'
+ end
=20
- def get_role_inbox (rolename)
+ def get_role_inbox (rolename)
=20
- query '//*[@participant=3D"role-'+rolename+=
'"]'
- end
+ query '//*[@participant=3D"role-'+rolename+'"=
]'
+ end
=20
- #
- # Returns a array of workflow instance ids. Those are the ids of
- # the workflow instances associated with the given path.
- #
- def get_workflow_ids (path)
+ #
+ # returns all the workitems
+ #
+ def get_workitems
=20
- query '//*[@path=3D"'+path+'"]'
+ query '//*[@participant]'
+ end
=20
- # TODO : terminate me
- end
+ #
+ # Returns a array of workflow instance ids. Those are the ids of
+ # the workflow instances associated with the given path.
+ #
+ def get_workflow_ids (path)
=20
- #
- # Returns the JCR path of the workitem (with that fei).
- #
- def determine_path (fei)
+ query '//*[@path=3D"'+path+'"]'
=20
- fei =3D OpenWFE::FlowExpressionId.from_s(fei) if=
fei.is_a?(String)
+ # TODO : terminate me
+ end
=20
- wfid =3D fei.parent_workflow_instance_id
- a_wfid =3D get_wfid_generator.split_wfid(wfid)
+ #
+ # Returns the JCR path of the workitem (with that fei).
+ #
+ def determine_path (fei)
=20
- path =3D '/'
- path << a_wfid[-2]
- path << '/'
- path << a_wfid[-1]
- path << '/'
- path << OpenWFE.ensure_for_filename(fei.wfname)
- path << '__'
- path << fei.workflow_instance_id
- path << '__'
- path << fei.expression_id
+ fei =3D OpenWFE::FlowExpressionId.from_s(fei) if fei.is=
_a?(String)
=20
- path
- end
+ wfid =3D fei.parent_workflow_instance_id
+ a_wfid =3D get_wfid_generator.split_wfid(wfid)
=20
- #
- # Returns the path of the content item pointed at by the workite=
m
- # (given by its string flow expression id).
- #
- def get_content_path (sfei)
+ path =3D '/'
+ path << a_wfid[-2]
+ path << '/'
+ path << a_wfid[-1]
+ path << '/'
+ path << OpenWFE.ensure_for_filename(fei.wfname)
+ path << '__'
+ path << fei.workflow_instance_id
+ path << '__'
+ path << fei.expression_id
=20
- workitem =3D fetch sfei
- workitem.path
- end
+ path
+ end
=20
- #
- # Fetches a workitem a returns the content of the given field.
- # Complex designations are possible, for example "customers=
.0.name" or
- # "car.motor.combustion_chambers.2"
- #
- def lookup_workitem_field (sfei, fieldname)
+ #
+ # Returns the path of the content item pointed at by the workitem
+ # (given by its string flow expression id).
+ #
+ def get_content_path (sfei)
=20
- ldebug { "lookup_workitem_field() at #{sfei=
}" }
+ workitem =3D fetch sfei
+ workitem.path
+ end
=20
- wi =3D fetch sfei
- wi.lookup_attribute fieldname
- end
+ #
+ # Fetches a workitem a returns the content of the given field.
+ # Complex designations are possible, for example "customers.0.n=
ame" or
+ # "car.motor.combustion_chambers.2"
+ #
+ def lookup_workitem_field (sfei, fieldname)
=20
- #
- # Returns the fields (attributes) of the workitem given by the
- # string version of its flow expression id.
- #
- def get_workitem_fields (sfei)
+ ldebug { "lookup_workitem_field() at #{sfei}"=
}
=20
- wi =3D fetch sfei
- wi.attributes
- end
+ wi =3D fetch sfei
+ wi.lookup_attribute fieldname
+ end
=20
- protected
+ #
+ # Returns the fields (attributes) of the workitem given by the
+ # string version of its flow expression id.
+ #
+ def get_workitem_fields (sfei)
=20
- #
- # Extracts the workitem in the given Content instance
- #
- def fetch_from_content (content)
+ wi =3D fetch sfei
+ wi.attributes
+ end
=20
- return nil unless content
+ protected
=20
- s =3D content.getNodeData(WfConstants::NODED=
ATA_VALUE).getString
- YAML.load(s)
- end
+ #
+ # Extracts the workitem in the given Content instance
+ #
+ def fetch_from_content (content)
=20
- #
- # Fetches the content node for the given 'flow expression id=
'
- #
- def fetch_content (fei)
+ return nil unless content
=20
- path =3D determine_path fei
- @hm.getContent path
- end
+ s =3D content.getNodeData(WfConstants::NODEDATA_VALUE=
).getString
+ YAML.load(s)
+ end
=20
- def query (xpath_query_string)
+ #
+ # Fetches the content node for the given 'flow expression id'
+ #
+ def fetch_content (fei)
=20
- ldebug { "query() : #{xpath_query_strin=
g}" }
+ path =3D determine_path fei
+ @hm.getContent path
+ # this will throw an error if the path is missing :(
+ end
=20
- qm =3D MgnlContext.getSystemContext.getQuery=
Manager(
- WORKLIST_WORKSPACE)
- #qm =3D MgnlContext.getInstance.getQueryManager(
- # WORKLIST_WORKSPACE)
+ def query (xpath_query_string)
=20
- q =3D qm.createQuery xpath_query_string, Que=
ry::XPATH
+ linfo { "query() : #{xpath_query_string}" }
=20
- @mutex.synchronize do
+ qm =3D MgnlContext.getSystemContext.getQueryManager(
+ WORKLIST_WORKSPACE)
+ #qm =3D MgnlContext.getInstance.getQueryManager(
+ # WORKLIST_WORKSPACE)
=20
- result =3D q.execute
- result =3D result.getContent(WfConstants::NODENAME_W=
ORKITEM)
+ q =3D qm.createQuery xpath_query_string, Query::XPATH
=20
- ldebug { "query() found #{result.si=
ze} results" }
+ @mutex.synchronize do
=20
- workitems =3D java.util.ArrayList.new
+ result =3D q.execute
+ result =3D result.getContent(WfConstants::NODENAME_WORKITEM)
=20
- result.each do |c|
+ linfo { "query() found #{result.size} results&=
quot; }
=20
- next unless @hm.isExist(c.getHandle)
+ workitems =3D java.util.ArrayList.new
=20
- workitem =3D fetch_from_content c
+ result.each do |c|
=20
- workitems.add(workitem.toMap)
- end
+ next unless @hm.isExist(c.getHandle)
=20
- workitems
- end
- end
- end
+ workitem =3D fetch_from_content c
+
+ workitems.add(workitem.toMap)
+ end
+
+ workitems
+ end
+ end
+ end
end