Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 43754: SampleTypeDomainKind.hasNullValues override to filter out aliquot rows in "can field be made required" check #2583

Merged
merged 3 commits into from Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -185,7 +185,7 @@ public boolean hasNullValues(Domain domain, DomainProperty prop)
}
}

private boolean getTotalAndNonBlankSql(Domain domain, DomainProperty prop, SQLFragment allRowsSQL, SQLFragment nonBlankRowsSQL)
protected boolean getTotalAndNonBlankSql(Domain domain, DomainProperty prop, SQLFragment allRowsSQL, SQLFragment nonBlankRowsSQL)
{
if (getStorageSchemaName() == null)
{
Expand Down
26 changes: 26 additions & 0 deletions internal/src/org/labkey/experiment/api/SampleTypeDomainKind.java
Expand Up @@ -32,6 +32,7 @@
import org.labkey.api.data.PropertyStorageSpec;
import org.labkey.api.data.RuntimeSQLException;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SqlSelector;
import org.labkey.api.data.TableInfo;
import org.labkey.api.data.UpdateableTableInfo;
import org.labkey.api.exp.ExperimentException;
Expand All @@ -44,6 +45,7 @@
import org.labkey.api.exp.api.SampleTypeService;
import org.labkey.api.exp.property.AbstractDomainKind;
import org.labkey.api.exp.property.Domain;
import org.labkey.api.exp.property.DomainProperty;
import org.labkey.api.exp.query.ExpSampleTypeTable;
import org.labkey.api.exp.query.SamplesSchema;
import org.labkey.api.gwt.client.DefaultValueType;
Expand Down Expand Up @@ -517,4 +519,28 @@ public SampleTypeDomainKindProperties getDomainKindProperties(GWTDomain domain,
ExpSampleType sampleType = domain != null ? SampleTypeService.get().getSampleType(domain.getDomainURI()) : null;
return new SampleTypeDomainKindProperties(sampleType);
}

@Override
public boolean hasNullValues(Domain domain, DomainProperty prop)
{
SQLFragment allRowsSQL = new SQLFragment();
SQLFragment nonBlankRowsSQL = new SQLFragment();

if (getTotalAndNonBlankSql(domain, prop, allRowsSQL, nonBlankRowsSQL))
{
// Issue 43754: Don't include aliquot rows in the null value check (see ExpMaterialTableImpl.createColumn for IsAliquot)
String table = domain.getStorageTableName();
allRowsSQL = new SQLFragment("SELECT * FROM exp.material WHERE LSID IN (")
cnathe marked this conversation as resolved.
Show resolved Hide resolved
.append("SELECT LSID FROM " + getStorageSchemaName() + "." + table)
.append(") AND RootMaterialLSID IS NULL");

long totalRows = new SqlSelector(ExperimentService.get().getSchema(), allRowsSQL).getRowCount();
long nonBlankRows = new SqlSelector(ExperimentService.get().getSchema(), nonBlankRowsSQL).getRowCount();
return totalRows != nonBlankRows;
}
else
{
return false;
}
}
}