forked from dbeaver/dbeaver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbeaver#18437 Support of InterSystems IRIS VIEW definition
To implement getViewDDL I added a plugin for InterSystems IRIS
- Loading branch information
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
plugins/org.jkiss.dbeaver.ext.intersystems/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: DBeaver InterSystems Support | ||
Bundle-SymbolicName: org.jkiss.dbeaver.ext.intersystems;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-Release-Date: 20240520 | ||
Require-Bundle: org.jkiss.dbeaver.model, | ||
org.jkiss.dbeaver.ext.generic | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-RequiredExecutionEnvironment: JavaSE-17 | ||
Bundle-Vendor: DBeaver Corp | ||
Bundle-ClassPath: . | ||
Automatic-Module-Name: org.jkiss.dbeaver.ext.intersystems | ||
Export-Package: org.jkiss.dbeaver.ext.intersystems.model | ||
Import-Package: org.jkiss.dbeaver.model.sql.format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source.. = src/ | ||
output.. = target/classes/ | ||
bin.includes = .,\ | ||
META-INF/,\ | ||
plugin.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.2"?> | ||
|
||
<plugin> | ||
|
||
<extension point="org.jkiss.dbeaver.generic.meta"> | ||
<meta id="intersystems" class="org.jkiss.dbeaver.ext.intersystems.model.InterSystemsMetaModel" driverClass="com.intersystems.jdbc.IRISDriver"/> | ||
</extension> | ||
|
||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jkiss.dbeaver</groupId> | ||
<artifactId>plugins</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../</relativePath> | ||
</parent> | ||
<artifactId>org.jkiss.dbeaver.ext.intersystems</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jkiss.dbeaver</groupId> | ||
<artifactId>org.jkiss.dbeaver.model</artifactId> | ||
<version>1.1.24-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jkiss.dbeaver</groupId> | ||
<artifactId>org.jkiss.dbeaver.ext.generic</artifactId> | ||
<version>2.3.217-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jkiss.dbeaver</groupId> | ||
<artifactId>org.jkiss.dbeaver.model.jdbc</artifactId> | ||
<version>1.0.24-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jkiss.dbeaver</groupId> | ||
<artifactId>org.jkiss.dbeaver.model.sql</artifactId> | ||
<version>1.0.121-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
....ext.intersystems/src/org/jkiss/dbeaver/ext/intersystems/model/InterSystemsMetaModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jkiss.dbeaver.ext.intersystems.model; | ||
|
||
import java.util.Map; | ||
|
||
import org.jkiss.code.NotNull; | ||
import org.jkiss.dbeaver.DBException; | ||
import org.jkiss.dbeaver.Log; | ||
import org.jkiss.dbeaver.ext.generic.model.GenericView; | ||
import org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel; | ||
import org.jkiss.dbeaver.model.DBPEvaluationContext; | ||
import org.jkiss.dbeaver.model.DBUtils; | ||
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; | ||
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet; | ||
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession; | ||
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; | ||
import org.jkiss.dbeaver.model.sql.format.SQLFormatUtils; | ||
|
||
public class InterSystemsMetaModel extends GenericMetaModel | ||
{ | ||
private static final Log log = Log.getLog(InterSystemsMetaModel.class); | ||
|
||
public InterSystemsMetaModel() { | ||
super(); | ||
} | ||
|
||
public String getViewDDL( | ||
@NotNull DBRProgressMonitor monitor, | ||
@NotNull GenericView view, | ||
@NotNull Map<String, Object> options) throws DBException { | ||
String sqlStatement = "SELECT View_Definition " | ||
+ " FROM INFORMATION_SCHEMA.VIEWS " | ||
+ "where TABLE_NAME=? and TABLE_SCHEMA=? "; | ||
try (JDBCSession session = DBUtils.openMetaSession(monitor, view, "Load source code")) { | ||
try (JDBCPreparedStatement dbStat = session.prepareStatement(sqlStatement)) { | ||
dbStat.setString(1, view.getName()); | ||
dbStat.setString(2, view.getContainer().getSchema().getName()); | ||
log.debug("Searching for view '%s' in schema '%s' ".formatted(view.getName(), view.getContainer().getSchema().getName())); | ||
try (JDBCResultSet dbResult = dbStat.executeQuery()) { | ||
if (dbResult.nextRow()) { | ||
String viewplain = dbResult.getString(1); | ||
return SQLFormatUtils.formatSQL(view.getDataSource(), viewplain); | ||
} | ||
} | ||
} | ||
} catch (Exception e) { | ||
throw new DBException("Can't read source code of '" + view.getFullyQualifiedName(DBPEvaluationContext.DDL) + "'", e); | ||
} | ||
return super.getViewDDL(monitor, view, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters