lib/openwfe/flowexpressionid.rb in openwferu-0.9.13 vs lib/openwfe/flowexpressionid.rb in openwferu-0.9.14
- old
+ new
@@ -28,12 +28,10 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#++
#
-# $Id: workitem.rb 3555 2006-11-13 00:47:53Z jmettraux $
-#
#
# "hecho en Costa Rica"
# enhanced in Japan
#
@@ -75,10 +73,14 @@
alias :wfid :workflow_instance_id
alias :wfid= :workflow_instance_id=
alias :expid :expression_id
alias :expid= :expression_id=
+ alias :expname :expression_name
+ alias :wfname :workflow_definition_name
+ alias :wfrevision :workflow_definition_revision
+
#
# Overrides the classical to_s()
#
def to_s ()
"(fei #{@owfe_version} #{@engine_id}/#{@initial_engine_id} #{@workflow_definition_url} #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_name} #{@expression_id})"
@@ -86,29 +88,32 @@
#
# Returns a hash version of this FlowExpressionId instance.
#
def to_h ()
+
h = {}
FIELDS.each { |f| h[f] = instance_eval("@#{f.to_s}") }
h
end
#
# Rebuilds a FlowExpressionId from its Hash representation.
#
def FlowExpressionId.from_h (h)
+
fei = FlowExpressionId.new
FIELDS.each { |f| fei.instance_variable_set("@#{f}", h[f]) }
fei
end
def hash ()
to_s().hash()
end
def == (other)
+
return false if not other.kind_of?(FlowExpressionId)
#return self.to_s == other.to_s
# no perf gain
@@ -145,21 +150,40 @@
return false unless self == o
OpenWFE::starts_with other_fei.expression_id, @expression_id
end
+ #
+ # Returns a deep copy of this FlowExpressionId instance.
+ #
def dup
+
OpenWFE::fulldup(self)
end
alias eql? ==
def to_debug_s
"(fei #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_id} #{@expression_name})"
end
+ #
+ # Returns a very short string representation (fei wfid expid expname).
+ #
def to_short_s
"(fei #{@workflow_instance_id} #{@expression_id} #{@expression_name})"
+ end
+
+ #
+ # Returns a URI escaped string with just the wfid and the expid, like
+ # '20070917-dupibodasa__0.0.1'
+ #
+ # Useful for unique identifier in URIs.
+ #
+ def to_web_s
+
+ eid = expid.gsub("\.", "_")
+ URI.escape("#{workflow_instance_id}__#{eid}")
end
#
# Yet another debugging method. Just returns the sub_instance_id and
# the expression_id, in a string.