use of com.baidu.hugegraph.entity.schema.EdgeLabelStyle in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method convert.
private static EdgeLabel convert(EdgeLabelEntity entity, HugeClient client) {
if (entity == null) {
return null;
}
Frequency frequency = entity.isLinkMultiTimes() ? Frequency.MULTIPLE : Frequency.SINGLE;
EdgeLabelStyle style = entity.getStyle();
return client.schema().edgeLabel(entity.getName()).sourceLabel(entity.getSourceLabel()).targetLabel(entity.getTargetLabel()).frequency(frequency).properties(toStringArray(entity.getPropNames())).sortKeys(toStringArray(entity.getSortKeys())).nullableKeys(toStringArray(entity.getNullableProps())).enableLabelIndex(entity.isOpenLabelIndex()).userdata(USER_KEY_CREATE_TIME, entity.getCreateTime()).userdata(USER_KEY_STYLE, JsonUtil.toJson(style)).build();
}
use of com.baidu.hugegraph.entity.schema.EdgeLabelStyle in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method convert.
private static EdgeLabel convert(EdgeLabelUpdateEntity entity, HugeClient client) {
if (entity == null) {
return null;
}
Set<String> properties = new HashSet<>();
if (entity.getAppendProperties() != null) {
entity.getAppendProperties().forEach(p -> {
properties.add(p.getName());
});
}
EdgeLabel.Builder builder;
builder = client.schema().edgeLabel(entity.getName()).properties(toStringArray(properties)).nullableKeys(toStringArray(properties));
EdgeLabel edgeLabel = builder.build();
Map<String, Object> userdata = edgeLabel.userdata();
EdgeLabelStyle style = entity.getStyle();
if (style != null) {
userdata.put(USER_KEY_STYLE, JsonUtil.toJson(style));
}
return edgeLabel;
}
use of com.baidu.hugegraph.entity.schema.EdgeLabelStyle in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelController method checkDisplayFields.
/**
* TODOļ¼merge with VertexLabelController.checkDisplayFields
*/
private static void checkDisplayFields(EdgeLabelEntity entity) {
EdgeLabelStyle style = entity.getStyle();
List<String> displayFields = style.getDisplayFields();
if (!CollectionUtils.isEmpty(displayFields)) {
Set<String> nullableProps = entity.getNullableProps();
Ex.check(!CollectionUtil.hasIntersection(displayFields, nullableProps), "schema.display-fields.cannot-be-nullable");
}
}
Aggregations