Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] fix accumulation score of expectations #1108

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading