Search in sources :

Example 1 with EdgeLabelStyle

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();
}
Also used : Frequency(com.baidu.hugegraph.structure.constant.Frequency) EdgeLabelStyle(com.baidu.hugegraph.entity.schema.EdgeLabelStyle)

Example 2 with EdgeLabelStyle

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;
}
Also used : EdgeLabel(com.baidu.hugegraph.structure.schema.EdgeLabel) EdgeLabelStyle(com.baidu.hugegraph.entity.schema.EdgeLabelStyle) HashSet(java.util.HashSet)

Example 3 with EdgeLabelStyle

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");
    }
}
Also used : EdgeLabelStyle(com.baidu.hugegraph.entity.schema.EdgeLabelStyle)

Aggregations

EdgeLabelStyle (com.baidu.hugegraph.entity.schema.EdgeLabelStyle)3 Frequency (com.baidu.hugegraph.structure.constant.Frequency)1 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)1 HashSet (java.util.HashSet)1