@Override public Map<String, com.haulmont.yarg.structure.ReportTemplate> getReportTemplates() { Map<String, com.haulmont.yarg.structure.ReportTemplate> templateMap = new HashMap<>(); for (ReportTemplate template : templates) { templateMap.put(template.getCode(), template); } return templateMap; }
public ReportTemplate getTemplateByCode(String templateCode) { ReportTemplate template = null; if (templates != null) { Iterator<ReportTemplate> iter = templates.iterator(); while (iter.hasNext() && template == null) { ReportTemplate temp = iter.next(); if (StringUtils.equalsIgnoreCase(temp.getCode(), templateCode)) { template = temp; } } } return template; }
@Override protected void initNewItem(ReportTemplate template) { if (StringUtils.isEmpty(template.getCode())) { Report report = template.getReport(); if (report != null) { if (report.getTemplates() == null || report.getTemplates().isEmpty()) template.setCode(ReportService.DEFAULT_TEMPLATE_CODE); else template.setCode("Template_" + Integer.toString(report.getTemplates().size())); } } }
@Override public void actionPerform(Component component) { ReportTemplate template = (ReportTemplate) target.getSingleSelected(); if (template != null) { ReportTemplate copy = metadata.getTools().copy(template); copy.setId(uuidSource.createUuid()); String copyNamingPattern = getMessage("template.copyNamingPattern"); String copyCode = String.format(copyNamingPattern, StringUtils.isEmpty(copy.getCode()) ? StringUtils.EMPTY : copy.getCode()); //noinspection unchecked List<String> codes = (List<String>) target.getDatasource().getItems().stream() .map(o -> ((ReportTemplate) o).getCode()) .filter(o -> !StringUtils.isEmpty((String) o)) .collect(Collectors.toList()); if (codes.contains(copyCode)) { String code = copyCode; int i = 0; while ((codes.contains(code))) { i += 1; code = copyCode + " " + i; } copyCode = code; } copy.setCode(copyCode); //noinspection unchecked target.getDatasource().addItem(copy); } }
protected String findTableCode(Report report) { for (ReportTemplate reportTemplate : report.getTemplates()) { if (ReportOutputType.TABLE.equals(reportTemplate.getReportOutputType())) return reportTemplate.getCode(); } return null; }
protected TemplateInfo mapTemplateInfo(ReportTemplate template) { TemplateInfo templateInfo = new TemplateInfo(); templateInfo.code = template.getCode(); templateInfo.outputType = template.getReportOutputType().toString(); return templateInfo; }
public void printReport() { if (inputParametersFrame != null && inputParametersFrame.getReport() != null) { if (validateAll()) { Map<String, Object> parameters = inputParametersFrame.collectParameters(); Report report = inputParametersFrame.getReport(); templateCode = report.getTemplates().stream() .filter(template -> template.getReportOutputType() == ReportOutputType.CHART) .findFirst().get().getCode(); ReportOutputDocument reportResult = reportGuiManager.getReportResult(report, parameters, templateCode); openChart(new String(reportResult.getContent(), StandardCharsets.UTF_8)); } } } }
protected boolean validateTemplateFile() { ReportTemplate template = getItem(); if (!Boolean.TRUE.equals(template.getCustom()) && hasTemplateOutput(template.getReportOutputType()) && template.getContent() == null) { StringBuilder notification = new StringBuilder(getMessage("template.uploadTemplate")); if (StringUtils.isEmpty(template.getCode())) { notification.append("\n").append(getMessage("template.codeMsg")); } if (template.getOutputType() == null) { notification.append("\n").append(getMessage("template.outputTypeMsg")); } showNotification(getMessage("validationFail.caption"), notification.toString(), NotificationType.TRAY); return false; } return true; } }
.filter(t -> Objects.equals(t.getCode(), body.template)) .findFirst() .orElseThrow(() -> new RestAPIException("Template not found",
public void printReport() { if (inputParametersFrame.getReport() != null) { if (validateAll()) { ReportTemplate template = inputParametersFrame.getReportTemplate(); if (template != null) { templateCode = template.getCode(); } Report report = inputParametersFrame.getReport(); Map<String, Object> parameters = inputParametersFrame.collectParameters(); if (bulkPrint) { reportGuiManager.bulkPrint(report, templateCode, inputParametersFrame.getOutputType(), inputParameter.getAlias(), selectedEntities, this, parameters); } else { reportGuiManager.printReport(report, parameters, templateCode, outputFileName, inputParametersFrame.getOutputType(), this); } } } }
} catch (IOException ex) { throw new RuntimeException( String.format("An error occurred while uploading file for template [%s]", getItem().getCode()), ex);
throw new RuntimeException(String.format( "An error occurred while uploading file for template [%s]", defaultTemplate.getCode()));