Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into dexamund…
Browse files Browse the repository at this point in the history
…sen/5718
  • Loading branch information
dexamundsen committed Feb 6, 2025
2 parents 3a474fe + ac4900d commit 1e38442
Show file tree
Hide file tree
Showing 35 changed files with 120 additions and 75 deletions.
2 changes: 0 additions & 2 deletions cli/src/main/java/bio/terra/tanagra/cli/utils/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ public final class Context {
private static final String LOG_FILENAME = "tanagra.log";
public static final String IS_TEST = "IS_TEST";
private static final String IS_TEST_TRUE_VALUE = "true";

// Env var name to optionally override where the context is persisted on disk.
private static final String CONTEXT_DIR_OVERRIDE_NAME = "TANAGRA_CONTEXT_PARENT_DIR";
// File paths related to persisting the context on disk.
private static final String CONTEXT_DIRNAME = ".tanagra";

// Singleton object that defines the current context or state.
private static Config currentConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
value = {"NP_NULL_PARAM_DEREF", "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"},
justification = "PCollection is using a Nullable coder")
public final class PathUtils {
private PathUtils() {}

// the path of nodes is currently encoded as a string. use this as the delimiter between nodes.
private static final String PATH_DELIMITER = ".";
private static final String PATH_DELIMITER_REGEX = "\\.";

private PathUtils() {}

/**
* Compute one path from each node in a hierarchy to a root node. If there are multiple paths from
* a given node to a root node, then select one at random.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public List<ActivityLog> getAllActivityLogs(
ACTIVITY_LOG_SELECT_SQL
+ (filterSql.isEmpty() ? "" : " WHERE " + filterSql)
+ " ORDER BY logged DESC LIMIT :limit OFFSET :offset";
LOGGER.debug("GET all activity logs: {}", sql);
return getActivityLogsHelper(sql, params);
}

Expand Down Expand Up @@ -186,7 +185,6 @@ private String renderSqlForActivityLogFilter(
@ReadTransaction
public ActivityLog getActivityLog(String activityLogId) {
String sql = ACTIVITY_LOG_SELECT_SQL + " WHERE id = :id";
LOGGER.debug("GET activity log: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", activityLogId);
List<ActivityLog> activityLogs = getActivityLogsHelper(sql, params);

Expand Down
4 changes: 0 additions & 4 deletions service/src/main/java/bio/terra/tanagra/db/AnnotationDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public List<AnnotationKey> getAllAnnotationKeys(String cohortId, int offset, int
String sql =
ANNOTATION_KEY_SELECT_SQL
+ " WHERE cohort_id = :cohort_id ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET all annotation keys: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("cohort_id", cohortId)
Expand All @@ -137,7 +136,6 @@ public List<AnnotationKey> getAnnotationKeysMatchingList(
String sql =
ANNOTATION_KEY_SELECT_SQL
+ " WHERE cohort_id = :cohort_id AND id IN (:ids) ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET matching annotation keys: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("cohort_id", cohortId)
Expand All @@ -150,7 +148,6 @@ public List<AnnotationKey> getAnnotationKeysMatchingList(
@ReadTransaction
public AnnotationKey getAnnotationKey(String cohortId, String annotationKeyId) {
String sql = ANNOTATION_KEY_SELECT_SQL + " WHERE cohort_id = :cohort_id AND id = :id";
LOGGER.debug("GET annotation key: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource().addValue("cohort_id", cohortId).addValue("id", annotationKeyId);
List<AnnotationKey> annotationKeys = getAnnotationKeysHelper(sql, params);
Expand Down Expand Up @@ -269,7 +266,6 @@ public void updateAnnotationValues(
@ReadTransaction
public List<AnnotationValue.Builder> getAllAnnotationValues(String cohortId) {
String sql = ANNOTATION_VALUE_SELECT_SQL + " WHERE av.cohort_id = :cohort_id";
LOGGER.debug("GET annotation values: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("cohort_id", cohortId);
return jdbcTemplate.query(sql, params, ANNOTATION_VALUE_ROW_MAPPER);
}
Expand Down
3 changes: 0 additions & 3 deletions service/src/main/java/bio/terra/tanagra/db/CohortDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public List<Cohort> getAllCohorts(String studyId, int offset, int limit) {
String sql =
COHORT_SELECT_SQL
+ " WHERE study_id = :study_id AND NOT is_deleted ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET ALL cohorts: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("study_id", studyId)
Expand All @@ -174,7 +173,6 @@ public List<Cohort> getCohortsMatchingList(Set<String> ids, int offset, int limi
String sql =
COHORT_SELECT_SQL
+ " WHERE id IN (:ids) AND NOT is_deleted ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET MATCHING cohorts: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("ids", ids)
Expand All @@ -187,7 +185,6 @@ public List<Cohort> getCohortsMatchingList(Set<String> ids, int offset, int limi
public Cohort getCohort(String id) {
// Fetch cohort.
String sql = COHORT_SELECT_SQL + " WHERE id = :id";
LOGGER.debug("GET cohort: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
List<Cohort> cohorts = getCohortsHelper(sql, params);

Expand Down
3 changes: 0 additions & 3 deletions service/src/main/java/bio/terra/tanagra/db/FeatureSetDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public List<FeatureSet> getAllFeatureSets(String studyId, int offset, int limit)
String sql =
FEATURE_SET_SELECT_SQL
+ " WHERE study_id = :study_id AND NOT is_deleted ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET ALL feature sets: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("study_id", studyId)
Expand All @@ -105,7 +104,6 @@ public List<FeatureSet> getFeatureSetsMatchingList(Set<String> ids, int offset,
String sql =
FEATURE_SET_SELECT_SQL
+ " WHERE id IN (:ids) AND NOT is_deleted ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET MATCHING feature sets: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("ids", ids)
Expand All @@ -118,7 +116,6 @@ public List<FeatureSet> getFeatureSetsMatchingList(Set<String> ids, int offset,
public FeatureSet getFeatureSet(String id) {
// Fetch feature set.
String sql = FEATURE_SET_SELECT_SQL + " WHERE id = :id";
LOGGER.debug("GET feature set: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
List<FeatureSet> featureSets = getFeatureSetsHelper(sql, params);

Expand Down
4 changes: 0 additions & 4 deletions service/src/main/java/bio/terra/tanagra/db/ReviewDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public List<Review> getAllReviews(String cohortId, int offset, int limit) {
String sql =
REVIEW_SELECT_SQL
+ " WHERE cohort_id = :cohort_id AND NOT is_deleted ORDER BY created DESC LIMIT :limit OFFSET :offset";
LOGGER.debug("GET ALL reviews: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("cohort_id", cohortId)
Expand All @@ -97,7 +96,6 @@ public List<Review> getReviewsMatchingList(Set<String> ids, int offset, int limi
String sql =
REVIEW_SELECT_SQL
+ " WHERE id IN (:ids) AND NOT is_deleted ORDER BY created DESC LIMIT :limit OFFSET :offset";
LOGGER.debug("GET MATCHING reviews: {}", sql);
MapSqlParameterSource params =
new MapSqlParameterSource()
.addValue("ids", ids)
Expand All @@ -110,7 +108,6 @@ public List<Review> getReviewsMatchingList(Set<String> ids, int offset, int limi
public Review getReview(String id) {
// Fetch review.
String sql = REVIEW_SELECT_SQL + " WHERE id = :id";
LOGGER.debug("GET review: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
List<Review> reviews = getReviewsHelper(sql, params);

Expand Down Expand Up @@ -196,7 +193,6 @@ public Map<Literal, Integer> getPrimaryEntityIdsToStableIndex(String reviewId) {
String sql =
PRIMARY_ENTITY_INSTANCE_SELECT_SQL
+ " WHERE review_id = :review_id ORDER BY stable_index ASC";
LOGGER.debug("GET primary entity instance ids: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("review_id", reviewId);
List<Pair<Literal, Integer>> idIndexPairs =
jdbcTemplate.query(sql, params, PRIMARY_ENTITY_INSTANCE_ROW_MAPPER);
Expand Down
3 changes: 0 additions & 3 deletions service/src/main/java/bio/terra/tanagra/db/StudyDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public List<Study> getAllStudies(
STUDY_SELECT_SQL
+ (filterSql.isEmpty() ? "" : " WHERE " + filterSql)
+ " ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET all studies: {}", sql);
return getStudiesHelper(sql, params);
}

Expand Down Expand Up @@ -160,7 +159,6 @@ public List<Study> getStudiesMatchingList(
+ " WHERE id IN (:ids) "
+ (filterSql.isEmpty() ? "" : "AND " + filterSql + " ")
+ "ORDER BY display_name LIMIT :limit OFFSET :offset";
LOGGER.debug("GET matching studies: {}", sql);
return getStudiesHelper(sql, params);
}

Expand Down Expand Up @@ -217,7 +215,6 @@ private String renderSqlForStudyFilter(
public Optional<Study> getStudyIfExists(String id) {
// Fetch study.
String sql = STUDY_SELECT_SQL + " WHERE id = :id";
LOGGER.debug("GET study: {}", sql);
MapSqlParameterSource params = new MapSqlParameterSource().addValue("id", id);
List<Study> studies = getStudiesHelper(sql, params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/** Utilities for working with Google application default credentials. */
public final class AppDefaultUtils {

private static final String GCP_ADC_JWT_ISSUER_URL = "https://accounts.google.com";

private AppDefaultUtils() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public final class UserId implements Serializable {
private static final String DISABLED_AUTHENTICATION_USER_ID = "authentication-disabled";

private final String subject;
private final String email;
private final String token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.apache.commons.lang3.tuple.Pair;

public final class Criteria {
private Criteria() {}

public static final Pair<String, bio.terra.tanagra.service.artifact.model.Criteria>
DEMOGRAPHICS_PREPACKAGED_DATA_FEATURE =
Pair.of(
Expand Down Expand Up @@ -67,6 +65,7 @@ private Criteria() {}
.build()))
.uiConfig("")
.build());

public static final Pair<String, bio.terra.tanagra.service.artifact.model.Criteria>
ETHNICITY_EQ_HISPANIC_OR_LATINO =
Pair.of(
Expand Down Expand Up @@ -115,6 +114,7 @@ private Criteria() {}
.uiConfig("")
.tags(Map.of())
.build());

public static final Pair<String, bio.terra.tanagra.service.artifact.model.Criteria>
PROCEDURE_EQ_AMPUTATION =
Pair.of(
Expand Down Expand Up @@ -163,4 +163,6 @@ private Criteria() {}
.build()))
.uiConfig("")
.build());

