Search in sources :

Example 1 with EntityTree

use of io.jmix.reports.app.EntityTree in project jmix by jmix-framework.

the class EntityTreeModelBuilder method buildEntityTree.

public EntityTree buildEntityTree(MetaClass metaClass) {
    EntityTreeStructureInfo entityTreeStructureInfo = new EntityTreeStructureInfo();
    EntityTreeNode root = createRootNode(metaClass);
    fillChildNodes(root, 1, new HashSet<>(), entityTreeStructureInfo);
    return new EntityTree(root, entityTreeStructureInfo);
}
Also used : EntityTreeNode(io.jmix.reports.entity.wizard.EntityTreeNode) EntityTreeStructureInfo(io.jmix.reports.app.EntityTreeStructureInfo) EntityTree(io.jmix.reports.app.EntityTree)

Example 2 with EntityTree

use of io.jmix.reports.app.EntityTree in project jmix by jmix-framework.

the class EditFetchPlanAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (dataSetsTable.getSingleSelected() != null) {
        final DataSet dataSet = dataSetsTable.getSingleSelected();
        if (DataSetType.SINGLE == dataSet.getType() || DataSetType.MULTI == dataSet.getType()) {
            MetaClass forEntityTreeModelMetaClass = findMetaClassByAlias(dataSet);
            if (forEntityTreeModelMetaClass != null) {
                final EntityTree entityTree = reportsWizard.buildEntityTree(forEntityTreeModelMetaClass);
                ReportRegion reportRegion = dataSetToReportRegion(dataSet, entityTree);
                if (reportRegion != null) {
                    if (reportRegion.getRegionPropertiesRootNode() == null) {
                        notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "dataSet.entityAliasInvalid")).withDescription(getNameForEntityParameter(dataSet)).show();
                    // without that root node region editor form will not initialized correctly and became empty. just return
                    } else {
                        // Open editor and convert saved in editor ReportRegion item to Fetch plan
                        reportRegion.setReportData(dataManager.create(ReportData.class));
                        reportRegion.setBandNameFromReport(dataSet.getName());
                        Map<String, Object> editorParams = new HashMap<>();
                        editorParams.put("rootEntity", reportRegion.getRegionPropertiesRootNode());
                        editorParams.put("scalarOnly", Boolean.TRUE);
                        RegionEditor screen = screenBuilders.editor(ReportRegion.class, dataSetsTable.getFrame().getFrameOwner()).editEntity(reportRegion).withScreenClass(RegionEditor.class).withOpenMode(OpenMode.DIALOG).withOptions(new MapScreenOptions(editorParams)).build();
                        screen.setAsFetchPlanEditor(true);
                        screen.setUpdatePermission(secureOperations.isEntityUpdatePermitted(metadata.getClass(Report.class), policyStore));
                        screen.addAfterCloseListener(afterCloseEvent -> {
                            if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
                                RegionEditor editor = (RegionEditor) afterCloseEvent.getSource();
                                reportRegion.setRegionProperties(editor.getEditedEntity().getRegionProperties());
                                dataSet.setFetchPlan(reportRegionToFetchPlan(entityTree, reportRegion));
                            }
                        });
                        screen.show();
                    }
                }
            }
        }
    }
}
Also used : RegionEditor(io.jmix.reportsui.screen.report.wizard.region.RegionEditor) MetaClass(io.jmix.core.metamodel.model.MetaClass) HashMap(java.util.HashMap) ReportData(io.jmix.reports.entity.wizard.ReportData) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) EntityTree(io.jmix.reports.app.EntityTree) ReportRegion(io.jmix.reports.entity.wizard.ReportRegion)

Example 3 with EntityTree

use of io.jmix.reports.app.EntityTree in project jmix by jmix-framework.

the class ReportWizardCreator method onNextBtnClick.

@Subscribe("nextBtn")
public void onNextBtnClick(Button.ClickEvent event) {
    MetaClass metaClass = metadata.findClass(getItem().getEntityName());
    if (metaClass == null) {
        notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "fillEntityMsg")).show();
        return;
    }
    if (detailsFragment.isNeedUpdateEntityModel()) {
        EntityTree entityTree = reportWizard.buildEntityTree(metaClass);
        regionsStepFragment.setEntityTreeHasSimpleAttrs(entityTree.getEntityTreeStructureInfo().isEntityTreeHasSimpleAttrs());
        regionsStepFragment.setEntityTreeHasCollections(entityTree.getEntityTreeStructureInfo().isEntityTreeRootHasCollections());
        getItem().setEntityTreeRootNode(entityTree.getEntityTreeRootNode());
        detailsFragment.setNeedUpdateEntityModel(false);
    }
    stepFragmentManager.nextFragment();
    centerWindow();
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) EntityTree(io.jmix.reports.app.EntityTree)

Aggregations

EntityTree (io.jmix.reports.app.EntityTree)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 EntityTreeStructureInfo (io.jmix.reports.app.EntityTreeStructureInfo)1 EntityTreeNode (io.jmix.reports.entity.wizard.EntityTreeNode)1 ReportData (io.jmix.reports.entity.wizard.ReportData)1 ReportRegion (io.jmix.reports.entity.wizard.ReportRegion)1 RegionEditor (io.jmix.reportsui.screen.report.wizard.region.RegionEditor)1 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)1 HashMap (java.util.HashMap)1