Skip to content

Commit

Permalink
[backend] Fix accumulation score of expectations (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 authored and johanah29 committed Jun 25, 2024
1 parent 6ba2684 commit 57dca7e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.openbas.database.model.Base;
import jakarta.persistence.Id;
import java.lang.reflect.Field;
import lombok.Getter;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
Expand Down Expand Up @@ -35,7 +37,12 @@ public BaseEvent(String type, Base data, ObjectMapper mapper) {
boolean isTargetClass = currentClass.getSuperclass().equals(Object.class);
Class<?> baseClass = isTargetClass ? currentClass : currentClass.getSuperclass();
String className = baseClass.getSimpleName().toLowerCase();
this.attributeId = className + "_id";
Field[] fields = baseClass.getDeclaredFields();
for (Field field : fields) {
if (field.isAnnotationPresent(Id.class)) {
this.attributeId = field.getAnnotation(JsonProperty.class).value();
}
}
this.schema = className + (className.endsWith("s") ? "es" : "s");
}

Expand Down

0 comments on commit 57dca7e

Please sign in to comment.