<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(service.gwt_rpc.qualified_proxy_name) %>;

@javax.annotation.Generated( "Domgen" )
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked", "Convert2Diamond", "PMD.UnusedPrivateField", "PMD.AddEmptyString" } )
public class <%= service.gwt_rpc.proxy_name %>
  implements <%= service.gwt_rpc.qualified_facade_service_name %>
{
  @javax.inject.Inject
  private <%= service.gwt_rpc.qualified_async_rpc_service_name %> _service;
<% if service.gwt_rpc.default_callback? -%>
  @javax.inject.Named( "<%= service.gwt_rpc.default_callback_name %>" )
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;
<% end -%>
<% if service.methods.any?{|m| m.parameters.any?{|p| p.struct? && p.referenced_struct.auto_bean? } || (m.return_value.struct? && m.return_value.referenced_struct.auto_bean?) } -%>
  @javax.inject.Inject
  private <%= service.data_module.repository.auto_bean.qualified_factory_name %> _factory;
<% end -%>
<% service.methods.select{|method| method.gwt_rpc?}.each do |method|
   method_name = Reality::Naming.camelize(method.name)
   parameters = method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?} -%>

  public void <%= method_name %>(<%= parameters.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" }.join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| Reality::Naming.camelize(p.name) } + ['null']).join(', ') %>);
  }

  public void <%= method_name %>(<%= (parameters.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback"]).join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| Reality::Naming.camelize(p.name) } + ['callback','null']).join(', ') %>);
  }

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback","final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_error_callback_name} errorCallback"]).join(', ') %>)
  {
<% method.parameters.select{|parameter| (parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| -%>
    <%= annotated_type(parameter, :gwt_rpc, :transport, :final => true) %> $<%= Reality::Naming.camelize(parameter.name) %> = <%= parameter.nullable? ? "null == #{Reality::Naming.camelize(parameter.name)} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? 'HashSet' : 'ArrayList' %><<%= parameter.gwt_rpc.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= Reality::Naming.camelize(parameter.name) %> ) {<% end %>
    for( final <%= parameter.gwt_rpc.java_component_type %> entity: <%= Reality::Naming.camelize(parameter.name) %> )
    {
    <%
       param_value =
       if parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? 'ordinal()' : 'name()'}"
       else
         if parameter.referenced_struct.auto_bean?
           'com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( entity ) ).getPayload()'
         else
           "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( entity )"
         end
       end
    %>
    $<%= Reality::Naming.camelize(parameter.name) %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
<% end -%>
<% if method.imit? -%>
    request( "<%= service.qualified_name %>.<%= method.name %>", <%= method.imit.graph_to_subscribe.nil? ? 'null' : "#{service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name}.getSessionContext().getKey() + \":\" + #{method.service.data_module.repository.imit.qualified_graph_enum_name}.#{Reality::Naming.uppercase_constantize(method.service.data_module.repository.imit.graph_by_name(method.imit.graph_to_subscribe).name)}.name()" %>, (session, request) -> {
<% end -%>
<% if method.keycloak? -%>
    updateTokenAndExecute( () -> {
<% end -%>
    _service.<%= method.gwt_rpc.name %>(<%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect do |parameter|
  param_value = Reality::Naming.camelize(parameter.name)
  if parameter.collection? && (parameter.enumeration? || parameter.struct?)
    param_value = "$#{param_value}"
  elsif parameter.enumeration? && parameter.enumeration.numeric_values?
    param_value = "#{param_value}.ordinal()"
  elsif parameter.enumeration? && parameter.enumeration.textual_values?
    param_value = "#{param_value}.name()"
  elsif parameter.struct?
    if parameter.referenced_struct.auto_bean?
      param_value = "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( #{parameter.name} ) ).getPayload()"
    else
      param_value = "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( #{param_value} )"
    end
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{Reality::Naming.camelize(parameter.name)} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.empty? ? '' : ', ' %>new <%= service.data_module.repository.gwt_rpc.qualified_async_callback_adapter_name %><<%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %>,<%= method.return_value.gwt_rpc.non_primitive_java_type(:boundary) %>>( <%= service.gwt_rpc.default_callback? ? '_callback' : 'null' -%>, callback, errorCallback<% if service.data_module.repository.imit? -%><% if method.imit? -%>, session, request<% else -%>, null, null<% end -%><% end -%> )
    {
      @java.lang.Override
      <%= annotated_type(method.return_value, :gwt_rpc, :boundary, :non_primitive => true, :protected => true, :final => true) %> convert( final <%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %> result )
      {
<%
   if !method.return_value.collection?
     result_string = 'result'
     if method.return_value.enumeration? && method.return_value.enumeration.numeric_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.valueOf( result )"
     elsif method.return_value.struct?
       if method.return_value.referenced_struct.auto_bean?
       result_string = "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, result ).as()"
       else
       result_string = "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( result )"
       end
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.struct?
     result_string = '$result'
   else
     result_string = 'result'
   end
-%>
<% if method.return_value.collection? && (method.return_value.enumeration? || method.return_value.struct?) -%>
        <%= annotated_type(method.return_value, :gwt_rpc, :boundary, :final => true) %> $result = <% if method.return_value.nullable? %>result == null ? null : <% end %>new java.util.<%=  method.return_value.collection_type == :set ? 'HashSet' : 'ArrayList' %><<%= method.return_value.gwt_rpc.java_component_type %>>();
        if ( null != result )
        {
          for( final <%= method.return_value.gwt_rpc.java_component_type(:transport) %> id: result )
          {
<%
         param_value =
         if method.return_value.enumeration?
           method.return_value.enumeration.textual_values? ?
             "#{method.return_value.gwt_rpc.java_component_type}.valueOf( id )" :
             "#{method.return_value.gwt_rpc.java_component_type}.values()[ id ]"
         else
           if method.return_value.referenced_struct.auto_bean?
           "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, id ).as()"
           else
           "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( id )"
           end
         end
-%>
            $result.add( <%= param_value %> );
          }
        }
<% end -%>
        return <%= result_string %>;
      }
    } );
<% if method.keycloak? -%>
    } );
<% end -%>
<% if method.imit? -%>
    } );
<% end -%>
  }
<% end -%>
<% if service.imit? -%>

  private void request( @javax.annotation.Nonnull final String key, @javax.annotation.Nullable final String cacheKey, @javax.annotation.Nonnull final org.realityforge.replicant.client.transport.RequestAction action )
  {
    <%= service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name %>.getSessionContext().request( key, cacheKey, action );
  }
<% end -%>
<% if service.keycloak? -%>

  private void updateTokenAndExecute( @javax.annotation.Nonnull final java.lang.Runnable action )
  {
    <%= service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name %>.updateTokenAndExecute( action );
  }
<% end -%>
}
<commit_msg>Ensure request is set after security token aquired so that static value for token is still valid when gwt-rpc call occurs<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(service.gwt_rpc.qualified_proxy_name) %>;

@javax.annotation.Generated( "Domgen" )
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked", "Convert2Diamond", "PMD.UnusedPrivateField", "PMD.AddEmptyString" } )
public class <%= service.gwt_rpc.proxy_name %>
  implements <%= service.gwt_rpc.qualified_facade_service_name %>
{
  @javax.inject.Inject
  private <%= service.gwt_rpc.qualified_async_rpc_service_name %> _service;
<% if service.gwt_rpc.default_callback? -%>
  @javax.inject.Named( "<%= service.gwt_rpc.default_callback_name %>" )
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;
<% end -%>
<% if service.methods.any?{|m| m.parameters.any?{|p| p.struct? && p.referenced_struct.auto_bean? } || (m.return_value.struct? && m.return_value.referenced_struct.auto_bean?) } -%>
  @javax.inject.Inject
  private <%= service.data_module.repository.auto_bean.qualified_factory_name %> _factory;
<% end -%>
<% service.methods.select{|method| method.gwt_rpc?}.each do |method|
   method_name = Reality::Naming.camelize(method.name)
   parameters = method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?} -%>

  public void <%= method_name %>(<%= parameters.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" }.join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| Reality::Naming.camelize(p.name) } + ['null']).join(', ') %>);
  }

  public void <%= method_name %>(<%= (parameters.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback"]).join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| Reality::Naming.camelize(p.name) } + ['callback','null']).join(', ') %>);
  }

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect{|p| "#{annotated_type(p, :gwt_rpc, :boundary, :final => true)} #{Reality::Naming.camelize(p.name)}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback","final @javax.annotation.Nullable #{service.data_module.repository.gwt.qualified_async_error_callback_name} errorCallback"]).join(', ') %>)
  {
<% method.parameters.select{|parameter| (parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| -%>
    <%= annotated_type(parameter, :gwt_rpc, :transport, :final => true) %> $<%= Reality::Naming.camelize(parameter.name) %> = <%= parameter.nullable? ? "null == #{Reality::Naming.camelize(parameter.name)} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? 'HashSet' : 'ArrayList' %><<%= parameter.gwt_rpc.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= Reality::Naming.camelize(parameter.name) %> ) {<% end %>
    for( final <%= parameter.gwt_rpc.java_component_type %> entity: <%= Reality::Naming.camelize(parameter.name) %> )
    {
    <%
       param_value =
       if parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? 'ordinal()' : 'name()'}"
       else
         if parameter.referenced_struct.auto_bean?
           'com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( entity ) ).getPayload()'
         else
           "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( entity )"
         end
       end
    %>
    $<%= Reality::Naming.camelize(parameter.name) %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
<% end -%>
<% if method.keycloak? -%>
    updateTokenAndExecute( () -> {
<% end -%>
<% if method.imit? -%>
    request( "<%= service.qualified_name %>.<%= method.name %>", <%= method.imit.graph_to_subscribe.nil? ? 'null' : "#{service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name}.getSessionContext().getKey() + \":\" + #{method.service.data_module.repository.imit.qualified_graph_enum_name}.#{Reality::Naming.uppercase_constantize(method.service.data_module.repository.imit.graph_by_name(method.imit.graph_to_subscribe).name)}.name()" %>, (session, request) -> {
<% end -%>
    _service.<%= method.gwt_rpc.name %>(<%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect do |parameter|
  param_value = Reality::Naming.camelize(parameter.name)
  if parameter.collection? && (parameter.enumeration? || parameter.struct?)
    param_value = "$#{param_value}"
  elsif parameter.enumeration? && parameter.enumeration.numeric_values?
    param_value = "#{param_value}.ordinal()"
  elsif parameter.enumeration? && parameter.enumeration.textual_values?
    param_value = "#{param_value}.name()"
  elsif parameter.struct?
    if parameter.referenced_struct.auto_bean?
      param_value = "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( #{parameter.name} ) ).getPayload()"
    else
      param_value = "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( #{param_value} )"
    end
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{Reality::Naming.camelize(parameter.name)} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.empty? ? '' : ', ' %>new <%= service.data_module.repository.gwt_rpc.qualified_async_callback_adapter_name %><<%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %>,<%= method.return_value.gwt_rpc.non_primitive_java_type(:boundary) %>>( <%= service.gwt_rpc.default_callback? ? '_callback' : 'null' -%>, callback, errorCallback<% if service.data_module.repository.imit? -%><% if method.imit? -%>, session, request<% else -%>, null, null<% end -%><% end -%> )
    {
      @java.lang.Override
      <%= annotated_type(method.return_value, :gwt_rpc, :boundary, :non_primitive => true, :protected => true, :final => true) %> convert( final <%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %> result )
      {
<%
   if !method.return_value.collection?
     result_string = 'result'
     if method.return_value.enumeration? && method.return_value.enumeration.numeric_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.valueOf( result )"
     elsif method.return_value.struct?
       if method.return_value.referenced_struct.auto_bean?
       result_string = "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, result ).as()"
       else
       result_string = "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( result )"
       end
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.struct?
     result_string = '$result'
   else
     result_string = 'result'
   end
-%>
<% if method.return_value.collection? && (method.return_value.enumeration? || method.return_value.struct?) -%>
        <%= annotated_type(method.return_value, :gwt_rpc, :boundary, :final => true) %> $result = <% if method.return_value.nullable? %>result == null ? null : <% end %>new java.util.<%=  method.return_value.collection_type == :set ? 'HashSet' : 'ArrayList' %><<%= method.return_value.gwt_rpc.java_component_type %>>();
        if ( null != result )
        {
          for( final <%= method.return_value.gwt_rpc.java_component_type(:transport) %> id: result )
          {
<%
         param_value =
         if method.return_value.enumeration?
           method.return_value.enumeration.textual_values? ?
             "#{method.return_value.gwt_rpc.java_component_type}.valueOf( id )" :
             "#{method.return_value.gwt_rpc.java_component_type}.values()[ id ]"
         else
           if method.return_value.referenced_struct.auto_bean?
           "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, id ).as()"
           else
           "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( id )"
           end
         end
-%>
            $result.add( <%= param_value %> );
          }
        }
<% end -%>
        return <%= result_string %>;
      }
    } );
<% if method.imit? -%>
    } );
<% end -%>
<% if method.keycloak? -%>
    } );
<% end -%>
  }
<% end -%>
<% if service.imit? -%>

  private void request( @javax.annotation.Nonnull final String key, @javax.annotation.Nullable final String cacheKey, @javax.annotation.Nonnull final org.realityforge.replicant.client.transport.RequestAction action )
  {
    <%= service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name %>.getSessionContext().request( key, cacheKey, action );
  }
<% end -%>
<% if service.keycloak? -%>

  private void updateTokenAndExecute( @javax.annotation.Nonnull final java.lang.Runnable action )
  {
    <%= service.data_module.repository.gwt_rpc.qualified_rpc_services_module_name %>.updateTokenAndExecute( action );
  }
<% end -%>
}

{'fraction_non_alphanumeric': 0.16945817778226213, 'fraction_numerical': 0.00010089799212995662, 'mean_word_length': 4.518652561247216, 'pattern_counts': {'":': 2, '<': 177, '<?xml version=': 0, '>': 197, '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': '7578709', 'n_tokens_mistral': 6818, 'n_tokens_neox': 6460, 'n_words': 856}