@Override
  public void deployArtifact(DeployableTemplate template) throws TemplateDeploymentException {
    try {
      int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
      String artifactId =
          template.getConfiguration().getFrom()
              + BatchScriptDeployerConstants.CONFIG_NAME_SEPARATOR
              + template.getConfiguration().getName();
      BatchScriptDeployerValueHolder.getAnalyticsProcessorService()
          .deleteScript(tenantId, artifactId);
      deployStreams(template);

      BatchScriptDeployerValueHolder.getAnalyticsProcessorService()
          .saveScript(
              tenantId,
              artifactId,
              template.getScript(),
              template.getConfiguration().getExecutionParameters());
    } catch (AnalyticsPersistenceException e) {
      throw new TemplateDeploymentException(
          "Error when saving batch script." + template.getConfiguration().getName(), e);
    }
  }