package com.heroku.myorchestrator.consumers.common;

import com.heroku.myorchestrator.config.enumerate.Kind;
import com.heroku.myorchestrator.consumers.ConsumerRouteBuilder;
import com.heroku.myorchestrator.util.MessageUtil;
import com.heroku.myorchestrator.util.consumers.IronmqUtil;
import org.springframework.stereotype.Component;

@Component
public class ChangingConsumer extends ConsumerRouteBuilder {

    public ChangingConsumer() {
        ironmq().changed();
        route().changing();
    }

    @Override
    public void configure() throws Exception {
        from(ironmq().consumeUri())
                .routeId(route().id())
                .choice()
                .when(MessageUtil.messageKindContains("seiyu"))
                    .choice()
                        .when(MessageUtil.messageKindIs(Kind.female_seiyu_category_members)).to("log:changing_" + Kind.female_seiyu_category_members.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.male_seiyu_category_members)).to("log:changing_" + Kind.male_seiyu_category_members.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.seiyu_category_members)).to("log:changing_" + Kind.seiyu_category_members.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.seiyu_category_members_include_template)).to("log:changing_" + Kind.seiyu_category_members_include_template.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.seiyu_has_recentchanges)).to("log:changing_" + Kind.seiyu_has_recentchanges.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.seiyu_template_include_pages)).to("log:changing_" + Kind.seiyu_template_include_pages.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.koepota_seiyu)).to("log:changing_" + Kind.koepota_seiyu.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.koepota_seiyu_all)).to("log:changing_" + Kind.koepota_seiyu_all.expression())
                        .otherwise().to("log:changing_seiyu_none")
                    .endChoice()
                .otherwise()
                    .choice()
                        .when(MessageUtil.messageKindIs(Kind.koepota_events)).to("log:changing_" + Kind.koepota_events.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.amiami_item)).to("log:changing_" + Kind.amiami_item.expression())
                        .otherwise()
                        .when(MessageUtil.messageKindIs(Kind.amiami_original_titles)).to("log:changing_" + Kind.amiami_original_titles.expression())
                        .otherwise().to("log:changing_none")
                    .endChoice()
                .end()
                .end()
                .end()
//                .endParent()
                .filter(MessageUtil.loadAffect())
                .split().body()
                .routingSlip(IronmqUtil.affectQueueUri());
    }
}

@@ -662,110 +662,8 @@
 e()%0A
-                .when(MessageUtil.messageKindContains(%22seiyu%22))%0A                    .choice()%0A        
     
@@ -817,53 +817,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -968,53 +968,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1109,53 +1109,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1284,53 +1284,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1427,53 +1427,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1580,53 +1580,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1703,53 +1703,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -1834,175 +1834,8 @@
 ())%0A
-                        .otherwise().to(%22log:changing_seiyu_none%22)%0A                    .endChoice()%0A                .otherwise()%0A                    .choice()%0A        
     
@@ -1959,53 +1959,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -2078,53 +2078,8 @@
 ())%0A
-                        .otherwise()%0A        
     
@@ -2231,24 +2231,16 @@
         
-        
 .otherwi
@@ -2288,122 +2288,12 @@
     
-    .endChoice()%0A                .end()%0A                .end()%0A                .end()%0A//                .endParent
+.end
 ()%0A 

modify message route on ChangingConsumer