NPE when setting supervisor for a Match (Employee was Null).

This commit is contained in:
Tom Vahlman 2012-02-08 19:57:28 +01:00
parent a1aec28a59
commit e89ff533bd

@ -19,7 +19,7 @@ import se.su.dsv.scipro.match.dataobject.ProjectIdea;
@Component(value="GreedyMatchingAlgorithm")
public class GreedyMatchingAlgorithm implements MatchingAlgorithm {
private Logger logger = Logger.getLogger(GreedyMatchingAlgorithm.class);
private Weights weights;
@ -93,12 +93,8 @@ public class GreedyMatchingAlgorithm implements MatchingAlgorithm {
while (projectIdeaIterator.hasNext()) {
ProjectIdea projectIdea = projectIdeaIterator.next();
logger.info("Matching project idea:" + projectIdea);
Match match = new Match();
match.setSupervisor(new Employee());
match.setProjectIdea(projectIdea);
Pair matchPair = new Pair(match, new Availability(null, 1L, 1, new ProjectClass()));
Iterator<Availability> availabilityIterator = availabilityList.iterator();
Pair matchPair = null;
Iterator<Availability> availabilityIterator = availabilityList.iterator();
while (availabilityIterator.hasNext()) {
Availability availability = availabilityIterator.next();
logger.info("Matching project idea with supervisor:" + availability.getSupervisor());
@ -113,10 +109,14 @@ public class GreedyMatchingAlgorithm implements MatchingAlgorithm {
logger.info("Not possible supervisor");
continue;
}
Match match = new Match();
match.setSupervisor(availability.getSupervisor());
match.setProjectIdea(projectIdea);
matchPair = new Pair(match, new Availability(null, 1L, 1, new ProjectClass()));
matchPair = getBestMatch(matchPair, availability);
}
if (matchPair.getMatch().getPoints() != -1) {
if (matchPair != null && matchPair.getMatch().getPoints() != -1) {
matchList.add(matchPair.getMatch());
projectIdeaIterator.remove();
}