提交 335abcd0 编写于 作者: S Serge Rider

#6860 H2GIS - geometry handler + driver config fix

上级 01af2de3
......@@ -5,6 +5,7 @@ Bundle-SymbolicName: org.jkiss.dbeaver.ext.h2gis;singleton:=true
Bundle-Version: 1.0.1.qualifier
Bundle-Release-Date: 20191007
Require-Bundle: org.jkiss.dbeaver.model,
org.jkiss.dbeaver.data.gis,
org.jkiss.dbeaver.ext.generic,
org.jkiss.dbeaver.ext.h2
Bundle-ActivationPolicy: lazy
......
......@@ -22,7 +22,7 @@
iconBig="icons/h2gis_icon_big.png"
category="H2"
class="org.h2.Driver"
sampleURL="jdbc:h2:{database}"
sampleURL="jdbc:h2:{file}"
webURL="http://www.h2gis.org/"
embedded="true"
description="H2GIS Embedded"
......@@ -66,4 +66,18 @@
<meta id="h2gis" class="org.jkiss.dbeaver.ext.h2gis.model.H2GISMetaModel" driverClass="org.h2.Driver"/>
</extension>
<extension point="org.jkiss.dbeaver.dataTypeProvider">
<provider
class="org.jkiss.dbeaver.ext.h2gis.data.H2GISValueHandlerProvider"
description="H2GIS data types provider"
id="org.jkiss.dbeaver.ext.h2gis.data.H2GISValueHandlerProvider"
label="H2GIS data types provider">
<datasource id="h2gis"/>
<type name="GEOMETRY"/>
</provider>
</extension>
</plugin>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* 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.h2gis.data;
import org.jkiss.dbeaver.data.gis.handlers.GISGeometryValueHandler;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.struct.DBSTypedObject;
import java.sql.SQLException;
/**
* H2GIS Server geometry handler
*/
public class H2GISGeometryValueHandler extends GISGeometryValueHandler {
public static final H2GISGeometryValueHandler INSTANCE = new H2GISGeometryValueHandler();
@Override
protected Object fetchColumnValue(DBCSession session, JDBCResultSet resultSet, DBSTypedObject type, int index) throws DBCException, SQLException {
return getValueFromObject(session, type,
resultSet.getObject(index),
false);
}
/*
protected void bindGeometryParameter(@NotNull JDBCSession session, @NotNull JDBCPreparedStatement statement, int paramIndex, @NotNull Geometry value) throws SQLException, DBCException {
statement.setString(paramIndex, value.toString());
}
@Override
protected byte[] convertGeometryToBinaryFormat(DBCSession session, Geometry geometry) throws DBCException {
throw new DBCException("Saving in SQL Server binary format not supported yet");
}
@Override
public String makeQueryBind(DBSAttributeBase attribute, Object value) throws DBCException {
int srid = 0;
if (value instanceof DBGeometry) {
srid = ((DBGeometry) value).getSRID();
} else if (value instanceof Geometry) {
srid = ((Geometry) value).getSRID();
}
return "geometry::STGeomFromText(?," + srid + ")";
}
*/
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* 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.h2gis.data;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.data.DBDPreferences;
import org.jkiss.dbeaver.model.data.DBDValueHandler;
import org.jkiss.dbeaver.model.data.DBDValueHandlerProvider;
import org.jkiss.dbeaver.model.struct.DBSTypedObject;
/**
* H2GIS data types provider
*/
public class H2GISValueHandlerProvider implements DBDValueHandlerProvider {
@Nullable
@Override
public DBDValueHandler getValueHandler(DBPDataSource dataSource, DBDPreferences preferences, DBSTypedObject typedObject)
{
if (typedObject.getTypeName().equalsIgnoreCase("GEOMETRY")) {
return H2GISGeometryValueHandler.INSTANCE;
} else {
return null;
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册