Skip to content

Commit 05f3f3f

Browse files
author
Andrew Pikler
committed
Add missing all clear message. Use purple if update is not recognized
1 parent 5862bfa commit 05f3f3f

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

oref-integration/src/main/java/com/github/pyckle/oref/integration/translationstores/FlashUpdateTypeConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class FlashUpdateTypeConstants
77
public static final String GREEN_LEAVE_BUILDING = "סיום שהייה בסמיכות למרחב המוגן";
88
public static final String GREEN_TERRORIST_THREAT_ENDED = "חדירת מחבלים - החשש הוסר";
99
public static final String GREEN_UAV_THREAT_ENDED = "חדירת כלי טיס עוין - האירוע הסתיים";
10+
public static final String GREEN_ROCKET_THREAT_ENDED = "ירי רקטות וטילים - האירוע הסתיים";
1011
public static final String YELLOW_STAY_CLOSE_TO_SHELTER = "יש לשהות בסמיכות למרחב המוגן";
1112
public static final String YELLOW_STAY_CLOSE_TO_SHELTER2 = "שהייה בסמיכות למרחב מוגן";
1213
public static final String YELLOW_LEAVE_SHELTER_STAY_CLOSE = "ניתן לצאת מהמרחב המוגן אך יש להישאר בקרבתו";

oref-integration/src/main/java/com/github/pyckle/oref/integration/translationstores/UpdateFlashType.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import java.awt.Color;
99
import java.util.List;
1010
import java.util.Set;
11+
import java.util.concurrent.ConcurrentHashMap;
1112

1213
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.GREEN_LEAVE_BUILDING;
1314
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.GREEN_NRC_LEAVE_BUILDING;
15+
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.GREEN_ROCKET_THREAT_ENDED;
1416
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.GREEN_TERRORIST_THREAT_ENDED;
1517
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.GREEN_UAV_THREAT_ENDED;
1618
import static com.github.pyckle.oref.integration.translationstores.FlashUpdateTypeConstants.ORANGE_ALERTS_EXPECTED_SHORTLY;
@@ -26,12 +28,15 @@
2628
public enum UpdateFlashType
2729
{
2830
GREEN(100, Color.GREEN, GREEN_NRC_LEAVE_BUILDING, GREEN_LEAVE_BUILDING, GREEN_TERRORIST_THREAT_ENDED,
29-
GREEN_UAV_THREAT_ENDED), // safe to leave building
31+
GREEN_ROCKET_THREAT_ENDED, GREEN_UAV_THREAT_ENDED), // safe to leave building
3032
YELLOW(90, Color.YELLOW, YELLOW_EARTHQUAKE, YELLOW_STAY_CLOSE_TO_SHELTER, YELLOW_STAY_CLOSE_TO_SHELTER2,
3133
YELLOW_LEAVE_SHELTER_STAY_CLOSE, YELLOW_LEAVE_SHELTER), // stay close to a shelter
3234
ORANGE(80, Color.ORANGE, ORANGE_ALERTS_EXPECTED_SHORTLY), // alerts expected area shortly
33-
RED(70, Color.RED, RED_NRC, RED_CONTINUE_SHELTER, RED_SHELTER_IMMEDIATELY); // go to shelter immediately
35+
RED(70, Color.RED, RED_NRC, RED_CONTINUE_SHELTER, RED_SHELTER_IMMEDIATELY), // go to shelter immediately
36+
UNKNOWN(60, new Color(255, 0, 255)) //purple
37+
;
3438

39+
private static final Set<String> unknownColor = ConcurrentHashMap.newKeySet();
3540
private static final Set<String> HISTORICAL_LABELS = Set.of("עדכון", "מבזק");
3641
private static final Logger logger = LoggerFactory.getLogger(OrefApiCachingService.class);
3742
private final int severity;
@@ -62,8 +67,10 @@ public static UpdateFlashType findUpdateFlashType(String hebTitle)
6267
if (HISTORICAL_LABELS.contains(hebTitle))
6368
return YELLOW;
6469

65-
logger.warn("Cannot find alert type for {}, defaulting to red.", hebTitle);
66-
return RED;
70+
// print out warning only once.
71+
if (unknownColor.add(hebTitle))
72+
logger.warn("Cannot find alert type for {}, return UNKNOWN.", hebTitle);
73+
return UNKNOWN;
6774
}
6875

6976
public Color getColor() {

0 commit comments

Comments
 (0)