@Test public void testTemplateUsingCatalogFields() throws Exception { String templateName = "templateCatalog"; String templateContent = null; String result = service.applyTemplate(templateName, templateContent, workflowInstance); Assert.assertEquals("EPISODE creator: Rute Santos, isPartOf: 20140119997, " + "title: Test Media Package, created: 2013-11-19T15:20:00Z, " + "SERIES creator: Harvard Extension School, description: http: + "subject: TEST E-19997", result); }
@Override public String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance) { if (templateContent == null && templateScannerRef.get() != null) { templateContent = templateScannerRef.get().getTemplate(templateName); } if (templateContent == null) { logger.warn("E-mail template not found: {}", templateName); return "TEMPLATE NOT FOUND: " + templateName; } HashMap<String, HashMap<String, String>> catalogs = initCatalogs(workflowInstance.getMediaPackage()); WorkflowOperationInstance failed = findFailedOperation(workflowInstance); List<Incident> incidentList = null; if (failed != null) { try { IncidentTree incidents = incidentService.getIncidentsOfJob(failed.getId(), true); incidentList = generateIncidentList(incidents); } catch (Exception e) { logger.error("Error when populating template with incidents", e); } } return DocUtil.generate(new EmailData(templateName, workflowInstance, catalogs, failed, incidentList), templateContent); }
EmailTemplateServiceImpl implements EmailTemplateService { @Override public String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance) { if (templateContent == null && templateScannerRef.get() != null) { templateContent = templateScannerRef.get().getTemplate(templateName); } if (templateContent == null) { logger.warn("E-mail template not found: {}", templateName); return "TEMPLATE NOT FOUND: " + templateName; } HashMap<String, HashMap<String, String>> catalogs = initCatalogs(workflowInstance.getMediaPackage()); WorkflowOperationInstance failed = findFailedOperation(workflowInstance); List<Incident> incidentList = null; if (failed != null) { try { IncidentTree incidents = incidentService.getIncidentsOfJob(failed.getId(), true); incidentList = generateIncidentList(incidents); } catch (Exception e) { logger.error("Error when populating template with incidents", e); } } return DocUtil.generate(new EmailData(templateName, workflowInstance, catalogs, failed, incidentList), templateContent); } }
EmailTemplateServiceImpl implements EmailTemplateService { @Override public String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance) { if (templateContent == null && templateScannerRef.get() != null) { templateContent = templateScannerRef.get().getTemplate(templateName); } if (templateContent == null) { logger.warn("E-mail template not found: {}", templateName); return "TEMPLATE NOT FOUND: " + templateName; } HashMap<String, HashMap<String, String>> catalogs = initCatalogs(workflowInstance.getMediaPackage()); WorkflowOperationInstance failed = findFailedOperation(workflowInstance); List<Incident> incidentList = null; if (failed != null) { try { IncidentTree incidents = incidentService.getIncidentsOfJob(failed.getId(), true); incidentList = generateIncidentList(incidents); } catch (Exception e) { logger.error("Error when populating template with incidents", e); } } return DocUtil.generate(new EmailData(templateName, workflowInstance, catalogs, failed, incidentList), templateContent); }  }
EmailTemplateServiceImpl implements EmailTemplateService { @Override public String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance) { if (templateContent == null && templateScannerRef.get() != null) { templateContent = templateScannerRef.get().getTemplate(templateName); } if (templateContent == null) { logger.warn("E-mail template not found: {}", templateName); return "TEMPLATE NOT FOUND: " + templateName; } HashMap<String, HashMap<String, String>> catalogs = initCatalogs(workflowInstance.getMediaPackage()); WorkflowOperationInstance failed = findFailedOperation(workflowInstance); List<Incident> incidentList = null; if (failed != null) { try { IncidentTree incidents = incidentService.getIncidentsOfJob(failed.getId(), true); incidentList = generateIncidentList(incidents); } catch (Exception e) { logger.error("Error when populating template with incidents", e); } } return DocUtil.generate(new EmailData(templateName, workflowInstance, catalogs, failed, incidentList), templateContent); }  @Override String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance); void setIncidentService(IncidentService incidentService); }
EmailTemplateServiceImpl implements EmailTemplateService { @Override public String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance) { if (templateContent == null && templateScannerRef.get() != null) { templateContent = templateScannerRef.get().getTemplate(templateName); } if (templateContent == null) { logger.warn("E-mail template not found: {}", templateName); return "TEMPLATE NOT FOUND: " + templateName; } HashMap<String, HashMap<String, String>> catalogs = initCatalogs(workflowInstance.getMediaPackage()); WorkflowOperationInstance failed = findFailedOperation(workflowInstance); List<Incident> incidentList = null; if (failed != null) { try { IncidentTree incidents = incidentService.getIncidentsOfJob(failed.getId(), true); incidentList = generateIncidentList(incidents); } catch (Exception e) { logger.error("Error when populating template with incidents", e); } } return DocUtil.generate(new EmailData(templateName, workflowInstance, catalogs, failed, incidentList), templateContent); }  @Override String applyTemplate(String templateName, String templateContent, WorkflowInstance workflowInstance); void setIncidentService(IncidentService incidentService); static final String DEFAULT_DELIMITER_FOR_MULTIPLE; }