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

org.jbpt.petri.untangling.pss.AbstractProcessSystem Maven / Gradle / Ivy

Go to download

The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes.

The newest version!
package org.jbpt.petri.untangling.pss;

import java.util.HashSet;
import java.util.Set;

import org.jbpt.petri.IFlow;
import org.jbpt.petri.IMarking;
import org.jbpt.petri.INetSystem;
import org.jbpt.petri.INode;
import org.jbpt.petri.IPlace;
import org.jbpt.petri.ITransition;
import org.jbpt.petri.unfolding.IBPNode;
import org.jbpt.petri.unfolding.ICondition;
import org.jbpt.petri.unfolding.ICut;
import org.jbpt.petri.unfolding.IEvent;
import org.jbpt.petri.untangling.IProcess;

/**
 * An abstract implementation of the {@link IProcessSystem} interface.
 * 
 * @author Artem Polyvyanyy
 */
public abstract class AbstractProcessSystem, C extends ICondition, E extends IEvent, 
											F extends IFlow, N extends INode, P extends IPlace, T extends ITransition, M extends IMarking>
											implements IProcessSystem
{
	private INetSystem system = null;
	private IProcess process = null;
	
	protected AbstractProcessSystem() {};
			
	public AbstractProcessSystem(INetSystem sys, IProcess pi) {
		if (sys==null) return;
		if (pi==null) return;
		
		this.system = sys;
		this.process = pi;
	}	
	
	@Override
	public Set getEnabledTransitions() {
		Set result = new HashSet();
		
		// get cuts that refer to the current marking
		Set> cuts = this.process.getCuts(this.system.getMarking().toMultiSet());
		
		for (E e : this.process.getEvents()) {
			for (ICut cut : cuts) {
				if (cut.containsAll(e.getPreConditions())) {
					result.add(e.getTransition());
				}
			}
		}
		
		return result;
	}
	
	@Override
	public boolean fire(T transition) {
		if (this.getEnabledTransitions().contains(transition))
			return this.system.fire(transition);
		else
			return false;
	}

	@Override
	public M getMarking() {
		return this.system.getMarking();
	}
	
	@Override
	public IProcess getProcess() {
		return this.process;
	}
	
	@Override
	public INetSystem getNetSystem() {
		return this.system;
	}

	@Override
	public void setSystem(INetSystem sys) {
		if (sys==null) return;
		this.system = sys;
	}
	
	@Override
	public void setProcess(IProcess pi) {
		if (pi==null) return;
		this.process = pi;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy