use of com.qlangtech.tis.git.GitUtils in project tis by qlangtech.
the class OfflineDatasourceAction method doReflectTableCols.
/**
* 通过sql语句反射sql语句中的列
*/
@Func(value = PermissionConstant.PERMISSION_DATASOURCE_EDIT, sideEffect = false)
public void doReflectTableCols(Context context) throws Exception {
String topology = this.getString("topology");
if (StringUtils.isEmpty(topology)) {
throw new IllegalArgumentException("param topology can not be null");
}
SqlDataFlowTopology wfTopology = SqlTaskNodeMeta.getSqlDataFlowTopology(topology);
Map<String, DependencyNode> /**
* id
*/
dumpNodes = wfTopology.getDumpNodes().stream().collect(Collectors.toMap((d) -> d.getId(), (d) -> d));
com.alibaba.fastjson.JSONArray sqlAry = this.parseJsonArrayPost();
com.alibaba.fastjson.JSONObject j = null;
// String sql = null;
// List<RowMetaData> rowMetaData = null;
List<SqlCols> colsMeta = Lists.newArrayList();
SqlCols sqlCols = null;
DependencyNode dumpNode = null;
TISTable tabCfg = null;
// List<ColumnMetaData> reflectCols = null;
for (int i = 0; i < sqlAry.size(); i++) {
j = sqlAry.getJSONObject(i);
// sql = j.getString("sql");
sqlCols = new SqlCols();
sqlCols.setKey(j.getString("key"));
String dumpNodeId = sqlCols.getKey();
dumpNode = dumpNodes.get(dumpNodeId);
if (dumpNode == null) {
throw new IllegalStateException("key:" + dumpNodeId + " can not find relevant dump node in topplogy '" + topology + "'");
}
// tabCfg = GitUtils.$().getTableConfig(dumpNode.getDbName(), dumpNode.getName());
DataSourceFactoryPluginStore dbPlugin = TIS.getDataBasePluginStore(new PostedDSProp(dumpNode.getDbName()));
TISTable tisTable = dbPlugin.loadTableMeta(dumpNode.getName());
if (CollectionUtils.isEmpty(tisTable.getReflectCols())) {
throw new IllegalStateException("db:" + dumpNode.getDbName() + ",table:" + dumpNode.getName() + " relevant table col reflect cols can not be empty");
}
sqlCols.setCols(tisTable.getReflectCols());
colsMeta.add(sqlCols);
}
this.setBizResult(context, colsMeta);
}
Aggregations