Skip to content

Commit

Permalink
parent change
Browse files Browse the repository at this point in the history
  • Loading branch information
oplekal committed Jan 2, 2025
1 parent 96561ff commit 5cabaa9
Show file tree
Hide file tree
Showing 7 changed files with 933 additions and 1,114 deletions.
1,831 changes: 919 additions & 912 deletions eperusteet/eperusteet-service/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package fi.vm.sade.eperusteet.config;

import com.fasterxml.jackson.databind.type.SimpleType;
import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.Schema;
import org.springdoc.core.customizers.PropertyCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
Expand All @@ -28,15 +30,18 @@ public OpenAPI springShopOpenAPI() {

@Bean
public PropertyCustomizer enumPropertyCustomizer() {
return (schema, type) -> {
Type javaType = type.getType();
if (javaType instanceof SimpleType && ((SimpleType) javaType).isEnumType()) {
Class<?> enumClass = ((SimpleType)javaType).getRawClass();
schema.setEnum(Arrays.stream(enumClass.getEnumConstants())
.map(enumConstant -> ((Enum<?>) enumConstant).name())
.collect(Collectors.toList()));
return new PropertyCustomizer() {
@Override
public Schema customize(Schema schema, AnnotatedType type) {
Type javaType = type.getType();
if (javaType instanceof SimpleType && ((SimpleType) javaType).isEnumType()) {
Class<?> enumClass = ((SimpleType) javaType).getRawClass();
schema.setEnum(Arrays.stream(enumClass.getEnumConstants())
.map(enumConstant -> ((Enum<?>) enumConstant).name())
.collect(Collectors.toList()));
}
return schema;
}
return schema;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,9 @@ public boolean equals(Object x, Object y) throws HibernateException {
return Objects.equals(x, y);
}

// @Override
// public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
// String str = rs.getString(names[0]);
// if (str != null) {
// try {
// JsonNode node = mapper.readTree(str);
// return node;
// } catch (IOException e) {
// throw new BusinessRuleViolationException("datan-luku-epaonnistui");
// }
// }
// return JsonNodeFactory.instance.objectNode();
// }

@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
if (value != null) {
// String jsonStr = gson.toJson(value);
try {
String s = mapper.writeValueAsString(value);
st.setObject(index, s, Types.OTHER);
Expand Down
178 changes: 0 additions & 178 deletions eperusteet/pom.xml

This file was deleted.

2 changes: 1 addition & 1 deletion generated/eperusteet.spec.json

Large diffs are not rendered by default.

0 comments on commit 5cabaa9

Please sign in to comment.