in gremlin/neptune-social-media-utils/src/main/java/com/aws/neptune/utils/generator/CSVGenerator.java [331:368]
public static void isValidConfig(CSVConfig config){
//TODO 1. one2one , many2one cannot have supernode
// 2. selfRef is only for same left and right vertex types
// 3. one2many , one2many cannot have more edges than the right vertex
List<String> typeArray = new ArrayList<String>();
config.VertexTypes.forEach(vertextype -> typeArray.add(vertextype.name));
for (EdgeTypeBean edgeType: config.EdgeTypes){
for (RelationBean relation: edgeType.relations) {
//validate left and right are in the vertex types
if(!typeArray.contains(relation.left)){
throw new RuntimeException("relationships: "
+ relation.left + " is not of vertex types: " + typeArray.toString());}
if(!typeArray.contains(relation.right))
throw new RuntimeException("relationships: "
+ relation.right + " is not of vertex types: " + typeArray.toString());
//validate supernode vertices don't exceed the number of vertices
Iterator<VertexTypeBean> vTypes = config.VertexTypes.iterator();
while (vTypes.hasNext()){
VertexTypeBean type = vTypes.next();
if (relation.left.equals(type.name) &&
relation.supernode != null &&
relation.supernode.get("vertices") > type.row){
ObjectMapper mapper = new ObjectMapper();
try {
mapper.writeValueAsString(relation);
throw new RuntimeException(
mapper.writeValueAsString(relation) +
"supernode.vertices is greater than " +
type.name + "'s row"
);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
}
}
}