package scoutmgr.server.service;

import javax.annotation.Nonnull;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Typed;
import javax.inject.Inject;
import javax.transaction.Transactional;
import org.realityforge.replicant.server.EntityMessage;
import org.realityforge.replicant.server.EntityMessageSet;
import scoutmgr.server.data_type.PeopleFilterDTO;
import scoutmgr.server.entity.dao.PersonRepository;
import scoutmgr.server.net.ScoutmgrGraphEncoder;
import scoutmgr.server.net.ScoutmgrSession;

@ApplicationScoped
@Transactional( Transactional.TxType.REQUIRED )
@Typed( ScoutmgrSessionContext.class )
public class ScoutmgrSessionContextImpl
  extends AbstractScoutmgrSessionContextImpl
  implements ScoutmgrSessionContext
{
  @Inject
  PersonRepository _personRepository;

  @Inject
  ScoutmgrGraphEncoder _encoder;

  @Override
  protected boolean isPeopleInteresting( @Nonnull final EntityMessage message,
                                         @Nonnull final ScoutmgrSession session,
                                         @Nonnull final PeopleFilterDTO filter )
  {
    // TODO: implement filter properly
    return true;
  }

  @Override
  public void collectForFilterChangePeople( @Nonnull final EntityMessageSet messages,
                                            @Nonnull final PeopleFilterDTO originalFilter,
                                            @Nonnull final PeopleFilterDTO currentFilter )
  {
    // never going to change filter, it's tied to a login.
  }

  @Override
  public void collectPeople( @Nonnull final EntityMessageSet messages,
                             @Nonnull final PeopleFilterDTO filter )
  {
    // TODO: implement filter properly
    _encoder.encodeObjects( messages, _personRepository.findAll());
  }
}

@@ -217,16 +217,128 @@
 tional;%0A
+import org.realityforge.replicant.server.ChangeSet;%0Aimport org.realityforge.replicant.server.ChannelDescriptor;%0A
 import o
@@ -440,24 +440,93 @@
 MessageSet;%0A
+import org.realityforge.replicant.server.transport.ReplicantSession;%0A
 import scout
@@ -667,52 +667,8 @@
 der;
-%0Aimport scoutmgr.server.net.ScoutmgrSession;
 %0A%0A@A
@@ -1134,24 +1134,25 @@
 l final 
-Scoutmgr
+Replicant
 Session 
@@ -1714,33 +1714,101 @@
 nal 
-EntityMessageSet messages
+ChannelDescriptor descriptor,%0A                             @Nonnull final ChangeSet changeSet
 ,%0A  
@@ -1913,24 +1913,86 @@
 er properly%0A
+    final EntityMessageSet messages = new EntityMessageSet();%0A
     _encoder
@@ -2047,14 +2047,59 @@
 All());%0A
+    changeSet.merge( descriptor, messages );%0A
   %7D%0A%7D%0A

Handle changed interface for filter methods