org.deckfour.xes.model.impl.XTraceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SEWOL Show documentation
Show all versions of SEWOL Show documentation
SEWOL provides support for the handling of workflow traces. Specifically it allows to specify the shape and content of process traces in terms of entries representing the execution of a specific workflow activity. SEWOL also allows to write these traces on disk as a log file with the help of a special file writer for process logs. Currently it supports plain text, Petrify, MXML and XES log file types. In order to specify security-related context information, SEWOL provides access control models such as access control lists (ACL) and role-based access control models (RBAC). All types of models can be conveniently edited with the help of appropriate dialogs.
The newest version!
/*
* OpenXES
*
* The reference implementation of the XES meta-model for event
* log data management.
*
* Copyright (c) 2008 Christian W. Guenther ([email protected])
*
*
* LICENSE:
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
* EXEMPTION:
*
* The use of this software can also be conditionally licensed for
* other programs, which do not satisfy the specified conditions. This
* requires an exemption from the general license, which may be
* granted on a per-case basis.
*
* If you want to license the use of this software with a program
* incompatible with the LGPL, please contact the author for an
* exemption at the following email address:
* [email protected]
*
*/
package org.deckfour.xes.model.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.Set;
import org.deckfour.xes.extension.XExtension;
import org.deckfour.xes.extension.std.XTimeExtension;
import org.deckfour.xes.model.XAttribute;
import org.deckfour.xes.model.XAttributeMap;
import org.deckfour.xes.model.XAttributeTimestamp;
import org.deckfour.xes.model.XEvent;
import org.deckfour.xes.model.XLog;
import org.deckfour.xes.model.XTrace;
import org.deckfour.xes.model.XVisitor;
import org.deckfour.xes.util.XAttributeUtils;
/**
* Memory-based implementation for the XTrace interface.
*
* @author Christian W. Guenther ([email protected])
*
*/
public class XTraceImpl extends ArrayList implements XTrace {
/**
* Serial version UID.
*/
private static final long serialVersionUID = 843122019760036963L;
/**
* Map of attributes for this trace.
*/
private XAttributeMap attributes;
/**
* Creates a new trace.
*
* @param attributeMap
* Attribute map used to store this trace's attributes.
*/
public XTraceImpl(XAttributeMap attributeMap) {
this.attributes = attributeMap;
}
/*
* (non-Javadoc)
*
* @see org.deckfour.xes.model.XAttributable#getAttributes()
*/
public XAttributeMap getAttributes() {
return attributes;
}
/*
* (non-Javadoc)
*
* @see org.deckfour.xes.model.XAttributable#getExtensions()
*/
public Set getExtensions() {
return XAttributeUtils.extractExtensions(attributes);
}
/*
* (non-Javadoc)
*
* @see org.deckfour.xes.model.XAttributable#setAttributes(java.util.Map)
*/
public void setAttributes(XAttributeMap attributes) {
this.attributes = attributes;
}
/* (non-Javadoc)
* @see org.deckfour.xes.model.XAttributable#hasAttributes()
*/
@Override
public boolean hasAttributes() {
return !attributes.isEmpty();
}
/**
* Creates a clone, i.e. deep copy, of this trace.
*/
public Object clone() {
XTraceImpl clone = (XTraceImpl) super.clone();
clone.attributes = (XAttributeMap) attributes.clone();
clone.clear();
for (XEvent event : this) {
clone.add((XEvent) event.clone());
}
return clone;
}
public synchronized int insertOrdered(XEvent event) {
if (this.size() == 0) {
// append if list is empty
add(event);
return 0;
}
XAttribute insTsAttr = event.getAttributes().get(
XTimeExtension.KEY_TIMESTAMP);
if (insTsAttr == null) {
// append if event has no timestamp
add(event);
return (size() - 1);
}
Date insTs = ((XAttributeTimestamp) insTsAttr).getValue();
for (int i = (size() - 1); i >= 0; i--) {
XAttribute refTsAttr = get(i).getAttributes().get(
XTimeExtension.KEY_TIMESTAMP);
if (refTsAttr == null) {
// trace contains events w/o timestamps, append.
add(event);
return (size() - 1);
}
Date refTs = ((XAttributeTimestamp) refTsAttr).getValue();
if (insTs.before(refTs) == false) {
// insert position reached
add(i + 1, event);
return (i + 1);
}
}
// beginning reached, insert at head
add(0, event);
return 0;
}
/*
* Runs the given visitor for the given log on this trace.
*
* (non-Javadoc)
* @see org.deckfour.xes.model.XTrace#accept(org.deckfour.xes.model.XVisitor, org.deckfour.xes.model.XLog)
*/
public void accept(XVisitor visitor, XLog log) {
/*
* First call.
*/
visitor.visitTracePre(this, log);
/*
* Visit the attributes.
*/
for (XAttribute attribute: attributes.values()) {
attribute.accept(visitor, this);
}
/*
* Visit the events.
*/
for (XEvent event: this) {
event.accept(visitor, this);
}
/*
* Last call.
*/
visitor.visitTracePost(this, log);
}
}