org.processmining.framework.models.petrinet.algorithms.logReplay
Class ReplayedLogReader

java.lang.Object
  extended by org.processmining.framework.models.petrinet.algorithms.logReplay.ReplayedLogReader
Direct Known Subclasses:
DiagnosticLogReader, ExtendedLogReader

public class ReplayedLogReader
extends java.lang.Object

A log reader involved in the log replay analysis method. It can be traversed with methods like reset(), hasNext(), and next() like with the LogReader class. Furthermore is used to extend the log reader interface with some more log access related methods, like finding a process instance by its ID.
Note that this implies that the whole log is kept in memory (this is not the case for the LogReader class), which can be problematic as soon as the log file becomes very big. However, since this class is intended to derive subclasses which will store diagnostic information for each of the traces this will happen anyway.

Author:
arozinat
See Also:
ReplayedLogTrace, ReplayedPetriNet, LogReplayAnalysisMethod

Field Summary
protected  java.util.Iterator logIterator
          Step through the diagnostic log offering access to the diagnostic log traces via methods like reset(), hasNext(), and next().
protected  java.util.HashMap logTraceMap
          Alternative data structure directly accessing all the diagnostic log traces contained in that log by their ID (i.e., their name).
protected  java.util.ArrayList logTraces
          The list of diagnostic log traces contained in that log.
protected  LogReader originalLogReader
          The encapsulated original log reader, which was used to create this enhanced log reader.
protected  java.util.ArrayList sortedTraceList
          List containing all log traces sorted with respect to the number of process instances represented by them in a descending manner (i.e., the trace representing the most process instances comes first, the one representing the least comes last).
 
Constructor Summary
ReplayedLogReader(LogReader logReader)
          Construct an enhanced log reader by wrapping the original one.
 
Method Summary
protected  ReplayedLogTrace createReplayedLogTrace(ProcessInstance pi)
          Wrappes the given process instance in a ReplayedLogTrace.
 java.util.ArrayList getDiagnosticLogTraces()
          Get the list of diagnostic log traces contained in that log.
 int getIndexOfLogTrace(java.lang.String id)
          Determines the index of the given trace with respect to the ordering of the log file.
 LogReader getLogReader()
          Returns the encapsulated log reader.
 LogSummary getLogSummary()
          Retrieves the log summary from the internally held LogReader to, e.g., find the corresponding log event for an audit trail entry.
 ReplayedLogTrace getLogTrace(java.lang.String id)
          Finds a specific trace in the log.
 java.util.ArrayList getLogTraceIDs()
          Creates a list of all the log trace IDs contained in the log.
 java.util.ArrayList getMostFrequentTraces(int perCentage)
          Gets the most frequent log traces determined by the given percentage from the log.
 int getOverallNumberOfProcessInstances()
          Returns the number of process instances represented by the aggregrated log traces (taking the number of instances represented by each trace into account).
 int getPercentage(java.util.ArrayList selectedTraces)
          Calculates the (rounded) percentage of process instances represented by the given log traces with respect to the whole log.
 int getSizeOfLog()
          Returns the number of traces contained in the log.
 boolean hasNext()
          Determines whether there is a log trace left to be read by the diagnostic log reader (i.e., the iterator is not yet located after the last element).
 ReplayedLogTrace next()
          Reads the current diagnostic log trace and move to the next one (i.e., fetch the next element and place the iterator in behind it).
 void reset()
          Resets the diagnostic log reader to its start position (i.e., the iterator is placed in front of the first element).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

originalLogReader

protected LogReader originalLogReader
The encapsulated original log reader, which was used to create this enhanced log reader.


logTraces

protected java.util.ArrayList logTraces
The list of diagnostic log traces contained in that log. They can be accessed via corresponding iterating methods like reset(), hasNext(), and next(), and the ordering corresponds to the ordering of the log.


logTraceMap

protected java.util.HashMap logTraceMap
Alternative data structure directly accessing all the diagnostic log traces contained in that log by their ID (i.e., their name).


sortedTraceList

protected java.util.ArrayList sortedTraceList
List containing all log traces sorted with respect to the number of process instances represented by them in a descending manner (i.e., the trace representing the most process instances comes first, the one representing the least comes last). If there are two traces representing the same number of instances, their ordering is arbitrary.


logIterator

protected java.util.Iterator logIterator
Step through the diagnostic log offering access to the diagnostic log traces via methods like reset(), hasNext(), and next().

Constructor Detail

ReplayedLogReader

public ReplayedLogReader(LogReader logReader)
Construct an enhanced log reader by wrapping the original one. Furthermore the diagnostic data structures are initialized by wrapping all process instances in a diagnostic log trace. Note that it is assumed here that the log might have been pre-processed and similar instances got summarized (since they share the same diagnostic results), i.e., that the log has already been aggregated on a logical level.

Parameters:
logReader - the original log reader
Method Detail

createReplayedLogTrace

protected ReplayedLogTrace createReplayedLogTrace(ProcessInstance pi)
Wrappes the given process instance in a ReplayedLogTrace.
This method should be overridden in order to define plugin-specific diagnostic data structures for log traces.

Parameters:
pi - the process instance to be wrapped
Returns:
the newly created log trace data structure

getDiagnosticLogTraces

public java.util.ArrayList getDiagnosticLogTraces()
Get the list of diagnostic log traces contained in that log.

Returns:
The list of log traces.

getLogReader

public LogReader getLogReader()
Returns the encapsulated log reader.

Returns:
the original log reader

reset

public void reset()
Resets the diagnostic log reader to its start position (i.e., the iterator is placed in front of the first element).
Note that here the iteration is not over the original log reader (see getLogReader() but over the log traces enhanced with diagnostic information.


hasNext

public boolean hasNext()
Determines whether there is a log trace left to be read by the diagnostic log reader (i.e., the iterator is not yet located after the last element).
Note that here the iteration is not over the original log reader (see getLogReader() but over the log traces enhanced with diagnostic information.

Returns:
true if there is a trace to be read, false otherwise

next

public ReplayedLogTrace next()
Reads the current diagnostic log trace and move to the next one (i.e., fetch the next element and place the iterator in behind it). Note that the existance of an element in that position should be checked before using logicalHasNext().
Note that here the iteration is not over the original log reader (see getLogReader() but over the log traces enhanced with diagnostic information.

Returns:
the current diagnostic log trace

getLogTrace

public ReplayedLogTrace getLogTrace(java.lang.String id)
Finds a specific trace in the log.

Parameters:
id - the ID of the trace (accessible by getName()) in the log
Returns:
the specified diagnostic log trace if found, null otherwise

getIndexOfLogTrace

public int getIndexOfLogTrace(java.lang.String id)
Determines the index of the given trace with respect to the ordering of the log file.

Parameters:
id - the ID of the trace (accessible by getName()) in the log
Returns:
the index of the trace, if found. -1 otherwise

getLogTraceIDs

public java.util.ArrayList getLogTraceIDs()
Creates a list of all the log trace IDs contained in the log.

Returns:
an ArrayList containing the IDs as Strings

getMostFrequentTraces

public java.util.ArrayList getMostFrequentTraces(int perCentage)
Gets the most frequent log traces determined by the given percentage from the log. While doing so the percentage might not be matched exactly as each trace can represent a number of process instances. The value is then rounded up and can be retrieved using the method getPerCentage.

Parameters:
perCentage - the percentage ranging from 1 to 100
Returns:
a list of trace IDs referencing the most frequent instances in the log

getPercentage

public int getPercentage(java.util.ArrayList selectedTraces)
Calculates the (rounded) percentage of process instances represented by the given log traces with respect to the whole log.

Parameters:
selectedTraces - the log traces (specified by their ID) for which the percentage is to be calculated
Returns:
the percentage ranging from 0 (empty list) to 100

getSizeOfLog

public int getSizeOfLog()
Returns the number of traces contained in the log.

Returns:
the number of log traces

getOverallNumberOfProcessInstances

public int getOverallNumberOfProcessInstances()
Returns the number of process instances represented by the aggregrated log traces (taking the number of instances represented by each trace into account).

Returns:
the number of process instances represented

getLogSummary

public LogSummary getLogSummary()
Retrieves the log summary from the internally held LogReader to, e.g., find the corresponding log event for an audit trail entry.

Returns:
LogSummary the LogSummary of the log