Skip to content

Commit

Permalink
导入目结果提示增加 [未识别条目]
Browse files Browse the repository at this point in the history
  • Loading branch information
wjm0729 committed Jan 13, 2021
1 parent 07f8063 commit 859dddb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public RestResult<Map<String, Object>> importAndPublishConfig(HttpServletRequest
}

List<ConfigAllInfo> configInfoList = null;
List<Map<String, String>> skipItemList = null;
List<Map<String, String>> unrecognizedList = null;
try {
ZipUtils.UnZipResult unziped = ZipUtils.unzip(file.getBytes());
ZipUtils.ZipItem metaDataZipItem = unziped.getMetaDataItem();
Expand All @@ -559,14 +559,14 @@ public RestResult<Map<String, Object>> importAndPublishConfig(HttpServletRequest
List<ZipUtils.ZipItem> itemList = unziped.getZipItemList();
if (itemList != null && !itemList.isEmpty()) {
configInfoList = new ArrayList<>(itemList.size());
skipItemList = new ArrayList<>();
unrecognizedList = new ArrayList<>();
for (ZipUtils.ZipItem item : itemList) {
String[] groupAdnDataId = item.getItemName().split(Constants.CONFIG_EXPORT_ITEM_FILE_SEPARATOR);
if (groupAdnDataId.length != 2) {
Map<String, String> skipitem = new HashMap<>(2);
skipitem.put("dataId", item.getItemName());
skipitem.put("group", "");
skipItemList.add(skipitem);
unrecognizedList.add(skipitem);
continue;
}
String group = groupAdnDataId[0];
Expand Down Expand Up @@ -611,15 +611,10 @@ public RestResult<Map<String, Object>> importAndPublishConfig(HttpServletRequest
requestIpApp, time.getTime(), InetUtils.getSelfIP(),
ConfigTraceService.PERSISTENCE_EVENT_PUB, configInfo.getContent());
}
// merge skip data
if (!skipItemList.isEmpty()) {
Integer skipCount = (Integer) saveResult.get("skipCount");
saveResult.put("skipCount", (skipCount == null ? 0 : skipCount) + skipItemList.size());
List<Map<String, String>> skipData = (List<Map<String, String>>) saveResult.get("skipData");
if (skipData != null) {
skipItemList.addAll(skipData);
}
saveResult.put("skipData", skipItemList);
// unrecognizedCount
if (!unrecognizedList.isEmpty()) {
saveResult.put("unrecognizedCount", unrecognizedList.size());
saveResult.put("unrecognizedData", unrecognizedList);
}
return RestResultUtils.success("导入成功", saveResult);
}
Expand Down
5 changes: 3 additions & 2 deletions console-ui/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ const I18N_CONF = {
configurationManagement8: 'configuration management',
queryResults: 'Search Results: Found',
articleMeetRequirements: 'configuration items',
fuzzyd: 'Add wildcard \'*\' for fuzzy query',
fuzzyg: 'Add wildcard \'*\' for fuzzy query',
fuzzyd: "Add wildcard '*' for fuzzy query",
fuzzyg: "Add wildcard '*' for fuzzy query",
query: 'Search',
advancedQuery9: 'Advanced Query',
application0: 'Application:',
Expand Down Expand Up @@ -303,6 +303,7 @@ const I18N_CONF = {
conflictConfig: 'Conflict-detected configuration items',
failureEntries: 'Failure entries',
unprocessedEntries: 'Unprocessed entries',
unrecognizedEntries: 'Unrecognized entries',
skippedEntries: 'skipped entries',
exportSelected: 'Export selected configs',
clone: 'Clone',
Expand Down
5 changes: 3 additions & 2 deletions console-ui/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ const I18N_CONF = {
configurationManagement8: '配置管理',
queryResults: '查询结果:共查询到',
articleMeetRequirements: '条满足要求的配置。',
fuzzyd: '添加通配符\'*\'进行模糊查询',
fuzzyg: '添加通配符\'*\'进行模糊查询',
fuzzyd: "添加通配符'*'进行模糊查询",
fuzzyg: "添加通配符'*'进行模糊查询",
query: '查询',
advancedQuery9: '高级查询',
application0: '归属应用:',
Expand Down Expand Up @@ -301,6 +301,7 @@ const I18N_CONF = {
conflictConfig: '检测到冲突的配置项',
failureEntries: '失败的条目',
unprocessedEntries: '未处理的条目',
unrecognizedEntries: '未识别的条目',
skippedEntries: '跳过的条目',
exportSelected: '导出选中的配置',
clone: '克隆',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,23 +1030,46 @@ class ConfigurationManagement extends React.Component {
<Table.Column title="Group" dataIndex="group" />
</Table>
</div>
<div>
<h5>
{locale.unrecognizedEntries}:{' '}
{ret.data.unrecognizedData ? ret.data.unrecognizedData.length : 0}
</h5>
<Table dataSource={ret.data.unrecognizedData}>
<Table.Column title="Data Id" dataIndex="dataId" />
<Table.Column title="Group" dataIndex="group" />
</Table>
</div>
</div>
),
});
} else if (ret.data.skipCount && ret.data.skipCount > 0) {
} else if (
(ret.data.skipData && ret.data.skipData.length > 0) ||
(ret.data.unrecognizedData && ret.data.unrecognizedData.length > 0)
) {
Dialog.alert({
title: isImport ? locale.importSucc : locale.cloneSucc,
content: (
<div style={{ width: '500px' }}>
<div>
<h5>
{locale.skippedEntries}: {ret.data.skipData.length}
{locale.skippedEntries}: {ret.data.skipData ? ret.data.skipData.length : 0}
</h5>
<Table dataSource={ret.data.skipData}>
<Table.Column title="Data Id" dataIndex="dataId" />
<Table.Column title="Group" dataIndex="group" />
</Table>
</div>
<div>
<h5>
{locale.unrecognizedEntries}:{' '}
{ret.data.unrecognizedData ? ret.data.unrecognizedData.length : 0}
</h5>
<Table dataSource={ret.data.unrecognizedData}>
<Table.Column title="Data Id" dataIndex="dataId" />
<Table.Column title="Group" dataIndex="group" />
</Table>
</div>
</div>
),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ public void testImport(){
uploadByteFile.setPrarmName("file");
String importResult = httpClient.post(SERVER_ADDR + CONFIG_CONTROLLER_PATH + importUrl, importPrarm, Collections.singletonList(uploadByteFile), null);

// test skip data
// test unrecognizedData
JsonNode importResObj = JacksonUtils.toObj(importResult);
int skipCount = importResObj.get("data").get("skipCount").intValue();
Assert.assertEquals(1, skipCount);
JsonNode skipNode = importResObj.get("data").get("skipData").get(0);
Assert.assertEquals("TEST_IMPORT/SUB_GROUP/test5.properties", skipNode.get("dataId").textValue());
int unrecognizedCount = importResObj.get("data").get("unrecognizedCount").intValue();
Assert.assertEquals(1, unrecognizedCount);
JsonNode unrecognizedData = importResObj.get("data").get("unrecognizedData").get(0);
Assert.assertEquals("TEST_IMPORT/SUB_GROUP/test5.properties", unrecognizedData.get("dataId").textValue());

String getDataUrl = "?search=accurate&dataId=&group=TEST_IMPORT&appName=&config_tags=&pageNo=1&pageSize=10&tenant=&namespaceId=";
String queryResult = httpClient.get(SERVER_ADDR + CONFIG_CONTROLLER_PATH + getDataUrl, null);
Expand Down

0 comments on commit 859dddb

Please sign in to comment.