[LIB-8] URL and HTML tag processing, new entities fields
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / cache / assign / EventAssigner.java
index 8c2cc8b..8ea144b 100644 (file)
@@ -18,6 +18,7 @@ package org.hedgecode.snooker.cache.assign;
 
 import org.hedgecode.snooker.api.APIException;
 import org.hedgecode.snooker.api.Event;
+import org.hedgecode.snooker.api.Player;
 import org.hedgecode.snooker.json.JsonEvent;
 
 /**
@@ -40,14 +41,28 @@ public class EventAssigner extends CacheIdAssigner<Event> {
 
     @Override
     public void assign(Event event) throws APIException {
+        JsonEvent jsonEvent = (JsonEvent) event;
         if (event.mainEventId() != event.eventId() && event.mainEventId() > 0) {
-            JsonEvent jsonEvent = (JsonEvent) event;
             jsonEvent.setMainEvent(
                     cacheScore.getCachedEvent(
                             event.mainEventId()
                     )
             );
         }
+        if (event.previousEditionId() > 0) {
+            jsonEvent.setPreviousEdition(
+                    cacheScore.getCachedEvent(
+                            event.previousEditionId()
+                    )
+            );
+        }
+        if (event.defendingChampionId() > 0) {
+            jsonEvent.setDefendingChampion(
+                    cacheScore.getCachedPlayer(
+                            event.defendingChampionId()
+                    )
+            );
+        }
     }
 
 }