package com.bitdubai.fermat_cry_plugin.layer.crypto_router.incoming_crypto.developer.bitdubai.version_1.util;

import com.bitdubai.fermat_api.layer.all_definition.event.PlatformEvent;
import com.bitdubai.fermat_api.layer.all_definition.transaction_transference_protocol.Specialist;
import com.bitdubai.fermat_api.layer.pip_platform_service.event_manager.DealsWithEvents;
import com.bitdubai.fermat_api.layer.pip_platform_service.event_manager.EventManager;
import com.bitdubai.fermat_api.layer.pip_platform_service.event_manager.EventSource;
import com.bitdubai.fermat_api.layer.pip_platform_service.event_manager.EventType;
import com.bitdubai.fermat_cry_plugin.layer.crypto_router.incoming_crypto.developer.bitdubai.version_1.exceptions.SpecialistNotRegisteredException;

import java.util.EnumSet;

/**
 * Created by eze on 12/06/15.
 */

/*
 * The purpose of this class is to identify the events that must be notified and raise them.
 */
public class EventsLauncher implements DealsWithEvents {

    /*
     * DealsWithEvents Interface member variabñes
     */
    private EventManager eventManager;

    public void sendEvents(EnumSet<Specialist> specialists) throws SpecialistNotRegisteredException {
        for(Specialist specialist : specialists) {

            switch (specialist) {
                case EXTRA_USER_SPECIALIST:
                    PlatformEvent platformEvent = eventManager.getNewEvent(EventType.INCOMING_CRYPTO_TRANSACTIONS_WAITING_TRANSFERENCE_EXTRA_USER);
                    platformEvent.setSource(EventSource.CRYPTO_ROUTER);
                    eventManager.raiseEvent(platformEvent);
                    System.out.println("TTF - INCOMING CRYPTO RELAY: EVENTSLAUNCHER - EVENTS RAISED");
                    break;
                default:
                    throw new SpecialistNotRegisteredException("I could not found the event for this specialist", null,"Soecialist: " + specialist.name() +" with code: " + specialist.getCode(),"Specialist not considered in switch statement");
            }
        }
    }

    /*
     * DealsWithEvents Interface methods implementation
     */
    @Override
    public void setEventManager(EventManager eventManager) {
        this.eventManager = eventManager;
    }
}

@@ -1349,16 +1349,100 @@
         
+/**%0A                     * Issue #553%0A                     */%0A                    //
 Platform
@@ -1581,16 +1581,18 @@
         
+//
 platform
@@ -1655,16 +1655,18 @@
         
+//
 eventMan
@@ -1696,16 +1696,1382 @@
 mEvent);
+%0A%0A                    PlatformEvent platformEventOnCryptoNetwork = eventManager.getNewEvent(EventType.INCOMING_CRYPTO_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_EXTRA_USER);%0A                    platformEventOnCryptoNetwork.setSource(EventSource.CRYPTO_ROUTER);%0A                    eventManager.raiseEvent(platformEventOnCryptoNetwork);%0A%0A                    PlatformEvent platformEventOnBlockchain = eventManager.getNewEvent(EventType.INCOMING_CRYPTO_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_EXTRA_USER);%0A                    platformEventOnBlockchain.setSource(EventSource.CRYPTO_ROUTER);%0A                    eventManager.raiseEvent(platformEventOnBlockchain);%0A%0A                    PlatformEvent platformEventReversedOnCryptoNetwork = eventManager.getNewEvent(EventType.INCOMING_CRYPTO_REVERSED_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_EXTRA_USER);%0A                    platformEventReversedOnCryptoNetwork.setSource(EventSource.CRYPTO_ROUTER);%0A                    eventManager.raiseEvent(platformEventReversedOnCryptoNetwork);%0A%0A                    PlatformEvent platformEventReversedOnBlockChain = eventManager.getNewEvent(EventType.INCOMING_CRYPTO_REVERSED_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_EXTRA_USER);%0A                    platformEventReversedOnBlockChain.setSource(EventSource.CRYPTO_ROUTER);%0A                    eventManager.raiseEvent(platformEventReversedOnBlockChain);%0A%0A
 %0A       

Fix #553 implementation