@@ -304,6 +304,7 @@ public void parseTextUploadFile(DataInfoUploadBO dataInfoUploadBO) {
304
304
var rootPath = String .format ("%s/%s" , userId , datasetId );
305
305
var errorBuilder = new StringBuilder ();
306
306
var dataInfoBOBuilder = DataInfoBO .builder ().datasetId (datasetId )
307
+ .parentId (Constants .DEFAULT_PARENT_ID )
307
308
.type (ItemTypeEnum .SINGLE_DATA )
308
309
.status (DataStatusEnum .VALID )
309
310
.annotationStatus (DataAnnotationStatusEnum .NOT_ANNOTATED )
@@ -349,7 +350,7 @@ public void parseTextUploadFile(DataInfoUploadBO dataInfoUploadBO) {
349
350
dataInfoBOList .add (dataInfoBO );
350
351
});
351
352
if (CollectionUtil .isNotEmpty (dataInfoBOList )) {
352
- insertBatch (dataInfoBOList , datasetId , errorBuilder );
353
+ insertBatch (dataInfoBOList , datasetId , errorBuilder , Constants . DEFAULT_PARENT_ID );
353
354
}
354
355
} catch (Exception e ) {
355
356
log .error ("Handle data error" , e );
@@ -463,7 +464,15 @@ public void commonParseUploadFile(DataInfoUploadBO dataInfoUploadBO, BiConsumer<
463
464
var dataAnnotationObjectBOBuilder = DataAnnotationObjectBO .builder ()
464
465
.datasetId (datasetId ).createdBy (userId ).createdAt (OffsetDateTime .now ()).sourceId (sourceId );
465
466
sceneFileList .forEach (sceneFile -> {
466
- var sceneId = this .saveScene (sceneFile , dataInfoUploadBO );
467
+ Long sceneId ;
468
+ try {
469
+ sceneId = this .saveScene (sceneFile , dataInfoUploadBO );
470
+ } catch (DuplicateKeyException e ) {
471
+ log .error ("The scene already exists,scene name is {}" , sceneFile .getName ());
472
+ errorBuilder .append ("Duplicate scene names:" ).append (sceneFile .getName ()).append (";" );
473
+ return ;
474
+ }
475
+
467
476
var dataNameList = getDataNamesFunction .apply (sceneFile );
468
477
if (CollectionUtil .isEmpty (dataNameList )) {
469
478
log .error ("The file in {} folder is empty" , sceneFile );
@@ -498,7 +507,7 @@ public void commonParseUploadFile(DataInfoUploadBO dataInfoUploadBO, BiConsumer<
498
507
}
499
508
});
500
509
if (CollectionUtil .isNotEmpty (dataInfoBOList )) {
501
- var resDataInfoList = this .insertBatch (dataInfoBOList , datasetId , errorBuilder );
510
+ var resDataInfoList = this .insertBatch (dataInfoBOList , datasetId , errorBuilder , sceneId );
502
511
this .saveBatchDataResult (resDataInfoList , dataAnnotationObjectBOList );
503
512
}
504
513
} catch (Exception e ) {
@@ -1045,9 +1054,9 @@ public String getFilename(File file) {
1045
1054
*
1046
1055
* @param dataInfoBOList Collection of data details
1047
1056
*/
1048
- public List <DataInfoBO > insertBatch (List <DataInfoBO > dataInfoBOList , Long datasetId , StringBuilder errorBuilder ) {
1057
+ public List <DataInfoBO > insertBatch (List <DataInfoBO > dataInfoBOList , Long datasetId , StringBuilder errorBuilder , Long parentId ) {
1049
1058
var names = dataInfoBOList .stream ().map (DataInfoBO ::getName ).collect (Collectors .toList ());
1050
- var existDataInfoList = this .findByNames (datasetId , names );
1059
+ var existDataInfoList = this .findByNames (datasetId , parentId , names );
1051
1060
if (CollUtil .isNotEmpty (existDataInfoList )) {
1052
1061
var existNames = existDataInfoList .stream ().map (DataInfoBO ::getName ).collect (Collectors .toList ());
1053
1062
dataInfoBOList = dataInfoBOList .stream ().filter (dataInfoBO -> !existNames .contains (dataInfoBO .getName ())).collect (Collectors .toList ());
@@ -1071,10 +1080,11 @@ public List<DataInfoBO> insertBatch(List<DataInfoBO> dataInfoBOList, Long datase
1071
1080
}
1072
1081
}
1073
1082
1074
- private List <DataInfoBO > findByNames (Long datasetId , List <String > names ) {
1083
+ private List <DataInfoBO > findByNames (Long datasetId , Long parentId , List <String > names ) {
1075
1084
var dataInfoLambdaQueryWrapper = Wrappers .lambdaQuery (DataInfo .class );
1076
1085
dataInfoLambdaQueryWrapper .eq (DataInfo ::getDatasetId , datasetId );
1077
1086
dataInfoLambdaQueryWrapper .in (DataInfo ::getName , names );
1087
+ dataInfoLambdaQueryWrapper .eq (DataInfo ::getParentId , parentId );
1078
1088
return DefaultConverter .convert (dataInfoDAO .list (dataInfoLambdaQueryWrapper ), DataInfoBO .class );
1079
1089
}
1080
1090
@@ -1145,4 +1155,4 @@ private void getLeafNodeList(List<Tree<String>> treeNodes, List<Tree<String>> le
1145
1155
}
1146
1156
});
1147
1157
}
1148
- }
1158
+ }
0 commit comments