Skip to content
Permalink
Browse files
Fix some small bugs and improve experience (#289)
1. Allowed modify set/list property in friendly way
2. Check fieldMapping valid
  • Loading branch information
Linary committed Jan 14, 2021
1 parent 98740d5 commit 2ac4b09c612609d04ab1368ab81effa23abd480a
Showing 5 changed files with 41 additions and 4 deletions.
@@ -52,6 +52,7 @@
import com.baidu.hugegraph.service.load.JobManagerService;
import com.baidu.hugegraph.service.schema.EdgeLabelService;
import com.baidu.hugegraph.service.schema.VertexLabelService;
import com.baidu.hugegraph.util.CollectionUtil;
import com.baidu.hugegraph.util.Ex;
import com.baidu.hugegraph.util.HubbleUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -299,6 +300,21 @@ private void checkVertexMappingValid(int connId, VertexMapping vertexMapping,
Ex.check(columnNames.containsAll(vertexMapping.getIdFields()),
"load.file-mapping.vertex.id-fields-should-in-column-names",
vertexMapping.getIdFields(), columnNames);
if (vl.getIdStrategy().isPrimaryKey()) {
Ex.check(vertexMapping.getIdFields().size() ==
vl.getPrimaryKeys().size(),
"load.file-mapping.vertex.id-fields-should-same-size-pks");
Ex.check(!CollectionUtils.containsAny(
vertexMapping.fieldMappingToMap().values(),
vl.getPrimaryKeys()),
"load.file-mapping.vertex.mapping-fields-cannot-contains-pk");
} else {
Ex.check(vertexMapping.getIdFields().size() == 1,
"load.file-mapping.vertex.id-fields-should-only-one");
}
Ex.check(CollectionUtil.allUnique(
vertexMapping.fieldMappingToMap().values()),
"load.file-mapping.mapping-fields-should-no-duplicate");
this.checkMappingValid(vertexMapping, fileMapping);
}

@@ -324,6 +340,9 @@ private void checkEdgeMappingValid(int connId, EdgeMapping edgeMapping,
Ex.check(columnNames.containsAll(edgeMapping.getTargetFields()),
"load.file-mapping.edge.target-fields-should-in-column-names",
edgeMapping.getTargetFields(), columnNames);
Ex.check(CollectionUtil.allUnique(
edgeMapping.fieldMappingToMap().values()),
"load.file-mapping.mapping-fields-should-no-duplicate");
this.checkMappingValid(edgeMapping, fileMapping);
}

@@ -45,6 +45,7 @@
import com.baidu.hugegraph.entity.schema.VertexLabelEntity;
import com.baidu.hugegraph.entity.schema.VertexLabelStyle;
import com.baidu.hugegraph.entity.schema.VertexLabelUpdateEntity;
import com.baidu.hugegraph.exception.ExternalException;
import com.baidu.hugegraph.service.schema.PropertyIndexService;
import com.baidu.hugegraph.service.schema.PropertyKeyService;
import com.baidu.hugegraph.service.schema.VertexLabelService;
@@ -195,11 +196,20 @@ public Map<String, Boolean> checkUsing(

@DeleteMapping
public void delete(@PathVariable("connId") int connId,
@RequestParam("names") List<String> names) {
@RequestParam("names") List<String> names,
@RequestParam(name = "skip_using",
defaultValue = "false")
boolean skipUsing) {
for (String name : names) {
this.vlService.checkExist(name, connId);
Ex.check(!this.vlService.checkUsing(name, connId),
"schema.vertexlabel.in-using", name);
if (this.vlService.checkUsing(name, connId)) {
if (skipUsing) {
continue;
} else {
throw new ExternalException("schema.vertexlabel.in-using",
name);
}
}
this.vlService.remove(name, connId);
}
}
@@ -182,7 +182,7 @@ private void fillProperties(int connId, SchemaLabelEntity schema,
try {
// DataTypeUtil.convert in loader need param InputSource
FileSource source = new FileSource();
ListFormat listFormat = new ListFormat("[", "]", ",");
ListFormat listFormat = new ListFormat("", "", ",");
source.listFormat(listFormat);
value = DataTypeUtil.convert(rawValue, propertyKey, source);
} catch (IllegalArgumentException e) {
@@ -131,9 +131,13 @@ load.file-mapping.vertex.not-exist.label=The vertex mapping doesn't exist with l
load.file-mapping.vertex.automatic-id-unsupported=The id strategy of the current vertex label is AUTOMATIC. Such data load operations are not supported. Please implement it by calling the API.
load.file-mapping.vertex.id-fields-cannot-be-empty=The id fields can't be empty
load.file-mapping.vertex.id-fields-should-in-column-names=The all id fields {0} should be existed in columns names {1}
load.file-mapping.vertex.id-fields-should-same-size-pks=The id strategy of the current vertex label is PRIMARYKEY, the id fields should be consistent with the number of primary keys
load.file-mapping.vertex.mapping-fields-cannot-contains-pk=The id strategy of the current vertex label is PRIMARYKEY, the mapping properties can no longer contain primary keys
load.file-mapping.vertex.id-fields-should-only-one=The id strategy of the current vertex label is PRIMARYKEY, an id field should be specified
load.file-mapping.edge.not-exist.label=The edge mapping doesn't exist with label {0}
load.file-mapping.edge.source-fields-cannot-be-empty=The source fields can't be empty
load.file-mapping.edge.target-fields-cannot-be-empty=The target fields can't be empty
load.file-mapping.mapping-fields-should-no-duplicate=Multiple fields are not allowed to map to same property
load.file-mapping.load-parameter.max-parse-error.illegal=The load parameter 'max-parse-errors' is illegal
load.file-mapping.load-parameter.max-insert-error.illegal=The load parameter 'max-insert-errors' is illegal
load.file-mapping.load-parameter.insert-timeout.illegal=The load parameter 'insert-timeout' is illegal
@@ -131,9 +131,13 @@ load.file-mapping.vertex.not-exist.label=不存在 label 为 {0} 的顶点映射
load.file-mapping.vertex.automatic-id-unsupported=当前顶点类型的 ID 策略为自动生成,不支持此类数据导入操作,请通过调用 API 实现
load.file-mapping.vertex.id-fields-cannot-be-empty=ID 列不能为空
load.file-mapping.vertex.id-fields-should-in-column-names=ID 列 {0} 必须都属于文件列 {1}
load.file-mapping.vertex.id-fields-should-same-size-pks=当前顶点类型的 ID 策略为主键属性,ID 列应该与主键属性个数一致
load.file-mapping.vertex.mapping-fields-cannot-contains-pk=当前顶点类型的 ID 策略为主键属性,映射的属性中不能再包含主键属性
load.file-mapping.vertex.id-fields-should-only-one=当前顶点类型的 ID 策略为自定义,应指定一个 ID 列
load.file-mapping.edge.not-exist.label=不存在 label 为 {0} 的边映射
load.file-mapping.edge.source-fields-cannot-be-empty=起点 ID 列不能为空
load.file-mapping.edge.target-fields-cannot-be-empty=终点 ID 列不能为空
load.file-mapping.mapping-fields-should-no-duplicate=不允许多列映射到同一属性
load.file-mapping.load-parameter.max-parse-error.illegal=导入参数 允许最大解析错误行数 不合法
load.file-mapping.load-parameter.max-insert-error.illegal=导入参数 允许最大插入错误行数 不合法
load.file-mapping.load-parameter.insert-timeout.illegal=导入参数 插入超时时间/s 不合法

0 comments on commit 2ac4b09

Please sign in to comment.