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

de.uni.freiburg.iig.telematik.sepia.petrinet.cpn.FiringRule Maven / Gradle / Ivy

Go to download

SEPIA provides implementations for various types of Petri nets. Along Place/Transition-nets, it supports Petri nets with distinguishable token colors and defines coloured workflow nets, where coloured tokens are interpreted as data elements used during process execution. To support information flow analysis of processes, SEPIA defines so-called IF-Nets, tailored for security-oriented workflow modeling which enable users to assign security-levels (HIGH, LOW) to transitions, data elements and persons/agents participating in the process execution.

The newest version!
package de.uni.freiburg.iig.telematik.sepia.petrinet.cpn;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import de.invation.code.toval.validate.Validate;


public class FiringRule implements Serializable{
	
	private static final long serialVersionUID = -7137530591652113124L;
	
	private Map> requiredTokens = new HashMap>();
	private Map> producedTokens = new HashMap>();
	
	
	public boolean containsRequirements(){
		return !requiredTokens.isEmpty();
	}
	
	public void addRequirement(String placeName, Map requirement) {
		Validate.notNull(placeName);
		Validate.notNull(requirement);
		Validate.noNullElements(requirement.keySet());
		Validate.noNullElements(requirement.values());
		
		for(Integer tokens : requirement.values()){
			Validate.bigger(tokens, 0);				
		}		
		requiredTokens.put(placeName, requirement);
	}
	
	
	public void addRequirement(String placeName, String color, Integer tokens) {
		Validate.notNull(placeName);
		Validate.notNull(color);
		Validate.notNull(tokens);
		Validate.bigger(tokens, 0);
		Map placeRequirements = requiredTokens.get(placeName);
		if(placeRequirements == null){
			placeRequirements = new HashMap();
			requiredTokens.put(placeName, placeRequirements);
		}
		placeRequirements.put(color, tokens);
	}
	
	public boolean containsProductions(){
		return !producedTokens.isEmpty();
	}
	
	public void addProduction(String placeName, Map production) {
		Validate.notNull(placeName);
		Validate.notNull(production);
		Validate.noNullElements(production.keySet());
		Validate.noNullElements(production.values());
		
		for(Integer tokens : production.values()){
			Validate.bigger(tokens, 0);				
		}	
		
		producedTokens.put(placeName, production);
	}
	
	public void addProduction(String placeName, String color, Integer tokens) {
		Validate.notNull(placeName);
		Validate.notNull(color);
		Validate.notNull(tokens);
		Validate.bigger(tokens, 0);
		Map placeProductions = producedTokens.get(placeName);
		if(placeProductions == null){
			placeProductions = new HashMap();
			producedTokens.put(placeName, placeProductions);
		}
		placeProductions.put(color, tokens);
	}
	
	public Map> getRequirements(){
		return requiredTokens;
	}
	
	public Map> getProductions(){
		return producedTokens;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy