<commit_before>package ch.openolitor.core.eventsourcing

import akka.actor.{ ActorRef, ActorSystem }
import akka.serialization._
import com.typesafe.config.ConfigFactory
import stamina._
import stamina.json._
import ch.openolitor.core.domain.EntityStoreJsonProtocol
import ch.openolitor.core.domain.EntityStore._
import ch.openolitor.stammdaten.eventsourcing.StammdatenEventStoreSerializer
import com.typesafe.scalalogging.LazyLogging
import ch.openolitor.stammdaten.models.CustomKundentyp
import ch.openolitor.stammdaten.models.CustomKundentypCreate
import ch.openolitor.core.eventsourcing.events._

class EventStoreSerializer extends StaminaAkkaSerializer(EventStoreSerializer.eventStorePersisters) with LazyLogging with StammdatenEventStoreSerializer {
  
  override def toBinary(obj: AnyRef): Array[Byte] = {
    logger.debug(s"EventStoreSerielizer: toBinary: $obj")
    try {
      super.toBinary(obj)
    }          
    catch {
      case e:Exception => 
        logger.error(s"Can't persist $obj", e)
        stammdatenPersisters.map { persister => 
          if (persister.canPersist(obj)) {
            logger.warn(s"Found persister:${persister.key}")
          }
        }
        throw e
    }
  }
}

object EventStoreSerializer extends EntityStoreJsonProtocol with StammdatenEventStoreSerializer { 
  
  val entityPersisters = Persisters(stammdatenPersisters)
  
  val entityStoreInitializedPersister = persister[EntityStoreInitialized]("entity-store-initialized")  
  val entityInsertEventPersister = new EntityInsertEventPersister[V1](entityPersisters)
  val entityUpdatedEventPersister = new EntityUpdatedEventPersister[V1](entityPersisters)
  val entityDeletedEventPersister = new EntityDeletedEventPersister[V1](entityPersisters)
  
  val eventStorePersisters = List(entityStoreInitializedPersister, entityInsertEventPersister, entityUpdatedEventPersister, entityDeletedEventPersister)  
}<commit_msg>OO-101: added buchhaltungeventpersisters to all event serializers<commit_after>package ch.openolitor.core.eventsourcing

import akka.actor.{ ActorRef, ActorSystem }
import akka.serialization._
import com.typesafe.config.ConfigFactory
import stamina._
import stamina.json._
import ch.openolitor.core.domain.EntityStoreJsonProtocol
import ch.openolitor.core.domain.EntityStore._
import ch.openolitor.stammdaten.eventsourcing.StammdatenEventStoreSerializer
import com.typesafe.scalalogging.LazyLogging
import ch.openolitor.stammdaten.models.CustomKundentyp
import ch.openolitor.stammdaten.models.CustomKundentypCreate
import ch.openolitor.core.eventsourcing.events._
import ch.openolitor.buchhaltung.eventsourcing.BuchhaltungEventStoreSerializer

class EventStoreSerializer extends StaminaAkkaSerializer(EventStoreSerializer.eventStorePersisters) with LazyLogging with StammdatenEventStoreSerializer {
  
  override def toBinary(obj: AnyRef): Array[Byte] = {
    logger.debug(s"EventStoreSerielizer: toBinary: $obj")
    try {
      super.toBinary(obj)
    }          
    catch {
      case e:Exception => 
        logger.error(s"Can't persist $obj", e)
        stammdatenPersisters.map { persister => 
          if (persister.canPersist(obj)) {
            logger.warn(s"Found persister:${persister.key}")
          }
        }
        throw e
    }
  }
}

object EventStoreSerializer extends EntityStoreJsonProtocol with StammdatenEventStoreSerializer with BuchhaltungEventStoreSerializer { 
  
  val entityPersisters = Persisters(stammdatenPersisters ++ buchhaltungPersisters)
  
  val entityStoreInitializedPersister = persister[EntityStoreInitialized]("entity-store-initialized")  
  val entityInsertEventPersister = new EntityInsertEventPersister[V1](entityPersisters)
  val entityUpdatedEventPersister = new EntityUpdatedEventPersister[V1](entityPersisters)
  val entityDeletedEventPersister = new EntityDeletedEventPersister[V1](entityPersisters)
  
  val eventStorePersisters = List(entityStoreInitializedPersister, entityInsertEventPersister, entityUpdatedEventPersister, entityDeletedEventPersister)  
}
{'fraction_non_alphanumeric': 0.07392706524435624, 'fraction_numerical': 0.002232696601339618, 'mean_word_length': 5.3197492163009406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7662414', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1166, 'n_words': 193}