private Criteria() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,42 @@
import java.util.List;

public final class CriteriaGroup {
private CriteriaGroup() {}

public static final CohortRevision.CriteriaGroup CRITERIA_GROUP_GENDER =
CohortRevision.CriteriaGroup.builder()
.displayName("group gender")
.criteria(List.of(GENDER_EQ_WOMAN.getValue()))
.build();

public static final CohortRevision.CriteriaGroup CRITERIA_GROUP_AGE =
CohortRevision.CriteriaGroup.builder()
.displayName("group gender")
.criteria(List.of(GENDER_EQ_WOMAN.getValue()))
.build();

public static final CohortRevision.CriteriaGroup CRITERIA_GROUP_DEMOGRAPHICS =
CohortRevision.CriteriaGroup.builder()
.displayName("group 1")
.criteria(List.of(GENDER_EQ_WOMAN.getValue(), ETHNICITY_EQ_HISPANIC_OR_LATINO.getValue()))
.build();

public static final CohortRevision.CriteriaGroup DISABLED_CRITERIA_GROUP_DEMOGRAPHICS =
CohortRevision.CriteriaGroup.builder()
.displayName("disabled group demographics")
.criteria(List.of(GENDER_EQ_WOMAN.getValue(), ETHNICITY_EQ_HISPANIC_OR_LATINO.getValue()))
.isDisabled(true)
.build();

public static final CohortRevision.CriteriaGroup CRITERIA_GROUP_CONDITION =
CohortRevision.CriteriaGroup.builder()
.displayName("group condition")
.criteria(List.of(CONDITION_EQ_TYPE_2_DIABETES.getValue()))
.build();

public static final CohortRevision.CriteriaGroup CRITERIA_GROUP_PROCEDURE =
CohortRevision.CriteriaGroup.builder()
.displayName("group procedure")
.criteria(List.of(PROCEDURE_EQ_AMPUTATION.getValue()))
.build();

private CriteriaGroup() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
import java.util.List;

public final class CriteriaGroupSection {
private CriteriaGroupSection() {}

public static final CohortRevision.CriteriaGroupSection CRITERIA_GROUP_SECTION_GENDER =
CohortRevision.CriteriaGroupSection.builder()
.displayName("section gender")
.criteriaGroups(List.of(CriteriaGroup.CRITERIA_GROUP_GENDER))
.build();

public static final CohortRevision.CriteriaGroupSection CRITERIA_GROUP_SECTION_AGE =
CohortRevision.CriteriaGroupSection.builder()
.displayName("section age")
.criteriaGroups(List.of(CriteriaGroup.CRITERIA_GROUP_AGE))
.build();

public static final CohortRevision.CriteriaGroupSection CRITERIA_GROUP_SECTION_DEMOGRAPHICS =
CohortRevision.CriteriaGroupSection.builder()
.displayName("section demographics")
.criteriaGroups(List.of(CriteriaGroup.CRITERIA_GROUP_DEMOGRAPHICS))
.build();

public static final CohortRevision.CriteriaGroupSection
CRITERIA_GROUP_SECTION_DEMOGRAPHICS_AND_CONDITION =
CohortRevision.CriteriaGroupSection.builder()
Expand Down Expand Up @@ -96,4 +97,6 @@ private CriteriaGroupSection() {}
.joinOperatorValue(null)
.setIsExcluded(false)
.build();

private CriteriaGroupSection() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
public final class FeatureSet {
private static final String UNDERLAY_NAME = "cmssynpuf";

private FeatureSet() {}

public static final bio.terra.tanagra.service.artifact.model.FeatureSet CS_DEMOGRAPHICS =
bio.terra.tanagra.service.artifact.model.FeatureSet.builder()
.underlay(UNDERLAY_NAME)
Expand All @@ -23,4 +21,6 @@ private FeatureSet() {}
.criteria(List.of(DEMOGRAPHICS_PREPACKAGED_DATA_FEATURE.getRight()))
.excludeOutputAttributesPerEntity(Map.of("person", List.of("id", "gender")))
.build();

private FeatureSet() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.List;

public final class CohortRevision {
private CohortRevision() {}

private static final String UNDERLAY_NAME = "sd";

public static final bio.terra.tanagra.service.artifact.model.CohortRevision CR_EMPTY =
Expand All @@ -34,12 +32,14 @@ private CohortRevision() {}
.sections(List.of(CGS_CONDITION_EXCLUDED, CGS_GENDER))
.setIsMostRecent(true)
.build();

public static final bio.terra.tanagra.service.artifact.model.CohortRevision CR_PROCEDURE =
bio.terra.tanagra.service.artifact.model.CohortRevision.builder()
.id("cr4")
.sections(List.of(CGS_PROCEDURE))
.setIsMostRecent(true)
.build();

public static final bio.terra.tanagra.service.artifact.model.CohortRevision
CR_GENDER_AND_DISABLED_CONDITION =
bio.terra.tanagra.service.artifact.model.CohortRevision.builder()
Expand All @@ -50,18 +50,23 @@ private CohortRevision() {}

public static final Cohort C_EMPTY =
Cohort.builder().underlay(UNDERLAY_NAME).id("c1").revisions(List.of(CR_EMPTY)).build();

public static final Cohort C_CONDITION_EXCLUDED =
Cohort.builder()
.underlay(UNDERLAY_NAME)
.id("c2")
.revisions(List.of(CR_CONDITION_EXCLUDED))
.build();

public static final Cohort C_CONDITION_EXCLUDED_AND_GENDER =
Cohort.builder()
.underlay(UNDERLAY_NAME)
.id("c3")
.revisions(List.of(CR_CONDITION_EXCLUDED_AND_GENDER))
.build();

public static final Cohort C_PROCEDURE =
Cohort.builder().underlay(UNDERLAY_NAME).id("c5").revisions(List.of(CR_PROCEDURE)).build();

private CohortRevision() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.Map;

public final class Criteria {
private Criteria() {}

public static final bio.terra.tanagra.service.artifact.model.Criteria GENDER_EQ_WOMAN =
bio.terra.tanagra.service.artifact.model.Criteria.builder()
.selectorOrModifierName("tanagra-gender")
Expand Down Expand Up @@ -99,6 +97,7 @@ private Criteria() {}
.build())
.build()))
.build();

public static final bio.terra.tanagra.service.artifact.model.Criteria
PROCEDURE_AGE_AT_OCCURRENCE_EQ_45 =
bio.terra.tanagra.service.artifact.model.Criteria.builder()
Expand Down Expand Up @@ -126,4 +125,6 @@ private Criteria() {}
.selectionData("")
.uiConfig("")
.build();

private Criteria() {}
}
Loading

0 comments on commit 1e38442

Please sign in to comment.