use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ReportBrowser method copyReport.
protected Report copyReport(Report source) {
source = dataManager.load(Id.of(source)).fetchPlan("report.edit").one();
Report copiedReport = metadataTools.deepCopy(source);
copiedReport.setId(UuidProvider.createUuid());
copiedReport.setName(reportsUtils.generateReportName(source.getName()));
copiedReport.setCode(null);
for (ReportTemplate copiedTemplate : copiedReport.getTemplates()) {
copiedTemplate.setId(UuidProvider.createUuid());
}
reports.save(copiedReport);
return copiedReport;
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ReportEditTemplatesFragment method onTemplatesTableDefault.
@Subscribe("templatesTable.default")
protected void onTemplatesTableDefault(Action.ActionPerformedEvent event) {
ReportTemplate template = templatesTable.getSingleSelected();
if (template != null) {
reportDc.getItem().setDefaultTemplate(template);
}
event.getSource().refreshState();
templatesTable.focus();
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ReportEditTemplatesFragment method onTemplatesTableCopy.
@Subscribe("templatesTable.copy")
protected void onTemplatesTableCopy(Action.ActionPerformedEvent event) {
ReportTemplate template = templatesTable.getSingleSelected();
if (template != null) {
ReportTemplate copy = metadataTools.copy(template);
copy.setId(UuidProvider.createUuid());
copy.setVersion(null);
String copyNamingPattern = messages.getMessage(getClass(), "template.copyNamingPattern");
String copyCode = String.format(copyNamingPattern, StringUtils.isEmpty(copy.getCode()) ? StringUtils.EMPTY : copy.getCode());
List<String> codes = templatesDc.getItems().stream().map(ReportTemplate::getCode).filter(o -> !StringUtils.isEmpty(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);
templatesDc.getMutableItems().add(copy);
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ShowPivotTableScreen method printReport.
@Subscribe("printReportBtn")
protected void printReport(Button.ClickEvent event) {
if (inputParametersFragment != null && inputParametersFragment.getReport() != null) {
ValidationErrors validationErrors = screenValidation.validateUiComponents(getWindow());
if (validationErrors.isEmpty()) {
Map<String, Object> parameters = inputParametersFragment.collectParameters();
Report report = inputParametersFragment.getReport();
String resultTemplateCode = templateCode;
if (templateCode == null) {
if (reportTemplateComboBox.getValue() != null) {
resultTemplateCode = reportTemplateComboBox.getValue().getCode();
} else {
resultTemplateCode = report.getTemplates().stream().filter(template -> template.getReportOutputType() == ReportOutputType.PIVOT_TABLE).findFirst().map(ReportTemplate::getCode).orElse(null);
}
}
ReportOutputDocument document = reportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(resultTemplateCode).run();
PivotTableData result = (PivotTableData) serialization.deserialize(document.getContent());
openPivotTable(result.getPivotTableJson(), result.getValues());
} else {
screenValidation.showValidationErrors(this, validationErrors);
}
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class InputParametersFragment method updateOutputTypes.
protected void updateOutputTypes() {
if (!containsAlterableTemplate(report)) {
setOutputTypeVisible(false);
return;
}
ReportTemplate template;
if (report.getTemplates() != null && report.getTemplates().size() > 1) {
template = templateComboBox.getValue();
} else {
template = report.getDefaultTemplate();
}
if (template != null && supportAlterableForTemplate(template)) {
List<ReportOutputType> outputTypes = ReportPrintHelper.getInputOutputTypesMapping().get(template.getExt());
if (outputTypes != null && !outputTypes.isEmpty()) {
outputTypeComboBox.setOptionsList(outputTypes);
if (outputTypeComboBox.getValue() == null) {
outputTypeComboBox.setValue(template.getReportOutputType());
}
setOutputTypeVisible(true);
} else {
outputTypeComboBox.setValue(null);
setOutputTypeVisible(false);
}
} else {
outputTypeComboBox.setValue(null);
setOutputTypeVisible(false);
}
}
Aggregations