All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deckfour.xes.info.impl.XAttributeInfoImpl Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.0.2
Show 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.info.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.deckfour.xes.extension.XExtension;
import org.deckfour.xes.info.XAttributeInfo;
import org.deckfour.xes.model.XAttribute;
import org.deckfour.xes.util.XAttributeUtils;

/**
 * This class provides aggregate information about attributes
 * within one container in the log type hierarchy. For example,
 * it may store information about all event attributes in a 
 * log.
 * 
 * @author Christian W. Guenther ([email protected])
 *
 */
public class XAttributeInfoImpl implements XAttributeInfo {
	
	/**
	 * Mapping from attribute keys to attribute prototypes.
	 */
	private Map keyMap;
	/**
	 * Mapping from attribute types to attribute prototypes.
	 */
	private Map, Set> typeMap;
	/**
	 * Mapping from attribute extensions to attribute prototypes.
	 */
	private Map> extensionMap;
	/**
	 * Attribute prototypes for non-extension attributes.
	 */
	private Set noExtensionSet;
	/**
	 * Mapping from attribute keys to absolute frequency.
	 */
	private Map frequencies;
	/**
	 * Total absolute frequency of all registered attributes.
	 */
	private int totalFrequency;
	
	/**
	 * Creates a new attribute information registry.
	 */
	public XAttributeInfoImpl() {
		keyMap = new HashMap();
		frequencies = new HashMap();
		typeMap = new HashMap, Set>();
		extensionMap = new HashMap>();
		noExtensionSet = new HashSet();
		totalFrequency = 0;
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getAttributes()
	 */
	public Collection getAttributes() {
		return Collections.unmodifiableCollection(keyMap.values());
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getAttributeKeys()
	 */
	public Collection getAttributeKeys() {
		return Collections.unmodifiableCollection(keyMap.keySet());
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getFrequency(java.lang.String)
	 */
	public int getFrequency(String key) {
		return frequencies.get(key);
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getFrequency(org.deckfour.xes.model.XAttribute)
	 */
	public int getFrequency(XAttribute attribute) {
		return getFrequency(attribute.getKey());
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getRelativeFrequency(java.lang.String)
	 */
	public double getRelativeFrequency(String key) {
		return (double)frequencies.get(key) / (double)totalFrequency;
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getRelativeFrequency(org.deckfour.xes.model.XAttribute)
	 */
	public double getRelativeFrequency(XAttribute attribute) {
		return getRelativeFrequency(attribute.getKey());
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getAttributesForType(org.deckfour.xes.model.XAttribute.Type)
	 */
	public Collection getAttributesForType(Class type) {
		Set typeSet = typeMap.get(type);
		if(typeSet == null) {
			typeSet = new HashSet(0);
		}
		return Collections.unmodifiableCollection(typeSet);
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getKeysForType(org.deckfour.xes.model.XAttribute.Type)
	 */
	public Collection getKeysForType(Class type) {
		Collection typeCollection = getAttributesForType(type);
		Set keySet = new HashSet();
		for(XAttribute attribute : typeCollection) {
			keySet.add(attribute.getKey());
		}
		return Collections.unmodifiableCollection(keySet);
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getAttributesForExtension(org.deckfour.xes.extension.XExtension)
	 */
	public Collection getAttributesForExtension(XExtension extension) {
		if(extension == null) {
			return getAttributesWithoutExtension();
		} else {
			Set extensionSet = extensionMap.get(extension);
			if(extensionSet == null) {
				extensionSet = new HashSet(0);
			}
			return Collections.unmodifiableCollection(extensionSet);
		}
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getKeysForExtension(org.deckfour.xes.extension.XExtension)
	 */
	public Collection getKeysForExtension(XExtension extension) {
		Collection extensionCollection = getAttributesForExtension(extension);
		Set keySet = new HashSet();
		for(XAttribute attribute : extensionCollection) {
			keySet.add(attribute.getKey());
		}
		return Collections.unmodifiableCollection(keySet);
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getAttributesWithoutExtension()
	 */
	public Collection getAttributesWithoutExtension() {
		return Collections.unmodifiableCollection(noExtensionSet);
	}
	
	/* (non-Javadoc)
	 * @see org.deckfour.xes.summary.XAttributeInfo#getKeysWithoutExtension()
	 */
	public Collection getKeysWithoutExtension() {
		return getKeysForExtension(null);
	}
	
	/**
	 * Registers a concrete attribute with this registry.
	 * 
	 * @param attribute Attribute to be registered.
	 */
	public void register(XAttribute attribute) {
		if(keyMap.containsKey(attribute.getKey()) == false) {
			// create new attribute prototype
			XAttribute prototype = XAttributeUtils.derivePrototype(attribute);
			// add to main map
			keyMap.put(attribute.getKey(), prototype);
			// initialize frequency
			frequencies.put(attribute.getKey(), 1);
			// register with type map
			Set typeSet = typeMap.get(XAttributeUtils.getType(prototype));
			if(typeSet == null) {
				typeSet = new HashSet();
				typeMap.put(XAttributeUtils.getType(prototype), typeSet);
			}
			typeSet.add(prototype);
			// register with extension map
			if(attribute.getExtension() == null) {
				// non-extension attribute
				noExtensionSet.add(prototype);
			} else {
				// register with extension map
				Set extensionSet = extensionMap.get(attribute.getExtension());
				if(extensionSet == null) {
					extensionSet = new HashSet();
					extensionMap.put(attribute.getExtension(), extensionSet);
				}
				extensionSet.add(prototype);
			}
		} else {
			// adjust frequency
			frequencies.put(attribute.getKey(), frequencies.get(attribute.getKey()) + 1);
		}
		// adjust total frequency
		totalFrequency++;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy