@Override
 public void undeployArtifact(String artifactId) throws TemplateDeploymentException {
   try {
     BatchScriptDeployerValueHolder.getAnalyticsProcessorService()
         .deleteScript(
             PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(), artifactId);
   } catch (AnalyticsPersistenceException e) {
     throw new TemplateDeploymentException("Error when deleting batch script " + artifactId, e);
   }
 }
  @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);
    }
  }