Skip to content
Snippets Groups Projects
Commit 575760c9 authored by Arsenij Solovjev's avatar Arsenij Solovjev
Browse files

[FIX] handle unknown favorite colors

The check for the optimal color assignment invariant
is not needed for the case that the favorite colors
are not initialized.

Change-Id: I61f67c7d26bb3bd0efebc126645c34073eeb4a1f
Reviewed-on: http://saros-build.imp.fu-berlin.de/gerrit/674


Tested-by: Jenkins CI
Reviewed-by: default avatarStefan Rossbach <srossbach@arcor.de>
Reviewed-by: default avatarArsenij Solovjev <xeper000@gmail.com>
Tested-by: default avatarArsenij Solovjev <xeper000@gmail.com>
parent 50faaaa4
No related branches found
No related tags found
No related merge requests found
......@@ -302,12 +302,21 @@ public class ChangeColorManager extends AbstractActivityProvider implements
applyStoredColors(assignedColors, colorIDSet);
/*
* on the first creation of a color id set all colors are
* UserColorID.UNKNOWN so avoid the case where everybody's
* favorite color is UserColorID.UNKNOWN and so would get
* UserColorID.UNKNOWN as current color id
* if there are users with favorite color
* UserColorID.UNKNOWN, then the optimal assignment cannot
* be known. So if there was already a valid assignment for
* these users we choose that, so that the users experience
* the reuse of colors.
*/
if (favoriteUserColors.containsValue(UserColorID.UNKNOWN)
&& isValidColorAssignment(assignedColors)) {
log.debug("color conflict resolve result = FAVORITE COLORS UNKNOWN, USING PREVIOUS COLOR ASSIGNMENT");
break resolveColorConflicts;
}
/*
* if color assignment is optimal, assignment is resolved.
*/
if (isOptimalColorAssignment(assignedColors)) {
log.debug("color conflict resolve result = ALREADY SOLVED");
break resolveColorConflicts;
......@@ -320,6 +329,11 @@ public class ChangeColorManager extends AbstractActivityProvider implements
// resolve the problem
autoAssignColors(assignedColors);
/*
* if favorite colors weren't initialized, there cannot be an
* optimal assignment
*/
if (!favoriteUserColors.containsValue(UserColorID.UNKNOWN))
assert isOptimalColorAssignment(assignedColors);
/* release all colors again as they will be removed again */
......@@ -397,10 +411,8 @@ public class ChangeColorManager extends AbstractActivityProvider implements
* </ul>
*
* @param assignedColors
* @return
*/
private Map<User, Integer> autoAssignColors(
Map<User, Integer> assignedColors) {
private void autoAssignColors(Map<User, Integer> assignedColors) {
List<User> usersToAutoAssignColors = new ArrayList<User>();
for (Map.Entry<User, Integer> entry : assignedColors.entrySet()) {
......@@ -416,7 +428,6 @@ public class ChangeColorManager extends AbstractActivityProvider implements
int colorID = getNextAvailableColorID();
assignedColors.put(currentUser, colorID);
}
return assignedColors;
}
private Map<User, Integer> getLastKnownFavoriteColors(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment