提交 5af68c70 编写于 作者: S Serge Rider

Value managers registry fix (datasource name)

上级 84a5adfd
...@@ -169,8 +169,9 @@ public class ResultSetValueController implements IAttributeController, IRowContr ...@@ -169,8 +169,9 @@ public class ResultSetValueController implements IAttributeController, IRowContr
@Override @Override
public IValueManager getValueManager() { public IValueManager getValueManager() {
DBSAttributeBase valueType = binding.getPresentationAttribute(); DBSAttributeBase valueType = binding.getPresentationAttribute();
final DBCExecutionContext executionContext = getExecutionContext();
return ValueManagerRegistry.findValueManager( return ValueManagerRegistry.findValueManager(
getDataSourceContainer(), executionContext == null ? null : executionContext.getDataSource(),
valueType, valueType,
getValueHandler().getValueObjectType(valueType)); getValueHandler().getValueObjectType(valueType));
} }
......
...@@ -21,6 +21,7 @@ import org.jkiss.code.NotNull; ...@@ -21,6 +21,7 @@ import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDataKind; import org.jkiss.dbeaver.model.DBPDataKind;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.impl.AbstractDescriptor; import org.jkiss.dbeaver.model.impl.AbstractDescriptor;
import org.jkiss.dbeaver.model.struct.DBSDataType; import org.jkiss.dbeaver.model.struct.DBSDataType;
...@@ -61,7 +62,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor ...@@ -61,7 +62,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
DBPDataKind dataKind; DBPDataKind dataKind;
ObjectType valueType; ObjectType valueType;
String extension; String extension;
DataSourceProviderDescriptor dataSource; String dataSource;
} }
private IValueManager instance; private IValueManager instance;
...@@ -80,7 +81,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor ...@@ -80,7 +81,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
String className = typeElement.getAttribute(ATTR_TYPE); String className = typeElement.getAttribute(ATTR_TYPE);
String ext = typeElement.getAttribute(ATTR_EXTENSION); String ext = typeElement.getAttribute(ATTR_EXTENSION);
String dspId = typeElement.getAttribute(ATTR_DATA_SOURCE); String dspId = typeElement.getAttribute(ATTR_DATA_SOURCE);
if (!CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(typeName) || !CommonUtils.isEmpty(className) || !CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(ext)) { if (!CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(typeName) || !CommonUtils.isEmpty(className) || !CommonUtils.isEmpty(dspId) || !CommonUtils.isEmpty(ext)) {
SupportInfo info = new SupportInfo(); SupportInfo info = new SupportInfo();
if (!CommonUtils.isEmpty(kindName)) { if (!CommonUtils.isEmpty(kindName)) {
try { try {
...@@ -99,10 +100,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor ...@@ -99,10 +100,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
info.extension = ext; info.extension = ext;
} }
if (!CommonUtils.isEmpty(dspId)) { if (!CommonUtils.isEmpty(dspId)) {
info.dataSource = DataSourceProviderRegistry.getInstance().getDataSourceProvider(dspId); info.dataSource = dspId;
if (info.dataSource == null) {
log.warn("Data source '" + dspId + "' not found");
}
} }
supportInfos.add(info); supportInfos.add(info);
} }
...@@ -128,13 +126,13 @@ public class ValueManagerDescriptor extends AbstractDescriptor ...@@ -128,13 +126,13 @@ public class ValueManagerDescriptor extends AbstractDescriptor
return instance; return instance;
} }
public boolean supportsType(@Nullable DBPDataSourceContainer dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType) public boolean supportsType(@Nullable DBPDataSource dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType)
{ {
final DBPDataKind dataKind = typedObject.getDataKind(); final DBPDataKind dataKind = typedObject.getDataKind();
for (SupportInfo info : supportInfos) { for (SupportInfo info : supportInfos) {
if (dataSource != null && info.dataSource != null) { if (dataSource != null && info.dataSource != null) {
DriverDescriptor driver = (DriverDescriptor) dataSource.getDriver(); DriverDescriptor driver = (DriverDescriptor) dataSource.getContainer().getDriver();
if (driver.getProviderDescriptor() != info.dataSource) { if (!info.dataSource.equals(driver.getProviderDescriptor().getId()) && !info.dataSource.equals(dataSource.getClass().getName())) {
continue; continue;
} }
} else if (checkDataSource) { } else if (checkDataSource) {
...@@ -169,8 +167,15 @@ public class ValueManagerDescriptor extends AbstractDescriptor ...@@ -169,8 +167,15 @@ public class ValueManagerDescriptor extends AbstractDescriptor
return true; return true;
} }
} }
if (!checkType && info.valueType == null && info.dataKind == null && info.typeName == null && info.extension == null) {
return true;
}
} }
return false; return false;
} }
@Override
public String toString() {
return id;
}
} }
\ No newline at end of file
...@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IExtensionRegistry; ...@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.jkiss.code.NotNull; import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.data.DBDContent; import org.jkiss.dbeaver.model.data.DBDContent;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
...@@ -66,7 +67,7 @@ public class ValueManagerRegistry { ...@@ -66,7 +67,7 @@ public class ValueManagerRegistry {
} }
@NotNull @NotNull
public IValueManager getManager(@Nullable DBPDataSourceContainer dataSource, @NotNull DBSTypedObject dataKind, @NotNull Class<?> valueType) { public IValueManager getManager(@Nullable DBPDataSource dataSource, @NotNull DBSTypedObject dataKind, @NotNull Class<?> valueType) {
// Check starting from most restrictive to less restrictive // Check starting from most restrictive to less restrictive
IValueManager manager = findManager(dataSource, dataKind, valueType, true, true); IValueManager manager = findManager(dataSource, dataKind, valueType, true, true);
if (manager == null) { if (manager == null) {
...@@ -84,7 +85,7 @@ public class ValueManagerRegistry { ...@@ -84,7 +85,7 @@ public class ValueManagerRegistry {
return manager; return manager;
} }
private IValueManager findManager(@Nullable DBPDataSourceContainer dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType) { private IValueManager findManager(@Nullable DBPDataSource dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType) {
for (ValueManagerDescriptor manager : managers) { for (ValueManagerDescriptor manager : managers) {
if (manager.supportsType(dataSource, typedObject, valueType, checkDataSource, checkType)) { if (manager.supportsType(dataSource, typedObject, valueType, checkDataSource, checkType)) {
return manager.getInstance(); return manager.getInstance();
...@@ -94,7 +95,7 @@ public class ValueManagerRegistry { ...@@ -94,7 +95,7 @@ public class ValueManagerRegistry {
} }
@NotNull @NotNull
public static IValueManager findValueManager(@Nullable DBPDataSourceContainer dataSource, @NotNull DBSTypedObject typedObject, @NotNull Class<?> valueType) { public static IValueManager findValueManager(@Nullable DBPDataSource dataSource, @NotNull DBSTypedObject typedObject, @NotNull Class<?> valueType) {
return getInstance().getManager(dataSource, typedObject, valueType); return getInstance().getManager(dataSource, typedObject, valueType);
} }
......
...@@ -451,7 +451,7 @@ public class ComplexObjectEditor extends TreeViewer { ...@@ -451,7 +451,7 @@ public class ComplexObjectEditor extends TreeViewer {
public IValueManager getValueManager() { public IValueManager getValueManager() {
DBSTypedObject valueType = getValueType(); DBSTypedObject valueType = getValueType();
return ValueManagerRegistry.findValueManager( return ValueManagerRegistry.findValueManager(
getExecutionContext().getDataSource().getContainer(), getExecutionContext().getDataSource(),
valueType, valueType,
getValueHandler().getValueObjectType(valueType)); getValueHandler().getValueObjectType(valueType));
} }
......
...@@ -792,7 +792,7 @@ ...@@ -792,7 +792,7 @@
id="org.jkiss.dbeaver.ext.generic.data.GenericValueHandlerProvider" id="org.jkiss.dbeaver.ext.generic.data.GenericValueHandlerProvider"
label="Generic data types provider"> label="Generic data types provider">
<datasource id="generic"/> <datasource id="generic"/>
<!-- Date/time value handler - needed to provide native datatime value formatting. Formatting itself provided in drivers configuration. --> <!-- Date/time value handler - needed to provide native datetime value formatting. Formatting itself provided in drivers configuration. -->
<type kind="DATETIME"/> <type kind="DATETIME"/>
</provider> </provider>
</extension> </extension>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册