Browse Source

Pull request #14743: REPORT-132950 - 【fr-fbp回归】236环境最新的镜像,数据连接编辑、删除等操作后保存报错NPE

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp/release to fbp/release

* commit '5f93a75d97d2cf963d1097db413f3a459fdf6a5c':
  REPORT-132950 - 【fr-fbp回归】236环境最新的镜像,数据连接编辑、删除等操作后保存报错NPE
fbp/release
Destiny.Lin-林锦龙 3 months ago
parent
commit
1409a9e19b
  1. 21
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  2. 28
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  3. 31
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java

21
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -222,12 +222,22 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
removedConnNames.add(s);
break;
case ADDED:
addConnections.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true));
validConnection.add(connection);
ConnectionInfoBean add = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true);
if (StringUtils.isNotEmpty(add.getConnectionData())) {
addConnections.add(add);
validConnection.add(connection);
} else {
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass());
}
break;
case UPDATED:
updateConnection.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true));
validConnection.add(connection);
ConnectionInfoBean update = ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true);
if (StringUtils.isNotEmpty(update.getConnectionData())) {
updateConnection.add(update);
validConnection.add(connection);
} else {
FineLoggerFactory.getLogger().error("Unable to find the corresponding processor : {}", connection.getClass());
}
break;
default:
break;
@ -251,7 +261,8 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
* @return
*/
private boolean needUpdate0(Connection origin, Connection connection) {
return !connection.equals(origin) || !isEmbedConnection(connection);
// 先不考虑插件
return !connection.equals(origin);
}
/**

28
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -7,6 +7,7 @@ import com.fr.data.driver.DriverLoader;
import com.fr.data.driver.config.DriverLoaderConfig;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.solution.entity.DriverClasses;
import com.fr.datasource.connection.impl.DefaultDatabaseType;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.core.ReactiveCardPane;
import com.fr.design.gui.ibutton.UIButton;
@ -22,6 +23,7 @@ import com.fr.design.utils.BrowseUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
@ -62,6 +64,16 @@ public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name";
private static final String OTHER_DB = "Others";
public static final String ORACLE = "Oracle";
public static final String DB2 = "DB2";
public static final String SQL_SERVER = "SQL Server";
public static final String MYSQL = "MySQL";
public static final String SYBASE = "Sybase";
public static final String ACCESS = "Access";
public static final String DERBY = "Derby";
public static final String POSTGRE = "Postgre";
public static final String SQLITE = "SQLite";
public static final String INCEPTOR = "Inceptor";
private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([-0-9a-zA-Z_\\.\\\\]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([-0-9a-zA-Z_\\.\\\\]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");
@ -69,9 +81,22 @@ public class JDBCDefPane extends JPanel {
// 编码转换.
private String originalCharSet = null;
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
// 用于映射connection的database字段
private static Map<String, String> dbTypeMap = new HashMap<>();
private JPanel linkPanel;
static {
dbTypeMap.put(ORACLE, DefaultDatabaseType.ORACLE.getType());
dbTypeMap.put(DB2, DefaultDatabaseType.IBM_DB2.getType());
dbTypeMap.put(SQL_SERVER, DefaultDatabaseType.MICROSOFT_SQL_SERVER.getType());
dbTypeMap.put(MYSQL, DefaultDatabaseType.MYSQL.getType());
dbTypeMap.put(SYBASE, DefaultDatabaseType.SAP_ASE.getType());
dbTypeMap.put(ACCESS, DefaultDatabaseType.OTHER.getType());
dbTypeMap.put(DERBY, DefaultDatabaseType.DERBY.getType());
dbTypeMap.put(POSTGRE, DefaultDatabaseType.POSTGRESQL.getType());
dbTypeMap.put(SQLITE, DefaultDatabaseType.SQLITE.getType());
dbTypeMap.put(INCEPTOR, DefaultDatabaseType.TRANSWARP_INCEPTOR.getType());
jdbcMap.put(OTHER_DB, new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:"),
new DriverURLName("org.hsqldb.jdbcDriver", "jdbc:hsqldb:file:[PATH_TO_DB_FILES]"), new DriverURLName("com.inet.tds.TdsDriver", "jdbc:inetdae7:localhost:1433/"),
new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
@ -106,7 +131,7 @@ public class JDBCDefPane extends JPanel {
private ReactiveCardPane centerPanel;
private ReactiveCardPane driverSelectRow;
// 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB};
private final String[] dbtype = {ORACLE, DB2, SQL_SERVER, MYSQL, SYBASE, ACCESS, DERBY, POSTGRE, SQLITE, INCEPTOR, OTHER_DB};
private JDBCDatabaseConnection jdbcDatabase;
@ -153,6 +178,7 @@ public class JDBCDefPane extends JPanel {
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
jdbcDatabase.setDatabase(dbTypeMap.getOrDefault(GeneralUtils.objectToString(dbtypeComboBox.getSelectedItem()), DefaultDatabaseType.OTHER.getType()));
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);

31
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java vendored

@ -12,6 +12,14 @@ import com.fanruan.config.impl.data.ConnectionConfigWriter;
import com.fanruan.config.impl.data.ConnectionConfigWriterFactory;
import com.fanruan.config.impl.data.TableDataConfigProviderFactory;
import com.fanruan.data.ConnectionConfigWrapper;
import com.fanruan.datasource.connection.processor.ElasticSearchConnectionProcessor;
import com.fanruan.datasource.connection.processor.FTPConnectionProcessor;
import com.fanruan.datasource.connection.processor.LocalFileConnectionProcessor;
import com.fanruan.datasource.connection.processor.PublicDatasetConnectionProcessor;
import com.fanruan.datasource.connection.processor.SSHConnectionProcessor;
import com.fanruan.datasource.connection.processor.SapRfcConnectionProcessor;
import com.fanruan.datasource.connection.processor.kafka.KafkaConnectionProcessor;
import com.fanruan.datasource.connection.processor.mongo.MongoConnectionProcessor;
import com.fanruan.workplace.http.codec.SerializerRegister;
import com.fanruan.workplace.http.codec.SerializerRegisterGroup;
import com.fanruan.workplace.http.codec.xml.XmlableSerializer;
@ -58,10 +66,7 @@ public class DesignDatasourceComponent extends DatasourceComponent {
public void prepare() {
super.prepare();
// 注册数据连接处理器
ConnectionProcessorFactory.register(JDBCConnectionProcessor.KEY);
ConnectionProcessorFactory.register(JNDIConnectionProcessor.KEY);
ConnectionProcessorFactory.register(ConnectionPluginProcessor.KEY);
ConnectionProcessorFactory.register(JDYConnectionProcessor.KEY);
initConnectionProcessor();
DataSetProcessorFactory.init();
Carina.getApplicationContext().singleton(LocalConnectionShell.class).set(new LocalConnectionSource());
Carina.getApplicationContext().singleton(LocalTableDataShell.class).set(new LocalTableDataSource());
@ -99,4 +104,22 @@ public class DesignDatasourceComponent extends DatasourceComponent {
public void stop() {
}
/**
* 设计器当前没有更好的扫描手段只能先手动注册了
*/
private void initConnectionProcessor() {
ConnectionProcessorFactory.register(JDBCConnectionProcessor.KEY);
ConnectionProcessorFactory.register(JNDIConnectionProcessor.KEY);
ConnectionProcessorFactory.register(ConnectionPluginProcessor.KEY);
ConnectionProcessorFactory.register(JDYConnectionProcessor.KEY);
ConnectionProcessorFactory.register(new KafkaConnectionProcessor());
ConnectionProcessorFactory.register(new MongoConnectionProcessor());
ConnectionProcessorFactory.register(new ElasticSearchConnectionProcessor());
ConnectionProcessorFactory.register(new FTPConnectionProcessor());
ConnectionProcessorFactory.register(new LocalFileConnectionProcessor());
ConnectionProcessorFactory.register(new PublicDatasetConnectionProcessor());
ConnectionProcessorFactory.register(new SapRfcConnectionProcessor());
ConnectionProcessorFactory.register(new SSHConnectionProcessor());
}
}

Loading…
Cancel
Save