简体   繁体   English

Intellij插件:从数据库获取存储过程

[英]Intellij plugin: get stored procedure from database

I'm working on an Intellij (all products: phpStorm, Rider, Idea, etc) plugin to generate code from a data source (database tool window). 我正在研究Intellij(所有产品:phpStorm,Rider,Idea等)插件,以从数据源(数据库工具窗口)生成代码。

I get the needed data like this: 我得到这样的所需数据:

// Get all data sources
ProjectManager pm = ProjectManager.getInstance();
Project[] projects = pm.getOpenProjects();
Arrays.stream(projects).map(project ->
       DbPsiFacade.getInstance(project).getDataSources())
       .flatMap(Collection::stream).collect(Collectors.toList());
// Get Tables
DasUtil.getTables(source);
// Get columns
DasUtil.getColumns(table);

But I did not find any way to get a list of DbRoutine, which seems to represent the stored procedure. 但是我没有找到任何方法来获取DbRoutine的列表,该列表似乎表示存储过程。

Anyone knows how to get it? 有人知道如何获得吗?

Thank you 谢谢

I finally did it using a different method: 我终于用另一种方法做到了:

DbDataSource dataSource = ...;
dataSource.getModel().traverser().forEach(dasObject ->
    {
        if (dasObject instanceof DasTable) {
        }
        else if (dasObject instanceof DasColumn) {
        }
        else if (dasObject instanceof DasIndex) {
        }
        else if (dasObject instanceof DasConstraint) {
        }
        else if (dasObject instanceof DasRoutine) {
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM