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

org.jbpt.pm.structure.UniqueIdCheck 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.

There is a newer version: 0.3.1
Show newest version
package org.jbpt.pm.structure;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import org.jbpt.pm.FlowNode;
import org.jbpt.pm.ProcessModel;


/**
 * Checks whether every {@link FlowNode} in the {@link ProcessModel} has a unique identifier. 
 * @author Christian Wiggert
 *
 */
public class UniqueIdCheck implements ICheck {

	@Override
	public List check(ProcessModel process) {
		List errors = new ArrayList();
		HashSet ids = new HashSet();
		HashSet duplicates = new HashSet();
		for (FlowNode node:process.getVertices()) {
			if (!ids.contains(node.getId()))
				ids.add(node.getId());
			else
				duplicates.add(node.getId());
		}
		for (String id:duplicates) {
			if (id.equals(""))
				errors.add("Some nodes have no ID.");
			else
				errors.add("The ID " + id + " occurs multiple times.");
		}
		return errors;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy