<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= repository.imit.encoder_package %>;

import org.realityforge.imit.server.EntityMessage;

/**
 * * Utility class that encodes RPC payloads from JPA entities for the repository "<%= repository.name %>".
 */
@javax.annotation.Generated( "Domgen" )
@SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
public class <%= repository.imit.rpc_jpa_encoder_name %>
{
  @javax.annotation.Resource
  private javax.transaction.TransactionSynchronizationRegistry _registry;
<% repository.imit.client_side_data_modules.each do |data_module| %>
  private final <%= data_module.imit.qualified_router_interface_name %> _<%= data_module.name %>Router = new <%= data_module.imit.qualified_router_interface_name %>Impl();
<% end %>


  @javax.persistence.PostUpdate
  @javax.persistence.PostPersist
  public void postUpdate( final Object object )
  {
    <% repository.imit.concrete_client_side_entities.each do |entity|
%>if( <%= entity.jpa.qualified_entity_name %>.class.isInstance( object ) )
    {
      final <%= entity.jpa.qualified_entity_name %> entity = <%= entity.jpa.qualified_entity_name %>.class.cast( object );
      final @javax.annotation.Nonnull java.io.Serializable id = entity.<%= getter_for(entity.primary_key) %>;
      final @javax.annotation.Nonnull java.util.HashMap<String, java.io.Serializable> attributes = <%= entity.data_module.imit.qualified_rpc_jpa_encoder_name %>.encode<%= entity.name %>( entity );
      final int transportID = <%= entity.imit.transport_id %>;
      final @javax.annotation.Nonnull java.util.HashMap<String, java.io.Serializable> routingKeys = _<%= entity.data_module.name %>Router.route<%= entity.name %>( entity );
      final EntityMessage change = new EntityMessage( id, transportID, routingKeys, attributes );
      addChange( change );
    }
    else <%
   end
%>
    {
      //Ignore
    }
  }

  @javax.persistence.PostRemove
  public void postRemove( final Object object )
  {
<% repository.imit.concrete_client_side_entities.each do |entity|
%>if( <%= entity.jpa.qualified_entity_name %>.class.isInstance( object ) )
    {
      final <%= entity.jpa.qualified_entity_name %> entity = <%= entity.jpa.qualified_entity_name %>.class.cast( object );
      final @javax.annotation.Nonnull java.io.Serializable id = entity.<%= getter_for(entity.primary_key) %>;
      final int transportID = <%= entity.imit.transport_id %>;
      final @javax.annotation.Nonnull java.util.HashMap<String, java.io.Serializable> routingKeys = _<%= entity.data_module.name %>Router.route<%= entity.name %>( entity );
      final EntityMessage change = new EntityMessage( id, transportID, routingKeys, null );
      addChange( change );
    }
    else <%
 end
%>
    {
      //Ignore
    }
  }

  @SuppressWarnings( { "unchecked" } )
  private void addChange( final EntityMessage change )
  {
    final javax.transaction.TransactionSynchronizationRegistry registry = getRegistry();
    java.util.LinkedList<EntityMessage> changes = (java.util.LinkedList<EntityMessage>) registry.getResource( EntityMessage.KEY );
    if ( null == changes )
    {
      changes = new java.util.LinkedList<EntityMessage>();
      registry.putResource( EntityMessage.KEY, changes );
    }
    changes.add( change );
  }

  /**
   * Access registry via JNDI. Can not use @javax.annotation.Resource as JPA 2.0 does not
   * support it. However our Guice based test infrastructure uses it.
   */
  private javax.transaction.TransactionSynchronizationRegistry getRegistry()
  {
    if ( null == _registry )
    {
      try
      {
        _registry = (javax.transaction.TransactionSynchronizationRegistry)
          new javax.naming.InitialContext().lookup( "java:comp/TransactionSynchronizationRegistry" );
      }
      catch ( final javax.naming.NamingException ne )
      {
        throw new IllegalStateException( "Unable to locate TransactionSynchronizationRegistry due to " + ne, ne );
      }
    }
    return _registry;
  }
}
<commit_msg>Replace HashMap with Map<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= repository.imit.encoder_package %>;

import org.realityforge.imit.server.EntityMessage;

/**
 * * Utility class that encodes RPC payloads from JPA entities for the repository "<%= repository.name %>".
 */
@javax.annotation.Generated( "Domgen" )
@SuppressWarnings( { "UnusedDeclaration", "JavaDoc" } )
public class <%= repository.imit.rpc_jpa_encoder_name %>
{
  @javax.annotation.Resource
  private javax.transaction.TransactionSynchronizationRegistry _registry;
<% repository.imit.client_side_data_modules.each do |data_module| %>
  private final <%= data_module.imit.qualified_router_interface_name %> _<%= data_module.name %>Router = new <%= data_module.imit.qualified_router_interface_name %>Impl();
<% end %>


  @javax.persistence.PostUpdate
  @javax.persistence.PostPersist
  public void postUpdate( final Object object )
  {
    <% repository.imit.concrete_client_side_entities.each do |entity|
%>if( <%= entity.jpa.qualified_entity_name %>.class.isInstance( object ) )
    {
      final <%= entity.jpa.qualified_entity_name %> entity = <%= entity.jpa.qualified_entity_name %>.class.cast( object );
      final @javax.annotation.Nonnull java.io.Serializable id = entity.<%= getter_for(entity.primary_key) %>;
      final @javax.annotation.Nonnull java.util.HashMap<String, java.io.Serializable> attributes = <%= entity.data_module.imit.qualified_rpc_jpa_encoder_name %>.encode<%= entity.name %>( entity );
      final int transportID = <%= entity.imit.transport_id %>;
      final @javax.annotation.Nonnull java.util.Map<String, java.io.Serializable> routingKeys = _<%= entity.data_module.name %>Router.route<%= entity.name %>( entity );
      final EntityMessage change = new EntityMessage( id, transportID, routingKeys, attributes );
      addChange( change );
    }
    else <%
   end
%>
    {
      //Ignore
    }
  }

  @javax.persistence.PostRemove
  public void postRemove( final Object object )
  {
<% repository.imit.concrete_client_side_entities.each do |entity|
%>if( <%= entity.jpa.qualified_entity_name %>.class.isInstance( object ) )
    {
      final <%= entity.jpa.qualified_entity_name %> entity = <%= entity.jpa.qualified_entity_name %>.class.cast( object );
      final @javax.annotation.Nonnull java.io.Serializable id = entity.<%= getter_for(entity.primary_key) %>;
      final int transportID = <%= entity.imit.transport_id %>;
      final @javax.annotation.Nonnull java.util.Map<String, java.io.Serializable> routingKeys = _<%= entity.data_module.name %>Router.route<%= entity.name %>( entity );
      final EntityMessage change = new EntityMessage( id, transportID, routingKeys, null );
      addChange( change );
    }
    else <%
 end
%>
    {
      //Ignore
    }
  }

  @SuppressWarnings( { "unchecked" } )
  private void addChange( final EntityMessage change )
  {
    final javax.transaction.TransactionSynchronizationRegistry registry = getRegistry();
    java.util.LinkedList<EntityMessage> changes = (java.util.LinkedList<EntityMessage>) registry.getResource( EntityMessage.KEY );
    if ( null == changes )
    {
      changes = new java.util.LinkedList<EntityMessage>();
      registry.putResource( EntityMessage.KEY, changes );
    }
    changes.add( change );
  }

  /**
   * Access registry via JNDI. Can not use @javax.annotation.Resource as JPA 2.0 does not
   * support it. However our Guice based test infrastructure uses it.
   */
  private javax.transaction.TransactionSynchronizationRegistry getRegistry()
  {
    if ( null == _registry )
    {
      try
      {
        _registry = (javax.transaction.TransactionSynchronizationRegistry)
          new javax.naming.InitialContext().lookup( "java:comp/TransactionSynchronizationRegistry" );
      }
      catch ( final javax.naming.NamingException ne )
      {
        throw new IllegalStateException( "Unable to locate TransactionSynchronizationRegistry due to " + ne, ne );
      }
    }
    return _registry;
  }
}

{'fraction_non_alphanumeric': 0.1244233886049121, 'fraction_numerical': 0.0004986909362922329, 'mean_word_length': 3.8442028985507246, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, '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': '977084', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2339, 'n_words': 491}