in client/migrationx/migrationx-transformer/src/main/java/com/aliyun/dataworks/migrationx/transformer/core/utils/DiCodeUtils.java [213:278]
public static String getDiCodeOdpsTablePrefix(String code) {
if (StringUtils.isBlank(code)) {
return null;
}
try {
JsonObject codeJson = GsonUtils.fromJsonString(code, JsonObject.class);
String srcType = codeJson.has("srcType") ? codeJson.get("srcType").getAsString() : null;
String srcGuid = codeJson.has("srcGuid") ? codeJson.get("srcGuid").getAsString() : null;
String dstType = codeJson.has("dstType") ? codeJson.get("dstType").getAsString() : null;
String dstGuid = codeJson.has("dstGuid") ? codeJson.get("dstGuid").getAsString() : null;
// 旧版的DI任务
if (codeJson.has("config") && codeJson.get("config").isJsonObject()) {
JsonObject config = codeJson.get("config").getAsJsonObject();
JsonObject reader = config.has("reader") ? config.get("reader").getAsJsonObject() : new JsonObject();
JsonObject writer = config.has("writer") ? config.get("writer").getAsJsonObject() : new JsonObject();
String guid = null;
if (StringUtils.equalsIgnoreCase("odps", srcType)) {
guid = reader.has("guid") ? reader.get("guid").getAsString() : null;
}
if (StringUtils.equalsIgnoreCase("odps", dstType)) {
guid = writer.has("guid") ? writer.get("guid").getAsString() : null;
}
if (StringUtils.isNotBlank(guid) && StringUtils.startsWith(guid, "odps.")) {
String[] parts = StringUtils.split(guid, ".");
if (parts.length >= 3) {
return parts[1];
}
}
}
// 新版的DI任务
if (codeJson.has("steps")) {
JsonArray steps = codeJson.get("steps").getAsJsonArray();
if (steps != null && steps.size() > 0) {
for (int i = 0; i < steps.size(); i++) {
JsonObject step = steps.get(i).getAsJsonObject();
if (!step.has("stepType")) {
continue;
}
String stepType = step.get("stepType").getAsString();
if (StringUtils.equalsIgnoreCase("odps", stepType)) {
if (step.has("parameter")) {
JsonObject parameter = step.get("parameter").getAsJsonObject();
String guid = parameter.has("guid") ? parameter.get("guid").getAsString() : null;
if (StringUtils.startsWith(guid, "odps.")) {
String[] parts = StringUtils.split(guid, ".");
if (parts.length >= 3) {
return parts[1];
}
}
}
}
}
}
}
} catch (Exception e) {
LOGGER.error("replace di code error, code: {}", code, e);
}
return null;
}