Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public interface IVisualizationSourceQuery

boolean isSkipVisitJoin();

boolean isVisitTagQuery();

/**
* True if any select or aggregate requires a left join explicitly. This is an override for any columns
* that might require some form of an INNER JOIN.
Expand Down
22 changes: 0 additions & 22 deletions study/src/org/labkey/study/query/StudyQuerySchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public class StudyQuerySchema extends UserSchema implements UserSchema.HasContex
public static final String VISIT_TAG_TABLE_NAME = "VisitTag";
public static final String VISIT_TAG_MAP_TABLE_NAME = "VisitTagMap";
public static final String VISIT_ALIASES = "VisitAliases";
public static final String VISUALIZATION_VISIT_TAG_TABLE_NAME = "VisualizationVisitTag";
public static final String VISIT_MAP_TABLE_NAME = "VisitMap";

public static final String STUDY_DATA_TABLE_NAME = "StudyData";
Expand Down Expand Up @@ -642,27 +641,6 @@ public TableInfo createTable(String name, ContainerFilter cf)
{
return new VisitMapTable(this, cf);
}
if (name.startsWith(VISUALIZATION_VISIT_TAG_TABLE_NAME))
{
// Name is encoded with useProtocolDay boolean, tagName, and altQueryName
String params = name.substring(VISUALIZATION_VISIT_TAG_TABLE_NAME.length());
boolean useProtocolDay;
if (params.startsWith("-true"))
{
params = params.substring(params.indexOf("-true") + 6);
useProtocolDay = true;
}
else
{
params = params.substring(params.indexOf("-false") + 7);
useProtocolDay = false;
}
int hyphenIndex = params.indexOf("-");
String tagName = hyphenIndex > -1 ? params.substring(0, hyphenIndex) : params;
String altQueryName = hyphenIndex > -1 ? params.substring(hyphenIndex + 1) : null;

return new VisualizationVisitTagTable(this, cf, getStudy(), getUser(), tagName, useProtocolDay, altQueryName);
}

// Might be a dataset
DatasetDefinition dsd = getDatasetDefinitionByQueryName(name);
Expand Down
104 changes: 0 additions & 104 deletions study/src/org/labkey/study/query/VisualizationVisitTagTable.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -177,31 +177,28 @@ public List<Pair<VisualizationSourceColumn, VisualizationSourceColumn>> getJoinC

joinCols.add(new Pair<>(firstSubjectCol, secondSubjectCol));

if (!first.isVisitTagQuery() && ! second.isVisitTagQuery())
{
// attempt to lookup the dataset using the queryName by label and then by name
Dataset firstDataset = StudyService.get().resolveDataset(first.getContainer(), first.getQueryName());
Dataset secondDataset = StudyService.get().resolveDataset(second.getContainer(), second.getQueryName());
// attempt to lookup the dataset using the queryName by label and then by name
Dataset firstDataset = StudyService.get().resolveDataset(first.getContainer(), first.getQueryName());
Dataset secondDataset = StudyService.get().resolveDataset(second.getContainer(), second.getQueryName());

boolean subjectJoinOnly = isGroupByQuery || first.isSkipVisitJoin() || second.isSkipVisitJoin();
boolean subjectJoinOnly = isGroupByQuery || first.isSkipVisitJoin() || second.isSkipVisitJoin();

// if either query is a demographic dataset, it's sufficient to join on subject only:
if (!subjectJoinOnly && (firstDataset == null || firstDataset.getKeyType() != Dataset.KeyType.SUBJECT) &&
(secondDataset == null || secondDataset.getKeyType() != Dataset.KeyType.SUBJECT))
// if either query is a demographic dataset, it's sufficient to join on subject only:
if (!subjectJoinOnly && (firstDataset == null || firstDataset.getKeyType() != Dataset.KeyType.SUBJECT) &&
(secondDataset == null || secondDataset.getKeyType() != Dataset.KeyType.SUBJECT))
{
VisualizationSourceColumn firstSequenceCol = getVisitJoinColumn(factory, first, firstSubjectNounSingular);
VisualizationSourceColumn secondSequenceCol = getVisitJoinColumn(factory, second, secondSubjectNounSingular);
joinCols.add(new Pair<>(firstSequenceCol, secondSequenceCol));

// for datasets with matching 3rd keys, join on subject/visit/key (if neither are pivoted), allowing null results for this column so as to follow the lead of the primary measure column for this query:
if (firstDataset != null && firstDataset.getKeyType() == Dataset.KeyType.SUBJECT_VISIT_OTHER &&
secondDataset != null && secondDataset.getKeyType() == Dataset.KeyType.SUBJECT_VISIT_OTHER &&
first.getPivot() == null && second.getPivot() == null && firstDataset.hasMatchingExtraKey(secondDataset))
{
VisualizationSourceColumn firstSequenceCol = getVisitJoinColumn(factory, first, firstSubjectNounSingular);
VisualizationSourceColumn secondSequenceCol = getVisitJoinColumn(factory, second, secondSubjectNounSingular);
joinCols.add(new Pair<>(firstSequenceCol, secondSequenceCol));

// for datasets with matching 3rd keys, join on subject/visit/key (if neither are pivoted), allowing null results for this column so as to follow the lead of the primary measure column for this query:
if (firstDataset != null && firstDataset.getKeyType() == Dataset.KeyType.SUBJECT_VISIT_OTHER &&
secondDataset != null && secondDataset.getKeyType() == Dataset.KeyType.SUBJECT_VISIT_OTHER &&
first.getPivot() == null && second.getPivot() == null && firstDataset.hasMatchingExtraKey(secondDataset))
{
VisualizationSourceColumn firstKeyCol = factory.create(first.getSchema(), first.getQueryName(), firstDataset.getKeyPropertyName(), true);
VisualizationSourceColumn secondKeyCol = factory.create(second.getSchema(), second.getQueryName(), secondDataset.getKeyPropertyName(), true);
joinCols.add(new Pair<>(firstKeyCol, secondKeyCol));
}
VisualizationSourceColumn firstKeyCol = factory.create(first.getSchema(), first.getQueryName(), firstDataset.getKeyPropertyName(), true);
VisualizationSourceColumn secondKeyCol = factory.create(second.getSchema(), second.getQueryName(), secondDataset.getKeyPropertyName(), true);
joinCols.add(new Pair<>(firstKeyCol, secondKeyCol));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,6 @@ public boolean isSkipVisitJoin()
return false;
}

@Override
public boolean isVisitTagQuery()
{
return false;
}

@Override
public boolean isRequireLeftJoin()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ public boolean requireInnerJoin()
return false;
}

@Override
public boolean isVisitTagQuery()
{
return _queryName.startsWith("VisualizationVisitTag");
}

@Override
public boolean isRequireLeftJoin()
{
Expand Down Expand Up @@ -213,7 +207,7 @@ public String getSelectListName(Set<VisualizationSourceColumn> selectAliases)

private static void addToColMap(Map<String, Set<VisualizationSourceColumn>> colMap, String name, VisualizationSourceColumn alias)
{
Set<VisualizationSourceColumn> aliases = colMap.computeIfAbsent(name, k -> new LinkedHashSet<>());
Set<VisualizationSourceColumn> aliases = colMap.computeIfAbsent(name, n -> new LinkedHashSet<>());
aliases.add(alias);
}

Expand Down Expand Up @@ -434,7 +428,7 @@ public String getGroupByClause()
return "";
}

private void appendValueList(StringBuilder sql, VisualizationSourceColumn col) throws org.labkey.api.visualization.SQLGenerationException
private void appendValueList(StringBuilder sql, VisualizationSourceColumn col)
{
if (col.getValues() != null && !col.getValues().isEmpty())
{
Expand All @@ -457,7 +451,7 @@ private void appendValueList(StringBuilder sql, VisualizationSourceColumn col) t
}
}

public String getPivotClause() throws org.labkey.api.visualization.SQLGenerationException
public String getPivotClause()
{
if (_pivot != null)
{
Expand Down Expand Up @@ -560,7 +554,7 @@ private String appendSimpleFilter(StringBuilder where, SimpleFilter filter, Stri
return separator;
}

public String getWhereClause() throws org.labkey.api.visualization.SQLGenerationException
public String getWhereClause()
{
StringBuilder where = new StringBuilder();
String sep = "WHERE ";
Expand Down Expand Up @@ -598,12 +592,11 @@ public String getWhereClause() throws org.labkey.api.visualization.SQLGeneration
@Override
public String getSQL(VisualizationSourceColumn.Factory factory) throws SQLGenerationException
{
String sql = getSelectClause(factory) + "\n" +
return getSelectClause(factory) + "\n" +
getFromClause() + "\n" +
getWhereClause() + "\n" +
getGroupByClause() + "\n" +
getPivotClause() + "\n";
return sql;
}

@Override
Expand Down