Skip to content

Commit

Permalink
fixes for FeAnalysisEntity to properly map design column, fixed enum …
Browse files Browse the repository at this point in the history
…in aggregate analysis
  • Loading branch information
spinsysmpeterson committed Dec 24, 2024
1 parent 9e71e01 commit 7739165
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private Object doTask(JobParameters parameters) {

/* final Map<String, JobParameter> jobParameters = parameters.getParameters(); MDACA Spring Boot 3 migration compilation issue */
final Map<String, JobParameter<?>> jobParameters = parameters.getParameters();
final Integer sourceId = Integer.valueOf(jobParameters.get(SOURCE_ID).toString());
final Integer sourceId = Integer.valueOf(jobParameters.get(SOURCE_ID).getValue().toString());
final String targetTable = jobParameters.get(TARGET_TABLE).getValue().toString();
final String sql = sourceAwareSqlRender.renderSql(sourceId, DROP_TABLE_SQL, TARGET_TABLE, targetTable );

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.ohdsi.webapi.feanalysis.domain;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.ohdsi.circe.cohortdefinition.builders.CriteriaColumn;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter
public class CriteriaColumnListConverter implements AttributeConverter<List<CriteriaColumn>, String> {

private static final String DELIMITER = ",";

@Override
public String convertToDatabaseColumn(List<CriteriaColumn> attribute) {
if (attribute == null || attribute.isEmpty()) {
return null;
}
return attribute.stream()
.map(CriteriaColumn::name) // Convert enum to its string name
.collect(Collectors.joining(DELIMITER));
}

@Override
public List<CriteriaColumn> convertToEntityAttribute(String dbData) {
if (dbData == null || dbData.isEmpty()) {
return Collections.emptyList();
}
return Arrays.stream(dbData.split(DELIMITER))
.map(CriteriaColumn::valueOf) // Convert string name back to enum
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

import jakarta.persistence.*;
import java.util.List;

import java.util.List;
@Entity
@Table(name = "fe_analysis_aggregate")
// @TypeDef(typeClass = EnumListType.class, name = "enumm-list") MDACA Spring Boot 3 migration compilation issue
@Convert(attributeName = "enumm-list", converter = EnumListType.class)
public class FeAnalysisAggregateEntity implements FeatureAnalysisAggregate, WithId<Integer> {

@Id
@Id
@GenericGenerator(
name = "fe_aggregate_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
Expand Down Expand Up @@ -65,13 +63,10 @@ public class FeAnalysisAggregateEntity implements FeatureAnalysisAggregate, With
@Column(name = "missing_means_zero")
private boolean isMissingMeansZero;


@Column(name = "criteria_columns")
/* MDACA Spring Boot 3 migration compilation issue, see package-info.java
@Type(value = enumm-list.class, parameters = {
@Parameter(name = "enumClass", value = "org.ohdsi.circe.cohortdefinition.builders.CriteriaColumn")
})
*/
private List<CriteriaColumn> columns;
@Convert(converter = CriteriaColumnListConverter.class)
private List<CriteriaColumn> columns;

@Override
public Integer getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
@Table(name = "fe_analysis")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorFormula(
"""
CASE WHEN type = 'CRITERIA_SET' THEN CONCAT(CONCAT(type,'_'),stat_type) \
ELSE type END\
"""
"CASE WHEN type = 'CRITERIA_SET' THEN CONCAT(CONCAT(type,'_'),stat_type) ELSE type END"
)
public abstract class FeAnalysisEntity<T> extends CommonEntity<Integer> implements FeatureAnalysis<T, Integer>, Comparable<FeAnalysisEntity<String>> {

Expand Down Expand Up @@ -71,7 +68,6 @@ public FeAnalysisEntity(final FeAnalysisEntity<T> entityForCopy) {
@Column
private String name;

@Lob
@Column(name = "design", insertable = false, updatable = false)
private String rawDesign;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ohdsi.webapi.feanalysis.domain;

import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
Expand All @@ -15,8 +16,8 @@ public FeAnalysisWithStringEntity() {
public FeAnalysisWithStringEntity(final FeAnalysisWithStringEntity analysis) {
super(analysis);
}
@Lob

@Column
private String design;

@Override
Expand Down

0 comments on commit 7739165

Please sign in to comment.