use of com.baidu.hugegraph.entity.schema.VertexLabelEntity in project incubator-hugegraph-toolchain by apache.
the class GraphController method checkParamsValid.
private void checkParamsValid(int connId, VertexEntity entity, boolean create) {
Ex.check(!StringUtils.isEmpty(entity.getLabel()), "common.param.cannot-be-null-or-empty", "label");
// If schema doesn't exist, it will throw exception
VertexLabelEntity vlEntity = this.vlService.get(entity.getLabel(), connId);
IdStrategy idStrategy = vlEntity.getIdStrategy();
if (create) {
Ex.check(idStrategy.isCustomize(), () -> entity.getId() != null, "common.param.cannot-be-null", "id");
} else {
Ex.check(entity.getId() != null, "common.param.cannot-be-null", "id");
}
Set<String> nonNullableProps = vlEntity.getNonNullableProps();
Map<String, Object> properties = entity.getProperties();
Ex.check(properties.keySet().containsAll(nonNullableProps), "graph.vertex.all-nonnullable-prop.should-be-setted");
}
use of com.baidu.hugegraph.entity.schema.VertexLabelEntity in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method checkVertexMappingValid.
private void checkVertexMappingValid(int connId, VertexMapping vertexMapping, FileMapping fileMapping) {
VertexLabelEntity vl = this.vlService.get(vertexMapping.getLabel(), connId);
Ex.check(!vl.getIdStrategy().isAutomatic(), "load.file-mapping.vertex.automatic-id-unsupported");
Ex.check(!CollectionUtils.isEmpty(vertexMapping.getIdFields()), "load.file-mapping.vertex.id-fields-cannot-be-empty");
FileSetting fileSetting = fileMapping.getFileSetting();
List<String> columnNames = fileSetting.getColumnNames();
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);
}
use of com.baidu.hugegraph.entity.schema.VertexLabelEntity in project incubator-hugegraph-toolchain by apache.
the class VertexLabelController method checkConflicts.
@PostMapping("check_conflict")
public ConflictDetail checkConflicts(@PathVariable("connId") int connId, @RequestParam("reused_conn_id") int reusedConnId, @RequestBody ConflictCheckEntity entity) {
Ex.check(!CollectionUtils.isEmpty(entity.getVlEntities()), "common.param.cannot-be-empty", "vertexlabels");
Ex.check(CollectionUtils.isEmpty(entity.getPkEntities()), "common.param.must-be-null", "propertykeys");
Ex.check(CollectionUtils.isEmpty(entity.getPiEntities()), "common.param.must-be-null", "propertyindexes");
Ex.check(CollectionUtils.isEmpty(entity.getElEntities()), "common.param.must-be-null", "edgelabels");
Ex.check(connId != reusedConnId, "schema.conn.cannot-reuse-self");
Set<String> pkNames = new HashSet<>();
Set<String> piNames = new HashSet<>();
for (VertexLabelEntity e : entity.getVlEntities()) {
pkNames.addAll(e.getPropNames());
piNames.addAll(e.getIndexProps());
}
entity.setPkEntities(this.pkService.list(pkNames, reusedConnId, false));
entity.setPiEntities(this.piService.list(piNames, reusedConnId, false));
return this.vlService.checkConflict(entity, connId, false);
}
Aggregations