forked from OHDSI/WebAPI
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes for FeAnalysisEntity to properly map design column, fixed enum …
…in aggregate analysis
- Loading branch information
1 parent
9e71e01
commit 7739165
Showing
5 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/ohdsi/webapi/feanalysis/domain/CriteriaColumnListConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters