org.jbpt.pm.structure.UniqueIdCheck Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbpt-bpm Show documentation
Show all versions of jbpt-bpm Show documentation
The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes.
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