Package org.processmining.log.utils
Class XUtils
- java.lang.Object
-
- org.processmining.log.utils.XUtils
-
public final class XUtils extends java.lang.ObjectCommonly used methods for handling XES logs- Author:
- F. Mannhardt
-
-
Field Summary
Fields Modifier and Type Field Description static org.deckfour.xes.classification.XEventClassINVISIBLEACTIVITYThe invisible activity.static org.deckfour.xes.classification.XEventClassMOVEONMODELACTIVITYThe move-on-model activity.static org.deckfour.xes.classification.XEventClassifierSTANDARDCLASSIFIER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassignConceptName(org.deckfour.xes.model.XEvent event, java.lang.String name)static voidassignConceptName(org.deckfour.xes.model.XLog log, java.lang.String name)static voidassignConceptName(org.deckfour.xes.model.XTrace trace, java.lang.String name)static voidassignTimestamp(org.deckfour.xes.model.XEvent event, long timestamp)static voidassignTimestamp(org.deckfour.xes.model.XEvent event, java.util.Date timestamp)static org.deckfour.xes.model.XAttributecloneAttributeWithChangedKey(org.deckfour.xes.model.XAttribute oldAttribute, java.lang.String newKey)Creates a deep clone of theXAttributewith the same value, but a changed key.static org.deckfour.xes.model.XAttributecloneAttributeWithChangedKeyWithFactory(org.deckfour.xes.model.XAttribute oldAttribute, java.lang.String newKey, org.deckfour.xes.factory.XFactory factory)Creates a deep clone of theXAttributewith the same value, but a changed key.static org.deckfour.xes.model.XLogcloneLogWithoutClassifier(org.deckfour.xes.model.XLog log)Creates a deep clone of the supplied event log without classifiersstatic org.deckfour.xes.model.XLogcloneLogWithoutGlobals(org.deckfour.xes.model.XLog log)Creates a deep clone of the supplied event log without globalsstatic org.deckfour.xes.model.XLogcloneLogWithoutGlobalsAndClassifiers(org.deckfour.xes.model.XLog log)Creates a deep clone of the supplied event log without globals and without classifiersstatic booleancontainsEventWithName(java.lang.String eventName, org.deckfour.xes.model.XTrace trace)static voidcopyLogMetadata(org.deckfour.xes.model.XLog oldLog, org.deckfour.xes.model.XLog newLog)Copies the meta data (classifiers, globals, extension) from the oldLog to the newLog.static <T extends TraceVariant<?>>
intcountVariants(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, com.google.common.base.Function<org.deckfour.xes.model.XTrace,T> variantFunction)static intcountVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClasses eventClasses)static intcountVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClassifier classifier)static org.deckfour.xes.model.XAttributecreateAttribute(java.lang.String attributeName, java.lang.Object attributeValue)Creates an appropriateXAttribute, decided on the type of the parameter atttributeValue.static org.deckfour.xes.model.XAttributecreateAttribute(java.lang.String attributeName, java.lang.Object attributeValue, org.deckfour.xes.extension.XExtension extension)Creates an appropriateXAttribute, deciding by the type of the parameter atttributeValue.static org.deckfour.xes.model.XAttributecreateAttributeWithFactory(java.lang.String attributeName, java.lang.Object attributeValue, org.deckfour.xes.factory.XFactory factory)Creates an appropriateXAttribute, decided on the type of the parameter atttributeValue.static org.deckfour.xes.classification.XEventClassescreateEventClasses(org.deckfour.xes.classification.XEventClassifier classifier, java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)Obtain the event classes from the supplied collection of traces using the specified classifier.static org.deckfour.xes.model.XLogcreateLogFrom(org.deckfour.xes.model.XLog oldLog)Creates a new log with attributes and meta data (classifiers, globals, extension) from the oldLog.static org.deckfour.xes.model.XLogcreateLogFrom(org.deckfour.xes.model.XLog oldLog, org.deckfour.xes.factory.XFactory factory)Creates a new log with attributes and meta data (classifiers, globals, extension) from the oldLog.static java.util.NavigableSet<java.lang.String>getAllEventNamesSorted(org.deckfour.xes.model.XLog log)static java.lang.Class<?>getAttributeClass(org.deckfour.xes.model.XAttribute attribute)Returns the Java class of theXAttributevalue.static java.lang.ObjectgetAttributeValue(org.deckfour.xes.model.XAttribute attribute)Returns the value of theXAttributeasObjectstatic java.lang.StringgetConceptName(org.deckfour.xes.model.XAttributable element)Returns the event name.static org.deckfour.xes.classification.XEventClassifiergetDefaultClassifier(org.deckfour.xes.model.XLog log)Added by Eric Verbeek Returns a default classifier to use with an event log.static java.util.Set<java.lang.String>getEventAttributeKeys(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)static java.util.Map<java.lang.String,java.lang.Class<?>>getEventAttributeTypes(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)static org.deckfour.xes.model.XEventgetLatestEventWithName(java.lang.String eventName, org.deckfour.xes.model.XTrace trace)static java.util.List<org.deckfour.xes.classification.XEventClassifier>getStandardAndLogDefinedEventClassifiers(org.deckfour.xes.model.XLog log)Returns both the event classifiers defined by the XLog, as well as the three standard classifiersXLogInfoImpl.NAME_CLASSIFIER,XLogInfoImpl.RESOURCE_CLASSIFIERandXLogInfoImpl.STANDARD_CLASSIFIER.static java.util.DategetTimestamp(org.deckfour.xes.model.XEvent event)Returns the event time.static java.util.Set<java.lang.String>getTraceAttributeKeys(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)static java.util.Map<java.lang.String,java.lang.Class<?>>getTraceAttributeTypes(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)static <T extends TraceVariant<E>,E>
com.google.common.collect.ImmutableListMultimap<T,org.deckfour.xes.model.XTrace>getVariants(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, com.google.common.base.Function<org.deckfour.xes.model.XTrace,T> variantFunction)Groups traces in aListMultimapby a genericFunction.static com.google.common.collect.ImmutableListMultimap<TraceVariantByClassifier,org.deckfour.xes.model.XTrace>getVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClasses eventClasses)Groups traces in aListMultimapby their event classification.static com.google.common.collect.ImmutableListMultimap<TraceVariantByClassifier,org.deckfour.xes.model.XTrace>getVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClassifier classifier)Groups traces in aListMultimapby their event classification.static booleanisSameType(org.deckfour.xes.model.XAttribute obj1, org.deckfour.xes.model.XAttribute obj2)Checks whether both objects implement the same XAttribute interfacestatic booleanisStandardExtensionAttribute(org.deckfour.xes.model.XAttribute attribute)Returns whether the attribute key matches one of the registered standard extensions of XES.static org.deckfour.xes.model.XLogloadLog(java.io.File file)static org.deckfour.xes.model.XLogloadLog(java.io.InputStream is)static org.deckfour.xes.model.XLogloadLog(java.lang.String string)static voidputAttribute(org.deckfour.xes.model.XAttributable attributable, org.deckfour.xes.model.XAttribute attribute)Adds a singleXAttributeto the suppliedXAttributable.static voidputAttributes(org.deckfour.xes.model.XAttributable attributable, java.lang.Iterable<org.deckfour.xes.model.XAttribute> attributes)Adds multipleXAttributeto the suppliedXAttributable.static java.lang.StringrenameLogWithProMLabel(org.processmining.framework.plugin.PluginContext context, org.deckfour.xes.model.XLog log)Rename the XLog with the label for the ProM provided objectstatic voidsaveLog(org.deckfour.xes.model.XLog log, java.io.File file)static voidsaveLogGzip(org.deckfour.xes.model.XLog log, java.io.File file)static voidsaveLogPlain(org.deckfour.xes.model.XLog log, java.io.File file)static voidsaveLogWithSerializer(org.deckfour.xes.model.XLog log, java.io.File file, org.deckfour.xes.out.XSerializer logSerializer)static java.lang.StringstringifyAttributes(org.deckfour.xes.model.XAttributeMap map)static java.lang.StringstringifyEvent(org.deckfour.xes.model.XEvent e)static java.lang.StringstringifyEvent(org.deckfour.xes.model.XEvent e, org.deckfour.xes.classification.XEventClassifier classifier)static java.lang.StringstringifyLog(org.deckfour.xes.model.XLog l)static java.lang.StringstringifyLog(org.deckfour.xes.model.XLog l, org.deckfour.xes.classification.XEventClassifier classifier)static java.lang.StringstringifyTrace(org.deckfour.xes.model.XTrace t)static java.lang.StringstringifyTrace(org.deckfour.xes.model.XTrace t, org.deckfour.xes.classification.XEventClassifier classifier)
-
-
-
Field Detail
-
INVISIBLEACTIVITY
public static final org.deckfour.xes.classification.XEventClass INVISIBLEACTIVITY
The invisible activity. Activity to be used for mapping silent transitions on.
-
MOVEONMODELACTIVITY
public static final org.deckfour.xes.classification.XEventClass MOVEONMODELACTIVITY
The move-on-model activity. Activity to be used for mapping transition on that are not covered by the log at hand. As such, they will always have to be a move-on-model.
-
STANDARDCLASSIFIER
public static final org.deckfour.xes.classification.XEventClassifier STANDARDCLASSIFIER
-
-
Method Detail
-
isStandardExtensionAttribute
public static boolean isStandardExtensionAttribute(org.deckfour.xes.model.XAttribute attribute)
Returns whether the attribute key matches one of the registered standard extensions of XES.- Parameters:
attribute-- Returns:
- whether the attribute is one of the standard extension attributes
-
getDefaultClassifier
public static org.deckfour.xes.classification.XEventClassifier getDefaultClassifier(org.deckfour.xes.model.XLog log)
Added by Eric Verbeek Returns a default classifier to use with an event log. If the log contains classifiers, then the first classifier is returned. Otherwise, the standard MXML classifier is constructed and returned.- Parameters:
log-- Returns:
- A default classifier to use with the provided log.
-
getStandardAndLogDefinedEventClassifiers
public static java.util.List<org.deckfour.xes.classification.XEventClassifier> getStandardAndLogDefinedEventClassifiers(org.deckfour.xes.model.XLog log)
Returns both the event classifiers defined by the XLog, as well as the three standard classifiersXLogInfoImpl.NAME_CLASSIFIER,XLogInfoImpl.RESOURCE_CLASSIFIERandXLogInfoImpl.STANDARD_CLASSIFIER.- Parameters:
log-- Returns:
- a list of event classifiers that can be used on the log
-
getConceptName
public static java.lang.String getConceptName(org.deckfour.xes.model.XAttributable element)
Returns the event name.- Parameters:
element-- Returns:
- the value of the "concept:name" attribute or "null"
-
assignConceptName
public static void assignConceptName(org.deckfour.xes.model.XLog log, java.lang.String name)
-
assignConceptName
public static void assignConceptName(org.deckfour.xes.model.XEvent event, java.lang.String name)
-
assignConceptName
public static void assignConceptName(org.deckfour.xes.model.XTrace trace, java.lang.String name)
-
getTimestamp
public static java.util.Date getTimestamp(org.deckfour.xes.model.XEvent event)
Returns the event time.- Parameters:
event-- Returns:
- the value of the "time:timestamp" attribute or "null"
-
assignTimestamp
public static void assignTimestamp(org.deckfour.xes.model.XEvent event, java.util.Date timestamp)
-
assignTimestamp
public static void assignTimestamp(org.deckfour.xes.model.XEvent event, long timestamp)
-
loadLog
public static org.deckfour.xes.model.XLog loadLog(java.lang.String string) throws java.io.UnsupportedEncodingException, java.lang.Exception- Throws:
java.io.UnsupportedEncodingExceptionjava.lang.Exception
-
loadLog
public static org.deckfour.xes.model.XLog loadLog(java.io.File file) throws java.io.FileNotFoundException, java.lang.Exception- Throws:
java.io.FileNotFoundExceptionjava.lang.Exception
-
loadLog
public static org.deckfour.xes.model.XLog loadLog(java.io.InputStream is) throws java.lang.Exception- Throws:
java.lang.Exception
-
saveLog
public static void saveLog(org.deckfour.xes.model.XLog log, java.io.File file) throws java.io.FileNotFoundException, java.io.IOException- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
saveLogPlain
public static void saveLogPlain(org.deckfour.xes.model.XLog log, java.io.File file) throws java.io.FileNotFoundException, java.io.IOException- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
saveLogGzip
public static void saveLogGzip(org.deckfour.xes.model.XLog log, java.io.File file) throws java.io.FileNotFoundException, java.io.IOException- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
saveLogWithSerializer
public static void saveLogWithSerializer(org.deckfour.xes.model.XLog log, java.io.File file, org.deckfour.xes.out.XSerializer logSerializer) throws java.io.FileNotFoundException, java.io.IOException- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
containsEventWithName
public static boolean containsEventWithName(java.lang.String eventName, org.deckfour.xes.model.XTrace trace)
-
getLatestEventWithName
public static org.deckfour.xes.model.XEvent getLatestEventWithName(java.lang.String eventName, org.deckfour.xes.model.XTrace trace)
-
getAllEventNamesSorted
public static java.util.NavigableSet<java.lang.String> getAllEventNamesSorted(org.deckfour.xes.model.XLog log)
-
stringifyEvent
public static java.lang.String stringifyEvent(org.deckfour.xes.model.XEvent e, org.deckfour.xes.classification.XEventClassifier classifier)
-
stringifyEvent
public static java.lang.String stringifyEvent(org.deckfour.xes.model.XEvent e)
-
stringifyTrace
public static java.lang.String stringifyTrace(org.deckfour.xes.model.XTrace t, org.deckfour.xes.classification.XEventClassifier classifier)
-
stringifyTrace
public static java.lang.String stringifyTrace(org.deckfour.xes.model.XTrace t)
-
stringifyLog
public static java.lang.String stringifyLog(org.deckfour.xes.model.XLog l, org.deckfour.xes.classification.XEventClassifier classifier)
-
stringifyLog
public static java.lang.String stringifyLog(org.deckfour.xes.model.XLog l)
-
stringifyAttributes
public static java.lang.String stringifyAttributes(org.deckfour.xes.model.XAttributeMap map)
-
cloneAttributeWithChangedKey
public static org.deckfour.xes.model.XAttribute cloneAttributeWithChangedKey(org.deckfour.xes.model.XAttribute oldAttribute, java.lang.String newKey)Creates a deep clone of theXAttributewith the same value, but a changed key.- Parameters:
oldAttribute-newKey-- Returns:
- copy of the supplied attribute
-
cloneAttributeWithChangedKeyWithFactory
public static org.deckfour.xes.model.XAttribute cloneAttributeWithChangedKeyWithFactory(org.deckfour.xes.model.XAttribute oldAttribute, java.lang.String newKey, org.deckfour.xes.factory.XFactory factory)Creates a deep clone of theXAttributewith the same value, but a changed key.- Parameters:
oldAttribute-newKey-factory-- Returns:
- copy of the supplied attribute
-
cloneLogWithoutClassifier
public static org.deckfour.xes.model.XLog cloneLogWithoutClassifier(org.deckfour.xes.model.XLog log)
Creates a deep clone of the supplied event log without classifiers- Parameters:
log-- Returns:
- a clone of the supplied log
-
cloneLogWithoutGlobals
public static org.deckfour.xes.model.XLog cloneLogWithoutGlobals(org.deckfour.xes.model.XLog log)
Creates a deep clone of the supplied event log without globals- Parameters:
log-- Returns:
- a clone of the supplied log
-
cloneLogWithoutGlobalsAndClassifiers
public static org.deckfour.xes.model.XLog cloneLogWithoutGlobalsAndClassifiers(org.deckfour.xes.model.XLog log)
Creates a deep clone of the supplied event log without globals and without classifiers- Parameters:
log-- Returns:
- a clone of the supplied log
-
createLogFrom
public static org.deckfour.xes.model.XLog createLogFrom(org.deckfour.xes.model.XLog oldLog)
Creates a new log with attributes and meta data (classifiers, globals, extension) from the oldLog.- Parameters:
oldLog-- Returns:
-
createLogFrom
public static org.deckfour.xes.model.XLog createLogFrom(org.deckfour.xes.model.XLog oldLog, org.deckfour.xes.factory.XFactory factory)Creates a new log with attributes and meta data (classifiers, globals, extension) from the oldLog.- Parameters:
oldLog-factory-- Returns:
-
copyLogMetadata
public static void copyLogMetadata(org.deckfour.xes.model.XLog oldLog, org.deckfour.xes.model.XLog newLog)Copies the meta data (classifiers, globals, extension) from the oldLog to the newLog.- Parameters:
oldLog-newLog-
-
isSameType
public static boolean isSameType(org.deckfour.xes.model.XAttribute obj1, org.deckfour.xes.model.XAttribute obj2)Checks whether both objects implement the same XAttribute interface- Parameters:
obj1-obj2-- Returns:
-
getAttributeValue
public static java.lang.Object getAttributeValue(org.deckfour.xes.model.XAttribute attribute)
Returns the value of theXAttributeasObject- Parameters:
attribute-- Returns:
- value of the attribute
-
getAttributeClass
public static java.lang.Class<?> getAttributeClass(org.deckfour.xes.model.XAttribute attribute)
Returns the Java class of theXAttributevalue.- Parameters:
attribute-- Returns:
- class of the attribute
-
createAttribute
public static org.deckfour.xes.model.XAttribute createAttribute(java.lang.String attributeName, java.lang.Object attributeValue)Creates an appropriateXAttribute, decided on the type of the parameter atttributeValue.- Parameters:
attributeName-attributeValue-- Returns:
-
createAttributeWithFactory
public static org.deckfour.xes.model.XAttribute createAttributeWithFactory(java.lang.String attributeName, java.lang.Object attributeValue, org.deckfour.xes.factory.XFactory factory)Creates an appropriateXAttribute, decided on the type of the parameter atttributeValue.- Parameters:
attributeName-attributeValue-factory-- Returns:
-
createAttribute
public static org.deckfour.xes.model.XAttribute createAttribute(java.lang.String attributeName, java.lang.Object attributeValue, org.deckfour.xes.extension.XExtension extension)Creates an appropriateXAttribute, deciding by the type of the parameter atttributeValue.- Parameters:
attributeName-attributeValue-extension-- Returns:
- a
XAttributewith correct type
-
putAttributes
public static void putAttributes(org.deckfour.xes.model.XAttributable attributable, java.lang.Iterable<org.deckfour.xes.model.XAttribute> attributes)Adds multipleXAttributeto the suppliedXAttributable.- Parameters:
attributable-attributes-
-
putAttribute
public static void putAttribute(org.deckfour.xes.model.XAttributable attributable, org.deckfour.xes.model.XAttribute attribute)Adds a singleXAttributeto the suppliedXAttributable.- Parameters:
attributable-attribute-
-
renameLogWithProMLabel
public static java.lang.String renameLogWithProMLabel(org.processmining.framework.plugin.PluginContext context, org.deckfour.xes.model.XLog log)Rename the XLog with the label for the ProM provided object- Parameters:
context-log-- Returns:
- the old name
-
createEventClasses
public static org.deckfour.xes.classification.XEventClasses createEventClasses(org.deckfour.xes.classification.XEventClassifier classifier, java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)Obtain the event classes from the supplied collection of traces using the specified classifier. Uses theXEventcached in theXLogInfoif available and in case the trace are, in fact, aXLog.- Parameters:
classifier-traces-- Returns:
-
getEventAttributeKeys
public static java.util.Set<java.lang.String> getEventAttributeKeys(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)
-
getEventAttributeTypes
public static java.util.Map<java.lang.String,java.lang.Class<?>> getEventAttributeTypes(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)
-
getTraceAttributeKeys
public static java.util.Set<java.lang.String> getTraceAttributeKeys(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)
-
getTraceAttributeTypes
public static java.util.Map<java.lang.String,java.lang.Class<?>> getTraceAttributeTypes(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces)
-
getVariantsByClassifier
public static com.google.common.collect.ImmutableListMultimap<TraceVariantByClassifier,org.deckfour.xes.model.XTrace> getVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClassifier classifier)
Groups traces in aListMultimapby their event classification. AListMultimapinstead of anSetMultimapis returned as the input traces are not required to be aSet.- Parameters:
traces-classifier-- Returns:
-
countVariantsByClassifier
public static int countVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClassifier classifier)
-
getVariantsByClassifier
public static com.google.common.collect.ImmutableListMultimap<TraceVariantByClassifier,org.deckfour.xes.model.XTrace> getVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClasses eventClasses)
Groups traces in aListMultimapby their event classification. AListMultimapinstead of anSetMultimapis returned as the input traces are not required to be aSet.- Parameters:
traces-eventClasses-- Returns:
-
countVariantsByClassifier
public static int countVariantsByClassifier(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, org.deckfour.xes.classification.XEventClasses eventClasses)
-
getVariants
public static <T extends TraceVariant<E>,E> com.google.common.collect.ImmutableListMultimap<T,org.deckfour.xes.model.XTrace> getVariants(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, com.google.common.base.Function<org.deckfour.xes.model.XTrace,T> variantFunction)
Groups traces in aListMultimapby a genericFunction. AListMultimapinstead of anSetMultimapis returned as the input traces are not required to be aSet.- Parameters:
traces-variantFunction-- Returns:
-
countVariants
public static <T extends TraceVariant<?>> int countVariants(java.lang.Iterable<org.deckfour.xes.model.XTrace> traces, com.google.common.base.Function<org.deckfour.xes.model.XTrace,T> variantFunction)
-
-