Skip to content

Commit

Permalink
[backend] fix path property
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Jun 18, 2024
1 parent 41915fb commit 1b73c2d
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 1b73c2d

Please sign in to comment.