Class: XES::Log

Inherits:
Object
  • Object
show all
Extended by:
AttributeAccessor
Defined in:
lib/xes/log.rb

Overview

Log represents log element of XES.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AttributeAccessor

define_attribute

Constructor Details

#initializeLog

Returns a new instance of Log.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/xes/log.rb', line 92

def initialize
  @xes_version = "1.4"
  @xes_features = ""
  @openxes_version = nil
  @xmlns = "http://www.xes-standard.org/"
  @extensions = []
  @event_global = Global.event
  @trace_global = Global.trace
  @classifiers = []
  @attributes = []
  @traces = []
end

Instance Attribute Details

#attributesArray<Attribute>

Returns XES attribute elements.

Returns:

  • (Array<Attribute>)

    XES attribute elements



86
87
88
# File 'lib/xes/log.rb', line 86

def attributes
  @attributes
end

#classifiersArray<Classifier>

Returns XES classifiers.

Returns:



74
75
76
# File 'lib/xes/log.rb', line 74

def classifiers
  @classifiers
end

#concept_nameString

Returns the value of attribute “concept:name”.

Returns:

  • (String)

    the value of attribute “concept:name”



9
# File 'lib/xes/log.rb', line 9

define_attribute "concept:name", "string"

#event_globalArray<Global>

Returns XES global elements for event attributes.

Returns:

  • (Array<Global>)

    XES global elements for event attributes



78
79
80
# File 'lib/xes/log.rb', line 78

def event_global
  @event_global
end

#extensionsArray<Extension>

Returns XES extensions.

Returns:



70
71
72
# File 'lib/xes/log.rb', line 70

def extensions
  @extensions
end

#identity_idString

Returns the value of attribute “identity:id”.

Returns:

  • (String)

    the value of attribute “identity:id”



24
# File 'lib/xes/log.rb', line 24

define_attribute "identity:id", "id"

#lifecycle_modelString

Returns the value of attribute “lifecycle:model”.

Returns:

  • (String)

    the value of attribute “lifecycle:model”



14
# File 'lib/xes/log.rb', line 14

define_attribute "lifecycle:model", "string"

#openxes_versionString

Returns openxes version for faking ProM.

Returns:

  • (String)

    openxes version for faking ProM



62
63
64
# File 'lib/xes/log.rb', line 62

def openxes_version
  @openxes_version
end

#semantic_modelReferenceString

Returns the value of attribute “semantic:modelReference”.

Returns:

  • (String)

    the value of attribute “semantic:modelReference”



19
# File 'lib/xes/log.rb', line 19

define_attribute "semantic:modelReference", "string"

#trace_globalArray<Global>

Returns XES global elements for trace attributes.

Returns:

  • (Array<Global>)

    XES global elements for trace attributes



82
83
84
# File 'lib/xes/log.rb', line 82

def trace_global
  @trace_global
end

#tracesArray<XESTrace>

Returns XES trace elements.

Returns:

  • (Array<XESTrace>)

    XES trace elements



90
91
92
# File 'lib/xes/log.rb', line 90

def traces
  @traces
end

#xes_featuresString

Returns XES features.

Returns:

  • (String)

    XES features



58
59
60
# File 'lib/xes/log.rb', line 58

def xes_features
  @xes_features
end

#xes_versionString

Returns XES version.

Returns:

  • (String)

    XES version



54
55
56
# File 'lib/xes/log.rb', line 54

def xes_version
  @xes_version
end

#xmlnsString

Returns xmlns value.

Returns:

  • (String)

    xmlns value



66
67
68
# File 'lib/xes/log.rb', line 66

def xmlns
  @xmlns
end

Class Method Details

.defaultLog

Create new instance with default values.

Returns:

  • (Log)

    new log instance



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xes/log.rb', line 31

def default
  new.tap do |log|
    log.xes_version = "1.4"
    log.xes_features = "nested-attributes"
    log.openxes_version = "1.0RC7"
    log.extensions = [
      EXTENSION[:concept],
      EXTENSION[:identity],
      EXTENSION[:time],
      EXTENSION[:lifecycle],
      EXTENSION[:organizational],
    ]
    log.classifiers = [
      CLASSIFIER[:mxml_legacy_classifier],
      CLASSIFIER[:event_name],
      CLASSIFIER[:resource]
    ]
  end
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/xes/log.rb', line 137

def ==(other)
  return false unless other.kind_of?(self.class)
  return false unless @xes_version == other.xes_version
  return false unless @xes_features == other.xes_features
  return false unless @openxes_version == other.openxes_version
  return false unless @xmlns == other.xmlns
  return false unless @extensions == other.extensions
  return false unless @event_global == other.event_global
  return false unless @trace_global == other.trace_global
  return false unless @classifiers == other.classifiers
  return false unless @attributes == other.attributes
  return false unless @traces == other.traces
  return true
end

#formatREXML::Element

Format as a XML element.

Returns:

  • (REXML::Element)

    XML element

Raises:

  • FormatError format error when the log is formattable



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/xes/log.rb', line 119

def format
  raise FormatError.new(self) unless formattable?

  REXML::Element.new("log").tap do |log|
    log.attributes["xes.version"] = @xes_version.to_s if @xes_version
    log.attributes["xes.features"] = @xes_features.to_s if @xes_features
    log.attributes["openxes.version"] = @openxes_version.to_s if @openxes_version
    log.attributes["xmlns"] = @xmlns.to_s if @xmlns
    @extensions.each {|ext| log.elements << ext.format if ext.formattable?}
    @classifiers.each {|classifier| log.elements << classifier.format if classifier.formattable?}
    log.elements << @event_global.format if @event_global.formattable?
    log.elements << @trace_global.format if @trace_global.formattable?
    @attributes.each {|attribute| log.elements << attribute.format if attribute.formattable?}
    @traces.each {|trace| log.elements << trace.format if trace.formattable?}
  end
end

#formattable?Boolean

Return true if the element is formattable.

Returns:

  • (Boolean)

    true if the element is formattable



109
110
111
# File 'lib/xes/log.rb', line 109

def formattable?
  @traces.any? {|trace| trace.formattable?}
end

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



154
155
156
# File 'lib/xes/log.rb', line 154

def hash
  @attributes.hash + @events.hash
end