use of com.baidu.hugegraph.entity.schema.ConflictStatus in project incubator-hugegraph-toolchain by apache.
the class EdgeLabelService method checkConflict.
public ConflictDetail checkConflict(ConflictCheckEntity entity, int connId, boolean compareEachOther) {
ConflictDetail detail = new ConflictDetail(SchemaType.EDGE_LABEL);
if (CollectionUtils.isEmpty(entity.getElEntities())) {
return detail;
}
Map<String, EdgeLabelEntity> originElEntities = new HashMap<>();
for (EdgeLabelEntity e : this.list(connId)) {
originElEntities.put(e.getName(), e);
}
this.pkService.checkConflict(entity.getPkEntities(), detail, connId, compareEachOther);
this.piService.checkConflict(entity.getPiEntities(), detail, connId, compareEachOther);
this.vlService.checkConflict(entity.getVlEntities(), detail, connId, compareEachOther);
for (EdgeLabelEntity elEntity : entity.getElEntities()) {
// Firstly check if any properties are conflicted
if (detail.anyPropertyKeyConflict(elEntity.getPropNames())) {
detail.add(elEntity, ConflictStatus.DEP_CONFLICT);
continue;
}
// Then check if any property indexes are conflicted
if (detail.anyPropertyIndexConflict(elEntity.getIndexProps())) {
detail.add(elEntity, ConflictStatus.DEP_CONFLICT);
continue;
}
// Then determine if source/target vertex labels are conflicted
if (detail.anyVertexLabelConflict(elEntity.getLinkLabels())) {
detail.add(elEntity, ConflictStatus.DEP_CONFLICT);
continue;
}
// Then check conflict of edge label itself
EdgeLabelEntity originElEntity = originElEntities.get(elEntity.getName());
ConflictStatus status = SchemaEntity.compare(elEntity, originElEntity);
detail.add(elEntity, status);
}
if (compareEachOther) {
compareWithEachOther(detail, SchemaType.EDGE_LABEL);
}
return detail;
}
use of com.baidu.hugegraph.entity.schema.ConflictStatus in project incubator-hugegraph-toolchain by apache.
the class VertexLabelService method checkConflict.
public void checkConflict(List<VertexLabelEntity> entities, ConflictDetail detail, int connId, boolean compareEachOther) {
if (CollectionUtils.isEmpty(entities)) {
return;
}
Map<String, VertexLabelEntity> originEntities = new HashMap<>();
for (VertexLabelEntity entity : this.list(connId)) {
originEntities.put(entity.getName(), entity);
}
for (VertexLabelEntity entity : entities) {
if (detail.anyPropertyKeyConflict(entity.getPropNames())) {
detail.add(entity, ConflictStatus.DEP_CONFLICT);
continue;
}
if (detail.anyPropertyIndexConflict(entity.getIndexProps())) {
detail.add(entity, ConflictStatus.DEP_CONFLICT);
continue;
}
VertexLabelEntity originEntity = originEntities.get(entity.getName());
ConflictStatus status = SchemaEntity.compare(entity, originEntity);
detail.add(entity, status);
}
// Compare resued entities with each other
if (compareEachOther) {
compareWithEachOther(detail, SchemaType.VERTEX_LABEL);
}
}
use of com.baidu.hugegraph.entity.schema.ConflictStatus in project incubator-hugegraph-toolchain by apache.
the class SchemaService method compareWithOthers.
public static <T extends SchemaEntity> ConflictStatus compareWithOthers(int currentIdx, List<SchemaConflict<T>> conflicts) {
SchemaConflict<T> current = conflicts.get(currentIdx);
T currentEntity = current.getEntity();
// May changed
ConflictStatus status = current.getStatus();
for (int i = 0; i < conflicts.size(); i++) {
if (currentIdx == i) {
continue;
}
SchemaConflict<T> other = conflicts.get(i);
T otherEntity = other.getEntity();
if (!currentEntity.getName().equals(otherEntity.getName())) {
continue;
}
if (currentEntity.equals(otherEntity)) {
status = ConflictStatus.EXISTED;
} else {
status = ConflictStatus.DUPNAME;
break;
}
}
return status;
}
use of com.baidu.hugegraph.entity.schema.ConflictStatus in project incubator-hugegraph-toolchain by apache.
the class SchemaService method compareWithEachOther.
public static <T extends SchemaEntity> void compareWithEachOther(ConflictDetail detail, SchemaType type) {
List<SchemaConflict<T>> conflicts = detail.getConflicts(type);
for (int i = 0; i < conflicts.size(); i++) {
SchemaConflict<T> conflict = conflicts.get(i);
if (conflict.getStatus().isConflicted()) {
continue;
}
ConflictStatus status = compareWithOthers(i, conflicts);
conflict.setStatus(status);
}
}
use of com.baidu.hugegraph.entity.schema.ConflictStatus in project incubator-hugegraph-toolchain by apache.
the class PropertyIndexService method checkConflict.
public void checkConflict(List<PropertyIndex> entities, ConflictDetail detail, int connId, boolean compareEachOther) {
if (CollectionUtils.isEmpty(entities)) {
return;
}
Map<String, PropertyIndex> originEntities = new HashMap<>();
for (PropertyIndex entity : this.list(connId)) {
originEntities.put(entity.getName(), entity);
}
for (PropertyIndex entity : entities) {
if (detail.anyPropertyKeyConflict(entity.getFields())) {
detail.add(entity, ConflictStatus.DEP_CONFLICT);
continue;
}
PropertyIndex originEntity = originEntities.get(entity.getName());
ConflictStatus status = SchemaEntity.compare(entity, originEntity);
detail.add(entity, status);
}
// Compare resued entities with each other
if (compareEachOther) {
compareWithEachOther(detail, SchemaType.PROPERTY_INDEX);
}
}
Aggregations