package com.cloudera.server.web.cmon.include;

import com.cloudera.cmon.MetricSchema.MetricContextEnum;
import com.cloudera.server.web.cmon.ContextQueryModel;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Constructor;
import org.jamon.AbstractRenderer;
import org.jamon.AbstractTemplateImpl;
import org.jamon.AbstractTemplateProxy;
import org.jamon.AbstractTemplateProxy.ImplData;
import org.jamon.AbstractTemplateProxy.Intf;
import org.jamon.Renderer;
import org.jamon.TemplateManager;
import org.jamon.annotations.Template;

@Template(signature="D71D24668D378EC0EAC04155D51BE849", requiredArguments={@org.jamon.annotations.Argument(name="queryModel", type="ContextQueryModel"), @org.jamon.annotations.Argument(name="tableId", type="String"), @org.jamon.annotations.Argument(name="contextEnum", type="MetricContextEnum"), @org.jamon.annotations.Argument(name="serviceId", type="long")})
public class ContextTreeTableAjax extends AbstractTemplateProxy
{
  public ContextTreeTableAjax(TemplateManager p_manager)
  {
    super(p_manager);
  }

  protected ContextTreeTableAjax(String p_path)
  {
    super(p_path);
  }

  public ContextTreeTableAjax()
  {
    super("/com/cloudera/server/web/cmon/include/ContextTreeTableAjax");
  }

  protected AbstractTemplateProxy.ImplData makeImplData()
  {
    return new ImplData();
  }

  public ImplData getImplData() {
    return (ImplData)super.getImplData();
  }

  public AbstractTemplateImpl constructImpl(Class<? extends AbstractTemplateImpl> p_class)
  {
    try
    {
      return (AbstractTemplateImpl)p_class.getConstructor(new Class[] { TemplateManager.class, ImplData.class }).newInstance(new Object[] { getTemplateManager(), getImplData() });
    }
    catch (RuntimeException e)
    {
      throw e;
    }
    catch (Exception e) {
    }
    throw new RuntimeException(e);
  }

  protected AbstractTemplateImpl constructImpl()
  {
    return new ContextTreeTableAjaxImpl(getTemplateManager(), getImplData());
  }

  public Renderer makeRenderer(ContextQueryModel queryModel, String tableId, MetricSchema.MetricContextEnum contextEnum, long serviceId) {
    return new AbstractRenderer(queryModel, tableId, contextEnum, serviceId)
    {
      public void renderTo(Writer jamonWriter)
        throws IOException
      {
        ContextTreeTableAjax.this.render(jamonWriter, this.val$queryModel, this.val$tableId, this.val$contextEnum, this.val$serviceId);
      }
    };
  }

  public void render(Writer jamonWriter, ContextQueryModel queryModel, String tableId, MetricSchema.MetricContextEnum contextEnum, long serviceId) throws IOException
  {
    renderNoFlush(jamonWriter, queryModel, tableId, contextEnum, serviceId);
    jamonWriter.flush();
  }

  public void renderNoFlush(Writer jamonWriter, ContextQueryModel queryModel, String tableId, MetricSchema.MetricContextEnum contextEnum, long serviceId) throws IOException
  {
    ImplData implData = getImplData();
    implData.setQueryModel(queryModel);
    implData.setTableId(tableId);
    implData.setContextEnum(contextEnum);
    implData.setServiceId(serviceId);
    Intf instance = (Intf)getTemplateManager().constructImpl(this);
    instance.renderNoFlush(jamonWriter);
    reset();
  }

  public static class ImplData extends AbstractTemplateProxy.ImplData
  {
    private ContextQueryModel m_queryModel;
    private String m_tableId;
    private MetricSchema.MetricContextEnum m_contextEnum;
    private long m_serviceId;

    public void setQueryModel(ContextQueryModel queryModel)
    {
      this.m_queryModel = queryModel;
    }

    public ContextQueryModel getQueryModel() {
      return this.m_queryModel;
    }

    public void setTableId(String tableId)
    {
      this.m_tableId = tableId;
    }

    public String getTableId() {
      return this.m_tableId;
    }

    public void setContextEnum(MetricSchema.MetricContextEnum contextEnum)
    {
      this.m_contextEnum = contextEnum;
    }

    public MetricSchema.MetricContextEnum getContextEnum() {
      return this.m_contextEnum;
    }

    public void setServiceId(long serviceId)
    {
      this.m_serviceId = serviceId;
    }

    public long getServiceId() {
      return this.m_serviceId;
    }
  }

  public static abstract interface Intf extends AbstractTemplateProxy.Intf
  {
    public abstract void renderNoFlush(Writer paramWriter)
      throws IOException;
  }
}