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

org.jbpt.petri.querying.AbstractStructuralQuerying 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.querying;

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.IEvent;

/**
 * An implementation of the {@link IStructuralQuerying} interface.
 * 
 * @author Artem Polyvyanyy
 */
public class AbstractStructuralQuerying, C extends ICondition, E extends IEvent, F extends IFlow, N extends INode, P extends IPlace, T extends ITransition, M extends IMarking> 
	implements IStructuralQuerying {
	
	protected INetSystem sys = null;
	
	public AbstractStructuralQuerying(INetSystem sys) {
		if (sys==null) return;
		
		this.sys = sys;
	}
	
	public INetSystem getNetSystem() {
		return this.sys;
	}

	@Override
	public boolean areModeledAll(Set setOfLabels) {
		if (setOfLabels==null) return true;
		if (setOfLabels.isEmpty()) return true;
		
		Set sol = new HashSet(setOfLabels);
		for (T t : this.sys.getTransitions()) {
			if (sol.remove(t.getLabel())) {
				if (sol.isEmpty())
					return true;
			}
		}
		
		return false;
	}

	@Override
	public boolean isModeledOne(Set setOfLabels) {
		if (setOfLabels==null) return true;
		if (setOfLabels.isEmpty()) return true;
		
		for (T t : this.sys.getTransitions()) {
			if (setOfLabels.contains(t.getLabel()))
				return true;
		}
		
		return false;
	}

	@Override
	public boolean areModeledAllExpanded(Set> setsOfLabels) {
		if (setsOfLabels==null) return true;
		if (setsOfLabels.isEmpty()) return true;
		
		Set> ssol = new HashSet>();
		for (T t : this.sys.getTransitions()) {
			for (Set sol : setsOfLabels) {
				if (sol.contains(t.getLabel())) {
					ssol.add(sol);
					if (ssol.size()==setsOfLabels.size()) return true;
				}
			}
		}
		
		return false;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy