CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 347 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 329 |
"/api/ux/tabular/jooq/study/{masterTableNameOrViewName}.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> customStudyTabularRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
List<Field<?>> allFields = Arrays.asList(typableTable.table().fields());
List<Field<?>> selectedFields = new ArrayList<>(allFields);
var bindValues = new ArrayList<Object>();
// Create the participant dashboard table
var participantDashboardTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
"all_participant_dashboard_cached");
// Create the final condition based on the filter model
Condition finalCondition = createFilterWhereCondition(payload.filterModel(),
participantDashboardTable);
if (payload.filterModel() != null && !payload.filterModel().isEmpty()) {
payload.filterModel().forEach((field, filter) -> {
selectedFields.add(createFilterCondition(field, filter.type(), filter.filter(),
filter.secondFilter()));
});
}
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.select(selectedFields) // Selecting the specified fields
.from(typableTable.table())
.leftJoin(participantDashboardTable.table()) // Join with the participant dashboard table
.on(typableTable.column("study_id").eq(participantDashboardTable.column("study_id")))
.where(finalCondition)
.groupBy(field("all_study_summary_cached.study_id")); // Optionally order by created_at or other
// fields
if (payload.sortModel() != null && !payload.sortModel().isEmpty()) {
query = (@NotNull SelectHavingStep<Record>) query.orderBy(createSortCondition(payload.sortModel(),
participantDashboardTable));
}
LOG.info("Get Activity Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Activity Details Corresponds to a Query {}:", query);
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
private Field<String> createFilterCondition(String field, String type, Object filter,
Object secondFilter) {
Field<String> totalParticipantPercentage;
switch (type) {
// Create the total participant percentage field
case "equals":
@Nonnull
@NotNull
Field<String> totalParticipantPercentageEq = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(field("study_participant_dashboard_metrics_view." + field)
.eq(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
// selectedFields.add(totalParticipantPercentageEq);
totalParticipantPercentage = totalParticipantPercentageEq;
break;
case "notEqual":
@Nonnull
Field<String> totalParticipantPercentageNotEq = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(
field("study_participant_dashboard_metrics_view." + field)
.notEqual(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageNotEq;
break;
case "lessOrEqual":
@Nonnull
Field<String> totalParticipantPercentageLte = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(field("study_participant_dashboard_metrics_view." + field)
.le(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageLte;
break;
case "lessThan":
@Nonnull
Field<String> totalParticipantPercentageLt = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(field("study_participant_dashboard_metrics_view." + field)
.lt(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageLt;
break;
case "greatersOrEqual":
@Nonnull
Field<String> totalParticipantPercentageGte = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(field("study_participant_dashboard_metrics_view." + field)
.ge(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageGte;
break;
case "greaterThan":
@Nonnull
Field<String> totalParticipantPercentageGt = DSL
.concat(DSL
.round(DSL
.countDistinct(
when(field("study_participant_dashboard_metrics_view." + field)
.gt(filter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageGt;
break;
case "between":
@Nonnull
Field<String> totalParticipantPercentageBtw = DSL
.concat(DSL
.round(DSL
.countDistinct(when(
field("study_participant_dashboard_metrics_view." + field).between(
filter,
secondFilter),
field("study_participant_dashboard_metrics_view.participant_id")))
.cast(Double.class)
.mul(inline(100.0).cast(Double.class))
.div(countDistinct(
field("study_participant_dashboard_metrics_view.participant_id"))
.cast(Double.class)),
inline(2))
.cast(String.class), // cast to String for concatenation
inline("%") // append "%" symbol
)
.as(field);
totalParticipantPercentage = totalParticipantPercentageBtw;
break;
default:
throw new IllegalArgumentException(
"Unknown filter type '" + type + "' in filter for field '" + field
+ "' see JooqRowsSupplier::createCondition");
}
;
return totalParticipantPercentage;
}
private @NotNull SortField<Object> createSortCondition(
List<lib.aide.tabular.TabularRowsRequest.SortModel> sortModel,
TypableTable participantDashboardTable) {
for (final var sort : sortModel) {
final var sortField = participantDashboardTable.column(sort.colId());
if ((sort.sort()).equals("asc")) {
return field(sortField).asc();
} else if ((sort.sort()).equals("desc")) {
return field(sortField).desc();
} else {
LOG.info("Not a Valid Sort Field");
}
}
return null;
}
private Condition createFilterWhereCondition(Map<String, FilterModel> filterModel,
TypableTable participantDashboardTable) {
List<Condition> conditions = new ArrayList<>();
// Combine all conditions into a single Condition using AND
return conditions.isEmpty() ? trueCondition() : and(conditions);
}
@Hidden
@Operation(summary = "Fetch participant data from participant_data_view")
@PostMapping(value = "/api/ux/tabular/jooq/participant/{schemaName}/{viewName}.json", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 242 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 224 |
"/api/ux/tabular/jooq/column/{schemaName}/{masterTableNameOrViewName}/{columnName}/{columnValue}.json" })
@ResponseBody
public Object tabularColumnCustom(final @PathVariable(required = false) String schemaName,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable String masterTableNameOrViewName, final @PathVariable String columnName,
final @PathVariable String columnValue) {
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var result = udiPrimeDbConfig.dsl().select(selectedColumns.stream()
.map(typableTable::column) // dynamically map column names
.toArray(org.jooq.Field[]::new))
.from(typableTable.table())
.where(typableTable.column(columnName).eq(columnValue))
.fetch()
.intoMaps();
if (selectedColumns.contains("activity_data")) {
auditService.FormatActivityDataResponse(result);
}
return result;
}
private Condition createCondition(Map<String, FilterModel> filter) {
List<Condition> conditionsList = new ArrayList<>();
// Process the filter model
filter.forEach((field, filterModel) -> {
// Extract the logical operator if present
List<Condition> filterConditions = new ArrayList<>();
if (filterModel.operator() == null) {
String type = filterModel.type();
Object filterValue = filterModel.filter();
Object secondFilter = filterModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilter));
conditionsList.add(and(filterConditions));
}
else if (filterModel.conditions() != null) {
// Iterate over each condition and create the respective condition
for (TabularRowsRequest.ConditionsFilterModel conditionModel : filterModel.conditions()) {
String type = conditionModel.type();
Object filterValue = conditionModel.filter();
Object secondFilterValue = conditionModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilterValue));
}
// Combine conditions using the specified operator (AND/OR)
Condition combinedCondition;
if (filterModel.operator().equalsIgnoreCase("AND")) {
combinedCondition = and(filterConditions);
} else if (filterModel.operator().equalsIgnoreCase("OR")) {
combinedCondition = or(filterConditions); // Use OR here
} else {
throw new IllegalArgumentException("Unknown operator '" + filterModel.operator() + "'");
}
// Add combined condition to conditions list
conditionsList.add(combinedCondition);
}
});
// Combine all filter conditions into the main query condition
Condition finalCondition = and(conditionsList); // Use AND for combining all conditions
return finalCondition;
}
private Condition individualCondition(final String field, String type, Object filter, Object secondFilter) {
// Create individual condition based on filter type
Condition individualCondition = switch (type) {
case "like" -> field(field).likeIgnoreCase("%" + filter + "%");
case "equals" -> field(field).eq(param(field, filter));
case "notEqual" -> field(field).notEqual(param(field, filter));
case "number" -> field(field).eq(param(field, filter));
case "date" -> field(field).eq(param(field, filter));
case "contains" -> field(field).likeIgnoreCase("%" + filter + "%");
case "notContains" -> field(field).notLikeIgnoreCase("%" + filter + "%");
case "startsWith" -> field(field).startsWith(filter);
case "endsWith" -> field(field).endsWith(filter);
case "lessOrEqual" -> field(field).lessOrEqual(filter);
case "greaterOrEqual" -> field(field).greaterOrEqual(filter);
case "greaterThan" -> field(field).greaterThan(filter);
case "lessThan" -> field(field).lessThan(filter);
case "between" -> field(field).cast(SQLDataType.REAL)
.between(Float.valueOf(filter.toString()),
Float.valueOf(secondFilter.toString()));
case "blank" -> field(field).cast(SQLDataType.VARCHAR).eq(param(field, ""));
case "notBlank" -> field(field).cast(SQLDataType.VARCHAR).notEqual(param(field, ""));
default -> throw new IllegalArgumentException(
"Unknown filter type '" + type + "' for field '" + field + "'");
};
return individualCondition;
}
@Hidden
@SuppressWarnings("unchecked")
@Operation(summary = "SQL Custom rows for Study Summary ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 683 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 649 |
"/api/ux/tabular/jooq/study/population/dashboard_all_research_study_view.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> customPopulationTabularRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
final var schemaName = "drh_stateless_research_study";
try {
final var masterTableNameOrViewName = "dashboard_population_research_study_view";
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
// Define the specific column names you need
List<String> columnNames = Arrays.asList("study_id", "study_display_id", "title"); // Replace with actual
// column
// names
// Convert column names to jOOQ Field objects
List<Field<?>> selectedFields = columnNames.stream()
.map(col -> DSL.field(DSL.name(schemaName, masterTableNameOrViewName, col)))
.collect(Collectors.toList());
LOG.info("Typable Table: {}", typableTable.table());
LOG.info("Table Name: {}", typableTable.table().getName());
LOG.info("Schema: {}", typableTable.table().getSchema());
LOG.info("Fields: {}", Arrays.toString(typableTable.table().fields()));
var bindValues = new ArrayList<Object>();
// Create the participant dashboard table
var participantMetricsTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
"study_participant_dashboard_metrics_view");
// Create the final condition based on the filter model
Condition finalCondition = createFilterWhereCondition(payload.filterModel(),
participantMetricsTable);
if (payload.filterModel() != null && !payload.filterModel().isEmpty()) {
payload.filterModel().forEach((field, filter) -> {
selectedFields.add(createFilterCondition(field, filter.type(),
filter.filter(),
filter.secondFilter()));
});
}
final var userId = userNameService.getUserId();
final var userPartyId = partyService.getPartyIdByUserId(userId);
final var organizationPartyId = partyService.getOrganizationPartyIdByUser(userId);
LOG.info("Get Study Details Corresponds to the userPartyId: {}, organizationPartyId: {}", userPartyId,
organizationPartyId);
Condition condition = DSL
.or(
DSL.field("visibility_name").eq("Public"),
DSL.field("study_participant_dashboard_metrics_view.organization_party_id")
.eq(organizationPartyId),
DSL.and(
DSL.field("visibility_name").eq("Private"),
DSL.field("created_by").eq(userPartyId)))
.and(DSL.field("deleted_at").isNull())
.and(DSL.field("rec_status_id").eq(1))
.and(
DSL.or(
DSL.field("visibility").notEqual("Private"),
DSL.field("created_by").eq(userPartyId)));
finalCondition = finalCondition == null ? condition : finalCondition.and(condition);
bindValues.add("Public");
bindValues.add(organizationPartyId);
bindValues.add("Private");
bindValues.add(userPartyId);
bindValues.add(1);
bindValues.add("Private");
bindValues.add(userPartyId);
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.select(selectedFields) // Selecting the specified fields
.from(typableTable.table())
.leftJoin(participantMetricsTable.table()) // Join with the participantdashboard table
.on(field("dashboard_population_research_study_view.study_id")
.eq(field("study_participant_dashboard_metrics_view.study_id")))
.where(finalCondition);
// .groupBy(field("dashboard_population_research_study_view.study_id")); //
// Optionally order by
// created_at or
// other
// fields
// if (payload.sortModel() != null && !payload.sortModel().isEmpty()) {
// query = (@NotNull SelectHavingStep<Record>)
// query.orderBy(createSortCondition(payload.sortModel(),
// participantMetricsTable));
// }
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL All Study Summary ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/InvestigatorController.java | 343 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/ParticipantController.java | 67 |
LOG.info("Getting details for studyId: {} , participantId: {}", studyDisplayId, participantDisplayId);
// Create params object
Params params = new Params("DCLP1-001-001");
model.addAttribute("params", params);
List<Map<String, LocalDate>> dateRangeValues = List.of(
new HashMap<String, LocalDate>() {
{
put("start_date", LocalDate.of(2023, 6, 1));
put("end_date", LocalDate.of(2023, 6, 10));
}
});
LocalDate startDate = LocalDate.of(2023, 6, 1);
LocalDate endDate = LocalDate.of(2023, 6, 10);
// Calculate the difference in days
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
// Format the number of days as an integer
String formattedDays = String.format("%d", daysBetween);
model.addAttribute("daysBetween", formattedDays);
// Sample data for percentage_of_time
Map<String, String> percentageOfTime = Map.of("percentage_active", "75");
// Sample data for no_of_days_worn
Map<String, String> noOfDaysWorn = Map.of("Number_of_Days_CGM_Worn", "28");
// Sample data for mean_glucose_for_each_patient
Map<String, String> meanGlucoseForEachPatient = Map.of("MeanGlucose", "150");
// Sample data for indicator
Map<String, String> indicator = Map.of("GMI", "7.0");
// Sample data for glycemic_variability_per_patient
Map<String, String> glycemicVariabilityPerPatient = Map.of("coefficient_of_variation", "30");
model.addAttribute("date_range_values", dateRangeValues);
model.addAttribute("percentage_of_time", percentageOfTime);
model.addAttribute("no_of_days_worn", noOfDaysWorn);
model.addAttribute("mean_glucose_for_each_patient", meanGlucoseForEachPatient);
model.addAttribute("indicator", indicator);
model.addAttribute("glycemic_variability_per_patient", glycemicVariabilityPerPatient);
// Create a DecimalFormat object with one decimal place
DecimalFormat df = new DecimalFormat("#.0");
// Format the number to one decimal place
String formattedNumber1 = df.format(1.111);
String formattedNumber2 = df.format(8.9455);
String formattedNumber3 = df.format(88.7);
String formattedNumber4 = df.format(1.2);
String formattedNumber5 = df.format(0.2);
// Example data structure for timeInRangesView
List<TimeInRange> timeInRangesView = List.of(
new TimeInRange("Participant1", 250, 12.3, "23h 20m", formattedNumber1),
new TimeInRange("Participant2", 180, 50.0, "195h 40m", formattedNumber2),
new TimeInRange("Participant3", 70, 50.0, "1947h 10m", formattedNumber3),
new TimeInRange("Participant4", 54, 50.0, "25h 20m", formattedNumber4),
new TimeInRange("Participant5", 22, 50.0, "03h 45m", formattedNumber5)
// Add more entries as needed
);
model.addAttribute("timeInRangesView", timeInRangesView);
model.addAttribute("isCalculationShown", false);
List<AgpStudyParticipant> studyParticipantsWithRangeView = List.of(
new AgpStudyParticipant("70.7", "3.71", "25.1", "0.476", "0.0322", "27.3"));
model.addAttribute("study_participants_with_range_view", studyParticipantsWithRangeView);
model.addAttribute("time_in_tight_range", 62.1);
List<ComponentData> componentsPrimary = List.of(
new ComponentData("Liability Index", 0.113, "Value 1", "mg/dL"),
new ComponentData("Hypoglycemic Episodes", 349, "hypoglycemic_episodes", ""),
new ComponentData("Euglycemic Episodes", 23366.0, "euglycemic_episodes", ""),
new ComponentData("Hyperglycemic Episodes", 2629, "hyperglycemic_episodes", ""),
new ComponentData("M Value", 0.00224, "m_value", "mg/dL"),
new ComponentData("Mean Amplitude", 144, "mean_amplitude", ""),
new ComponentData("Average Daily Risk Range", 144, "average_daily_risk", "mg/dL"),
new ComponentData("J Index", 645, "j_index", "mg/dL"),
new ComponentData("Low Blood Glucose Index", 391116186, "lbgi", ""),
new ComponentData("High Blood Glucose Index", 24485149.1, "hbgi", "")
);
model.addAttribute("componentsPrimary", componentsPrimary);
List<ComponentData> componentsSecondary = List.of(
new ComponentData("Glycemic Risk Assessment Diabetes Equation (GRADE)", 7.79, "GRADE", ""),
new ComponentData("Continuous Overall Net Glycemic Action (CONGA)", 5.64, "conga_hourly_mean", ""),
new ComponentData("Mean of Daily Differences", 0.000835136468891167, "mean_daily_difference", "")
);
model.addAttribute("componentsSecondary", componentsSecondary);
// Page description and notes to show on top of the page
String[] pageDescription = {
"The Participants Detail page is a comprehensive report that includes glucose statistics, such as the Ambulatory Glucose Profile (AGP), Glycemia Risk Index (GRI), Daily Glucose Profile, and all other metrics data."
};
String[] notes = {
"The loading time for the AGP and GRI is currently a bit high due to data fetching and calculations. It needs optimization.",
"Need to optimize the UI of the loader for individual metrics and charts."
};
model.addAttribute("pageDescription", pageDescription);
model.addAttribute("notes", notes);
return presentation.populateModel("page/investigator/participantInfo", model, request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsController.java | 102 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 266 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 248 |
}
private Condition createCondition(Map<String, FilterModel> filter) {
List<Condition> conditionsList = new ArrayList<>();
// Process the filter model
filter.forEach((field, filterModel) -> {
// Extract the logical operator if present
List<Condition> filterConditions = new ArrayList<>();
if (filterModel.operator() == null) {
String type = filterModel.type();
Object filterValue = filterModel.filter();
Object secondFilter = filterModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilter));
conditionsList.add(and(filterConditions));
}
else if (filterModel.conditions() != null) {
// Iterate over each condition and create the respective condition
for (TabularRowsRequest.ConditionsFilterModel conditionModel : filterModel.conditions()) {
String type = conditionModel.type();
Object filterValue = conditionModel.filter();
Object secondFilterValue = conditionModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilterValue));
}
// Combine conditions using the specified operator (AND/OR)
Condition combinedCondition;
if (filterModel.operator().equalsIgnoreCase("AND")) {
combinedCondition = and(filterConditions);
} else if (filterModel.operator().equalsIgnoreCase("OR")) {
combinedCondition = or(filterConditions); // Use OR here
} else {
throw new IllegalArgumentException("Unknown operator '" + filterModel.operator() + "'");
}
// Add combined condition to conditions list
conditionsList.add(combinedCondition);
}
});
// Combine all filter conditions into the main query condition
Condition finalCondition = and(conditionsList); // Use AND for combining all conditions
return finalCondition;
}
private Condition individualCondition(final String field, String type, Object filter, Object secondFilter) {
// Create individual condition based on filter type
Condition individualCondition = switch (type) {
case "like" -> field(field).likeIgnoreCase("%" + filter + "%");
case "equals" -> field(field).eq(param(field, filter));
case "notEqual" -> field(field).notEqual(param(field, filter));
case "number" -> field(field).eq(param(field, filter));
case "date" -> field(field).eq(param(field, filter));
case "contains" -> field(field).likeIgnoreCase("%" + filter + "%");
case "notContains" -> field(field).notLikeIgnoreCase("%" + filter + "%");
case "startsWith" -> field(field).startsWith(filter);
case "endsWith" -> field(field).endsWith(filter);
case "lessOrEqual" -> field(field).lessOrEqual(filter);
case "greaterOrEqual" -> field(field).greaterOrEqual(filter);
case "greaterThan" -> field(field).greaterThan(filter);
case "lessThan" -> field(field).lessThan(filter);
case "between" -> field(field).cast(SQLDataType.REAL)
.between(Float.valueOf(filter.toString()),
Float.valueOf(secondFilter.toString()));
case "blank" -> field(field).cast(SQLDataType.VARCHAR).eq(param(field, ""));
case "notBlank" -> field(field).cast(SQLDataType.VARCHAR).notEqual(param(field, ""));
default -> throw new IllegalArgumentException(
"Unknown filter type '" + type + "' for field '" + field + "'");
};
return individualCondition;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 268 |
| org/diabetestechnology/drh/service/http/pg/filter/CustomTabularFilter.java | 24 |
private Condition createCondition(Map<String, FilterModel> filter) {
List<Condition> conditionsList = new ArrayList<>();
// Process the filter model
filter.forEach((field, filterModel) -> {
// Extract the logical operator if present
List<Condition> filterConditions = new ArrayList<>();
if (filterModel.operator() == null) {
String type = filterModel.type();
Object filterValue = filterModel.filter();
Object secondFilter = filterModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilter));
conditionsList.add(and(filterConditions));
}
else if (filterModel.conditions() != null) {
// Iterate over each condition and create the respective condition
for (TabularRowsRequest.ConditionsFilterModel conditionModel : filterModel.conditions()) {
String type = conditionModel.type();
Object filterValue = conditionModel.filter();
Object secondFilterValue = conditionModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilterValue));
}
// Combine conditions using the specified operator (AND/OR)
Condition combinedCondition;
if (filterModel.operator().equalsIgnoreCase("AND")) {
combinedCondition = and(filterConditions);
} else if (filterModel.operator().equalsIgnoreCase("OR")) {
combinedCondition = or(filterConditions); // Use OR here
} else {
throw new IllegalArgumentException("Unknown operator '" + filterModel.operator() + "'");
}
// Add combined condition to conditions list
conditionsList.add(combinedCondition);
}
});
// Combine all filter conditions into the main query condition
Condition finalCondition = and(conditionsList); // Use AND for combining all conditions
return finalCondition;
}
private Condition individualCondition(final String field, String type, Object filter, Object secondFilter) {
// Create individual condition based on filter type
Condition individualCondition = switch (type) {
case "like" -> field(field).likeIgnoreCase("%" + filter + "%");
case "equals" -> field(field).eq(param(field, filter));
case "notEqual" -> field(field).notEqual(param(field, filter));
case "number" -> field(field).eq(param(field, filter));
case "date" -> field(field).eq(param(field, filter));
case "contains" -> field(field).likeIgnoreCase("%" + filter + "%");
case "notContains" -> field(field).notLikeIgnoreCase("%" + filter + "%");
case "startsWith" -> field(field).startsWith(filter);
case "endsWith" -> field(field).endsWith(filter);
case "lessOrEqual" -> field(field).lessOrEqual(filter);
case "greaterOrEqual" -> field(field).greaterOrEqual(filter);
case "greaterThan" -> field(field).greaterThan(filter);
case "lessThan" -> field(field).lessThan(filter);
case "between" -> field(field).cast(SQLDataType.REAL)
.between(Float.valueOf(filter.toString()),
Float.valueOf(secondFilter.toString()));
case "blank" -> field(field).cast(SQLDataType.VARCHAR).eq(param(field, ""));
case "notBlank" -> field(field).cast(SQLDataType.VARCHAR).notEqual(param(field, ""));
default -> throw new IllegalArgumentException(
"Unknown filter type '" + type + "' for field '" + field + "'");
};
return individualCondition;
}
@Hidden | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/filter/CustomTabularFilter.java | 24 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 250 |
public Condition createCondition(Map<String, FilterModel> filter) {
List<Condition> conditionsList = new ArrayList<>();
// Process the filter model
filter.forEach((field, filterModel) -> {
// Extract the logical operator if present
List<Condition> filterConditions = new ArrayList<>();
if (filterModel.operator() == null) {
String type = filterModel.type();
Object filterValue = filterModel.filter();
Object secondFilter = filterModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilter));
conditionsList.add(and(filterConditions));
}
else if (filterModel.conditions() != null) {
// Iterate over each condition and create the respective condition
for (TabularRowsRequest.ConditionsFilterModel conditionModel : filterModel.conditions()) {
String type = conditionModel.type();
Object filterValue = conditionModel.filter();
Object secondFilterValue = conditionModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilterValue));
}
// Combine conditions using the specified operator (AND/OR)
Condition combinedCondition;
if (filterModel.operator().equalsIgnoreCase("AND")) {
combinedCondition = and(filterConditions);
} else if (filterModel.operator().equalsIgnoreCase("OR")) {
combinedCondition = or(filterConditions); // Use OR here
} else {
throw new IllegalArgumentException("Unknown operator '" + filterModel.operator() + "'");
}
// Add combined condition to conditions list
conditionsList.add(combinedCondition);
}
});
// Combine all filter conditions into the main query condition
Condition finalCondition = and(conditionsList); // Use AND for combining all conditions
return finalCondition;
}
private Condition individualCondition(final String field, String type, Object filter, Object secondFilter) {
// Create individual condition based on filter type
Condition individualCondition = switch (type) {
case "like" -> field(field).likeIgnoreCase("%" + filter + "%");
case "equals" -> field(field).eq(param(field, filter));
case "notEqual" -> field(field).notEqual(param(field, filter));
case "number" -> field(field).eq(param(field, filter));
case "date" -> field(field).eq(param(field, filter));
case "contains" -> field(field).likeIgnoreCase("%" + filter + "%");
case "notContains" -> field(field).notLikeIgnoreCase("%" + filter + "%");
case "startsWith" -> field(field).startsWith(filter);
case "endsWith" -> field(field).endsWith(filter);
case "lessOrEqual" -> field(field).lessOrEqual(filter);
case "greaterOrEqual" -> field(field).greaterOrEqual(filter);
case "greaterThan" -> field(field).greaterThan(filter);
case "lessThan" -> field(field).lessThan(filter);
case "between" -> field(field).cast(SQLDataType.REAL)
.between(Float.valueOf(filter.toString()),
Float.valueOf(secondFilter.toString()));
case "blank" -> field(field).cast(SQLDataType.VARCHAR).eq(param(field, ""));
case "notBlank" -> field(field).cast(SQLDataType.VARCHAR).notEqual(param(field, ""));
default -> throw new IllegalArgumentException(
"Unknown filter type '" + type + "' for field '" + field + "'");
};
return individualCondition;
}
@NotNull | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsController.java | 104 |
| org/diabetestechnology/drh/service/http/pg/filter/CustomTabularFilter.java | 24 |
private Condition createCondition(Map<String, FilterModel> filter) {
List<Condition> conditionsList = new ArrayList<>();
// Process the filter model
filter.forEach((field, filterModel) -> {
// Extract the logical operator if present
List<Condition> filterConditions = new ArrayList<>();
if (filterModel.operator() == null) {
String type = filterModel.type();
Object filterValue = filterModel.filter();
Object secondFilter = filterModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilter));
conditionsList.add(and(filterConditions));
}
else if (filterModel.conditions() != null) {
// Iterate over each condition and create the respective condition
for (TabularRowsRequest.ConditionsFilterModel conditionModel : filterModel.conditions()) {
String type = conditionModel.type();
Object filterValue = conditionModel.filter();
Object secondFilterValue = conditionModel.secondFilter();
// Add individual condition to the list of conditions
filterConditions.add(individualCondition(field, type, filterValue, secondFilterValue));
}
// Combine conditions using the specified operator (AND/OR)
Condition combinedCondition;
if (filterModel.operator().equalsIgnoreCase("AND")) {
combinedCondition = and(filterConditions);
} else if (filterModel.operator().equalsIgnoreCase("OR")) {
combinedCondition = or(filterConditions); // Use OR here
} else {
throw new IllegalArgumentException("Unknown operator '" + filterModel.operator() + "'");
}
// Add combined condition to conditions list
conditionsList.add(combinedCondition);
}
});
// Combine all filter conditions into the main query condition
Condition finalCondition = and(conditionsList); // Use AND for combining all conditions
return finalCondition;
}
private Condition individualCondition(final String field, String type, Object filter, Object secondFilter) {
// Create individual condition based on filter type
Condition individualCondition = switch (type) {
case "like" -> field(field).likeIgnoreCase("%" + filter + "%");
case "equals" -> field(field).eq(param(field, filter));
case "notEqual" -> field(field).notEqual(param(field, filter));
case "number" -> field(field).eq(param(field, filter));
case "date" -> field(field).eq(param(field, filter));
case "contains" -> field(field).likeIgnoreCase("%" + filter + "%");
case "notContains" -> field(field).notLikeIgnoreCase("%" + filter + "%");
case "startsWith" -> field(field).startsWith(filter);
case "endsWith" -> field(field).endsWith(filter);
case "lessOrEqual" -> field(field).lessOrEqual(filter);
case "greaterOrEqual" -> field(field).greaterOrEqual(filter);
case "greaterThan" -> field(field).greaterThan(filter);
case "lessThan" -> field(field).lessThan(filter);
case "between" -> field(field).cast(SQLDataType.REAL)
.between(Float.valueOf(filter.toString()),
Float.valueOf(secondFilter.toString()));
case "blank" -> field(field).cast(SQLDataType.VARCHAR).eq(param(field, ""));
case "notBlank" -> field(field).cast(SQLDataType.VARCHAR).notEqual(param(field, ""));
default -> throw new IllegalArgumentException(
"Unknown filter type '" + type + "' for field '" + field + "'");
};
return individualCondition;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 921 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 887 |
"/api/ux/tabular/jooq/distinct/db/file/{schemaName}/{masterTableNameOrViewName}.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@Hidden
public TabularRowsResponse<?> distinctTabularFileIntractionRowstRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable(required = false) String schemaName,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 1);
allSelectedFields[selectedFields.length] = min(field("created_at")).as("min_created_at"); // Add minimum
Condition finalCondition = createCondition(payload.filterModel()); // created_at
Field<String> studyDisplayIdField = field("study_display_id", String.class);
Field<String> fileCategory = field("file_category", String.class);
Condition condition1 = studyDisplayIdField.isNotNull(); // Ensure it applies
Condition condition2 = fileCategory.eq(DSL.value(FileType.DATABASE)); // Ensure it applies
// Apply filters
finalCondition = DSL.and(condition1);
finalCondition = DSL.and(condition2);
bindValues.add(FileType.DATABASE);
// Log the final condition before executing the query
LOG.info("Final WHERE condition: {}", finalCondition);
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.from(typableTable.table())
.where(finalCondition)
.groupBy(
selectedColumns.stream()
.map(typableTable::column) // Dynamically map column names
.toArray(org.jooq.Field[]::new))
.orderBy(field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
// bindValues.add(100);
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL rows for a sub-grid based on file_category and study_display_id")
@GetMapping(value = "/api/ux/tabular/jooq/{schemaName}/{viewName}/{file_category}/{fileCategory}/study_id/{studyId}.json") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 852 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 818 |
"/api/ux/tabular/jooq/distinct/file_interaction/{schemaName}/{viewName}.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@Hidden
public TabularRowsResponse<?> distinctFileInteractionRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable String viewName,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(), viewName);
var bindValues = new ArrayList<Object>();
// Parse columns to select
List<String> selectedColumns = Arrays.asList(columns.split(","));
var selectedFields = selectedColumns.stream()
.map(DSL::field)
.toArray(org.jooq.Field[]::new);
// Add min(created_at) for ordering
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 1);
allSelectedFields[selectedFields.length] = min(field("created_at")).as("min_created_at");
// Apply filters from payload
Field<String> studyDisplayIdField = field(typableTable.column("study_display_id")).cast(String.class);
Condition condition = studyDisplayIdField.isNotNull();
LOG.info("Condition for study_display_id: {}", condition);
// Apply filters
Condition finalCondition = condition;
// Log the final condition before executing the query
LOG.info("Final WHERE condition: {}", finalCondition);
// Construct SQL query using jOOQ
var query = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.from(typableTable.table())
.where(finalCondition)
.groupBy(
selectedColumns.stream()
.map(typableTable::column)
.toArray(org.jooq.Field[]::new))
.orderBy(field("min_created_at").desc());
LOG.info("Fetching distinct file interaction rows for schema: {}", schemaName.toLowerCase());
LOG.info("Generated SQL Query: {}", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), viewName, (Query) query, bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL distinct File Interaction rows from activity table ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1036 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1001 |
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
Field<String> userNameField = DSL
.selectDistinct(DSL.field("name", String.class))
.from("drh_stateless_authentication.profile_details_view")
.where(DSL.field("party_id").eq(DSL.field("created_by")))
.asField("user_name");
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 2);
allSelectedFields[selectedFields.length] = userNameField;
LOG.info("Selected columns: {}", selectedColumns);
allSelectedFields[selectedFields.length + 1] = min(field("created_at")).as("min_created_at"); // Add
// minimum
LOG.info("All selected fields: {}", Arrays.toString(allSelectedFields));
Condition finalCondition = createCondition(payload.filterModel()); // created_at
// TO DO: add permission check for admin and non-admin users
if (presentation.isAuthenticatedUser()) {
LOG.info("Applying additional conditions for non-admin user.");
final var createdBy = userNameService.getCurrentUserPartyId();
Select<?> sessionUniqueIdSubquery = DSL
.selectDistinct(DSL.field("session_unique_id", String.class))
.from("drh_stateless_activity_audit.vw_activity_log")
.where(DSL.field("created_by").eq(DSL.val(createdBy)));
// final var userName = userNameService.getUserName();
if (StringUtils.hasText(createdBy)) {
bindValues.add(createdBy);
// final var sessionUniqueIds = "(select distinct session_unique_id from
// drh_stateless_activity_audit.vw_activity_log where created_by= '"
// + createdBy + "')";
finalCondition = and(finalCondition,
DSL.field("created_by").isNotNull(),
DSL.field("session_unique_id").in(sessionUniqueIdSubquery));
} // else {
// finalCondition = and(finalCondition,
// DSL.field("user_name").eq(userName));
// }
// bindValues.add(userName);
LOG.info("Final condition for non-admin user: {}", finalCondition);
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
// bindValues.add(100);
} else {
LOG.info("Applying additional conditions for non-admin user.");
final var userName = userNameService.getUserName();
final var uniqueSessionId = ObservabilityRequestFilter.uniqueSession;
LOG.info("Unique Session ID: {}", uniqueSessionId);
bindValues.add(userName);
bindValues.add(uniqueSessionId);
finalCondition = and(finalCondition,
// DSL.field("user_name").eq(userName),
DSL.field("session_unique_id").eq(uniqueSessionId));
LOG.info("Final condition for non-admin user: {}", finalCondition);
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1147 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1109 |
"/api/ux/tabular/jooq/distinct/org/audit/drh_stateless_activity_audit/vw_activity_log.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> distinctOrgTabularAuditRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
final var schemaName = "drh_stateless_activity_audit";
final var masterTableNameOrViewName = "vw_activity_log";
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
Field<String> userNameField = DSL
.selectDistinct(DSL.field("name", String.class))
.from("drh_stateless_authentication.profile_details_view")
.where(DSL.field("party_id").eq(DSL.field("created_by")))
.asField("user_name");
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 2);
allSelectedFields[selectedFields.length] = userNameField;
LOG.info("Selected columns: {}", selectedColumns);
allSelectedFields[selectedFields.length + 1] = min(field("created_at")).as("min_created_at"); // Add
// minimum
LOG.info("All selected fields: {}", Arrays.toString(allSelectedFields));
Condition finalCondition = createCondition(payload.filterModel()); // created_at
Condition notSuperAdminCondition = DSL.notExists(
DSL.selectOne()
.from("drh_stateless_authentication.super_admin_view")
.where(DSL.field("party_id").eq(DSL.field("created_by"))));
final var organizationPartyId = userNameService.getCurrentUserOrganizationPartyId();
finalCondition = and(finalCondition,
DSL.field("organization_party_id").eq(organizationPartyId));
bindValues.add(organizationPartyId);
finalCondition = and(finalCondition,
DSL.field("created_by").isNotNull());
finalCondition = finalCondition.and(notSuperAdminCondition);
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase()); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 135 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 130 |
"/api/ux/tabular/jooq/distinct/audit/drh_stateless_activity_audit/vw_activity_log.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> distinctTabularAuditRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
final var schemaName = "drh_stateless_activity_audit";
final var masterTableNameOrViewName = "vw_activity_log";
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
Field<String> userNameField = DSL
.selectDistinct(DSL.field("name", String.class))
.from("drh_stateless_authentication.profile_details_view")
.where(DSL.field("party_id").eq(DSL.field("created_by")))
.asField("user_name");
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 2);
allSelectedFields[selectedFields.length] = userNameField;
LOG.info("Selected columns: {}", selectedColumns);
allSelectedFields[selectedFields.length + 1] = min(field("created_at")).as("min_created_at"); // Add
// minimum
LOG.info("All selected fields: {}", Arrays.toString(allSelectedFields));
Condition finalCondition = createCondition(payload.filterModel()); // created_at
// TO DO: add permission check for admin and non-admin users
final var organizationPartyId = userNameService.getCurrentUserOrganizationPartyId();
finalCondition = and(finalCondition,
DSL.field("organization_party_id").eq(organizationPartyId));
bindValues.add(organizationPartyId);
bindValues.add("anonymous");
finalCondition = or(finalCondition,
DSL.field("user_name").isNotNull());
finalCondition = or(finalCondition,
DSL.lower(DSL.field("user_name", String.class)).eq(DSL.value("anonymous"))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 610 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 592 |
@PostMapping(value = "/api/ux/tabular/jooq/participant/{schemaName}/{viewName}.json", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> fetchParticipantData(
@RequestParam(name = "studyId") String studyId,
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
final @PathVariable String viewName,
@RequestParam(required = false, defaultValue = "*") String columns,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
var bindValues = new ArrayList<Object>();
bindValues.add(studyId); // Bind studyId as a parameter
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
viewName);
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Convert column names to jOOQ fields
.toArray(org.jooq.Field[]::new);
Condition condition = DSL.field("study_id").eq(DSL.val(studyId));
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.select(selectedFields)
.from(typableTable.table())
.where(condition)
.orderBy(DSL.field("participant_id"));
LOG.info("Fetching participant data for schema: {} and studyId: {}", schemaName.toLowerCase(), studyId);
LOG.info("Generated SQL Query: {}", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), viewName, query, bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
LOG.error("Error executing SQL query for schema '{}' and studyId '{}': {}", schemaName, studyId,
e.getMessage(), e);
throw new RuntimeException("Error fetching participant data for studyId '" + studyId + "'", e);
}
}
@GetMapping("/cache") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/PrimeController.java | 72 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/ProfileVerifyController.java | 49 |
model.addAttribute("isAuthenticated", false);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated() && !(authentication
.getPrincipal() instanceof AnonymousAuthenticationToken)) {
LOG.info("User is authenticated: {}", authentication.getPrincipal());
String userName = "Anonymous";
final var providerId = userNameService.getUserId();
final var statusId = masterService.getUserVerificationStatusId(UserVerificationStatus.COMPLETED);
Boolean isUserVerified = practitionerService.isUserVerified(providerId, statusId);
Boolean isSuperAdmin = presentation.isSuperAdmin();
model.addAttribute("isUserVerified", isUserVerified);
Boolean isAdmin = userNameService.isAdmin();
model.addAttribute("isAdmin", isAdmin);
// Handle both OAuth2 and database authentication
if (authentication.getPrincipal() instanceof OAuth2User) {
LOG.info("Oauth2User User Home");
OAuth2User oauth2User = (OAuth2User) authentication.getPrincipal();
model.addAttribute("isAuthenticated", true);
model.addAttribute("userProvider", oauth2User.getAttribute("provider"));
userName = oauth2User.getAttribute("name") != null ? oauth2User.getAttribute("name")
: oauth2User
.getAttribute("login");
model.addAttribute("userName", userName);
model.addAttribute("isSuperAdmin", false);
} else if (authentication.getPrincipal() instanceof UserDetails) {
LOG.info("DRH User Home");
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
model.addAttribute("isAuthenticated", true);
model.addAttribute("userProvider", "Database");
model.addAttribute("isSuperAdmin", presentation.isSuperAdmin());
userName = userDetails.getUsername();
model.addAttribute("userName", userName);
} else {
LoginLogger.anonymousLogin(userName);
}
Boolean existingUser = practitionerService.isUserExists();
model.addAttribute("isProfileCompleted", existingUser);
model.addAttribute("Organization", practitionerService.getUserOrganization());
model.addAttribute("isSuperAdmin", presentation.isSuperAdmin());
if (existingUser) {
final var name = presentation.getUsername();
model.addAttribute("userName", name);
LoginLogger.practitionerLogin(userName);
} else if (userName != null && userName.equalsIgnoreCase("Anonymous")) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 137 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1149 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 132 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 991 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1111 |
public TabularRowsResponse<?> distinctTabularAuditRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
final var schemaName = "drh_stateless_activity_audit";
final var masterTableNameOrViewName = "vw_activity_log";
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
Field<String> userNameField = DSL
.selectDistinct(DSL.field("name", String.class))
.from("drh_stateless_authentication.profile_details_view")
.where(DSL.field("party_id").eq(DSL.field("created_by")))
.asField("user_name");
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 2);
allSelectedFields[selectedFields.length] = userNameField;
LOG.info("Selected columns: {}", selectedColumns);
allSelectedFields[selectedFields.length + 1] = min(field("created_at")).as("min_created_at"); // Add
// minimum
LOG.info("All selected fields: {}", Arrays.toString(allSelectedFields));
Condition finalCondition = createCondition(payload.filterModel()); // created_at | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ParticipantService.java | 198 |
| org/diabetestechnology/drh/service/http/pg/service/ParticipantService.java | 414 |
LOG.info("Update Participant Inline Data Query: {}", query);
final var result = query
.fetchOneInto(JSONB.class);
LOG.info("Edit participant Result: {}", result);
if (result != null) {
@SuppressWarnings("unchecked")
Map<String, Object> resultMap = new ObjectMapper().readValue(result.data(), Map.class);
String status = (String) resultMap.get("status");
String message = (String) resultMap.get("message");
final var studyId = getStudyIdOfParticipant(participantId);
String hubInteractionId = interactionService.getHubIntercationIdOfStudyParticipant(studyId);
if ("failure".equalsIgnoreCase(status)) {
LOG.info("Database status is failure. Message: {}", message);
LOG.warn("Failed to edit participant data: {}", message);
throw new IllegalArgumentException("Failed to save participant data: " + message);
} else if ("success".equalsIgnoreCase(status)) {
interactionService.saveStudyParticipantInteraction(studyId, participantId,
hubInteractionId, ActionType.UPDATE_PARTICIPANT, ActionDescription.UPDATE_PARTICIPANT,
null, null, jsonInput.data(), result.data(), null,
ResponseCode.SUCCESS, ActionStatus.SUCCESS, ActionType.UPDATE_PARTICIPANT,
ActionStatus.SUCCESS);
return result;
} else {
LOG.info("Database status is not success. Message: {} Status {}", message, status);
LOG.warn("Failed to edit participant data: {}", message);
throw new IllegalArgumentException("Failed to save participant data: " + message);
}
} else {
LOG.warn("Database function returned null. Participant data may not have been saved.");
throw new IllegalArgumentException("Failed to save participant data: Database function returned null.");
}
} catch (Exception e) {
LOG.error("Error while updating participant data for participantId={}: {}", participantId, e.getMessage(),
e);
final var message = "Error while updating participant data for participantId: " + participantId + " . " | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 182 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 180 |
DSL.lower(DSL.field("user_name", String.class)).eq(DSL.value("anonymous")));
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
// var query = udiPrimeDbConfig.dsl()
// .select(allSelectedFields)
// .distinctOn(DSL.field("session_unique_id")) // Use DISTINCT ON for
// session_unique_id
// .from(typableTable.table())
// .where(finalCondition)
// .groupBy(
// Stream.concat(
// selectedColumns.stream().map(typableTable::column), // dynamic fields
// Stream.of(field("user_name")) // static user_name field
// ).toArray(Field[]::new))
// .orderBy(
// DSL.field("session_unique_id").asc(), // required for DISTINCT ON
// DSL.field("min_created_at").desc() // additional sorting
// );
Table<?> innerQuery = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.distinctOn(DSL.field("session_unique_id"))
.from(typableTable.table())
.where(finalCondition)
.groupBy(
Stream.concat(
selectedColumns.stream().map(typableTable::column),
Stream.of(field("user_name"))).toArray(Field[]::new))
.orderBy(
DSL.field("session_unique_id").asc(),
DSL.field("min_created_at").desc())
.asTable("distinct_session_rows");
// 2. Outer query: apply final ordering
var query = udiPrimeDbConfig.dsl()
.selectFrom(innerQuery)
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL Columns from a master table or view for a specific column value")
@GetMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 801 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 767 |
"/api/ux/tabular/jooq/research-study/dashboard/custom_dashboard_all_research_study_view.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@Hidden
public TabularRowsResponse<?> customAllStudyDashboardTabularRows(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
final var userId = userNameService.getUserId();
final var userPartyId = partyService.getPartyIdByUserId(userId);
final List<Map<String, Object>> result = new ArrayList<>();
// Correct way to call a table-valued function in PostgreSQL via jOOQ
udiPrimeDbConfig.dsl().transaction(configuration -> {
DSLContext ctx = DSL.using(configuration);
result.addAll(ctx
.select()
.from(DSL.table("drh_stateless_research_study.get_all_studies_test({0})", DSL.val(userPartyId)))
.fetchMaps());
});
// Log query execution (if required)
if (includeGeneratedSqlInResp) {
LOG.info("Executed query: SELECT * FROM drh_stateless_research_study.get_all_studies_test(?)");
LOG.info("Query parameters: {}", userPartyId);
}
// Construct and return response
return new TabularRowsResponse<>(
includeGeneratedSqlInResp ? "SELECT * FROM drh_stateless_research_study.get_all_studies_test(?)"
: null,
result,
result.size(),
null);
} catch (DataAccessException e) {
LOG.error("Error executing SQL function: {}", e.getMessage(), e);
return new TabularRowsResponse<>(
includeGeneratedSqlInErrorResp
? "SELECT * FROM drh_stateless_research_study.get_all_studies_test(?)"
: null,
List.of(),
0,
"Error fetching data from database");
}
}
@Operation(summary = "SQL distinct file interaction rows from file_interaction_view")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1108 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1198 |
Table<?> baseQuery = DSL
.select(allSelectedFields)
.distinctOn(DSL.field("session_unique_id")) // Pick one row per session
.from(typableTable.table())
.where(finalCondition)
.groupBy(
Stream.concat(
selectedColumns.stream().map(typableTable::column),
Stream.of(field("user_name"))).toArray(Field[]::new))
.orderBy(
DSL.field("session_unique_id").asc(),
DSL.field("min_created_at").desc())
.asTable("base_result");
var query = udiPrimeDbConfig.dsl()
.selectFrom(baseQuery)
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 258 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 246 |
public Object parentFailedParticipantFileInteraction(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
final @PathVariable String masterTableNameOrViewName,
@RequestParam(required = false, defaultValue = "*") String columns,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
TypableTable typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
Condition finalCondition = payload.filterModel() != null
? customTabularFilter.createCondition(payload.filterModel())
: null;
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"),
DSL.field("study_display_id"),
DSL.field("study_title"),
DSL.field("file_category"),
DSL.field("organization_name"),
DSL.field(
"organization_party_id")) // Selecting the specified fields
.from(typableTable.table())
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and((DSL.field("study_id").isNotNull())) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 125 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 126 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 167 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 345 |
bindValues.add(FileType.DATABASE);
if (!userNameService.isAdmin()) {
final var currentUserId = userNameService.getCurrentUserPartyId();
query = query.and(DSL.field("created_by").eq(DSL.value(currentUserId)));
bindValues.add(currentUserId);
}
if (payload.sortModel() != null && !payload.sortModel().isEmpty()) {
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "List of Database file uploaded against a study") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 266 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 311 |
try {
TypableTable typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
Condition finalCondition = payload.filterModel() != null
? customTabularFilter.createCondition(payload.filterModel())
: null;
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"),
DSL.field("study_display_id"),
DSL.field("study_title"),
DSL.field("file_category"),
DSL.field("organization_name"),
DSL.field(
"organization_party_id")) // Selecting the specified fields
.from(typableTable.table())
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and((DSL.field("study_id").isNotNull()))
.and(DSL.field("study_display_id").isNotNull())
.and(DSL.field("interaction_status").eq(ActionStatus.FAILED))
.and(DSL.field("organization_party_id").eq(DSL.value(organizationId)))
.and(DSL.field("file_category").eq(DSL.value(FileType.PARTICIPANT))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ChunkDatabaseMigrationService.java | 821 |
| org/diabetestechnology/drh/service/http/pg/service/DatabaseMigrationService.java | 362 |
"investigators", "publications", "authors", "institutions", "labs", "sites", "elaboration"));
// Validate each table
for (Map.Entry<String, Set<String>> entry : tableColumnsMap.entrySet()) {
String tableName = entry.getKey();
Set<String> requiredColumns = entry.getValue();
String query = "PRAGMA table_info(" + tableName + ")";
Result<Record> result = sqliteDsl.fetch(query);
LOG.info("Record of Table : {} {}", tableName, result);
// Extract column names
Set<String> existingColumns = new HashSet<>();
LOG.info("Reading existing columns of table {}", tableName);
for (Record record : result) {
LOG.info("Column : {}.{}", tableName, record.get("name", String.class));
existingColumns.add(record.get("name", String.class));
}
// If any table is missing required columns, return false
if (!existingColumns.containsAll(requiredColumns)) {
Set<String> missingColumns = new HashSet<>(requiredColumns);
missingColumns.removeAll(existingColumns); // Get missing columns
LOG.warn("Missing required columns: {} of Table: {}", missingColumns, tableName);
LOG.debug("Table: {}, Existing columns: {}", tableName, existingColumns);
LOG.debug("Table: {},Required columns: {}", tableName, requiredColumns);
LOG.debug("Table: {},Missing columns: {}", tableName, missingColumns);
return false;
}
}
return true; // Both tables have all required columns
}
public boolean validateParticipantData(String filePath, DSLContext sqliteDsl) throws Exception { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 147 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1036 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1159 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 142 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1121 |
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName.toLowerCase(),
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
Field<String> userNameField = DSL
.selectDistinct(DSL.field("name", String.class))
.from("drh_stateless_authentication.profile_details_view")
.where(DSL.field("party_id").eq(DSL.field("created_by")))
.asField("user_name");
// Parse desired columns if provided (comma-separated)
List<String> selectedColumns = Arrays.asList(columns.split(","));
// Prepare the array of selected columns
var selectedFields = selectedColumns.stream()
.map(DSL::field) // Map each column name to field()
.toArray(org.jooq.Field[]::new);
// Create a new array to hold all fields including min created_at
var allSelectedFields = Arrays.copyOf(selectedFields, selectedFields.length + 2);
allSelectedFields[selectedFields.length] = userNameField;
LOG.info("Selected columns: {}", selectedColumns);
allSelectedFields[selectedFields.length + 1] = min(field("created_at")).as("min_created_at"); // Add
// minimum
LOG.info("All selected fields: {}", Arrays.toString(allSelectedFields));
Condition finalCondition = createCondition(payload.filterModel()); // created_at | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/constant/LogName.java | 3 |
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/constant/LogType.java | 3 |
public class LogName {
// LEVEL 0
public static final String ERROR = "Error";
// LEVEL 1
public static final String SKIP_LOGIN = "Skip Login";
public static final String ORCID_LOGIN = "Orcid Login";
public static final String GIT_LOGIN = "GitHub Login";
public static final String HOME = "Home";
public static final String STUDIES = "Studies";
public static final String COHORT = "Cohort";
public static final String ASK_DRH = "Ask DRH";
// public static final String ACTIVITY_LOG = "Activity Log";
public static final String CONSOLE = "Console";
public static final String DOCUMENTATION = "Documentation";
public static final String PROFILE = "Profile";
public static final String PROFILE_EMAIL = "Profile Email";
public static final String VERIFY_OTP = "Verify OTP";
public static final String CREATE_USER_PROFILE = "Create User Profile";
public static final String LOGOUT = "Logout";
// LEVEL 2
// STUDIES
public static final String DASHBOARD = "Dashboard";
public static final String ALL_STUDIES = "All Studies";
public static final String POPULATION_PERCENTAGE = "Population Percentage";
public static final String MY_STUDIES = "My Studies";
// ADK_DRH
public static final String ASK_DRH_DATA = "Ask DRH Data";
public static final String ASK_DRH_RESEARCH_JOURNAL = "Ask DRH Research Journal";
public static final String ASK_DRH_ICODE = "Ask DRH iCODE";
// CONSOLE
public static final String CONSOLE_PROJECT = "Project";
public static final String CONSOLE_HEALTH_INFORMATION = "Health Information";
public static final String CONSOLE_SCHEMA = "Schema";
// DOCUMENTATION
public static final String DOCUMENTATION_OPEN_API = "DRH Open API UI";
public static final String DOCUMENTATION_ANNOUNCEMENTS = "Announcements";
// LEVEL 3
public static final String STUDIES_INDIVIDUAL = "Study Details";
public static final String STUDIES_PARTICIPANT = "Participant Detils"; | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1073 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1160 |
var query = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.distinctOn(DSL.field("session_unique_id")) // Use DISTINCT ON for session_unique_id
.from(typableTable.table())
.where(finalCondition)
.groupBy(
Stream.concat(
selectedColumns.stream().map(typableTable::column), // dynamic fields
Stream.of(field("user_name")) // static user_name field
).toArray(Field[]::new))
.orderBy(
DSL.field("session_unique_id").asc(), // required for DISTINCT ON
DSL.field("min_created_at").desc() // additional sorting
);
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 127 |
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 332 |
HttpServletResponse response = getCurrentResponse();
// final var requestUrl = request.getRequestURI();
final var statusCode = response.getStatus();
final var httpMethod = request.getMethod();
final var userAgent = request.getHeader("User-Agent");
final var localHost = InetAddress.getLocalHost();
final var ipAddress = localHost.getHostAddress();
final var provenance = "%s.doFilterInternal".formatted(ActivityLogService.class.getName());
final var initiator = request.getRemoteUser();
final var initiatorHost = request.getRemoteHost();
final var sessionId = request.getSession().getId();
// extractSessionContent(request);
final var userId = userNameService.getUserId();
String userName = userNameService.getUserName();
final var appVersion = presentation.getVersion().toString();
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("httpMethod", httpMethod);
dataMap.put("userAgent", userAgent);
dataMap.put("ipAddress", ipAddress);
dataMap.put("provenance", provenance);
dataMap.put("statusCode", statusCode);
dataMap.put("initiator", initiator);
dataMap.put("initiatorHost", initiatorHost); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 125 |
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 205 |
.from("drh_stateless_authentication.user_list_view");
if (!presentation.isSuperAdmin()) {
final var organizationPartyId = userNameService.getCurrentUserOrganizationPartyId();
SelectConditionStep<Record1<JSONB>> sqlQuery = query
.where(DSL.field("organization_party_id").eq(DSL.val(organizationPartyId)));
LOG.info("Query for fetching user list: {}", sqlQuery);
JSONB jsonbResult = sqlQuery.fetchOneInto(JSONB.class);
if (jsonbResult == null) {
LOG.warn("No users found.");
return JSONB.jsonb("{}");
}
return jsonbResult;
} else {
LOG.info("Query for fetching user list: {}", query);
JSONB jsonbResult = query.fetchOneInto(JSONB.class);
if (jsonbResult == null) {
LOG.warn("No users found.");
return JSONB.jsonb("{}");
}
return jsonbResult;
}
} catch (DataAccessException e) {
LOG.error("Database error while fetching user list: {}", e.getMessage());
throw new RuntimeException("Database error occurred. Please try again later.");
} catch (Exception e) {
LOG.error("Unexpected error while fetching user list: {}", e.getMessage());
throw new RuntimeException("An unexpected error occurred.");
}
}
public JSONB getDistinctUserList() { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/SessionReportController.java | 105 |
| org/diabetestechnology/drh/service/http/pg/ux/SessionReportController.java | 156 |
Map<String, Object> responseMap = Map.of();
if (response != null) {
try {
responseMap = objectMapper.readValue(response.data(), new TypeReference<Map<String, Object>>() {
});
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
LOG.error("Failed to parse JSON response: {}", response.data(), e);
} catch (IOException e) {
LOG.error("IO error while parsing JSON response: {}", response.data(), e);
}
}
if ("Success".equalsIgnoreCase((String) responseMap.get("status"))) {
return Response.builder()
.data(responseMap)
.status("success")
.message("Session report retrieved successfully.")
.errors(null)
.build();
} else {
return Response.builder()
.data(Map.of())
.status("error")
.message("Failed to fetch session report.")
.errors(null)
.build();
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 105 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 126 |
Field<String> parentFileInteractionId = DSL.field("p.file_interaction_id", String.class);
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("p.study_id"),
DSL.field("p.study_display_id"),
DSL.field("p.study_title"),
DSL.field("p.file_category"),
DSL.field("p.organization_name"),
DSL.field(
"p.organization_party_id")) // Selecting the specified fields
.from(p)
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and((DSL.field("p.interaction_hierarchy")
.eq(DSL.value("null")))
.or(DSL.field("p.interaction_hierarchy").isNull()))
.and(DSL.field("p.study_id").isNotNull())
.and(DSL.field("p.study_display_id").isNotNull())
.and(DSL.field("p.interaction_status").notEqual(ActionStatus.FAILED))
.and(DSL.field("p.organization_party_id").eq(DSL.value(organizationId)))
.and(DSL.field("p.file_category").eq(DSL.value(FileType.PARTICIPANT))) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 995 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 961 |
@GetMapping(value = "/api/ux/tabular/jooq/{schemaName}/{viewName}/{file_category}/{fileCategory}/study_id/{studyId}.json")
@ResponseBody
@Hidden
public Object getSubFileGridData(
final @PathVariable String schemaName,
final @PathVariable String viewName,
final @PathVariable String fileCategory,
final @PathVariable String studyId) {
// Fetch the result using the dynamically determined table and column
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName, viewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where(typableTable.column(
"file_category").eq(fileCategory))
.and(typableTable.column("study_id").eq(studyId))
.orderBy(typableTable.column("created_at").desc());
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
LOG.info("Get Study Details Corresponds to the view {}:", viewName);
LOG.info("Get Study Details Corresponds to the fileCategory {}:", fileCategory);
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return query.fetch().intoMaps();
}
@Operation(summary = "User specific distinct activity rows from activity table ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 259 |
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 410 |
LOG.error("failed to set activity log data: {}", e.getMessage(), e);
}
Map<String, Object> heirarchy = results.isEmpty() ? null : results.get(0);
if (heirarchy != null) {
if (heirarchy.get("hierarchy_path") != null)
activityLog.setHierarchyPath((heirarchy.get("hierarchy_path").toString()) + ", "
+ requestUrl);
else
activityLog.setHierarchyPath(requestUrl);
if (logDetails != null) {
if (heirarchy.get("activity_hierarchy") != null) {
activityLog.setActivityHierarchy(
(heirarchy.get("activity_hierarchy").toString()) + ", " +
activityLog.getActivityType());
} else {
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
}
} else {
if (logDetails != null) {
activityLog.setHierarchyPath(requestUrl);
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
}
activityLog.setSessionUniqueId(uniqueSessionId);
return activityLog;
}
private void setActivityDataFromLogDetails(LogDetails logDetails, ActivityLog activityLog) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/OrcidUserController.java | 72 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/OrcidUserController.java | 312 |
ResponseEntity<String> response = orcidUserDetailService.getOrcidUserInfo(orcidId);
String name = orcidUserDetailService.extractFullName(response.getBody().toString());
String email = orcidUserDetailService.extractEmail(response.getBody().toString());
String institution = orcidUserDetailService.extractInstitution(response.getBody().toString());
Map<String, Object> userDetails = new HashMap<>(Map.of("orcidId", orcidId));
userDetails.put("userName", name);
userDetails.put("userEmail", email);
userDetails.put("userInstitution", institution);
// Return the response
return Response.builder()
.data(userDetails)
.status("success")
.message("Successfully read ORCID details")
.errors(null)
.build();
} catch (Exception e) {
return Response.builder()
.data(new HashMap<>())
.status("error")
.message("Error fetching ORCID details") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 90 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 255 |
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
Condition finalCondition = payload.filterModel() != null
? customTabularFilter.createCondition(payload.filterModel())
: null;
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"),
DSL.field("study_display_id"),
DSL.field("study_title"),
DSL.field("file_category"),
DSL.field("organization_name"),
DSL.field(
"organization_party_id")) // Selecting the specified fields
.from(typableTable.table())
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and(((DSL.field("interaction_hierarchy") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 254 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 311 |
try {
TypableTable typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
Condition finalCondition = payload.filterModel() != null
? customTabularFilter.createCondition(payload.filterModel())
: null;
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"),
DSL.field("study_display_id"),
DSL.field("study_title"),
DSL.field("file_category"),
DSL.field("organization_name"),
DSL.field(
"organization_party_id")) // Selecting the specified fields
.from(typableTable.table()).where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and(((DSL.field("study_id").isNotNull()))) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 133 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 268 |
}
if (payload.sortModel() != null && !payload.sortModel().isEmpty()) {
query = (@NotNull SelectConditionStep<Record>) query.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Interaction details of a successful study_interaction_id value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ChunkDatabaseMigrationService.java | 553 |
| org/diabetestechnology/drh/service/http/pg/service/DatabaseMigrationService.java | 210 |
JSONB dbData, DSLContext sqliteDsl, String sqliteDbName) {
LOG.info("Copying tables from SQLite to Postgres");
try {
LOG.info("Distinct db_file_ids from SQLITE: {}", distinctDbFileIds);
final var sqStudyDisplayId = duckDsl.fetchOne(
"SELECT DISTINCT study_display_id FROM " + sqliteDbName + ".participant")
.get("study_display_id", String.class);
LOG.info("Study Display Id from SQLITE: {}", sqStudyDisplayId);
final var pgStudyDisplayId = dsl
.selectDistinct(DSL.field("study_display_id", String.class))
.from("drh_stateless_research_study.research_study_view")
.where(DSL.field("study_id").eq(DSL.value(
studyId)))
.fetchOneInto(String.class);
LOG.info("Study Display Id from POSTGRES: {}", pgStudyDisplayId);
LOG.debug("dbFileId: {}", distinctDbFileIds);
if (!(sqStudyDisplayId.toString()).equals(pgStudyDisplayId.toString())) {
LOG.debug("Study display id mismatch between SQLite and Postgres, SQLite: {}, Postgres: {}",
sqStudyDisplayId, pgStudyDisplayId);
return "Study display id mismatch between SQLite and Postgres";
} else {
if (!validateRequiredColumns(filePath, sqliteDsl)) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 90 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 267 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 312 |
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
Condition finalCondition = payload.filterModel() != null
? customTabularFilter.createCondition(payload.filterModel())
: null;
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"),
DSL.field("study_display_id"),
DSL.field("study_title"),
DSL.field("file_category"),
DSL.field("organization_name"),
DSL.field(
"organization_party_id")) // Selecting the specified fields
.from(typableTable.table())
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and(((DSL.field("interaction_hierarchy") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ChunkDatabaseMigrationService.java | 775 |
| org/diabetestechnology/drh/service/http/pg/service/DatabaseMigrationService.java | 324 |
}
private String prepareJson(String fileId, String fileName, String fileURL, String uploadTimestamp, long fileSize,
String studyId, String userPartyId, String organizationPartyId) {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode jsonObject = objectMapper.createObjectNode();
jsonObject.put("db_file_id", fileId);
jsonObject.put("file_name", fileName);
jsonObject.put("file_url", fileURL);
jsonObject.put("upload_timestamp", uploadTimestamp);
jsonObject.put("uploaded_by", userPartyId);
jsonObject.put("file_size", fileSize);
jsonObject.put("study_id", studyId);
jsonObject.put("org_party_id", organizationPartyId);
jsonObject.put("current_user_id", userPartyId);
return jsonObject.toString();
}
private boolean exists(String studyd) {
return dsl.fetchExists(
dsl.selectOne().from("drh_stateless_raw_data.cgm_raw_db_view").where("study_id = ?", studyd));
}
public Pair<DSLContext, Connection> createSQLiteDSL(String sqliteFilePath) throws Exception { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ChunkDatabaseMigrationService.java | 486 |
| org/diabetestechnology/drh/service/http/pg/service/DatabaseMigrationService.java | 143 |
private void detachSqliteDatabase(String sqliteDbName) {
if (isDatabaseAttached(sqliteDbName)) {
LOG.info("Detaching SQLite database");
duckDsl.execute("DETACH " + sqliteDbName + ";");
LOG.info("SQLite database detached");
} else {
LOG.info("SQLite database " + sqliteDbName + " is not attached. Skipping detachment.");
}
}
private void detachPostgresDatabase() {
try {
LOG.info("Checking if Postgres database '{}' is attached", postgresDbName);
// Check if the database is attached
String query = "SHOW DATABASES;";
List<String> attachedDatabases = duckDsl.fetch(query)
.getValues(0, String.class);
if (attachedDatabases.contains(postgresDbName)) {
LOG.info("Detaching Postgres database '{}'", postgresDbName);
duckDsl.execute("DETACH DATABASE " + postgresDbName + ";");
} else {
LOG.info("Postgres database '{}' is not attached, skipping detach", postgresDbName);
}
} catch (Exception e) {
LOG.error("Error while detaching Postgres database: {}", e.getMessage(), e);
}
}
private boolean isDatabaseAttached(String sqliteDbName) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 201 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 250 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
final var response = query.fetch().intoMaps();
return Map.of("rows", response);
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 323 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 384 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.FAILED)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
final var response = query.fetch().intoMaps();
return Map.of("rows", response);
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 133 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 292 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 175 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 353 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "List of Database file uploaded against a study") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 135 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 292 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Successful CGM File Interaction against a specific participant") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 414 |
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 646 |
LOG.info("Super Admin access detected. Fetching permissions for 'Super Admin'");
final var query = dsl.select(DSL.field("role_name"))
.from(DSL.table("drh_stateless_authentication.super_admin_view"))
.where(DSL.field("party_id").eq(userPartyId));
roleNames = query.fetch(DSL.field("role_name"), String.class);
} else {
final var query = dsl
.select(DSL.field("jsonb_agg(DISTINCT user_roles)", JSONB.class))
.from("drh_stateless_authentication.user_list_view")
.where(DSL.field("party_id").eq(userPartyId));
LOG.info("Query for fetching user roles: {}", query);
JSONB roleJson = query.fetchOneInto(JSONB.class);
if (roleJson == null || roleJson.data() == null) {
LOG.warn("No roles found for userPartyId: {}", userPartyId);
return (Map.of("status", "error", "message", "User roles not found")).toString(); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 917 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 990 |
if (citationRecordId == null) {
throw new IllegalStateException("Citation ID not returned from saveStudyCitation");
}
LOG.info("Saving authors for studyId: {}, citationId: {}", studyId, citationId);
Object authorResponse = researchStudyService.saveAuthors(
studyId,
request.collaboration_team().coAuthorsName(),
citationId);
responseMap.put("authorResponse", authorResponse.toString());
return Response.builder()
.status("success")
.message("Citations and authors saved successfully")
.data(responseMap)
.errors(null)
.build();
} catch (Exception e) {
LOG.error("Failed to save citations", e);
return Response.builder()
.status("error")
.message("Failed to save citations")
.data(Collections.emptyMap())
.errors(e.getMessage())
.build();
}
}
@PostMapping("/research-study/citations") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/jdbc/JdbcResponse.java | 14 |
| org/diabetestechnology/drh/service/http/pg/Response.java | 14 |
public JdbcResponse(Builder builder) {
this.data = builder.data;
this.status = builder.status;
this.message = builder.message;
this.errors = builder.errors;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private Map<String, Object> data;
private String status;
private String message;
private Object errors;
public Builder data(Map<String, Object> data) {
this.data = data;
return this;
}
public Builder status(String status) {
this.status = status;
return this;
}
public Builder message(String message) {
this.message = message;
return this;
}
public Builder errors(Object errors) {
this.errors = errors;
return this;
}
public JdbcResponse build() { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/AIConversationController.java | 54 |
| org/diabetestechnology/drh/service/http/pg/ux/SessionReportController.java | 104 |
JSONB response = aiConversationService.saveAIConversation(aiConversationRequest);
Map<String, Object> responseMap = Map.of();
if (response != null) {
try {
responseMap = objectMapper.readValue(response.data(), new TypeReference<Map<String, Object>>() {
});
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
LOG.error("Failed to parse JSON response: {}", response.data(), e);
} catch (IOException e) {
LOG.error("IO error while parsing JSON response: {}", response.data(), e);
}
}
if ("Success".equalsIgnoreCase((String) responseMap.get("status"))) {
return Response.builder()
.data(responseMap)
.status("success")
.message("AI conversation saved successfully.") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 263 |
| org/diabetestechnology/drh/service/http/pg/service/DbActivityService.java | 72 |
Map<String, Object> heirarchy = results.isEmpty() ? null : results.get(0);
if (heirarchy != null) {
if (heirarchy.get("hierarchy_path") != null)
activityLog.setHierarchyPath((heirarchy.get("hierarchy_path").toString()) + ", "
+ requestUrl);
else
activityLog.setHierarchyPath(requestUrl);
if (logDetails != null) {
if (heirarchy.get("activity_hierarchy") != null) {
activityLog.setActivityHierarchy(
(heirarchy.get("activity_hierarchy").toString()) + ", " +
activityLog.getActivityType());
} else {
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
}
} else {
if (logDetails != null) {
activityLog.setHierarchyPath(requestUrl);
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/service/interaction/ActivityLogService.java | 413 |
| org/diabetestechnology/drh/service/http/pg/service/DbActivityService.java | 72 |
Map<String, Object> heirarchy = results.isEmpty() ? null : results.get(0);
if (heirarchy != null) {
if (heirarchy.get("hierarchy_path") != null)
activityLog.setHierarchyPath((heirarchy.get("hierarchy_path").toString()) + ", "
+ requestUrl);
else
activityLog.setHierarchyPath(requestUrl);
if (logDetails != null) {
if (heirarchy.get("activity_hierarchy") != null) {
activityLog.setActivityHierarchy(
(heirarchy.get("activity_hierarchy").toString()) + ", " +
activityLog.getActivityType());
} else {
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
}
} else {
if (logDetails != null) {
activityLog.setHierarchyPath(requestUrl);
activityLog.setActivityHierarchy(activityLog.getActivityType());
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/AIConversationController.java | 55 |
| org/diabetestechnology/drh/service/http/pg/ux/SessionReportController.java | 156 |
Map<String, Object> responseMap = Map.of();
if (response != null) {
try {
responseMap = objectMapper.readValue(response.data(), new TypeReference<Map<String, Object>>() {
});
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
LOG.error("Failed to parse JSON response: {}", response.data(), e);
} catch (IOException e) {
LOG.error("IO error while parsing JSON response: {}", response.data(), e);
}
}
if ("Success".equalsIgnoreCase((String) responseMap.get("status"))) {
return Response.builder()
.data(responseMap)
.status("success")
.message("AI conversation saved successfully.") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 177 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 52 |
public Response saveResearchStudySettings(@RequestBody ResearchStudySettingsRequest request) {
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("save research study settings: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 204 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 86 |
String responseString = studyResponse.toString();
JsonNode responseJson = OBJECT_MAPPER.readTree(responseString);
if (responseJson.has("status") && "failure".equals(responseJson.get("status").asText())) {
String errorMessage = responseJson.has("message") ? responseJson.get("message").asText()
: "Unknown error occurred.";
JsonNode errorDetails = responseJson.has("error_details") ? responseJson.get("error_details") : null;
return Response.builder()
.data(Map.of())
.status("error")
.message(errorMessage)
.errors(errorDetails != null ? errorDetails.toString() : null)
.build();
}
return Response.builder()
.data(Map.of("studyId", | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/PartyService.java | 180 |
| org/diabetestechnology/drh/service/http/pg/service/PractitionerService.java | 208 |
Object principal = authentication.getPrincipal();
String organizationPartyId = "";
if (principal instanceof UserDetails) {
organizationPartyId = dsl
.select(DSL.field("organization_party_id"))
.from("drh_stateless_authentication.super_admin_view")
.where(DSL.field("email").eq(DSL.val(userId)))
.limit(1) // To ensure we only check if at least one row exists
.fetchOneInto(String.class);
} else {
LOG.info("Fetching user details for user ID: {}", userId);
organizationPartyId = dsl
.select(DSL.field("organization_party_id"))
.from("drh_stateless_authentication.user_profile_view")
.where(DSL.field("provider_user_id").eq(DSL.val(userId)))
.limit(1) // To ensure we only check if at least one row exists
.fetchOneInto(String.class);
}
LOG.debug("Fetched organizationPartyId for user {}: {}", userId, organizationPartyId); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 177 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 184 |
public Response saveResearchStudySettings(@RequestBody ResearchStudySettingsRequest request) {
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("save research study settings: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 52 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 184 |
@Valid @RequestBody ParticipantDataRequest request) {
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("Saving participant data: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/PubMedController.java | 65 |
| org/diabetestechnology/drh/service/http/pg/ux/PubMedController.java | 97 |
final var metadata = pubMedService.getMetadata(pubmedId);
try {
LOG.info("Metadata corresponds to the given is PUBMED ID: {}", metadata);
if (metadata != null) {
return Response.builder()
.data(new HashMap<>(Map.of("metadata",
metadata)))
.status("success")
.message("Metadata found")
.build();
}
return Response.builder()
.data(new HashMap<>())
.status("failed")
.message("Details not found")
.build();
} catch (Exception e) {
return Response.builder()
.data(new HashMap<>())
.status("error")
.message("Failed to read Metadata")
.errors("Error in reading Metadata: ")
.build();
}
}
@GetMapping("/crossref/metadata") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 165 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 208 |
final @PathVariable String participantId) {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
var p = typableTable.table().as("p");
var c = typableTable.table().as("c"); // For child interactions
Field<String> parentFileInteractionId = DSL.field("p.file_interaction_id", String.class);
final var query = udiPrimeDbConfig.dsl().selectFrom(p)
.where((DSL.field("p.participant_id").eq(DSL.value(
participantId)))
.and((DSL.field("p.interaction_hierarchy")
.eq(DSL.val("null"))))
.and(DSL.field("p.file_category").eq(DSL.value(FileType.CGM))) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 179 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 59 |
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("save research study settings: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 53 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 59 |
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("Saving participant data: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 185 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 59 |
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
}
LOG.info("Updating participant data: {}", request); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/UserRoleController.java | 172 |
| org/diabetestechnology/drh/service/http/pg/ux/UserRoleController.java | 212 |
JsonNode responseJson = OBJECT_MAPPER.readTree(response.toString());
if (responseJson.has("status") && "failure".equals(responseJson.get("status").asText())) {
String errorMessage = responseJson.has("message") ? responseJson.get("message").asText()
: "Unknown error occurred.";
JsonNode errorDetails = responseJson.has("error_details") ? responseJson.get("error_details") : null;
LOG.error("Error fetching roles and permissions: " + errorMessage);
return Response.builder()
.data(Map.of())
.status("error")
.message(errorMessage)
.errors(errorDetails != null ? errorDetails.toString() : null)
.build();
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/OrcidUserController.java | 104 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/OrcidUserController.java | 152 |
public ResponseEntity<Object> getDiscoFeed() {
String url = "https://orcid.org/Shibboleth.sso/DiscoFeed";
try {
// Set up headers with the cookie
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.COOKIE, "geolocation=US");
// Create the HTTP entity with headers
HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
// Make the API call with the custom headers
ResponseEntity<String> response = restTemplate.exchange(
url,
HttpMethod.GET,
requestEntity,
String.class);
if (response.getStatusCode().is2xxSuccessful() && response.getBody() != null) {
// Parse the JSON response
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, Object>> jsonResponse = objectMapper.readValue(
response.getBody(),
new TypeReference<List<Map<String, Object>>>() {
});
// Extract 'value' from 'DisplayNames'
List<String> displayNames = jsonResponse.stream() | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 179 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyInvestigatorController.java | 113 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 53 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantController.java | 185 |
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 146 |
query = (@NotNull SelectConditionStep<Record>) query.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Interaction details of a successful study_interaction_id value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 270 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 146 |
query = (@NotNull SelectConditionStep<Record>) query.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Details of a failed study_interaction_id value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyInvestigatorController.java | 113 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 59 |
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(request.studyId()))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
request.studyId());
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(request.studyId())) {
LOG.warn("Access denied: Study {} is archived.", request.studyId());
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 133 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "List of Database file uploaded against a study") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 135 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Successful CGM File Interaction against a specific participant") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 292 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Failed CGM File Interaction against a specific CGM file") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 175 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Successful Meals Or Fitness File Interaction against a specific participant") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 353 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Failed Meals Or Fitness File Interaction against a specific Meals Or Fitness file") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 133 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 270 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 175 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 353 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 146 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 331 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "List of Database file uploaded against a study") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 135 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 270 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 146 |
query = (@org.jetbrains.annotations.NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Successful CGM File Interaction against a specific participant") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 292 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 270 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 146 |
query = (SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) query
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "Failed CGM File Interaction against a specific CGM file") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsController.java | 177 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 80 |
}
private @NotNull SortField<Object> createSortCondition(
List<lib.aide.tabular.TabularRowsRequest.SortModel> sortModel,
TypableTable participantDashboardTable) {
for (final var sort : sortModel) {
final var sortField = participantDashboardTable.column(sort.colId());
if ((sort.sort()).equals("asc")) {
return field(sortField).asc();
} else if ((sort.sort()).equals("desc")) {
return field(sortField).desc();
} else {
LOG.info("Not a Valid Sort Field");
}
}
return null;
}
@SuppressWarnings("unchecked")
@Operation(summary = "SQL Custom Dashboard Summary ") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ChunkDatabaseMigrationService.java | 516 |
| org/diabetestechnology/drh/service/http/pg/service/DatabaseMigrationService.java | 173 |
private boolean isDatabaseAttached(String sqliteDbName) {
String checkQuery = "PRAGMA database_list;";
List<Record> attachedDatabases = duckDsl.fetch(checkQuery);
boolean isDatabaseAttached = false;
// Check if the database is attached
for (Record db : attachedDatabases) {
if (db.get("name").equals(sqliteDbName)) {
isDatabaseAttached = true;
break;
}
}
return isDatabaseAttached;
}
private void attachPostgresDatabase() {
try {
LOG.info("Attaching Postgres database as {}", postgresDbName);
duckDsl.execute("DROP SCHEMA IF EXISTS " + postgresDbName + " CASCADE;");
duckDsl.execute(
"ATTACH '' AS " + postgresDbName + " (TYPE POSTGRES);");
LOG.info("PostgreSQL database attached as: {}", postgresDbName);
} catch (Exception e) {
LOG.error("Error while attaching Postgres database: {}", e.getMessage(), e);
}
}
private void attachSqliteDatabase(String tempFilePath, String sqliteDbName) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 63 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 205 |
JsonNode responseJson = OBJECT_MAPPER.readTree(studyResponse);
if (responseJson.has("status") && "failure".equals(responseJson.get("status").asText())) {
String errorMessage = responseJson.has("message") ? responseJson.get("message").asText()
: "Unknown error occurred.";
JsonNode errorDetails = responseJson.has("error_details") ? responseJson.get("error_details") : null;
return Response.builder()
.data(Map.of())
.status("error")
.message(errorMessage)
.errors(errorDetails != null ? errorDetails.toString() : null)
.build();
}
return Response.builder()
.data(Map.of("studyId", | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 216 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 250 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL()); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 337 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 384 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.FAILED)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL()); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 49 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 51 |
public class TabularRowsStudyCGMInteractionControllerCustom {
static private final Logger LOG = LoggerFactory.getLogger(
TabularRowsStudyCGMInteractionControllerCustom.class);
private final UdiSecondaryDbConfig udiPrimeDbConfig;
private final UserNameService userNameService;
private final PartyService partyService;
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsStudyCGMInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 164 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 298 |
public Object childSuccessStudyInteraction(final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName, final @PathVariable String studyInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("study_interaction_id").eq(DSL.value(
studyInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + studyInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 203 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 360 |
public Object childSuccessStudyParticipantInteraction(final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable String studyParticipantInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("participant_interaction_id").eq(DSL.value(
studyParticipantInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + studyParticipantInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 63 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 133 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 205 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyParticipantFileController.java | 87 |
JsonNode responseJson = OBJECT_MAPPER.readTree(studyResponse);
if (responseJson.has("status") && "failure".equals(responseJson.get("status").asText())) {
String errorMessage = responseJson.has("message") ? responseJson.get("message").asText()
: "Unknown error occurred.";
JsonNode errorDetails = responseJson.has("error_details") ? responseJson.get("error_details") : null;
return Response.builder()
.data(Map.of())
.status("error")
.message(errorMessage)
.errors(errorDetails != null ? errorDetails.toString() : null)
.build();
}
return Response.builder()
.data(Map.of("studyId", | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 134 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 307 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 293 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 136 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 270 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 176 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 354 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 147 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 332 |
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(),
typableTable));
}
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName, masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "List of Database file uploaded against a study") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 141 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 297 |
bindValues.add(ActionStatus.FAILED);
if (!userNameService.isAdmin()) {
final var currentUserId = userNameService.getCurrentUserPartyId();
query = query.and(DSL.field("created_by").eq(DSL.value(currentUserId)));
bindValues.add(currentUserId);
}
if (payload.sortModel() != null && !payload.sortModel().isEmpty()) {
query = (@NotNull SelectConditionStep<Record6<Object, Object, Object, Object, Object, Object>>) ((SelectConditionStep<?>) query)
.orderBy(
customTabularFilter.createSortCondition(payload.sortModel(), typableTable));
}
LOG.info("Get Participant File Interaction Details Corresponds to the schema {}:", schemaName); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/PractitionerController.java | 172 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 374 |
JsonNode responseJson = OBJECT_MAPPER.readTree(resultObj.toString());
if (responseJson.has("status") && "failure".equals(responseJson.get("status").asText())) {
String errorMessage = responseJson.has("message") ? responseJson.get("message").asText()
: "Unknown error occurred.";
JsonNode errorDetails = responseJson.has("error_details") ? responseJson.get("error_details") : null;
LOG.error("Error updating archive status : " + errorMessage);
return Response.builder()
.data(Map.of())
.status("error")
.message(errorMessage)
.errors(errorDetails != null ? errorDetails.toString() : null)
.build();
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1124 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1085 |
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL distinctOrganization Specific activity rows from activity table ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 246 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 380 |
public Object childSuccessMealsOrFitnessFileInteraction(
final @PathVariable String fileInteractionId) {
final var schemaName = "drh_stateless_activity_audit";
final var masterTableNameOrViewName = "file_interaction_view";
try {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/ResearchStudyService.java | 847 |
| org/diabetestechnology/drh/service/http/pg/service/ResearchStudyService.java | 931 |
DSL.val(request.citation_data_source().name()), DSL.cast(DSL.val(activityData), JSONB.class)));
LOG.info("Executing SQL Query: {}", query);
JSONB result = query.fetchOneInto(JSONB.class);
LOG.info("Study citation saved successfully for studyId: {}", studyId);
if (result != null) {
return new ObjectMapper().readValue(result.data(), new TypeReference<Map<String, Object>>() {
});
} else {
return Map.of("status", "error", "message", "No data returned");
}
} catch (Exception e) {
LOG.error("Error saving study citation: {}", e.getMessage(), e);
return Map.of("status", "error", "message", "Failed to save study citation");
}
}
public Object saveAuthors(String studyId, String[] authorNames, String citationId) { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 218 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1123 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 200 |
.selectFrom(innerQuery)
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL Columns from a master table or view for a specific column value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 80 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 83 |
public Object parentDatabaseFileInteraction(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
final @PathVariable String masterTableNameOrViewName,
@RequestParam(required = false, defaultValue = "*") String columns,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp)
throws SQLException {
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 280 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 304 |
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("study_id"), DSL.field("organization_party_id"), DSL
.field("study_display_id"),
DSL.field(
"study_title"),
DSL.field("organization_name"), DSL.field(
"created_by_name"),
DSL.field(
createdAt))
.from(typableTable
.table().as("spv"))
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and(
studyParticipantInteractionId.in(subquery)
.or(studyId.isNull()))
.and(createdBy.eq(userId)) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsController.java | 177 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 581 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 563 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 80 |
}
private @NotNull SortField<Object> createSortCondition(
List<lib.aide.tabular.TabularRowsRequest.SortModel> sortModel,
TypableTable participantDashboardTable) {
for (final var sort : sortModel) {
final var sortField = participantDashboardTable.column(sort.colId());
if ((sort.sort()).equals("asc")) {
return field(sortField).asc();
} else if ((sort.sort()).equals("desc")) {
return field(sortField).desc();
} else {
LOG.info("Not a Valid Sort Field");
}
}
return null;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 219 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1085 |
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL Columns from a master table or view for a specific column value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 47 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 50 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 51 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 53 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 53 |
TabularRowsDatabaseFileInteractionControllerCustom.class);
private final UdiSecondaryDbConfig udiPrimeDbConfig;
private final UserNameService userNameService;
private final PartyService partyService;
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsDatabaseFileInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 201 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1085 |
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL Columns from a master table or view for a specific column value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 218 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1213 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 200 |
.selectFrom(innerQuery)
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 109 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 567 |
public Response editResearchStudy(@PathVariable String studyId, @RequestBody JsonNode studyData) {
if (!userNameService.getCurrentUserPartyId().equalsIgnoreCase(researchStudyService.getStudyOwner(studyId))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
studyId);
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
}
if (researchStudyService.getResearchStudyArchiveStatus(studyId)) {
LOG.warn("Access denied: Study {} is archived.", studyId);
Response response = Response.builder()
.status("failure")
.message("The study is archived; edits and updates are not allowed.")
.build();
return response;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsController.java | 179 |
| org/diabetestechnology/drh/service/http/pg/filter/CustomTabularFilter.java | 99 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 565 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 82 |
private @NotNull SortField<Object> createSortCondition(
List<lib.aide.tabular.TabularRowsRequest.SortModel> sortModel,
TypableTable participantDashboardTable) {
for (final var sort : sortModel) {
final var sortField = participantDashboardTable.column(sort.colId());
if ((sort.sort()).equals("asc")) {
return field(sortField).asc();
} else if ((sort.sort()).equals("desc")) {
return field(sortField).desc();
} else {
LOG.info("Not a Valid Sort Field");
}
}
return null;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 583 |
| org/diabetestechnology/drh/service/http/pg/filter/CustomTabularFilter.java | 99 |
private @NotNull SortField<Object> createSortCondition(
List<lib.aide.tabular.TabularRowsRequest.SortModel> sortModel,
TypableTable participantDashboardTable) {
for (final var sort : sortModel) {
final var sortField = participantDashboardTable.column(sort.colId());
if ((sort.sort()).equals("asc")) {
return field(sortField).asc();
} else if ((sort.sort()).equals("desc")) {
return field(sortField).desc();
} else {
LOG.info("Not a Valid Sort Field");
}
}
return null;
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1023 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 989 |
"/api/ux/tabular/jooq/user/distinct/audit/drh_stateless_activity_audit/vw_activity_log.json" }, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TabularRowsResponse<?> distinctTabularAuditRowsOfUser(
final @RequestBody @Nonnull TabularRowsRequest payload,
@RequestParam(required = false, defaultValue = "*") String columns,
final @PathVariable(required = false) String notEqColumnName,
final @PathVariable(required = false) String notEqColumnValue,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
final var schemaName = "drh_stateless_activity_audit";
final var masterTableNameOrViewName = "vw_activity_log";
try { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/InteractionService.java | 275 |
| org/diabetestechnology/drh/service/http/pg/service/InteractionService.java | 292 |
final var query = DSL.selectOne()
.from("drh_stateless_activity_audit.file_interaction_view")
.where(DSL.field("study_id").eq(DSL.val(studyId)))
.and(DSL.field("file_category").eq(DSL.value(FileType.DATABASE)))
.and(DSL.field("interaction_action_type_id")
.eq(DSL.val(masterService.getActiontype(ActionType.SAVE_DB_CONTENT))))
.and(DSL.field("interaction_status_id")
.eq(DSL.val(masterService.getInteractionStatus(FileProcessingStatus.SUCCESS))));
LOG.info("Check entry for Study Database File . Query: {}", query);
final var exists = dsl.fetchExists(query); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 205 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 237 |
public Object childDatabaseFileInteractionModal(final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where(typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL());
// Execute the query and return the result
return query.fetch().intoMaps();
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1214 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1172 |
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 886 |
| org/diabetestechnology/drh/service/http/pg/ux/ResearchStudyController.java | 949 |
@RequestBody PublicationUpdateRequest request) {
String studyId = request.collaboration_team().studyId();
Map<String, Object> responseMap = new HashMap<>();
LOG.info("Saving citations for studyId: {}", studyId);
try {
if (!userNameService.getCurrentUserPartyId()
.equalsIgnoreCase(researchStudyService.getStudyOwner(studyId))) {
LOG.warn("Access denied: User {} is not the owner of study {}", userNameService.getCurrentUserPartyId(),
studyId);
return Response.builder()
.data(Map.of())
.status("error")
.message("Access denied: Only the study owner is permitted to edit this research study.")
.errors(null)
.build();
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 219 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1172 |
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1124 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1172 |
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1214 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1085 |
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/InteractionService.java | 85 |
| org/diabetestechnology/drh/service/http/pg/service/InteractionService.java | 545 |
public void saveStudyInteraction(String studyId, String hubInteractionId, String interactionType,
String description, String fromState,
String toState, String request, String response, String errorResponse, int responseCode, String status,
String actionType, String actionStatus) {
try {
final var userId = userNameService.getUserId();
final var userPartyId = partyService.getPartyIdByUserId(userId);
final var organizationPartyId = partyService.getOrganizationPartyIdByUser(userId);
final var uri = HttpRequestResponseUtil.getCurrentRequest().getRequestURI();
ObjectNode jsonNode = objectMapper.createObjectNode();
jsonNode.put("hub_interaction_id", hubInteractionId);
jsonNode.put("study_id", studyId);
jsonNode.put("organization_party_id", organizationPartyId); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 201 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1172 |
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 183 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 214 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 335 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 199 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 321 |
public Object childDatabaseFileInteraction(final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\""))))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 219 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 972 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1124 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 201 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 938 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1085 |
.orderBy(DSL.field("min_created_at").desc()); // if paginated
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
}
@Operation(summary = "SQL Columns from a master table or view for a specific column value") | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 102 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 125 |
final var userId = userNameService.getUserId();
final var organizationId = partyService.getOrganizationPartyIdByUser(userId);
// Construct the jOOQ query
var query = udiPrimeDbConfig.dsl()
.selectDistinct(DSL.field("p.study_id"),
DSL.field("p.study_display_id"),
DSL.field("p.study_title"),
DSL.field("p.file_category"),
DSL.field("p.organization_name"),
DSL.field(
"p.organization_party_id")) // Selecting the specified fields
.from(p)
.where("1=1");
if (finalCondition != null) {
query = query.and(finalCondition);
}
query = query.and(DSL.field("p.study_id").isNotNull()) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/InvestigatorController.java | 285 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/InvestigatorController.java | 505 |
public String cgmparticipantData(@PathVariable String studyId,
@PathVariable String participantId,
Model model, final HttpServletRequest request, @RequestParam(required = false) String tab) {
model.addAttribute("studyId", studyId);
model.addAttribute("participantId", participantId);
model.addAttribute("tab", tab);
String studyDisplayId = researchStudyService.getStudyDisplayId(studyId);
String participantDisplayId = researchStudyService.getParticipantDisplayId(participantId);
model.addAttribute("studyDisplayId", studyDisplayId);
model.addAttribute("participantDisplayId", participantDisplayId);
LOG.info("Getting details for studyId: {} , participantId: {}", studyDisplayId, participantDisplayId);
String[] pageDescription = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 111 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 106 |
})
@ResponseBody
public Object filterByStudyDisplayId(
@PathVariable String schemaName,
@PathVariable String masterTableNameOrViewName,
@PathVariable String studyDisplayId) {
// Get table reference dynamically
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(
Tables.class, schemaName, masterTableNameOrViewName);
// Define condition for filtering by study_display_id
Condition studyDisplayCondition = typableTable.column("study_display_id").eq(studyDisplayId);
// Build and execute query (Removed activity_log_level condition)
final var query = udiPrimeDbConfig.dsl()
.selectFrom(typableTable.table())
.where(studyDisplayCondition);
return query.fetch().intoMaps();
}
@Operation(summary = "SQL distinct activity rows from activity table ")
@PostMapping(value = { | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 216 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 384 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 258 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 247 |
public Object parentFailedParticipantFileInteraction(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
final @PathVariable String masterTableNameOrViewName,
@RequestParam(required = false, defaultValue = "*") String columns,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp) {
try {
TypableTable typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>();
final var userId = userNameService.getUserId(); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 337 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 250 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.FAILED))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 201 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 384 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.SUCCESS))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 323 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 250 |
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where((typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)))
.or((DSL.field("jsonb_path_query_first(interaction_hierarchy::jsonb, '$[0]')::text")
.eq(DSL.val("\"" + fileInteractionId + "\"")))))
.and(DSL.field("interaction_status").eq(DSL.val(ActionStatus.FAILED))); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 972 |
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1214 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1172 |
LOG.info("Get Study Details Corresponds to the schema {}:", schemaName.toLowerCase());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
// bindValues.add(100);
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName, (Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 1214 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 938 |
.orderBy(DSL.field("min_created_at").desc());
LOG.info("Get Study Details Corresponds to a Query {}:", query.getSQL());
return new JooqRowsSupplier.Builder()
.withRequest(payload)
.withQuery(Tables.class, schemaName.toLowerCase(), masterTableNameOrViewName,
(Query) query,
bindValues)
.withDSL(udiPrimeDbConfig.dsl())
.withLogger(LOG)
.includeGeneratedSqlInResp(includeGeneratedSqlInResp)
.includeGeneratedSqlInErrorResp(includeGeneratedSqlInErrorResp)
.build()
.response();
} catch (
DataAccessException e) {
throw new RuntimeException("Error executing SQL query for '" + schemaName + "'", e);
}
} | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 347 |
| org/diabetestechnology/drh/service/http/pg/service/UserRoleService.java | 407 |
List<String> roleNames;
if (!presentation.isAuthenticatedUser()) {
LOG.info("Guest access detected. Fetching permissions for 'Guest'");
roleNames = List.of("Guest");
}
if (presentation.isSuperAdmin()) {
LOG.info("Super Admin access detected. Fetching permissions for 'Super Admin'");
final var query = dsl.select(DSL.field("role_name"))
.from(DSL.table("drh_stateless_authentication.super_admin_view"))
.where(DSL.field("party_id").eq(userPartyId));
roleNames = query.fetch(DSL.field("role_name"), String.class); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 205 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 223 |
public Object childDatabaseFileInteractionModal(final @PathVariable(required = false) String schemaName,
final @PathVariable String masterTableNameOrViewName,
final @PathVariable String fileInteractionId) {
// Fetch the result using the dynamically determined table and column; if
// jOOQ-generated types were found, automatic column value mapping will occur
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class, schemaName,
masterTableNameOrViewName);
final var query = udiPrimeDbConfig.dsl().selectFrom(typableTable.table())
.where(typableTable.column("file_interaction_id").eq(DSL.value(
fileInteractionId)));
LOG.info("Get Study Interaction Details Corresponds to the schema {}:", schemaName);
LOG.info("Get Study Interaction Details Corresponds to a Query {}:", query.getSQL()); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/hub/prime/ux/TabularRowsControllerCustom.java | 202 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1073 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1160 |
Table<?> innerQuery = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.distinctOn(DSL.field("session_unique_id"))
.from(typableTable.table())
.where(finalCondition)
.groupBy(
Stream.concat(
selectedColumns.stream().map(typableTable::column),
Stream.of(field("user_name"))).toArray(Field[]::new))
.orderBy(
DSL.field("session_unique_id").asc(),
DSL.field("min_created_at").desc()) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 52 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 54 |
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsDatabaseFileInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDatabaseFileInteractionControllerCustom.java | 80 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 84 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 81 |
public Object parentDatabaseFileInteraction(
final @RequestBody @Nonnull TabularRowsRequest payload,
final @PathVariable String schemaName,
final @PathVariable String masterTableNameOrViewName,
@RequestParam(required = false, defaultValue = "*") String columns,
@RequestHeader(value = "X-Include-Generated-SQL-In-Response", required = false) boolean includeGeneratedSqlInResp,
@RequestHeader(value = "X-Include-Generated-SQL-In-Error-Response", required = false, defaultValue = "true") boolean includeGeneratedSqlInErrorResp)
throws SQLException {
try {
final var typableTable = JooqRowsSupplier.TypableTable.fromTablesRegistry(Tables.class,
schemaName,
masterTableNameOrViewName);
var bindValues = new ArrayList<Object>(); | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 184 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1073 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsDbSession.java | 1160 |
Table<?> innerQuery = udiPrimeDbConfig.dsl()
.select(allSelectedFields)
.distinctOn(DSL.field("session_unique_id"))
.from(typableTable.table())
.where(finalCondition)
.groupBy(
Stream.concat(
selectedColumns.stream().map(typableTable::column),
Stream.of(field("user_name"))).toArray(Field[]::new))
.orderBy(
DSL.field("session_unique_id").asc(),
DSL.field("min_created_at").desc()) | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsParticipantFileInteractionControllerCustom.java | 55 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 54 |
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsParticipantFileInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyCGMInteractionControllerCustom.java | 56 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 54 |
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsStudyCGMInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyInteractionControllerCustom.java | 58 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 54 |
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsStudyInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
| File | Line |
|---|---|
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyMealsOrFitnessInteractionControllerCustom.java | 58 |
| org/diabetestechnology/drh/service/http/pg/ux/TabularRowsStudyParticipantInteractionControllerCustom.java | 54 |
private final CustomTabularFilter customTabularFilter;
@Bean
public com.fasterxml.jackson.databind.Module jsonbModule() {
com.fasterxml.jackson.databind.module.SimpleModule module = new SimpleModule();
module.addSerializer(org.jooq.JSONB.class, new JsonSerializer<org.jooq.JSONB>() {
@Override
public void serialize(org.jooq.JSONB value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
gen.writeRawValue(value.data()); // or gen.writeString(value.data());
}
});
return module;
}
public TabularRowsStudyMealsOrFitnessInteractionControllerCustom(final UdiSecondaryDbConfig udiPrimeDbConfig, | |
