in src/main/java/com/microsoft/spring/data/gremlin/conversion/source/GremlinSourceEdgeWriter.java [43:83]
public void write(@NonNull Object domain, @NonNull MappingGremlinConverter converter,
@NonNull GremlinSource source) throws GremlinInvalidEntityIdFieldException {
if (!(source instanceof GremlinSourceEdge)) {
throw new GremlinUnexpectedSourceTypeException("should be the instance of GremlinSourceEdge");
}
source.setId(converter.getIdFieldValue(domain));
final GremlinSourceEdge sourceEdge = (GremlinSourceEdge) source;
final GremlinPersistentEntity<?> persistentEntity = converter.getPersistentEntity(domain.getClass());
final ConvertingPropertyAccessor accessor = converter.getPropertyAccessor(domain);
for (final Field field : FieldUtils.getAllFields(domain.getClass())) {
final PersistentProperty property = persistentEntity.getPersistentProperty(field.getName());
if (property == null) {
continue;
}
final Object object = accessor.getProperty(property);
if (field.getName().equals(Constants.PROPERTY_ID) || field.getAnnotation(Id.class) != null) {
continue;
} else if (field.getName().equals(GREMLIN_PROPERTY_CLASSNAME)) {
throw new GremlinEntityInformationException("Domain Cannot use pre-defined field name: "
+ GREMLIN_PROPERTY_CLASSNAME);
} else if (field.getAnnotation(EdgeFrom.class) != null) {
final Object vertexId = this.getIdValue(object, converter);
if (vertexId == null) {
throw new GremlinInvalidEntityIdFieldException("The vertex id for the from vertex cannot be null!");
}
sourceEdge.setVertexIdFrom(vertexId);
} else if (field.getAnnotation(EdgeTo.class) != null) {
final Object vertexId = this.getIdValue(object, converter);
if (vertexId == null) {
throw new GremlinInvalidEntityIdFieldException("The vertex id for the to vertex cannot be null!");
}
sourceEdge.setVertexIdTo(vertexId);
}
source.setProperty(field.getName(), accessor.getProperty(property));
}
}