Skip to content

Commit 07f3130

Browse files
Hotfixes from release candidate for 2.15.0 (#2452)
* Added CacheEvict to delete functions. * Fixed a regression where Concept Set Annotation field CreatedBy, CreatedDate, ModifiedBy, ModifiedDate were not handled correctly after moving away from a per-annotation entity permission schema * Adding antiResourceLocking for Tomcat 9 prep. * Removed references to BigQuerySparkTranslate.sparkHandleInsert as this is no longer necessary with DataBricks > 2.0 * Handle missing query param for demographic stats. Fixes #2446. * Reference the correct join field in CcRepository findByFeAnalysis query. Fixes #2447. --------- Co-authored-by: oleg-odysseus <oleg.himself@gmail.com>
1 parent 78996c3 commit 07f3130

10 files changed

Lines changed: 72 additions & 34 deletions

File tree

src/main/java/org/ohdsi/webapi/cohortcharacterization/GenerateCohortCharacterizationTasklet.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ protected String[] prepareQueries(ChunkContext chunkContext, CancelableJdbcTempl
109109
.replaceAll("#", tempSchema + "." + sessionId + "_")
110110
.replaceAll("tempdb\\.\\.", "");
111111
}
112-
if (source.getSourceDialect().equals("spark")) {
113-
try {
114-
sql = BigQuerySparkTranslate.sparkHandleInsert(sql, source.getSourceConnection());
115-
} catch (SQLException e) {
116-
e.printStackTrace();
117-
}
118-
}
119-
120112
final String translatedSql = SqlTranslate.translateSql(sql, source.getSourceDialect(), sessionId, tempSchema);
121113
return SqlSplit.splitSql(translatedSql);
122114
}

src/main/java/org/ohdsi/webapi/cohortcharacterization/repository/CcRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public interface CcRepository extends EntityGraphJpaRepository<CohortCharacteriz
2424
@Query("SELECT cc FROM CohortCharacterizationEntity cc JOIN cc.cohortDefinitions cd WHERE cd = ?1")
2525
List<CohortCharacterizationEntity> findByCohortDefinition(CohortDefinition cd);
2626

27-
@Query("SELECT cc FROM CohortCharacterizationEntity cc JOIN cc.featureAnalyses fa WHERE fa = ?1")
28-
List<CohortCharacterizationEntity> findByFeatureAnalysis(FeAnalysisEntity feAnalysis);
27+
@Query("SELECT cc FROM CohortCharacterizationEntity cc JOIN cc.featureAnalyses fa WHERE fa.featureAnalysis = :fa")
28+
List<CohortCharacterizationEntity> findByFeatureAnalysis(@Param("fa") FeAnalysisEntity feAnalysis);
2929

3030
@Query("SELECT DISTINCT cc FROM CohortCharacterizationEntity cc JOIN FETCH cc.tags t WHERE lower(t.name) in :tagNames")
3131
List<CohortCharacterizationEntity> findByTags(@Param("tagNames") List<String> tagNames);

src/main/java/org/ohdsi/webapi/cohortdefinition/GenerateCohortTasklet.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@ private String[] prepareQueriesDemographic(ChunkContext chunkContext, Cancelable
172172
.contains(source.getSourceDialect())) {
173173
sql = sql.replaceAll("#", tempSchema + "." + sessionId + "_").replaceAll("tempdb\\.\\.", "");
174174
}
175-
if (source.getSourceDialect().equals("spark")) {
176-
try {
177-
sql = BigQuerySparkTranslate.sparkHandleInsert(sql, source.getSourceConnection());
178-
} catch (SQLException e) {
179-
e.printStackTrace();
180-
}
181-
}
182175

183176
final String translatedSql = SqlTranslate.translateSql(sql, source.getSourceDialect(), sessionId, tempSchema);
184177
return SqlSplit.splitSql(translatedSql);

src/main/java/org/ohdsi/webapi/conceptset/annotation/ConceptSetAnnotation.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import org.hibernate.annotations.GenericGenerator;
44
import org.hibernate.annotations.Parameter;
55
import org.ohdsi.webapi.model.CommonEntity;
6+
import org.ohdsi.webapi.shiro.Entities.UserEntity;
67

78
import javax.persistence.Column;
89
import javax.persistence.Entity;
10+
import javax.persistence.FetchType;
911
import javax.persistence.GeneratedValue;
1012
import javax.persistence.Id;
13+
import javax.persistence.JoinColumn;
14+
import javax.persistence.ManyToOne;
1115
import javax.persistence.Table;
1216
import java.io.Serializable;
17+
import java.util.Date;
1318

1419
@Entity(name = "ConceptSetAnnotation")
1520
@Table(name = "concept_set_annotation")
@@ -50,6 +55,57 @@ public class ConceptSetAnnotation implements Serializable {
5055
@Column(name = "copied_from_concept_set_ids")
5156
private String copiedFromConceptSetIds;
5257

58+
@ManyToOne(fetch = FetchType.LAZY)
59+
@JoinColumn(name = "created_by_id", updatable = false)
60+
private UserEntity createdBy;
61+
@ManyToOne(fetch = FetchType.LAZY)
62+
@JoinColumn(name = "modified_by_id")
63+
private UserEntity modifiedBy;
64+
@Column(name = "created_date", updatable = false)
65+
private Date createdDate;
66+
@Column(name = "modified_date")
67+
private Date modifiedDate;
68+
69+
public UserEntity getCreatedBy() {
70+
71+
return createdBy;
72+
}
73+
74+
public void setCreatedBy(UserEntity createdBy) {
75+
76+
this.createdBy = createdBy;
77+
}
78+
79+
public UserEntity getModifiedBy() {
80+
81+
return modifiedBy;
82+
}
83+
84+
public void setModifiedBy(UserEntity modifiedBy) {
85+
86+
this.modifiedBy = modifiedBy;
87+
}
88+
89+
public Date getCreatedDate() {
90+
91+
return createdDate;
92+
}
93+
94+
public void setCreatedDate(Date createdDate) {
95+
96+
this.createdDate = createdDate;
97+
}
98+
99+
public Date getModifiedDate() {
100+
101+
return modifiedDate;
102+
}
103+
104+
public void setModifiedDate(Date modifiedDate) {
105+
106+
this.modifiedDate = modifiedDate;
107+
}
108+
53109
public Integer getId() {
54110
return id;
55111
}

src/main/java/org/ohdsi/webapi/pathway/PathwayStatisticsTasklet.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ private int[] savePathwayCodes(List<PathwayCode> pathwayCodes) {
170170

171171
private int[] savePaths(Source source, Long generationId) throws SQLException {
172172
String sql = SAVE_PATHS_SQL;
173-
if (source.getSourceDialect().equals("spark")) {
174-
sql = SqlRender.renderSql(sql,
175-
new String[]{"target_database_schema", GENERATION_ID},
176-
new String[]{source.getTableQualifier(SourceDaimon.DaimonType.Results), generationId.toString()}
177-
);
178-
sql = BigQuerySparkTranslate.sparkHandleInsert(sql, source.getSourceConnection());
179-
}
180173

181174
PreparedStatementRenderer pathwayEventsPsr = new PreparedStatementRenderer(
182175
source,

src/main/java/org/ohdsi/webapi/service/CohortDefinitionService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public CohortDTO saveCohortDefinition(@PathParam("id") final int id, CohortDTO d
864864
@Transactional
865865
public JobExecutionResource generateCohort(@PathParam("id") final int id,
866866
@PathParam("sourceKey") final String sourceKey,
867-
@QueryParam("demographic") Boolean demographicStat) {
867+
@QueryParam("demographic") boolean demographicStat) {
868868
Source source = getSourceRepository().findBySourceKey(sourceKey);
869869
CohortDefinition currentDefinition = this.cohortDefinitionRepository.findOne(id);
870870
UserEntity user = userRepository.findByLogin(security.getSubject());
@@ -990,6 +990,7 @@ public List<String> getNamesLike(String copyName) {
990990
@DELETE
991991
@Produces(MediaType.APPLICATION_JSON)
992992
@Path("/{id}")
993+
@CacheEvict(cacheNames = CachingSetup.COHORT_DEFINITION_LIST_CACHE, allEntries = true)
993994
public void delete(@PathParam("id") final int id) {
994995
// perform the JPA update in a separate transaction
995996
this.getTransactionTemplateRequiresNew().execute(new TransactionCallbackWithoutResult() {

src/main/java/org/ohdsi/webapi/service/CohortGenerationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public CohortGenerationService(CohortDefinitionRepository cohortDefinitionReposi
9797
}
9898

9999
public JobExecutionResource generateCohortViaJob(UserEntity userEntity, CohortDefinition cohortDefinition,
100-
Source source, Boolean demographicStat) {
100+
Source source, boolean demographicStat) {
101101
CohortGenerationInfo info = cohortDefinition.getGenerationInfoList().stream()
102102
.filter(val -> Objects.equals(val.getId().getSourceId(), source.getSourceId())).findFirst()
103103
.orElse(new CohortGenerationInfo(cohortDefinition, source.getSourceId()));

src/main/java/org/ohdsi/webapi/service/ConceptSetService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ public void assignTag(@PathParam("id") final Integer id, final int tagId) {
689689
@Produces(MediaType.APPLICATION_JSON)
690690
@Path("/{id}/tag/{tagId}")
691691
@Transactional
692+
@CacheEvict(cacheNames = CachingSetup.CONCEPT_SET_LIST_CACHE, allEntries = true)
692693
public void unassignTag(@PathParam("id") final Integer id, @PathParam("tagId") final int tagId) {
693694
ConceptSet entity = getConceptSetRepository().findById(id);
694695
unassignTag(entity, tagId);
@@ -722,6 +723,7 @@ public void assignPermissionProtectedTag(@PathParam("id") final int id, final in
722723
@Produces(MediaType.APPLICATION_JSON)
723724
@Path("/{id}/protectedtag/{tagId}")
724725
@Transactional
726+
@CacheEvict(cacheNames = CachingSetup.CONCEPT_SET_LIST_CACHE, allEntries = true)
725727
public void unassignPermissionProtectedTag(@PathParam("id") final int id, @PathParam("tagId") final int tagId) {
726728
unassignTag(id, tagId);
727729
}
@@ -940,6 +942,8 @@ public boolean saveConceptSetAnnotation(@PathParam("id") final int conceptSetId,
940942
conceptSetAnnotation.setVocabularyVersion(newAnnotationData.getVocabularyVersion());
941943
conceptSetAnnotation.setConceptSetVersion(newAnnotationData.getConceptSetVersion());
942944
conceptSetAnnotation.setConceptId(newAnnotationData.getConceptId());
945+
conceptSetAnnotation.setCreatedBy(getCurrentUser());
946+
conceptSetAnnotation.setCreatedDate(new Date());
943947
return conceptSetAnnotation;
944948
}).collect(Collectors.toList());
945949

@@ -973,6 +977,10 @@ private ConceptSetAnnotation copyAnnotation(ConceptSetAnnotation sourceConceptSe
973977
targetConceptSetAnnotation.setAnnotationDetails(sourceConceptSetAnnotation.getAnnotationDetails());
974978
targetConceptSetAnnotation.setConceptId(sourceConceptSetAnnotation.getConceptId());
975979
targetConceptSetAnnotation.setVocabularyVersion(sourceConceptSetAnnotation.getVocabularyVersion());
980+
targetConceptSetAnnotation.setCreatedBy(sourceConceptSetAnnotation.getCreatedBy());
981+
targetConceptSetAnnotation.setCreatedDate(sourceConceptSetAnnotation.getCreatedDate());
982+
targetConceptSetAnnotation.setModifiedBy(sourceConceptSetAnnotation.getModifiedBy());
983+
targetConceptSetAnnotation.setModifiedDate(sourceConceptSetAnnotation.getModifiedDate());
976984
targetConceptSetAnnotation.setCopiedFromConceptSetIds(appendCopiedFromConceptSetId(sourceConceptSetAnnotation.getCopiedFromConceptSetIds(), sourceConceptSetId));
977985
return targetConceptSetAnnotation;
978986
}
@@ -1015,6 +1023,8 @@ private AnnotationDTO convertAnnotationEntityToDTO(ConceptSetAnnotation conceptS
10151023
annotationDTO.setVocabularyVersion(conceptSetAnnotation.getVocabularyVersion());
10161024
annotationDTO.setConceptSetVersion(conceptSetAnnotation.getConceptSetVersion());
10171025
annotationDTO.setCopiedFromConceptSetIds(conceptSetAnnotation.getCopiedFromConceptSetIds());
1026+
annotationDTO.setCreatedBy(conceptSetAnnotation.getCreatedBy() != null ? conceptSetAnnotation.getCreatedBy().getName() : null);
1027+
annotationDTO.setCreatedDate(conceptSetAnnotation.getCreatedDate() != null ? conceptSetAnnotation.getCreatedDate().toString() : null);
10181028
return annotationDTO;
10191029
}
10201030

src/main/java/org/ohdsi/webapi/util/PreparedStatementRenderer.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ final Map<String, Object> buildParamValueMap(String[] parameters, Object[] value
285285
}
286286

287287
public String getSql() {
288-
if (targetDialect.equals("spark")) {
289-
try {
290-
sql = BigQuerySparkTranslate.sparkHandleInsert(sql, source.getSourceConnection());
291-
} catch (SQLException e) {
292-
e.printStackTrace();
293-
}
294-
}
295288
return SqlTranslate.translateSingleStatementSql(sql, targetDialect, sessionId, tempSchema);
296289
}
297290

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Context antiJARLocking="true" path="/WebAPI"/>
2+
<Context antiJARLocking="true" antiResourceLocking="true" path="/WebAPI"/>

0 commit comments

Comments
 (0)