Getting StoreProcedures name from databaseTools in 2021.1 API

Answered

I've being using Intellij 17 till now & with the lastest update to 2021.1 I needed
to change the code -


DatabaseSystem databaseSystem = getDataSource();
JBIterable<String> jbIterable = databaseSystem.getModel().traverser()
.expand(dasObject -> dasObject instanceof DbPackage || dasObject instanceof DasNamespace)
.filter(SybaseProcedureGroup.class)
.map(BasicNamedElement::getName);
spNamesMap = jbIterable.toSet().stream().collect(Collectors.toMap(o -> o, o -> o));
return jbIterable.toSet();

I tried changing the code to -

DasDataSource databaseSystem = getDataSource();
JBIterable<String> jbIterable = databaseSystem.getModel().traverser()
.expand(dasObject -> dasObject instanceof DbPackage || dasObject instanceof DasNamespace)
.filter(AseProcedureGroup.class)
.map(aseProcedureGroup -> aseProcedureGroup.getProcedures()) // here's the problem
spNamesMap = jbIterable.toSet().stream().collect(Collectors.toMap(o -> o, o -> o));
return jbIterable.toSet();

With the line marked I have a problem, what's the proper way to get the name in the new API?

0
2 comments

In first snippet you were collecting procedure group names:

      .filter(SybaseProcedureGroup.class)
.map(BasicNamedElement::getName);

So I think in new one you should collect them too:

      .filter(AseProcedureGroup.class)
//.map(aseProcedureGroup -> aseProcedureGroup.getProcedures()) // here's the problem
.map(BasicNamedElement::getName)


But I suggest you not to use any class that inherits `Basic***` they are generated and we won't keep them compatible in any way.
You'd better to stick to `Das*` interfaces && ObjectKind:

if (databaseSystem.getDbms() != Dbms.SYBASE) return ...
JBIterable
<String> jbIterable = databaseSystem.getModel().traverser()
.expand(dasObject -> dasObject instanceof DasNamespace)
.filter(dasObject -> dasObject.getKind() == ObjectKind.PACKAGE) //procedure groups are packages :)
.map(DasObject::getName);



0

Thank you for the fast reply, it seems to compile fine, still trying to get a valid runtime test

0

Please sign in to leave a comment.