diff --git a/TODO_ContainerFilter.md b/TODO_ContainerFilter.md new file mode 100644 index 0000000000..25f134d94a --- /dev/null +++ b/TODO_ContainerFilter.md @@ -0,0 +1,48 @@ +remove interface ContainerFilterable (migrate method to protected methods e.g. on FilteredTable) + +remove class DelegatingContainerFilter + +test ContainerFilter for ExperimentService.get().createQCFlagsTable + +SpecimenForeignKey calls to getSpecimenTableInfo(null) + +Find classes that override: +- UserSchema.createTable(String name) +- AssayProtocolSchema.createProviderTable(String name) +- AssayProtocolSchema.createDataTable(boolean includeCopiedToStudyColumns) +- AssayProtocolSchema.createRunsTable() +- AssayResultTable.AssayResultTable(AssayProtocolSchema schema, boolean includeCopiedToStudyColumns) + +convert schemas: ms2, study, annoucements, flow + +Find classes that use constructor +- SimpleTable(SchemaType schema, TableInfo table) + +Who is still depending on AbstractExpSchema.setupTable(T table) to set containerFilter??? + +LineageTableInfo + +More clean up of QueryForeignKey (Builder?) +More clean up of PdLookupForeignKey (.create()?) + +QueryDefinitionImpl.getTable() remove usage of deprecated method w/o ContainerFilter + +Issues.AllIssuesTable +IsuesTable.RelatedIssues lookup uses setFk() on locked table + +search for "TODO ContainerFilter" + +Check subclasses of LookupForeignKey. getLookupTableInfo() should use getLookupContainerFilter() + +update MultiValuedForeignKey to take CF, check usages of passed in FK to make sure they are configured with CF + +Check that subclasses of QueryView initialize ContainerFilter when they construct TableInfo + +How does setting effectiveContainer (when != source container) on QFK affect the ContainerFilter? If effectiveContainer != sourceContainer +maybe it should have the same effect as setting lookupContainer? see for instance, ExperimentsTable in oconnorexperiments + + + +OTHER BIGGER IDEAS +* separate ContainerFilter factory e.g. CurrentContainer(?) from ContainerFilter bound instance e.g. "CurrentContainer("/home") +* Make ColumnInfo and ColumnRenderProperties read-only interfaces and AbstactColumnInfo the constrctable implementation \ No newline at end of file diff --git a/elisa/src/org/labkey/elisa/ElisaProtocolSchema.java b/elisa/src/org/labkey/elisa/ElisaProtocolSchema.java index dd464b049d..cd70e053fc 100644 --- a/elisa/src/org/labkey/elisa/ElisaProtocolSchema.java +++ b/elisa/src/org/labkey/elisa/ElisaProtocolSchema.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.query.FilteredTable; import org.labkey.api.security.User; @@ -36,8 +37,8 @@ public ElisaProtocolSchema(User user, Container container, @NotNull ElisaAssayPr } @Override - public FilteredTable createDataTable(boolean includeCopiedToStudyColumns) + public FilteredTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - return new ElisaResultsTable(this, includeCopiedToStudyColumns); + return new ElisaResultsTable(this, cf, includeCopiedToStudyColumns); } } diff --git a/elisa/src/org/labkey/elisa/query/ElisaResultsTable.java b/elisa/src/org/labkey/elisa/query/ElisaResultsTable.java index 812a9434b2..2372867f99 100644 --- a/elisa/src/org/labkey/elisa/query/ElisaResultsTable.java +++ b/elisa/src/org/labkey/elisa/query/ElisaResultsTable.java @@ -15,7 +15,9 @@ */ package org.labkey.elisa.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpSampleSet; import org.labkey.api.exp.api.ExperimentService; @@ -41,9 +43,9 @@ */ public class ElisaResultsTable extends AssayResultTable { - public ElisaResultsTable(final AssayProtocolSchema schema, boolean includeCopiedToStudyColumns) + public ElisaResultsTable(final AssayProtocolSchema schema, ContainerFilter cf, boolean includeCopiedToStudyColumns) { - super(schema, includeCopiedToStudyColumns); + super(schema, cf, includeCopiedToStudyColumns); List visibleColumns = new ArrayList<>(); @@ -60,19 +62,19 @@ public ElisaResultsTable(final AssayProtocolSchema schema, boolean includeCopied } // add a lookup to the material table - ColumnInfo specimenColumn = _columnMap.get(ElisaDataHandler.ELISA_INPUT_MATERIAL_DATA_PROPERTY); + BaseColumnInfo specimenColumn = (BaseColumnInfo)_columnMap.get(ElisaDataHandler.ELISA_INPUT_MATERIAL_DATA_PROPERTY); specimenColumn.setFk(new LookupForeignKey("LSID") { public TableInfo getLookupTableInfo() { - ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema); + ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema, cf); // Make sure we are filtering to the same set of containers materials.setContainerFilter(getContainerFilter()); if (sampleSet != null) { materials.setSampleSet(sampleSet, true); } - ColumnInfo propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); + var propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); if (propertyCol.getFk() instanceof PropertyForeignKey) { ((PropertyForeignKey)propertyCol.getFk()).addDecorator(new SpecimenPropertyColumnDecorator(_provider, _protocol, schema)); diff --git a/elispotassay/src/org/labkey/elispot/ElispotProtocolSchema.java b/elispotassay/src/org/labkey/elispot/ElispotProtocolSchema.java index 0baf120ca9..350ab0f323 100644 --- a/elispotassay/src/org/labkey/elispot/ElispotProtocolSchema.java +++ b/elispotassay/src/org/labkey/elispot/ElispotProtocolSchema.java @@ -21,6 +21,7 @@ import org.labkey.api.data.ActionButton; import org.labkey.api.data.ButtonBar; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.CrosstabMember; import org.labkey.api.data.DataRegion; import org.labkey.api.data.TableInfo; @@ -67,6 +68,7 @@ public ElispotAssayProvider getProvider() return (ElispotAssayProvider)super.getProvider(); } + @Override public Set getTableNames() { Set names = super.getTableNames(); @@ -75,26 +77,27 @@ public Set getTableNames() return names; } - public TableInfo createProviderTable(String name) + @Override + public TableInfo createProviderTable(String name, ContainerFilter cf) { if (name.equalsIgnoreCase(ANTIGEN_TABLE_NAME)) { Domain domain = AbstractAssayProvider.getDomainByPrefix(getProtocol(), ElispotAssayProvider.ASSAY_DOMAIN_ANTIGEN_WELLGROUP); if (null != domain) - return new ElispotRunAntigenTable(this, domain, getProtocol()); + return new ElispotRunAntigenTable(this, cf, domain, getProtocol()); } else if (name.equalsIgnoreCase(ANTIGEN_STATS_TABLE_NAME)) { - return ElispotAntigenCrosstabTable.create((ElispotRunAntigenTable) createProviderTable(ANTIGEN_TABLE_NAME), getProtocol(), this); + return ElispotAntigenCrosstabTable.create((ElispotRunAntigenTable) createProviderTable(ANTIGEN_TABLE_NAME, cf), getProtocol(), this); } - return super.createProviderTable(name); + return super.createProviderTable(name, cf); } @Override - public ElispotRunDataTable createDataTable(boolean includeCopiedToStudyColumns) + public ElispotRunDataTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - ElispotRunDataTable table = new ElispotRunDataTable(this, getProtocol()); + ElispotRunDataTable table = new ElispotRunDataTable(this, cf, getProtocol()); if (includeCopiedToStudyColumns) { addCopiedToStudyColumns(table, true); @@ -116,6 +119,7 @@ public ElispotResultsQueryView(ExpProtocol protocol, ViewContext context, QueryS super(protocol, context, settings); } + @Override public DataView createDataView() { DataView view = super.createDataView(); diff --git a/elispotassay/src/org/labkey/elispot/ElispotProviderSchema.java b/elispotassay/src/org/labkey/elispot/ElispotProviderSchema.java index e1e38bb14a..4fa75e5773 100644 --- a/elispotassay/src/org/labkey/elispot/ElispotProviderSchema.java +++ b/elispotassay/src/org/labkey/elispot/ElispotProviderSchema.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.EnumTableInfo; import org.labkey.api.data.TableInfo; import org.labkey.api.security.User; @@ -53,7 +54,7 @@ public Set getTableNames() } @Override - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { if (name.equalsIgnoreCase(ELISPOT_PLATE_READER_TABLE)) { @@ -69,6 +70,6 @@ public String getValue(ElispotAssayProvider.PlateReaderType e) return result; } - return super.createTable(name); + return super.createTable(name, cf); } } diff --git a/elispotassay/src/org/labkey/elispot/query/ElispotAntigenCrosstabTable.java b/elispotassay/src/org/labkey/elispot/query/ElispotAntigenCrosstabTable.java index fd9e85e278..aaf0f2af85 100644 --- a/elispotassay/src/org/labkey/elispot/query/ElispotAntigenCrosstabTable.java +++ b/elispotassay/src/org/labkey/elispot/query/ElispotAntigenCrosstabTable.java @@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.AggregateColumnInfo; -import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.CrosstabDimension; import org.labkey.api.data.CrosstabMeasure; @@ -110,12 +110,13 @@ public ElispotAntigenCrosstabTable(CrosstabSettings crosstabSettings, ArrayList< { super(crosstabSettings, members); _nonBasePropertyNames = nonBasePropertyNames; - getColumn("InstanceCount").setHidden(true); - getColumn("Run").setHidden(true); - getColumn("SpecimenLsid").setHidden(true); + getMutableColumn("InstanceCount").setHidden(true); + getMutableColumn("Run").setHidden(true); + getMutableColumn("SpecimenLsid").setHidden(true); setTitle("AntigenStats"); } + @NotNull @Override public ContainerFilter getContainerFilter() { @@ -153,7 +154,7 @@ public Sort getDefaultSort() } @Override - protected ColumnInfo createMemberMeasureCol(@Nullable CrosstabMember member, CrosstabMeasure measure) + protected BaseColumnInfo createMemberMeasureCol(@Nullable CrosstabMember member, CrosstabMeasure measure) { AggregateColumnInfo column = (AggregateColumnInfo)super.createMemberMeasureCol(member, measure); column.setCrosstabColumnDimension(measure.getSourceColumn().getFieldKey()); diff --git a/elispotassay/src/org/labkey/elispot/query/ElispotRunAntigenTable.java b/elispotassay/src/org/labkey/elispot/query/ElispotRunAntigenTable.java index 7b3e030819..31deffc002 100644 --- a/elispotassay/src/org/labkey/elispot/query/ElispotRunAntigenTable.java +++ b/elispotassay/src/org/labkey/elispot/query/ElispotRunAntigenTable.java @@ -16,6 +16,7 @@ package org.labkey.elispot.query; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; @@ -41,9 +42,9 @@ */ public class ElispotRunAntigenTable extends PlateBasedAssayRunDataTable { - public ElispotRunAntigenTable(final AssaySchema schema, final Domain domain, ExpProtocol protocol) + public ElispotRunAntigenTable(final AssaySchema schema, ContainerFilter cf, final Domain domain, ExpProtocol protocol) { - super(schema, StorageProvisioner.createTableInfo(domain), protocol); + super(schema, StorageProvisioner.createTableInfo(domain), cf, protocol); setDescription("Contains one row per well for the \"" + protocol.getName() + "\" ELISpot assay design."); setTitle("Antigen"); this.setPublic(false); @@ -55,7 +56,7 @@ public ElispotRunAntigenTable(final AssaySchema schema, final Domain domain, Exp else sql.append("CONCAT(AntigenName, ' (', REPLACE(AntigenWellgroupName, 'Antigen ', ''), ')') END"); - ColumnInfo antigenHeading = new ExprColumn(this, "AntigenHeading", sql, JdbcType.VARCHAR, getColumn("AntigenWellgroupName"), getColumn("AntigenName")); + ExprColumn antigenHeading = new ExprColumn(this, "AntigenHeading", sql, JdbcType.VARCHAR, getColumn("AntigenWellgroupName"), getColumn("AntigenName")); antigenHeading.setHidden(true); addColumn(antigenHeading); } @@ -82,19 +83,20 @@ protected ColumnInfo resolveColumn(String name) { // Hook up a column that joins back to this table so that the columns formerly under the Properties // node can still be queried there. - result = wrapColumn("Properties", getRealTable().getColumn("ObjectId")); - result.setIsUnselectable(true); - LookupForeignKey fk = new LookupForeignKey("ObjectId") + var wrapped = wrapColumn("Properties", getRealTable().getColumn("ObjectId")); + wrapped.setIsUnselectable(true); + LookupForeignKey fk = new LookupForeignKey(getContainerFilter(), "ObjectId", null) { @Override public TableInfo getLookupTableInfo() { Domain domain = AbstractAssayProvider.getDomainByPrefix(_protocol, ElispotAssayProvider.ASSAY_DOMAIN_ANTIGEN_WELLGROUP); - return new ElispotRunAntigenTable(_userSchema, domain, _protocol); + return new ElispotRunAntigenTable(_userSchema, getLookupContainerFilter(), domain, _protocol); } }; fk.setPrefixColumnCaption(false); - result.setFk(fk); + wrapped.setFk(fk); + result = wrapped; } return result; @@ -109,7 +111,7 @@ protected void addPropertyColumns(final AssaySchema schema, final ExpProtocol pr { continue; } - ColumnInfo wrapColumn = addWrapColumn(column); + var wrapColumn = addWrapColumn(column); if ("AntigenLsid".equalsIgnoreCase(column.getName()) || "SpecimenLsid".equalsIgnoreCase(column.getName())) wrapColumn.setHidden(true); else if ("Mean".equalsIgnoreCase(column.getName()) || "Median".equalsIgnoreCase(column.getName())) diff --git a/elispotassay/src/org/labkey/elispot/query/ElispotRunDataTable.java b/elispotassay/src/org/labkey/elispot/query/ElispotRunDataTable.java index 781862e9a3..6877067f1a 100644 --- a/elispotassay/src/org/labkey/elispot/query/ElispotRunDataTable.java +++ b/elispotassay/src/org/labkey/elispot/query/ElispotRunDataTable.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.DataColumn; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.DisplayColumnFactory; @@ -49,19 +50,19 @@ */ public class ElispotRunDataTable extends PlateBasedAssayRunDataTable { - public ElispotRunDataTable(final AssaySchema schema, final ExpProtocol protocol) + public ElispotRunDataTable(final AssaySchema schema, ContainerFilter cf, final ExpProtocol protocol) { - this(schema, ElispotManager.getTableInfoElispotRunData(), protocol); + this(schema, ElispotManager.getTableInfoElispotRunData(), cf, protocol); } - public ElispotRunDataTable(final AssaySchema schema, TableInfo table, final ExpProtocol protocol) + public ElispotRunDataTable(final AssaySchema schema, TableInfo table, ContainerFilter cf, final ExpProtocol protocol) { - super(schema, table, protocol); + super(schema, table, cf, protocol); setDescription("Contains one row per sample for the \"" + protocol.getName() + "\" ELISpot assay design."); // display column for spot counts - ColumnInfo col = getColumn(FieldKey.fromParts(ElispotDataHandler.SFU_PROPERTY_NAME)); + var col = getMutableColumn(FieldKey.fromParts(ElispotDataHandler.SFU_PROPERTY_NAME)); if (col != null) { col.setDisplayColumnFactory(new DisplayColumnFactory() @@ -75,7 +76,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) } // display column for spot size - ColumnInfo spotSizeCol = getColumn(FieldKey.fromParts(ElispotDataHandler.SPOT_SIZE_PROPERTY_NAME)); + var spotSizeCol = getMutableColumn(FieldKey.fromParts(ElispotDataHandler.SPOT_SIZE_PROPERTY_NAME)); if (spotSizeCol != null) { spotSizeCol.setDisplayColumnFactory(new DisplayColumnFactory() @@ -98,7 +99,7 @@ protected void addPropertyColumns(final AssaySchema schema, final ExpProtocol pr { continue; // already added or added below } - ColumnInfo wrapColumn = addWrapColumn(column); + var wrapColumn = addWrapColumn(column); if ("ObjectUri".equalsIgnoreCase(column.getName()) || "RowId".equalsIgnoreCase(column.getName())) wrapColumn.setHidden(true); } @@ -114,13 +115,14 @@ protected void addPropertyColumns(final AssaySchema schema, final ExpProtocol pr } } - ColumnInfo antigenLsidColumn = getColumn("AntigenLsid"); + var antigenLsidColumn = getMutableColumn("AntigenLsid"); antigenLsidColumn.setLabel("Antigen"); - antigenLsidColumn.setFk(new LookupForeignKey(null, "AntigenName") + antigenLsidColumn.setFk(new LookupForeignKey( (String)null, "AntigenName") { @Override public TableInfo getLookupTableInfo() { + // TODO ContainerFilter return ElispotManager.getTableInfoElispotAntigen(_protocol); } }); @@ -136,18 +138,19 @@ protected ColumnInfo resolveColumn(String name) { // Hook up a column that joins back to this table so that the columns formerly under the Properties // node can still be queried there. - result = wrapColumn("Properties", getRealTable().getColumn("ObjectId")); - result.setIsUnselectable(true); - LookupForeignKey fk = new LookupForeignKey("ObjectId") + var wrapped = wrapColumn("Properties", getRealTable().getColumn("ObjectId")); + wrapped.setIsUnselectable(true); + LookupForeignKey fk = new LookupForeignKey(getContainerFilter(), "ObjectId", null) { @Override public TableInfo getLookupTableInfo() { - return new ElispotRunDataTable(_userSchema, _protocol); + return new ElispotRunDataTable(_userSchema, getLookupContainerFilter(), _protocol); } }; fk.setPrefixColumnCaption(false); - result.setFk(fk); + wrapped.setFk(fk); + result = wrapped; } return result; diff --git a/elispotassay/src/org/labkey/elispot/query/PlateBasedAssayRunDataTable.java b/elispotassay/src/org/labkey/elispot/query/PlateBasedAssayRunDataTable.java index 48e36a55b1..3a3b834888 100644 --- a/elispotassay/src/org/labkey/elispot/query/PlateBasedAssayRunDataTable.java +++ b/elispotassay/src/org/labkey/elispot/query/PlateBasedAssayRunDataTable.java @@ -17,7 +17,6 @@ package org.labkey.elispot.query; import org.labkey.api.data.*; -import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.api.ExpSampleSet; import org.labkey.api.exp.api.ExperimentService; @@ -47,9 +46,9 @@ public String getInputMaterialPropertyName() return ElispotDataHandler.ELISPOT_INPUT_MATERIAL_DATA_PROPERTY; } - public PlateBasedAssayRunDataTable(final AssaySchema schema, final TableInfo table, final ExpProtocol protocol) + public PlateBasedAssayRunDataTable(final AssaySchema schema, final TableInfo table, ContainerFilter cf, final ExpProtocol protocol) { - super(table, schema); + super(table, schema, cf); _protocol = protocol; final AssayProvider provider = AssayService.get().getProvider(protocol); @@ -63,7 +62,7 @@ public PlateBasedAssayRunDataTable(final AssaySchema schema, final TableInfo tab { public TableInfo getLookupTableInfo() { - ExpRunTable expRunTable = AssayService.get().createRunTable(protocol, provider, schema.getUser(), schema.getContainer()); + ExpRunTable expRunTable = AssayService.get().createRunTable(protocol, provider, schema.getUser(), schema.getContainer(), PlateBasedAssayRunDataTable.this.getContainerFilter()); expRunTable.setContainerFilter(getContainerFilter()); return expRunTable; } @@ -76,25 +75,23 @@ public TableInfo getLookupTableInfo() final boolean hasMaterialSpecimenPropertyColumnDecorator = hasMaterialSpecimenPropertyColumnDecorator(); String sampleDomainURI = AbstractAssayProvider.getDomainURIForPrefix(protocol, AbstractPlateBasedAssayProvider.ASSAY_DOMAIN_SAMPLE_WELLGROUP); final ExpSampleSet sampleSet = ExperimentService.get().getSampleSet(sampleDomainURI); - ColumnInfo materialColumn = getColumn("SpecimenLsid"); // new PropertyColumn(materialProperty, objectUriColumn, getContainer(), schema.getUser(), false); + var materialColumn = getMutableColumn("SpecimenLsid"); // new PropertyColumn(materialProperty, objectUriColumn, getContainer(), schema.getUser(), false); materialColumn.setLabel("Specimen"); materialColumn.setHidden(true); - materialColumn.setFk(new LookupForeignKey("LSID") + materialColumn.setFk(new LookupForeignKey(cf,"LSID", null) { public TableInfo getLookupTableInfo() { - ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema); - // Make sure we are filtering to the same set of containers - materials.setContainerFilter(getContainerFilter()); + ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema, getLookupContainerFilter()); if (sampleSet != null) { materials.setSampleSet(sampleSet, true); } - ColumnInfo propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); + var propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); if (hasMaterialSpecimenPropertyColumnDecorator && propertyCol.getFk() instanceof PropertyForeignKey) { ((PropertyForeignKey)propertyCol.getFk()).addDecorator(new SpecimenPropertyColumnDecorator(provider, protocol, schema)); - propertyCol.setDisplayColumnFactory(ColumnInfo.NOLOOKUP_FACTORY); + propertyCol.setDisplayColumnFactory(BaseColumnInfo.NOLOOKUP_FACTORY); } propertyCol.setHidden(false); materials.addColumn(ExpMaterialTable.Column.LSID).setHidden(true); @@ -103,7 +100,7 @@ public TableInfo getLookupTableInfo() }); ExprColumn runIdColumn = new ExprColumn(this, RUN_ID_COLUMN_NAME, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".RunID"), JdbcType.INTEGER); - ColumnInfo addedRunIdColumn = addColumn(runIdColumn); + var addedRunIdColumn = addColumn(runIdColumn); addedRunIdColumn.setHidden(true); Set hiddenProperties = new HashSet<>(); diff --git a/flow/src/org/labkey/flow/controllers/editscript/EditScriptForm.java b/flow/src/org/labkey/flow/controllers/editscript/EditScriptForm.java index 686d912ab0..2b293772a8 100644 --- a/flow/src/org/labkey/flow/controllers/editscript/EditScriptForm.java +++ b/flow/src/org/labkey/flow/controllers/editscript/EditScriptForm.java @@ -300,7 +300,7 @@ public String[] getAvailableKeywords() FlowSchema schema = new FlowSchema(getUser(), getContainer()); if (run != null) schema.setRun(run); - FlowPropertySet fps = new FlowPropertySet(schema.createFCSFileTable("foo")); + FlowPropertySet fps = new FlowPropertySet(schema.createFCSFileTable("foo", null)); keywords.addAll(fps.getVisibleKeywords()); } catch (Throwable t) diff --git a/flow/src/org/labkey/flow/controllers/executescript/SamplesConfirmGridView.java b/flow/src/org/labkey/flow/controllers/executescript/SamplesConfirmGridView.java index be7d80590c..c03b97ffaa 100644 --- a/flow/src/org/labkey/flow/controllers/executescript/SamplesConfirmGridView.java +++ b/flow/src/org/labkey/flow/controllers/executescript/SamplesConfirmGridView.java @@ -22,9 +22,11 @@ import org.labkey.api.collections.RowMapFactory; import org.labkey.api.data.AbstractForeignKey; import org.labkey.api.data.ActionButton; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ButtonBar; import org.labkey.api.data.CachedResultSets; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.Container; import org.labkey.api.data.DataRegion; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.InputColumn; @@ -36,6 +38,7 @@ import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpData; import org.labkey.api.query.FieldKey; +import org.labkey.api.security.User; import org.labkey.api.settings.AppProps; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.SimpleNamedObject; @@ -45,6 +48,7 @@ import org.labkey.flow.analysis.model.Workspace; import org.labkey.flow.data.FlowFCSFile; import org.labkey.flow.data.FlowRun; +import org.labkey.flow.query.FlowSchema; import org.labkey.flow.util.KeywordUtil; import org.springframework.validation.Errors; @@ -80,12 +84,12 @@ public class SamplesConfirmGridView extends GridView Map _runs = new HashMap<>(); - public SamplesConfirmGridView(SelectedSamples data, boolean resolving, Errors errors) + public SamplesConfirmGridView(User user, Container container, SelectedSamples data, boolean resolving, Errors errors) { - this(data.getKeywords(), data.getSamples(), resolving, data.getRows(), errors); + this(user, container, data.getKeywords(), data.getSamples(), resolving, data.getRows(), errors); } - public SamplesConfirmGridView(Collection keywords, List samples, boolean resolving, Map rows, Errors errors) + public SamplesConfirmGridView(User user, Container container, Collection keywords, List samples, boolean resolving, Map rows, Errors errors) { super(new SamplesConfirmDataRegion(), errors); @@ -96,19 +100,19 @@ public SamplesConfirmGridView(Collection keywords, List columns = new LinkedHashMap<>(); if (resolving) { - columns.put(MATCHED_FLAG_FIELD_KEY, new ColumnInfo(MATCHED_FLAG_FIELD_KEY, JdbcType.BOOLEAN)); - columns.put(MATCHED_FILE_FIELD_KEY, new ColumnInfo(MATCHED_FILE_FIELD_KEY, JdbcType.INTEGER)); - columns.put(CANDIDATE_FILES_FIELD_KEY, new ColumnInfo(CANDIDATE_FILES_FIELD_KEY, JdbcType.OTHER)); // List + columns.put(MATCHED_FLAG_FIELD_KEY, new BaseColumnInfo(MATCHED_FLAG_FIELD_KEY, JdbcType.BOOLEAN)); + columns.put(MATCHED_FILE_FIELD_KEY, new BaseColumnInfo(MATCHED_FILE_FIELD_KEY, JdbcType.INTEGER)); + columns.put(CANDIDATE_FILES_FIELD_KEY, new BaseColumnInfo(CANDIDATE_FILES_FIELD_KEY, JdbcType.OTHER)); // List } - columns.put(SAMPLE_ID_FIELD_KEY, new ColumnInfo(SAMPLE_ID_FIELD_KEY, JdbcType.VARCHAR)); - columns.put(SAMPLE_NAME_FIELD_KEY, new ColumnInfo(SAMPLE_NAME_FIELD_KEY, JdbcType.VARCHAR)); + columns.put(SAMPLE_ID_FIELD_KEY, new BaseColumnInfo(SAMPLE_ID_FIELD_KEY, JdbcType.VARCHAR)); + columns.put(SAMPLE_NAME_FIELD_KEY, new BaseColumnInfo(SAMPLE_NAME_FIELD_KEY, JdbcType.VARCHAR)); if (hasGroupInfo) - columns.put(GROUP_NAMES_FIELD_KEY, new ColumnInfo(GROUP_NAMES_FIELD_KEY, JdbcType.VARCHAR)); + columns.put(GROUP_NAMES_FIELD_KEY, new BaseColumnInfo(GROUP_NAMES_FIELD_KEY, JdbcType.VARCHAR)); for (String keyword : keywords) { FieldKey fieldKey = new FieldKey(null, keyword); - ColumnInfo col = new ColumnInfo(fieldKey, JdbcType.VARCHAR); + var col = new BaseColumnInfo(fieldKey, JdbcType.VARCHAR); col.setAlias(fieldKey.getName()); if (!columns.containsKey(fieldKey)) columns.put(fieldKey, col); @@ -223,9 +227,10 @@ public SamplesConfirmGridView(Collection keywords, List _files; NamedObjectList _list; - FCSFilesFilesForeignKey(List files) + FCSFilesFilesForeignKey(FlowSchema schema, List files) { + super(schema, null); _files = files; _list = new NamedObjectList(); diff --git a/flow/src/org/labkey/flow/controllers/executescript/importAnalysisReviewSamples.jsp b/flow/src/org/labkey/flow/controllers/executescript/importAnalysisReviewSamples.jsp index 31b266176e..496625c616 100644 --- a/flow/src/org/labkey/flow/controllers/executescript/importAnalysisReviewSamples.jsp +++ b/flow/src/org/labkey/flow/controllers/executescript/importAnalysisReviewSamples.jsp @@ -84,7 +84,7 @@ } SelectedSamples selectedSamples = form.getSelectedSamples(); - SamplesConfirmGridView resolveView = new SamplesConfirmGridView(selectedSamples, form.isResolving(), null); + SamplesConfirmGridView resolveView = new SamplesConfirmGridView(getUser(), container, selectedSamples, form.isResolving(), null); %> diff --git a/flow/src/org/labkey/flow/controllers/protocol/ProtocolForm.java b/flow/src/org/labkey/flow/controllers/protocol/ProtocolForm.java index 0002eae21c..49f195e1f4 100644 --- a/flow/src/org/labkey/flow/controllers/protocol/ProtocolForm.java +++ b/flow/src/org/labkey/flow/controllers/protocol/ProtocolForm.java @@ -45,7 +45,7 @@ public Map getKeywordFieldMap() options.put(FieldKey.fromParts("Name"), "FCS file name"); options.put(FieldKey.fromParts("Run", "Name"), "Run name"); FlowSchema schema = new FlowSchema(getUser(), getContainer()); - ExpDataTable table = schema.createFCSFileTable(null); + ExpDataTable table = schema.createFCSFileTable("FcsFile", null); FlowPropertySet fps = new FlowPropertySet(table); FieldKey keyKeyword = FieldKey.fromParts("Keyword"); for (String keyword : fps.getVisibleKeywords()) diff --git a/flow/src/org/labkey/flow/data/FlowProtocol.java b/flow/src/org/labkey/flow/data/FlowProtocol.java index d1d509608f..ca6b26dcef 100644 --- a/flow/src/org/labkey/flow/data/FlowProtocol.java +++ b/flow/src/org/labkey/flow/data/FlowProtocol.java @@ -284,7 +284,7 @@ public Map getSampleMap(User user) throws SQLException return Collections.emptyMap(); SamplesSchema schema = new SamplesSchema(user, getContainer()); - ExpMaterialTable sampleTable = schema.getSampleTable(ss); + ExpMaterialTable sampleTable = schema.getSampleTable(ss, null); List selectedColumns = new ArrayList<>(); ColumnInfo colRowId = sampleTable.getColumn(ExpMaterialTable.Column.RowId.toString()); selectedColumns.add(colRowId); @@ -572,7 +572,7 @@ public void updateFCSAnalysisName(User user) throws Exception } fs.insertParent(FieldKey.fromParts("FCSFile")); FlowSchema schema = new FlowSchema(user, getContainer()); - ExpDataTable table = schema.createFCSAnalysisTable("FCSAnalysis", FlowDataType.FCSAnalysis, false); + ExpDataTable table = schema.createFCSAnalysisTable("FCSAnalysis", null, FlowDataType.FCSAnalysis, false); Map columns = new HashMap<>(); ColumnInfo colRowId = table.getColumn(ExpDataTable.Column.RowId); columns.put(new FieldKey(null, "RowId"), colRowId); @@ -607,7 +607,7 @@ public void updateFCSAnalysisName(User user) throws Exception public String getFCSAnalysisName(FlowWell well) throws SQLException { FlowSchema schema = new FlowSchema(null, getContainer()); - ExpDataTable table = schema.createFCSFileTable("fcsFiles"); + ExpDataTable table = schema.createFCSFileTable("fcsFiles", null); ColumnInfo colRowId = table.getColumn(ExpDataTable.Column.RowId); SimpleFilter filter = new SimpleFilter(); filter.addCondition(colRowId, well.getRowId()); diff --git a/flow/src/org/labkey/flow/data/FlowProtocolSchema.java b/flow/src/org/labkey/flow/data/FlowProtocolSchema.java index 94633e4e80..68e3c9a849 100644 --- a/flow/src/org/labkey/flow/data/FlowProtocolSchema.java +++ b/flow/src/org/labkey/flow/data/FlowProtocolSchema.java @@ -18,8 +18,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilterable; +import org.labkey.api.data.ContainerFilter; +import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpProtocol; +import org.labkey.api.exp.query.ExpDataTable; import org.labkey.api.exp.query.ExpRunTable; import org.labkey.api.query.QuerySettings; import org.labkey.api.security.User; @@ -49,19 +51,21 @@ public FlowAssayProvider getProvider() } @Override - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { FlowSchema flowSchema = new FlowSchema(getUser(), getContainer()); //assert protocol == flowSchema.getProtocol(); - return (ExpRunTable)flowSchema.getTable(FlowTableType.Runs); + return (ExpRunTable)flowSchema.getTable(FlowTableType.Runs, cf); } @Override - public ContainerFilterable createDataTable(boolean includeCopiedToStudyColumns) + public TableInfo createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { FlowSchema flowSchema = new FlowSchema(getUser(), getContainer()); //assert protocol == flowSchema.getProtocol(); - return flowSchema.createFCSAnalysisTable(FlowTableType.FCSAnalyses.name(), FlowDataType.FCSAnalysis, includeCopiedToStudyColumns); + ExpDataTable ti; + ti = flowSchema.createFCSAnalysisTable(FlowTableType.FCSAnalyses.name(), cf, FlowDataType.FCSAnalysis, includeCopiedToStudyColumns); + return ti; } @Nullable diff --git a/flow/src/org/labkey/flow/data/FlowRun.java b/flow/src/org/labkey/flow/data/FlowRun.java index c4f9f27e2f..b760a7e2e9 100644 --- a/flow/src/org/labkey/flow/data/FlowRun.java +++ b/flow/src/org/labkey/flow/data/FlowRun.java @@ -447,7 +447,7 @@ public FlowFCSFile[] getFCSFilesToBeAnalyzed(FlowProtocol protocol, ScriptSettin return getFCSFiles(); FlowSchema schema = new FlowSchema(null, getContainer()); schema.setRun(this); - TableInfo table = schema.createFCSFileTable("FCSFiles"); + TableInfo table = schema.createFCSFileTable("FCSFiles", null); ColumnInfo colRowId = table.getColumn("RowId"); List ret = new ArrayList<>(); diff --git a/flow/src/org/labkey/flow/persist/FlowKeywordAuditProvider.java b/flow/src/org/labkey/flow/persist/FlowKeywordAuditProvider.java index 56594ddd97..0c39a19170 100644 --- a/flow/src/org/labkey/flow/persist/FlowKeywordAuditProvider.java +++ b/flow/src/org/labkey/flow/persist/FlowKeywordAuditProvider.java @@ -20,6 +20,7 @@ import org.labkey.api.audit.AuditTypeProvider; import org.labkey.api.audit.query.AbstractAuditDomainKind; import org.labkey.api.audit.query.DefaultAuditTypeTable; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.PropertyType; @@ -59,16 +60,16 @@ public class FlowKeywordAuditProvider extends AbstractAuditTypeProvider implemen } @Override - public TableInfo createTableInfo(UserSchema userSchema) + public TableInfo createTableInfo(UserSchema userSchema, ContainerFilter cf) { - DefaultAuditTypeTable table = new DefaultAuditTypeTable(this, createStorageTableInfo(), userSchema, getDefaultVisibleColumns()); + DefaultAuditTypeTable table = new DefaultAuditTypeTable(this, createStorageTableInfo(), userSchema, cf, getDefaultVisibleColumns()); DetailsURL url = DetailsURL.fromString("experiment/resolveLSID.view?lsid=${lsid}"); url.setStrictContainerContextEval(true); table.setDetailsURL(url); - table.getColumn(COLUMN_NAME_FILE).setURL(url); - table.getColumn(COLUMN_NAME_FILE).setURLTargetWindow("_blank"); + table.getMutableColumn(COLUMN_NAME_FILE).setURL(url); + table.getMutableColumn(COLUMN_NAME_FILE).setURLTargetWindow("_blank"); return table; } diff --git a/flow/src/org/labkey/flow/persist/FlowManager.java b/flow/src/org/labkey/flow/persist/FlowManager.java index 39fd6a9534..f70313770f 100644 --- a/flow/src/org/labkey/flow/persist/FlowManager.java +++ b/flow/src/org/labkey/flow/persist/FlowManager.java @@ -1345,7 +1345,7 @@ public int getFCSFileCount(User user, Container container) FlowSchema schema = new FlowSchema(user, container); // count(fcsfile) - TableInfo table = schema.getTable(FlowTableType.FCSFiles); + TableInfo table = schema.getTable(FlowTableType.FCSFiles, null); List aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT)); List columns = Collections.singletonList(table.getColumn("RowId")); @@ -1368,7 +1368,7 @@ public int getFCSFileSamplesCount(User user, Container container, boolean hasSam { FlowSchema schema = new FlowSchema(user, container); - TableInfo table = schema.getTable(FlowTableType.FCSFiles); + TableInfo table = schema.getTable(FlowTableType.FCSFiles, null); List aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT)); List columns = Collections.singletonList(table.getColumn("RowId")); SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("Sample", "Name"), null, hasSamples ? CompareType.NONBLANK : CompareType.ISBLANK); @@ -1389,7 +1389,7 @@ public int getFCSFileOnlyRunsCount(User user, Container container) SimpleFilter filter = new SimpleFilter(); filter.addCondition(FieldKey.fromParts("FCSFileCount"), 0, CompareType.NEQ); filter.addCondition(FieldKey.fromParts("ProtocolStep"), "Keywords", CompareType.EQUAL); - TableInfo table = schema.getTable(FlowTableType.Runs); + TableInfo table = schema.getTable(FlowTableType.Runs, null); List aggregates = Collections.singletonList(new Aggregate("RowId", Aggregate.BaseType.COUNT)); List columns = Collections.singletonList(table.getColumn("RowId")); Map> agg = new TableSelector(table, columns, filter, null).getAggregates(aggregates); diff --git a/flow/src/org/labkey/flow/query/AttributeForeignKey.java b/flow/src/org/labkey/flow/query/AttributeForeignKey.java index 002bcb0f3d..d462cdee21 100644 --- a/flow/src/org/labkey/flow/query/AttributeForeignKey.java +++ b/flow/src/org/labkey/flow/query/AttributeForeignKey.java @@ -18,9 +18,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; import org.labkey.api.data.*; import org.labkey.api.query.AliasManager; +import org.labkey.api.query.UserSchema; import org.labkey.flow.data.AttributeType; import org.labkey.flow.persist.AttributeCache; import org.labkey.flow.persist.FlowManager; @@ -41,12 +41,13 @@ public StringExpression getURL(ColumnInfo parent) protected Container _container; - public AttributeForeignKey(@NotNull Container c) + public AttributeForeignKey(UserSchema schema) { - _container = c; - assert _container != null; + super(schema, null); + _container = schema.getContainer(); } + @Override public TableInfo getLookupTableInfo() { VirtualTable ret = new VirtualTable(FlowManager.get().getSchema(), null) @@ -63,7 +64,7 @@ protected boolean isCaseSensitive() T attrName = entry.getAttribute(); AttributeCache.Entry preferred = entry.getAliasedEntry(); - ColumnInfo column = new ColumnInfo(new FieldKey(null, attrName.toString()), ret); + var column = new BaseColumnInfo(new FieldKey(null, attrName.toString()), ret); String alias = am.decideAlias(StringUtils.defaultString(preferred==null?null:preferred.getName(), attrName.toString())); column.setAlias(alias); initColumn(attrName, preferred, column); @@ -72,7 +73,7 @@ protected boolean isCaseSensitive() return ret; } - private void initColumn(T attrName, AttributeCache.Entry preferred, ColumnInfo column) + private void initColumn(T attrName, AttributeCache.Entry preferred, BaseColumnInfo column) { initColumn(attrName, preferred != null ? preferred.getName() : null, column); @@ -83,6 +84,7 @@ private void initColumn(T attrName, AttributeCache.Entry preferred, ColumnInfo c } } + @Override public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) { if (displayField == null) @@ -107,6 +109,6 @@ public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) abstract protected AttributeType type(); abstract protected Collection> getAttributes(); abstract protected SQLFragment sqlValue(ColumnInfo objectIdColumn, T attrName, int attrId); - abstract protected void initColumn(T attrName, String preferredName, ColumnInfo column); + abstract protected void initColumn(T attrName, String preferredName, BaseColumnInfo column); abstract protected T attributeFromString(String field); } diff --git a/flow/src/org/labkey/flow/query/BackgroundForeignKey.java b/flow/src/org/labkey/flow/query/BackgroundForeignKey.java index 99c20199d1..21f72ea353 100644 --- a/flow/src/org/labkey/flow/query/BackgroundForeignKey.java +++ b/flow/src/org/labkey/flow/query/BackgroundForeignKey.java @@ -16,6 +16,7 @@ package org.labkey.flow.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.SQLFragment; import org.labkey.api.query.ExprColumn; @@ -36,7 +37,7 @@ public class BackgroundForeignKey extends AttributeForeignKey public BackgroundForeignKey(FlowSchema schema, FlowPropertySet fps, FlowDataType type) { - super(schema.getContainer()); + super(schema); _schema = schema; _fps = fps; _type = type; @@ -48,11 +49,13 @@ protected AttributeType type() return AttributeType.statistic; } + @Override protected Collection getAttributes() { return _fps.getStatistics(); } + @Override protected StatisticSpec attributeFromString(String field) { try @@ -65,7 +68,8 @@ protected StatisticSpec attributeFromString(String field) } } - protected void initColumn(StatisticSpec stat, String preferredName, ColumnInfo column) + @Override + protected void initColumn(StatisticSpec stat, String preferredName, BaseColumnInfo column) { SubsetSpec subset = _fps.simplifySubset(stat.getSubset()); stat = new StatisticSpec(subset, stat.getStatistic(), stat.getParameter()); @@ -85,6 +89,7 @@ protected void initColumn(StatisticSpec stat, String preferredName, ColumnInfo c column.setFormat("#,##0.###"); } + @Override protected SQLFragment sqlValue(ColumnInfo objectIdColumn, StatisticSpec attrName, int attrId) { ICSMetadata ics = _schema.getProtocol().getICSMetadata(); diff --git a/flow/src/org/labkey/flow/query/BackgroundMethod.java b/flow/src/org/labkey/flow/query/BackgroundMethod.java index 7b03bd10b4..14c4d838d7 100644 --- a/flow/src/org/labkey/flow/query/BackgroundMethod.java +++ b/flow/src/org/labkey/flow/query/BackgroundMethod.java @@ -16,6 +16,7 @@ package org.labkey.flow.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.DbSchema; import org.labkey.api.data.JdbcType; @@ -36,9 +37,9 @@ public BackgroundMethod(FlowSchema schema, ColumnInfo objectIdColumn) _objectIdColumn = objectIdColumn; } - public ColumnInfo createColumnInfo(TableInfo parentTable, ColumnInfo[] arguments, String alias) + public BaseColumnInfo createColumnInfo(TableInfo parentTable, ColumnInfo[] arguments, String alias) { - ColumnInfo ret = super.createColumnInfo(parentTable, arguments, alias); + var ret = super.createColumnInfo(parentTable, arguments, alias); ret.setFormat("#,##0.###"); return ret; } diff --git a/flow/src/org/labkey/flow/query/FlowSchema.java b/flow/src/org/labkey/flow/query/FlowSchema.java index 2632e34753..b56c7ec74f 100644 --- a/flow/src/org/labkey/flow/query/FlowSchema.java +++ b/flow/src/org/labkey/flow/query/FlowSchema.java @@ -21,25 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.labkey.api.cache.CacheManager; import org.labkey.api.cache.StringKeyCache; -import org.labkey.api.data.AbstractTableInfo; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.ContainerForeignKey; -import org.labkey.api.data.ContainerManager; -import org.labkey.api.data.DataColumn; -import org.labkey.api.data.DbSchema; -import org.labkey.api.data.DisplayColumn; -import org.labkey.api.data.DisplayColumnFactory; -import org.labkey.api.data.FilterInfo; -import org.labkey.api.data.JdbcType; -import org.labkey.api.data.MaterializedQueryHelper; -import org.labkey.api.data.NullColumnInfo; -import org.labkey.api.data.RenderContext; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.Table; -import org.labkey.api.data.TableInfo; +import org.labkey.api.data.*; import org.labkey.api.exp.PropertyColumn; import org.labkey.api.exp.PropertyDescriptor; import org.labkey.api.exp.api.DataType; @@ -222,12 +204,13 @@ FlowProtocol getProtocol() return _protocol; } - public TableInfo createTable(String name) + @Override + public TableInfo createTable(String name, ContainerFilter cf) { try { FlowTableType type = FlowTableType.valueOf(name); - AbstractTableInfo table = (AbstractTableInfo)getTable(type); + AbstractTableInfo table = (AbstractTableInfo)getTable(type, cf); table.setDescription(type.getDescription()); return table; } @@ -238,24 +221,25 @@ public TableInfo createTable(String name) return null; } - public TableInfo getTable(FlowTableType type) + + public TableInfo getTable(FlowTableType type, ContainerFilter cf) { switch (type) { case FCSFiles: - return createFCSFileTable(type.toString()); + return createFCSFileTable(type.toString(), cf); case FCSAnalyses: - return createFCSAnalysisTable(type.toString(), FlowDataType.FCSAnalysis, true); + return createFCSAnalysisTable(type.toString(), cf, FlowDataType.FCSAnalysis, true); case CompensationControls: - return createCompensationControlTable(type.toString()); + return createCompensationControlTable(type.toString(), cf); case Runs: - return createRunTable(type.toString(), null); + return createRunTable(type.toString(), cf, null); case CompensationMatrices: - return createCompensationMatrixTable(type.toString()); + return createCompensationMatrixTable(type.toString(), cf); case AnalysisScripts: - return createAnalysisScriptTable(type.toString(), false); + return createAnalysisScriptTable(type.toString(), cf, false); case Analyses: - return createAnalysesTable(type.toString()); + return createAnalysesTable(type.toString(), cf); case Statistics: return createStatisticsTable(type.toString()); case Keywords: @@ -266,6 +250,7 @@ public TableInfo getTable(FlowTableType type) return null; } + @Override public Set getVisibleTableNames() { Set ret = new HashSet<>(); @@ -282,6 +267,7 @@ public QueryDefinition getQueryDef(FlowTableType qt) return getQueryDef(qt.name()); } + @Override public Set getTableNames() { Set ret = new LinkedHashSet<>(); @@ -327,6 +313,7 @@ public ActionURL urlFor(QueryAction action, FlowTableType type) return urlFor(action, getQueryDefForTable(type.name())); } + @Override public ActionURL urlFor(QueryAction action) { ActionURL ret = super.urlFor(action); @@ -334,6 +321,7 @@ public ActionURL urlFor(QueryAction action) return ret; } + @Override public ActionURL urlFor(QueryAction action, @NotNull QueryDefinition queryDef) { ActionURL ret = super.urlFor(action, queryDef); @@ -371,9 +359,9 @@ public QueryView createView(ViewContext context, QuerySettings settings, BindExc return sqlDataId; } */ - public ExpRunTable createRunTable(String alias, FlowDataType type) + public ExpRunTable createRunTable(String alias, ContainerFilter cf, FlowDataType type) { - ExpRunTable ret = ExperimentService.get().createRunTable(FlowTableType.Runs.toString(), this); + ExpRunTable ret = ExperimentService.get().createRunTable(FlowTableType.Runs.toString(), this, cf); if (_experiment != null) { @@ -395,7 +383,7 @@ public ExpRunTable createRunTable(String alias, FlowDataType type) ret.setDetailsURL(detailsURL); if (type == null || type == FlowDataType.FCSFile || type == FlowDataType.FCSAnalysis) { - ColumnInfo flag = ret.addColumn(ExpRunTable.Column.Flag); + var flag = ret.addColumn(ExpRunTable.Column.Flag); if (type != null) flag.setDescription(type.getLabel() + " Flag"); } @@ -403,11 +391,11 @@ public ExpRunTable createRunTable(String alias, FlowDataType type) ret.addColumn(ExpRunTable.Column.Created); ret.addColumn(ExpRunTable.Column.CreatedBy); - ColumnInfo containerCol = ret.addColumn(ExpRunTable.Column.Folder); + var containerCol = ret.addColumn(ExpRunTable.Column.Folder); containerCol.setHidden(true); ContainerForeignKey.initColumn(containerCol, this, null); - ColumnInfo colLSID = ret.addColumn(ExpRunTable.Column.LSID); + var colLSID = ret.addColumn(ExpRunTable.Column.LSID); colLSID.setHidden(true); ret.addColumn(ExpRunTable.Column.FilePathRoot).setHidden(true); @@ -418,43 +406,41 @@ public ExpRunTable createRunTable(String alias, FlowDataType type) ret.addColumn(ExpRunTable.Column.ProtocolStep); - ColumnInfo analysisFolder = ret.addColumn(ExpRunTable.Column.RunGroups); + var analysisFolder = ret.addColumn(ExpRunTable.Column.RunGroups); analysisFolder.setLabel("Analysis Folder"); ActionURL url = new ActionURL(RunController.ShowRunsAction.class, getContainer()).addParameter(FlowQueryView.DATAREGIONNAME_DEFAULT + ".sort", "ProtocolStep"); analysisFolder.setURL(StringExpressionFactory.create(url.getLocalURIString() + "&experimentId=${experimentId}")); if (type != FlowDataType.FCSFile) { - ColumnInfo colAnalysisScript; - colAnalysisScript = ret.addDataInputColumn("AnalysisScript", InputRole.AnalysisScript.toString()); - colAnalysisScript.setFk(new LookupForeignKey(new ActionURL(AnalysisScriptController.BeginAction.class, getContainer()), + var colAnalysisScript = ret.addDataInputColumn("AnalysisScript", InputRole.AnalysisScript.toString()); + colAnalysisScript.setFk(new LookupForeignKey(cf, new ActionURL(AnalysisScriptController.BeginAction.class, getContainer()), FlowParam.scriptId.toString(), - FlowTableType.AnalysisScripts.toString(), "RowId", "Name"){ public TableInfo getLookupTableInfo() { - return detach().createAnalysisScriptTable("Lookup", true); + return detach().createAnalysisScriptTable("Lookup", getLookupContainerFilter(), true); } }); - ColumnInfo colWorkspace = ret.addDataInputColumn("Workspace", InputRole.Workspace.toString()); - ExpDataTable workspacesTable = ExperimentService.get().createDataTable("Datas", this); + var colWorkspace = ret.addDataInputColumn("Workspace", InputRole.Workspace.toString()); + ExpDataTable workspacesTable = ExperimentService.get().createDataTable("Datas", this, cf); workspacesTable.setPublicSchemaName(ExpSchema.SCHEMA_NAME); workspacesTable.populate(); - colWorkspace.setFk(new QueryForeignKey(workspacesTable, null, "RowId", "Name")); + colWorkspace.setFk(QueryForeignKey + .from(ret.getUserSchema(), ret.getContainerFilter()) + .table(workspacesTable).key("RowId").display("Name")); colWorkspace.setHidden(true); } if (type != FlowDataType.CompensationMatrix && type != FlowDataType.FCSFile) { - ColumnInfo colCompensationMatrix; - colCompensationMatrix= ret.addDataInputColumn("CompensationMatrix", InputRole.CompensationMatrix.toString()); - colCompensationMatrix.setFk(new LookupForeignKey(null, null, - FlowTableType.CompensationMatrices.toString(), + var colCompensationMatrix= ret.addDataInputColumn("CompensationMatrix", InputRole.CompensationMatrix.toString()); + colCompensationMatrix.setFk(new LookupForeignKey(cf, "RowId", "Name") { public TableInfo getLookupTableInfo() { - return detach().createCompensationMatrixTable("Lookup"); + return detach().createCompensationMatrixTable("Lookup", getLookupContainerFilter()); } }); } @@ -522,11 +508,11 @@ class JoinFlowDataTable extends AbstractTableInfo implements ExpDataTable final String _expDataAlias; FlowPropertySet _fps; - JoinFlowDataTable(String name, FlowDataType type) + JoinFlowDataTable(String name, FlowDataType type, ContainerFilter cf) { super(getDbSchema(), name); _expDataAlias = "_expdata_"; - _expData = ExperimentService.get().createDataTable(name, FlowSchema.this); + _expData = ExperimentService.get().createDataTable(name, FlowSchema.this, cf); _flowObject = FlowManager.get().getTinfoObject(); _type = type; _fps = new FlowPropertySet(_expData); @@ -534,8 +520,8 @@ class JoinFlowDataTable extends AbstractTableInfo implements ExpDataTable ColumnInfo addStatisticColumn(String columnAlias) { - ColumnInfo colStatistic = addObjectIdColumn(columnAlias); - colStatistic.setFk(new StatisticForeignKey(getContainer(), _fps, _type)); + var colStatistic = addObjectIdColumn(columnAlias); + colStatistic.setFk(new StatisticForeignKey(FlowSchema.this, _fps, _type)); colStatistic.setIsUnselectable(true); addMethod(columnAlias, new StatisticMethod(getContainer(), colStatistic)); return colStatistic; @@ -543,7 +529,7 @@ ColumnInfo addStatisticColumn(String columnAlias) ColumnInfo addKeywordColumn(String columnAlias) { - ColumnInfo colKeyword = addObjectIdColumn(columnAlias); + var colKeyword = addObjectIdColumn(columnAlias); colKeyword.setFk(new KeywordForeignKey(FlowSchema.this, _fps)); colKeyword.setIsUnselectable(true); addMethod("Keyword", new KeywordMethod(getContainer(), colKeyword)); @@ -552,15 +538,15 @@ ColumnInfo addKeywordColumn(String columnAlias) ColumnInfo addGraphColumn(String columnAlias) { - ColumnInfo colGraph = addObjectIdColumn(columnAlias); - colGraph.setFk(new GraphForeignKey(getContainer(), _fps)); + var colGraph = addObjectIdColumn(columnAlias); + colGraph.setFk(new GraphForeignKey(FlowSchema.this, _fps)); colGraph.setIsUnselectable(true); return colGraph; } - ColumnInfo addObjectIdColumn(String name) + BaseColumnInfo addObjectIdColumn(String name) { - ColumnInfo underlyingColumn = _flowObject.getColumn("rowid"); + BaseColumnInfo underlyingColumn = (BaseColumnInfo)_flowObject.getColumn("rowid"); ExprColumn ret = new ExprColumn(this, name, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".objectid"), underlyingColumn.getJdbcType()); ret.copyAttributesFrom(underlyingColumn); addColumn(ret); @@ -579,7 +565,7 @@ public void addAllowablePermission(Class permission) _expData.addAllowablePermission(permission); } - ColumnInfo addExpColumn(ColumnInfo underlyingColumn) + BaseColumnInfo addExpColumn(@NotNull ColumnInfo underlyingColumn) { ExprColumn ret = new ExprColumn(this, underlyingColumn.getAlias(), underlyingColumn.getValueSql(ExprColumn.STR_TABLE_ALIAS), underlyingColumn.getJdbcType()); ret.copyAttributesFrom(underlyingColumn); @@ -630,6 +616,7 @@ public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class ret, ColumnInfo lookupColum for (Map.Entry entry : lookupTable.getExtendedColumns(includeHidden).entrySet()) { FieldKey fieldKey = entry.getKey(); - ColumnInfo col = entry.getValue(); + BaseColumnInfo col = (BaseColumnInfo)entry.getValue(); // Add the lookup column FieldKey as a parent to the column's FieldKey FieldKey newFieldKey = FieldKey.remap(fieldKey, lookupColumn.getFieldKey(), null); col.setFieldKey(newFieldKey); @@ -1328,20 +1360,20 @@ protected ColumnInfo resolveColumn(String name) public class FlowDataTable extends FastFlowDataTable { - FlowDataTable(String name, FlowDataType type) + FlowDataTable(String name, FlowDataType type, ContainerFilter cf) { - super(name, type); + super(name, type, cf); } } - public FlowDataTable createDataTable(String name, final FlowDataType type) + public FlowDataTable createDataTable(String name, final FlowDataType type, ContainerFilter cf) { - FlowDataTable ret = new FlowDataTable(name, type); + FlowDataTable ret = new FlowDataTable(name, type, cf); ret.addColumn(ExpDataTable.Column.Name); ret.addColumn(ExpDataTable.Column.RowId).setHidden(true); ret.addColumn(ExpDataTable.Column.LSID).setHidden(true); - ColumnInfo flag = ret.addColumn(ExpDataTable.Column.Flag); + var flag = ret.addColumn(ExpDataTable.Column.Flag); if (type != null) flag.setDescription(type.getLabel() + " Flag"); @@ -1349,18 +1381,18 @@ public FlowDataTable createDataTable(String name, final FlowDataType type) ret.addColumn(ExpDataTable.Column.CreatedBy).setHidden(true); ret.setTitleColumn("Name"); - ColumnInfo sourceProtocolApplication = ret.addColumn(ExpDataTable.Column.SourceProtocolApplication); + var sourceProtocolApplication = ret.addColumn(ExpDataTable.Column.SourceProtocolApplication); sourceProtocolApplication.setHidden(true); - ColumnInfo protocol = ret.addColumn(ExpDataTable.Column.Protocol); + var protocol = ret.addColumn(ExpDataTable.Column.Protocol); protocol.setHidden(true); - ColumnInfo colRun = ret.addColumn(ExpDataTable.Column.Run); - colRun.setFk(new LookupForeignKey(new ActionURL(RunController.ShowRunAction.class, getContainer()), FlowParam.runId, "RowId", "Name") + var colRun = ret.addColumn(ExpDataTable.Column.Run); + colRun.setFk(new LookupForeignKey(cf, new ActionURL(RunController.ShowRunAction.class, getContainer()), FlowParam.runId, "RowId", "Name") { public TableInfo getLookupTableInfo() { - return detach().createRunTable("run", type); + return detach().createRunTable("run", getLookupContainerFilter(), type); } }); if (_experiment != null) @@ -1472,15 +1504,15 @@ public Iterator iterator() } - public FlowDataTable createFCSFileTable(String name) + public FlowDataTable createFCSFileTable(String name, ContainerFilter cf) { - return createFCSFileTable(name, true); + return createFCSFileTable(name, cf, true); } - public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFromFCSFileTable) + public FlowDataTable createFCSFileTable(String name, ContainerFilter cf, boolean specimenRelativeFromFCSFileTable) { - final FlowDataTable ret = createDataTable(name, FlowDataType.FCSFile); - ret.getColumn(ExpDataTable.Column.Name).setURL(new DetailsURL(new ActionURL(WellController.ShowWellAction.class, getContainer()), Collections.singletonMap(FlowParam.wellId.toString(), ExpDataTable.Column.RowId.toString()))); + final FlowDataTable ret = createDataTable(name, FlowDataType.FCSFile, cf); + ret.getMutableColumn(ExpDataTable.Column.Name).setURL(new DetailsURL(new ActionURL(WellController.ShowWellAction.class, getContainer()), Collections.singletonMap(FlowParam.wellId.toString(), ExpDataTable.Column.RowId.toString()))); ret.setDetailsURL(new DetailsURL(new ActionURL(WellController.ShowWellAction.class, getContainer()), Collections.singletonMap(FlowParam.wellId.toString(), ExpDataTable.Column.RowId.toString()))); final ColumnInfo colKeyword = ret.addKeywordColumn("Keyword"); ExpSampleSet ss = null; @@ -1488,7 +1520,7 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro { ss = _protocol.getSampleSet(); } - ColumnInfo colMaterialInput = ret.addMaterialInputColumn("Sample", new SamplesSchema(getUser(), getContainer()), ExpMaterialRunInput.DEFAULT_ROLE, ss); + var colMaterialInput = ret.addMaterialInputColumn("Sample", new SamplesSchema(getUser(), getContainer()), ExpMaterialRunInput.DEFAULT_ROLE, ss); if (ss == null) { colMaterialInput.setHidden(true); @@ -1499,7 +1531,7 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro FieldKey specimenIdFieldKey = metadata != null ? removeParent(metadata.getSpecimenIdColumn(), FCSFILE_NAME) : null; if (specimenIdFieldKey != null) { - ColumnInfo colSpecimen = new FCSFileCoalescingColumn(ret, SPECIMENID_FIELDKEY, JdbcType.VARCHAR, metadata, true); + var colSpecimen = new FCSFileCoalescingColumn(ret, SPECIMENID_FIELDKEY, JdbcType.VARCHAR, metadata, true); ret.addColumn(colSpecimen); ExpProtocol protocol = getProtocol().getProtocol(); @@ -1511,7 +1543,7 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro } else { - ColumnInfo colSpecimen = new NullColumnInfo(ret, SPECIMENID_FIELDKEY, JdbcType.VARCHAR); + var colSpecimen = new NullColumnInfo(ret, SPECIMENID_FIELDKEY, JdbcType.VARCHAR); colSpecimen.setHidden(true); ret.addColumn(colSpecimen); } @@ -1521,13 +1553,13 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro FieldKey participantFieldKey = metadata != null ? removeParent(metadata.getParticipantColumn(), FCSFILE_NAME) : null; if (participantFieldKey != null) { - ColumnInfo col = new FCSFileCoalescingColumn(ret, PARTICIPANTID_FIELDKEY, JdbcType.VARCHAR, metadata, true); + var col = new FCSFileCoalescingColumn(ret, PARTICIPANTID_FIELDKEY, JdbcType.VARCHAR, metadata, true); ret.addColumn(col); // XXX: PTID ForeignKey ? } else { - ColumnInfo col = new NullColumnInfo(ret, PARTICIPANTID_FIELDKEY, JdbcType.VARCHAR); + var col = new NullColumnInfo(ret, PARTICIPANTID_FIELDKEY, JdbcType.VARCHAR); col.setHidden(true); ret.addColumn(col); } @@ -1536,13 +1568,13 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro FieldKey visitIdFieldKey = metadata != null ? removeParent(metadata.getVisitColumn(), FCSFILE_NAME) : null; if (visitIdFieldKey != null) { - ColumnInfo col = new FCSFileCoalescingColumn(ret, VISITID_FIELDKEY, JdbcType.DOUBLE, metadata, true); + var col = new FCSFileCoalescingColumn(ret, VISITID_FIELDKEY, JdbcType.DOUBLE, metadata, true); ret.addColumn(col); // XXX: PTID/Visit ForeignKey ? } else { - ColumnInfo col = new NullColumnInfo(ret, VISITID_FIELDKEY, JdbcType.VARCHAR); + var col = new NullColumnInfo(ret, VISITID_FIELDKEY, JdbcType.VARCHAR); col.setHidden(true); ret.addColumn(col); } @@ -1551,20 +1583,20 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro FieldKey dateFieldKey = metadata != null ? removeParent(metadata.getDateColumn(), FCSFILE_NAME) : null; if (dateFieldKey != null) { - ColumnInfo col = new FCSFileCoalescingColumn(ret, DATE_FIELDKEY, JdbcType.DOUBLE, metadata, true); + var col = new FCSFileCoalescingColumn(ret, DATE_FIELDKEY, JdbcType.DOUBLE, metadata, true); ret.addColumn(col); // XXX: PTID/Date ForeignKey ? } else { - ColumnInfo col = new NullColumnInfo(ret, DATE_FIELDKEY, JdbcType.DATE); + var col = new NullColumnInfo(ret, DATE_FIELDKEY, JdbcType.DATE); col.setHidden(true); ret.addColumn(col); } // TargetStudy { - ColumnInfo colTargetStudy = new FCSFileCoalescingColumn(ret, TARGET_STUDY_FIELDKEY, JdbcType.DOUBLE, metadata, true); + var colTargetStudy = new FCSFileCoalescingColumn(ret, TARGET_STUDY_FIELDKEY, JdbcType.DOUBLE, metadata, true); colTargetStudy.setLabel(AbstractAssayProvider.TARGET_STUDY_PROPERTY_CAPTION); colTargetStudy.setDisplayColumnFactory(_targetStudyDisplayColumnFactory); colTargetStudy.setHidden(true); @@ -1585,22 +1617,22 @@ public FlowDataTable createFCSFileTable(String name, boolean specimenRelativeFro colHasFile.setHidden(true); // Original input FCSFile (the FCSFile marked as a DataInput of this FCSFile) - ColumnInfo colFCSFile = new ExprColumn(ret, ORIGINAL_FCSFILE_FIELDKEY, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".fcsid"), JdbcType.INTEGER); + var colFCSFile = new ExprColumn(ret, ORIGINAL_FCSFILE_FIELDKEY, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".fcsid"), JdbcType.INTEGER); ret.addColumn(colFCSFile); colFCSFile.setHidden(true); - colFCSFile.setFk(new LookupForeignKey(new ActionURL(WellController.ShowWellAction.class, getContainer()), + colFCSFile.setFk(new LookupForeignKey(cf, new ActionURL(WellController.ShowWellAction.class, getContainer()), FlowParam.wellId.toString(), "RowId", "Name") { public TableInfo getLookupTableInfo() { - return detach().createFCSFileTable("FCSFile"); + return detach().createFCSFileTable("FCSFile", getLookupContainerFilter()); } }); // UNDONE: Ideally we should add a column to flow.object to idenfity these wells. // Returns true if this is an original FlowFCSFile (not a 'fake' FCSFile created by importing a FlowJo workspace) - ColumnInfo colOriginal = new ExprColumn(ret, "Original", new SQLFragment("(CASE WHEN " + ExprColumn.STR_TABLE_ALIAS + ".datafileurl NOT LIKE '%/attributes.flowdata.xml' THEN " + bTRUE + " ELSE " + bFALSE + " END)"), JdbcType.BOOLEAN); + var colOriginal = new ExprColumn(ret, "Original", new SQLFragment("(CASE WHEN " + ExprColumn.STR_TABLE_ALIAS + ".datafileurl NOT LIKE '%/attributes.flowdata.xml' THEN " + bTRUE + " ELSE " + bFALSE + " END)"), JdbcType.BOOLEAN); ret.addColumn(colOriginal); colOriginal.setHidden(true); @@ -1617,52 +1649,52 @@ public TableInfo getLookupTableInfo() } - public ExpDataTable createFCSAnalysisTable(String alias, FlowDataType type, boolean includeCopiedToStudyColumns) + public ExpDataTable createFCSAnalysisTable(String alias, ContainerFilter cf, FlowDataType type, boolean includeCopiedToStudyColumns) { - FlowDataTable ret = createDataTable(alias, type); + FlowDataTable ret = createDataTable(alias, type, cf); - ColumnInfo colAnalysisScript = new ExprColumn(ret, "AnalysisScript", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".scriptid"), JdbcType.INTEGER); + var colAnalysisScript = new ExprColumn(ret, "AnalysisScript", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".scriptid"), JdbcType.INTEGER); ret.addColumn(colAnalysisScript); - colAnalysisScript.setFk(new LookupForeignKey(new ActionURL(AnalysisScriptController.BeginAction.class, getContainer()), + colAnalysisScript.setFk(new LookupForeignKey(cf, new ActionURL(AnalysisScriptController.BeginAction.class, getContainer()), FlowParam.scriptId.toString(), "RowId", "Name"){ public TableInfo getLookupTableInfo() { - return detach().createAnalysisScriptTable("Lookup", true); + return detach().createAnalysisScriptTable("Lookup", getLookupContainerFilter(), true); } }); - ColumnInfo colCompensationMatrix = new ExprColumn(ret, "CompensationMatrix", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".compid"), JdbcType.INTEGER); + var colCompensationMatrix = new ExprColumn(ret, "CompensationMatrix", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".compid"), JdbcType.INTEGER); ret.addColumn(colCompensationMatrix); - colCompensationMatrix.setFk(new LookupForeignKey(new ActionURL(CompensationController.ShowCompensationAction.class, getContainer()), FlowParam.compId.toString(), + colCompensationMatrix.setFk(new LookupForeignKey(cf, new ActionURL(CompensationController.ShowCompensationAction.class, getContainer()), FlowParam.compId.toString(), "RowId", "Name"){ public TableInfo getLookupTableInfo() { - return detach().createCompensationMatrixTable("Lookup"); + return detach().createCompensationMatrixTable("Lookup", getLookupContainerFilter()); } }); DetailsURL detailsURL = new DetailsURL(new ActionURL(WellController.ShowWellAction.class, getContainer()), Collections.singletonMap(FlowParam.wellId.toString(), ExpDataTable.Column.RowId.toString())); - ret.getColumn(ExpDataTable.Column.Name).setURL(detailsURL); + ret.getMutableColumn(ExpDataTable.Column.Name).setURL(detailsURL); ret.setDetailsURL(detailsURL); if (getExperiment() != null) { ret.setExperiment(ExperimentService.get().getExpExperiment(getExperiment().getLSID())); } - ColumnInfo colStatistic = ret.addStatisticColumn("Statistic"); + var colStatistic = ret.addStatisticColumn("Statistic"); - ColumnInfo colBackground = ret.addBackgroundColumn("Background"); + var colBackground = ret.addBackgroundColumn("Background"); - ColumnInfo colGraph = ret.addGraphColumn("Graph"); + var colGraph = ret.addGraphColumn("Graph"); - ColumnInfo colFCSFile = new ExprColumn(ret, FCSFILE_FIELDKEY, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".fcsid"), JdbcType.INTEGER); + var colFCSFile = new ExprColumn(ret, FCSFILE_FIELDKEY, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".fcsid"), JdbcType.INTEGER); ret.addColumn(colFCSFile); - colFCSFile.setFk(new LookupForeignKey(new ActionURL(WellController.ShowWellAction.class, getContainer()), + colFCSFile.setFk(new LookupForeignKey(cf, new ActionURL(WellController.ShowWellAction.class, getContainer()), FlowParam.wellId.toString(), "RowId", "Name") { public TableInfo getLookupTableInfo() { - return detach().createFCSFileTable("FCSFile", false); + return detach().createFCSFileTable("FCSFile", getLookupContainerFilter(),false); } }); @@ -1733,9 +1765,9 @@ public static FieldKey removeParent(FieldKey fieldKey, String rootPart) } - public ExpDataTable createCompensationControlTable(String alias) + public ExpDataTable createCompensationControlTable(String alias, ContainerFilter cf) { - ExpDataTable ret = createFCSAnalysisTable(alias, FlowDataType.CompensationControl, false); + ExpDataTable ret = createFCSAnalysisTable(alias, cf, FlowDataType.CompensationControl, false); List defColumns = new ArrayList<>(ret.getDefaultVisibleColumns()); defColumns.add(FieldKey.fromParts("Statistic", new StatisticSpec(FCSAnalyzer.compSubset, StatisticSpec.STAT.Count, null).toString())); defColumns.add(FieldKey.fromParts("Statistic", new StatisticSpec(FCSAnalyzer.compSubset, StatisticSpec.STAT.Freq_Of_Parent, null).toString())); @@ -1743,35 +1775,35 @@ public ExpDataTable createCompensationControlTable(String alias) return ret; } - public FlowDataTable createCompensationMatrixTable(String alias) + public FlowDataTable createCompensationMatrixTable(String alias, ContainerFilter cf) { - FlowDataTable ret = createDataTable(alias, FlowDataType.CompensationMatrix); + FlowDataTable ret = createDataTable(alias, FlowDataType.CompensationMatrix, cf); if (getExperiment() != null) { ret.setExperiment(ExperimentService.get().getExpExperiment(getExperiment().getLSID())); } DetailsURL detailsURL = new DetailsURL(new ActionURL(CompensationController.ShowCompensationAction.class, getContainer()), Collections.singletonMap(FlowParam.compId.toString(), ExpDataTable.Column.RowId.toString())); ret.setDetailsURL(detailsURL); - ret.getColumn(ExpDataTable.Column.Name).setURL(detailsURL); + ret.getMutableColumn(ExpDataTable.Column.Name).setURL(detailsURL); ret.addStatisticColumn("Value"); // Only add download column -- the file column will always be blank ret.addDownloadColumn(); return ret; } - public FlowDataTable createAnalysisScriptTable(String alias, boolean includePrivate) + public FlowDataTable createAnalysisScriptTable(String alias, ContainerFilter cf, boolean includePrivate) { - FlowDataTable ret = createDataTable(alias, FlowDataType.Script); + FlowDataTable ret = createDataTable(alias, FlowDataType.Script, cf); if (!includePrivate) { SQLFragment runIdCondition = new SQLFragment("RunId IS NULL"); ret.addCondition(runIdCondition); } ret.addInputRunCountColumn("RunCount"); - ret.getColumn(ExpDataTable.Column.Run.toString()).setHidden(true); + ret.getMutableColumn(ExpDataTable.Column.Run.toString()).setHidden(true); DetailsURL detailsURL = new DetailsURL(new ActionURL(AnalysisScriptController.BeginAction.class, getContainer()), Collections.singletonMap(FlowParam.scriptId.toString(), "RowId")); ret.setDetailsURL(detailsURL); - ret.getColumn(ExpDataTable.Column.Name).setURL(detailsURL); + ret.getMutableColumn(ExpDataTable.Column.Name).setURL(detailsURL); ret.addFileColumn("File"); // Similar to 'ExpDataTable.Column.DataFileUrl' except uses the flow.object.uri column @@ -1781,21 +1813,21 @@ public FlowDataTable createAnalysisScriptTable(String alias, boolean includePriv return ret; } - public FlowDataTable createWorkspaceTable(String alias) + public FlowDataTable createWorkspaceTable(String alias, ContainerFilter cf) { - FlowDataTable ret = createDataTable(alias, FlowDataType.Workspace); + FlowDataTable ret = createDataTable(alias, FlowDataType.Workspace, cf); return ret; } - public ExpExperimentTable createAnalysesTable(String name) + public ExpExperimentTable createAnalysesTable(String name, ContainerFilter cf) { - ExpExperimentTable ret = ExperimentService.get().createExperimentTable(name, new ExpSchema(getUser(), getContainer())); + ExpExperimentTable ret = ExperimentService.get().createExperimentTable(name, new ExpSchema(getUser(), getContainer()), cf); ret.populate(); FlowProtocol compensationProtocol = FlowProtocolStep.calculateCompensation.getForContainer(getContainer()); FlowProtocol analysisProtocol = FlowProtocolStep.analysis.getForContainer(getContainer()); if (compensationProtocol != null) { - ColumnInfo colCompensationCount = ret.createRunCountColumn("CompensationRunCount", null, compensationProtocol.getProtocol()); + var colCompensationCount = ret.createRunCountColumn("CompensationRunCount", null, compensationProtocol.getProtocol()); ActionURL detailsURL = FlowTableType.Runs.urlFor(getUser(), getContainer(), "ProtocolStep", FlowProtocolStep.calculateCompensation.getName()); detailsURL.addParameter(FlowParam.experimentId, "${RowId}"); colCompensationCount.setURL(StringExpressionFactory.createURL(detailsURL)); @@ -1803,7 +1835,7 @@ public ExpExperimentTable createAnalysesTable(String name) } if (analysisProtocol != null) { - ColumnInfo colAnalysisRunCount = ret.createRunCountColumn("AnalysisRunCount", null, analysisProtocol.getProtocol()); + var colAnalysisRunCount = ret.createRunCountColumn("AnalysisRunCount", null, analysisProtocol.getProtocol()); ActionURL detailsURL = FlowTableType.Runs.urlFor(getUser(), getContainer(), "ProtocolStep", FlowProtocolStep.analysis.getName()); detailsURL.addParameter(FlowParam.experimentId, "${RowId}"); colAnalysisRunCount.setURL(StringExpressionFactory.createURL(detailsURL)); @@ -1813,7 +1845,7 @@ public ExpExperimentTable createAnalysesTable(String name) DetailsURL detailsUrl = new DetailsURL(new ActionURL(RunController.ShowRunsAction.class, getContainer()).addParameter(FlowQueryView.DATAREGIONNAME_DEFAULT + ".sort", "ProtocolStep"), Collections.singletonMap(FlowParam.experimentId.toString(), ExpExperimentTable.Column.RowId.toString())); ret.setDetailsURL(detailsUrl); - ret.getColumn(ExpExperimentTable.Column.Name).setURL(detailsUrl); + ret.getMutableColumn(ExpExperimentTable.Column.Name).setURL(detailsUrl); SQLFragment lsidCondition = new SQLFragment("LSID <> "); lsidCondition.appendStringLiteral(FlowExperiment.getExperimentRunExperimentLSID(getContainer())); ret.addCondition(lsidCondition); diff --git a/flow/src/org/labkey/flow/query/GraphForeignKey.java b/flow/src/org/labkey/flow/query/GraphForeignKey.java index 0f0f36c939..793fa12c71 100644 --- a/flow/src/org/labkey/flow/query/GraphForeignKey.java +++ b/flow/src/org/labkey/flow/query/GraphForeignKey.java @@ -16,8 +16,8 @@ package org.labkey.flow.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.Container; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.dialect.SqlDialect; import org.labkey.api.query.ExprColumn; @@ -33,9 +33,9 @@ public class GraphForeignKey extends AttributeForeignKey { FlowPropertySet _fps; - public GraphForeignKey(Container c, FlowPropertySet fps) + public GraphForeignKey(FlowSchema schema, FlowPropertySet fps) { - super(c); + super(schema); _fps = fps; } @@ -62,7 +62,7 @@ protected GraphSpec attributeFromString(String field) } } - protected void initColumn(final GraphSpec spec, String preferredName, ColumnInfo column) + protected void initColumn(final GraphSpec spec, String preferredName, BaseColumnInfo column) { column.setSqlTypeName("VARCHAR"); SubsetSpec subset = _fps.simplifySubset(spec.getSubset()); diff --git a/flow/src/org/labkey/flow/query/KeywordForeignKey.java b/flow/src/org/labkey/flow/query/KeywordForeignKey.java index 6b7f6a9be6..5174b430d2 100644 --- a/flow/src/org/labkey/flow/query/KeywordForeignKey.java +++ b/flow/src/org/labkey/flow/query/KeywordForeignKey.java @@ -16,21 +16,16 @@ package org.labkey.flow.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.SQLFragment; -import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.query.ExprColumn; -import org.labkey.api.study.assay.AssayProtocolSchema; -import org.labkey.api.study.assay.AssayProvider; -import org.labkey.api.study.assay.AssayService; import org.labkey.api.study.assay.SpecimenForeignKey; import org.labkey.flow.data.AttributeType; -import org.labkey.flow.data.ICSMetadata; import org.labkey.flow.persist.AttributeCache; import org.labkey.flow.util.KeywordUtil; import java.util.Collection; -import java.util.Map; public class KeywordForeignKey extends AttributeForeignKey { @@ -40,7 +35,7 @@ public class KeywordForeignKey extends AttributeForeignKey public KeywordForeignKey(FlowSchema schema, FlowPropertySet fps) { - super(schema.getContainer()); + super(schema); _schema = schema; _fps = fps; } @@ -51,17 +46,20 @@ protected AttributeType type() return AttributeType.keyword; } + @Override protected String attributeFromString(String field) { return field; } + @Override protected Collection getAttributes() { return _fps.getKeywordProperties(); } - protected void initColumn(String attrName, String preferredName, ColumnInfo column) + @Override + protected void initColumn(String attrName, String preferredName, BaseColumnInfo column) { column.setSqlTypeName("VARCHAR"); column.setLabel(attrName); @@ -74,6 +72,7 @@ protected void initColumn(String attrName, String preferredName, ColumnInfo colu column.setMeasure(false); } + @Override protected SQLFragment sqlValue(ColumnInfo objectIdColumn, String attrName, int attrId) { // SQL server 2000 does not allow a TEXT column (i.e. flow.keyword.value) to appear in this subquery. diff --git a/flow/src/org/labkey/flow/query/StatisticForeignKey.java b/flow/src/org/labkey/flow/query/StatisticForeignKey.java index 38a9933fa1..fa4bfb6ffc 100644 --- a/flow/src/org/labkey/flow/query/StatisticForeignKey.java +++ b/flow/src/org/labkey/flow/query/StatisticForeignKey.java @@ -16,6 +16,7 @@ package org.labkey.flow.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.SQLFragment; @@ -33,9 +34,9 @@ public class StatisticForeignKey extends AttributeForeignKey FlowPropertySet _fps; FlowDataType _type; - public StatisticForeignKey(Container c, FlowPropertySet fps, FlowDataType type) + public StatisticForeignKey(FlowSchema schema, FlowPropertySet fps, FlowDataType type) { - super(c); + super(schema); _fps = fps; _type = type; } @@ -63,7 +64,7 @@ protected StatisticSpec attributeFromString(String field) } } - protected void initColumn(StatisticSpec stat, String preferredName, ColumnInfo column) + protected void initColumn(StatisticSpec stat, String preferredName, BaseColumnInfo column) { SubsetSpec subset = _fps.simplifySubset(stat.getSubset()); stat = new StatisticSpec(subset, stat.getStatistic(), stat.getParameter()); diff --git a/flow/src/org/labkey/flow/query/StatisticMethod.java b/flow/src/org/labkey/flow/query/StatisticMethod.java index 1039675f5d..20d0234255 100644 --- a/flow/src/org/labkey/flow/query/StatisticMethod.java +++ b/flow/src/org/labkey/flow/query/StatisticMethod.java @@ -17,6 +17,7 @@ package org.labkey.flow.query; import org.jetbrains.annotations.NotNull; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.DbSchema; @@ -37,9 +38,9 @@ public StatisticMethod(@NotNull Container c, ColumnInfo objectIdColumn) _objectIdColumn = objectIdColumn; } - public ColumnInfo createColumnInfo(TableInfo parentTable, ColumnInfo[] arguments, String alias) + public BaseColumnInfo createColumnInfo(TableInfo parentTable, ColumnInfo[] arguments, String alias) { - ColumnInfo ret = super.createColumnInfo(parentTable, arguments, alias); + var ret = super.createColumnInfo(parentTable, arguments, alias); ret.setFormat("#,##0.###"); return ret; } diff --git a/luminex/src/org/labkey/luminex/LuminexDataHandler.java b/luminex/src/org/labkey/luminex/LuminexDataHandler.java index 9d78eb959d..982f1a2d5b 100644 --- a/luminex/src/org/labkey/luminex/LuminexDataHandler.java +++ b/luminex/src/org/labkey/luminex/LuminexDataHandler.java @@ -519,8 +519,8 @@ else if (col.getName().equals(NEGATIVE_BEAD_COLUMN_NAME)) private void saveDataRows(ExpRun expRun, User user, ExpProtocol protocol, Map> rows, List dataIds) throws SQLException, ValidationException { - // Do a query to find all of the rows that have already been inserted - LuminexDataTable tableInfo = ((LuminexProtocolSchema)AssayService.get().getProvider(protocol).createProtocolSchema(user, expRun.getContainer(), protocol, null)).createDataTable(false); + // Do a query to find all of the rows that have already been inserted + LuminexDataTable tableInfo = ((LuminexProtocolSchema)AssayService.get().getProvider(protocol).createProtocolSchema(user, expRun.getContainer(), protocol, null)).createDataTable(null, false); SimpleFilter filter = new SimpleFilter(new SimpleFilter.InClause(FieldKey.fromParts("Data"), dataIds)); Map existingRows = new HashMap<>(); @@ -815,7 +815,7 @@ public static void insertOrUpdateAnalyteSinglePointControlQCFlags(User user, Exp LuminexProtocolSchema schema = new LuminexProtocolSchema(user, expRun.getContainer(), (LuminexAssayProvider)provider, protocol, null); // query the QC Flags table to get any existing analyte/titration QC Flags - ExpQCFlagTable qcFlagTable = schema.createAnalyteSinglePointControlQCFlagTable(); + ExpQCFlagTable qcFlagTable = schema.createAnalyteSinglePointControlQCFlagTable(null); SimpleFilter analyteSinglePointControlFilter = new SimpleFilter(FieldKey.fromParts("Analyte"), analyte.getRowId()); analyteSinglePointControlFilter.addCondition(FieldKey.fromParts("SinglePointControl"), singlePointControl.getRowId()); List existingQCFlags = new TableSelector(qcFlagTable, analyteSinglePointControlFilter, null).getArrayList(AnalyteSinglePointControlQCFlag.class); @@ -824,7 +824,7 @@ public static void insertOrUpdateAnalyteSinglePointControlQCFlags(User user, Exp if (null != analyteSinglePointControl.getGuideSetId()) { - GuideSetTable guideSetTable = schema.createGuideSetTable(false); + GuideSetTable guideSetTable = schema.createGuideSetTable(null,false); GuideSet guideSetRow = new TableSelector(guideSetTable).getObject(analyteSinglePointControl.getGuideSetId(), GuideSet.class); if (guideSetRow == null) @@ -1456,7 +1456,7 @@ public static void insertOrUpdateAnalyteTitrationQCFlags(User user, ExpRun expRu LuminexProtocolSchema schema = new LuminexProtocolSchema(user, expRun.getContainer(), (LuminexAssayProvider)provider, protocol, null); // query the QC Flags table to get any existing analyte/titration QC Flags - ExpQCFlagTable qcFlagTable = schema.createAnalyteTitrationQCFlagTable(); + ExpQCFlagTable qcFlagTable = schema.createAnalyteTitrationQCFlagTable(null); SimpleFilter analyteTitrationFilter = new SimpleFilter(FieldKey.fromParts("Analyte"), analyte.getRowId()); analyteTitrationFilter.addCondition(FieldKey.fromParts("Titration"), titration.getRowId()); List existingAnalyteTitrationQCFlags = new TableSelector(qcFlagTable, analyteTitrationFilter, null).getArrayList(AnalyteTitrationQCFlag.class); @@ -1466,7 +1466,7 @@ public static void insertOrUpdateAnalyteTitrationQCFlags(User user, ExpRun expRu if (null != analyteTitration.getGuideSetId()) { // query the guide set table to get the average and stddev values for the out of guide set range comparisons - GuideSetTable guideSetTable = schema.createGuideSetTable(false); + GuideSetTable guideSetTable = schema.createGuideSetTable(null,false); GuideSet guideSetRow = new TableSelector(guideSetTable).getObject(analyteTitration.getGuideSetId(), GuideSet.class); if (guideSetRow == null) diff --git a/luminex/src/org/labkey/luminex/LuminexManager.java b/luminex/src/org/labkey/luminex/LuminexManager.java index 38cd747fa3..e8da0ac13b 100644 --- a/luminex/src/org/labkey/luminex/LuminexManager.java +++ b/luminex/src/org/labkey/luminex/LuminexManager.java @@ -665,7 +665,7 @@ private Set getWellKeysForRun(Integer runId, ExpProtocol protocol, Conta throw new NotFoundException("Luminex assay provider not found"); LuminexProtocolSchema schema = new LuminexProtocolSchema(user, container, (LuminexAssayProvider)provider, protocol, null); - LuminexDataTable table = new LuminexDataTable(schema); + LuminexDataTable table = new LuminexDataTable(schema, null); // data file, analyte, description, dilution, and type are needed to match an existing exclusion to data from an Excel file row FieldKey readerSerialNumberFK = FieldKey.fromParts("Data", "ReaderSerialNumber"); diff --git a/luminex/src/org/labkey/luminex/LuminexUnitTestContext.java b/luminex/src/org/labkey/luminex/LuminexUnitTestContext.java index f72da55b19..b46a014666 100644 --- a/luminex/src/org/labkey/luminex/LuminexUnitTestContext.java +++ b/luminex/src/org/labkey/luminex/LuminexUnitTestContext.java @@ -20,6 +20,7 @@ import org.jmock.Expectations; import org.jmock.Mockery; import org.jmock.lib.legacy.ClassImposteriser; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.exp.ExperimentException; import org.labkey.api.exp.api.ExpProtocol; @@ -196,9 +197,9 @@ public Map getRunProperties() public Map getAnalyteColumnProperties(String analyteName) { Map ret = new HashMap<>(); - ColumnInfo item = new ColumnInfo("PositivityThreshold"); + ColumnInfo item = new BaseColumnInfo("PositivityThreshold"); ret.put(item, "50.0"); - ColumnInfo item2 = new ColumnInfo("NegativeBead"); + ColumnInfo item2 = new BaseColumnInfo("NegativeBead"); ret.put(item2, "Blank (3)"); return ret; diff --git a/luminex/src/org/labkey/luminex/LuminexUploadWizardAction.java b/luminex/src/org/labkey/luminex/LuminexUploadWizardAction.java index e6ba5eabb4..1cfe33adef 100644 --- a/luminex/src/org/labkey/luminex/LuminexUploadWizardAction.java +++ b/luminex/src/org/labkey/luminex/LuminexUploadWizardAction.java @@ -22,6 +22,7 @@ import org.labkey.api.action.SpringActionController; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.data.ActionButton; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ButtonBar; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.DataColumn; @@ -200,7 +201,7 @@ private ModelAndView getAnalytesView(String[] analyteNames, final LuminexRunUplo { view.setInitialValue(inputName, analyteDefaultValue); - ColumnInfo info = analyteDP.getPropertyDescriptor().createColumnInfo(view.getDataRegion().getTable(), lsidColumn, getUser(), getContainer()); + var info = analyteDP.getPropertyDescriptor().createColumnInfo(view.getDataRegion().getTable(), lsidColumn, getUser(), getContainer()); info.setName(inputName); info.setDisplayColumnFactory(colInfo -> new DataColumn(colInfo) { @@ -248,7 +249,7 @@ else if (analyteDefaultValue != null) List negativeBeadCols = new ArrayList<>(); for (String analyte : analyteNames) { - ColumnInfo info = new ColumnInfo(LuminexProtocolSchema.getTableInfoAnalytes().getColumn(LuminexDataHandler.NEGATIVE_BEAD_COLUMN_NAME), view.getDataRegion().getTable()); + var info = new BaseColumnInfo(LuminexProtocolSchema.getTableInfoAnalytes().getColumn(LuminexDataHandler.NEGATIVE_BEAD_COLUMN_NAME), view.getDataRegion().getTable()); String inputName = AnalyteDefaultValueService.getAnalytePropertyName(analyte, LuminexDataHandler.NEGATIVE_BEAD_COLUMN_NAME); info.setName(inputName); info.setDisplayColumnFactory(new NegativeBeadDisplayColumnFactory(analyte, inputName, initNegativeControlAnalytes)); @@ -266,7 +267,7 @@ else if (analyteDefaultValue != null) List posThresholdCols = new ArrayList<>(); for (String analyte : analyteNames) { - ColumnInfo info = new ColumnInfo(LuminexProtocolSchema.getTableInfoAnalytes().getColumn(LuminexDataHandler.POSITIVITY_THRESHOLD_COLUMN_NAME), view.getDataRegion().getTable()); + var info = new BaseColumnInfo(LuminexProtocolSchema.getTableInfoAnalytes().getColumn(LuminexDataHandler.POSITIVITY_THRESHOLD_COLUMN_NAME), view.getDataRegion().getTable()); String inputName = AnalyteDefaultValueService.getAnalytePropertyName(analyte, LuminexDataHandler.POSITIVITY_THRESHOLD_COLUMN_NAME); info.setName(inputName); info.setDisplayColumnFactory(createAnalytePropertyDisplayColumnFactory(inputName, LuminexDataHandler.POSITIVITY_THRESHOLD_DISPLAY_NAME)); diff --git a/luminex/src/org/labkey/luminex/model/AnalyteSinglePointControl.java b/luminex/src/org/labkey/luminex/model/AnalyteSinglePointControl.java index 8dece6a75f..a0e77acc85 100644 --- a/luminex/src/org/labkey/luminex/model/AnalyteSinglePointControl.java +++ b/luminex/src/org/labkey/luminex/model/AnalyteSinglePointControl.java @@ -79,7 +79,7 @@ public void updateQCFlags(LuminexProtocolSchema schema) SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("Analyte"), analyte.getRowId()); filter.addCondition(FieldKey.fromParts("SinglePointControl"), control.getRowId()); - AnalyteSinglePointControlTable analyteSinglePointControlTable = schema.createAnalyteSinglePointControlTable(true); + AnalyteSinglePointControlTable analyteSinglePointControlTable = schema.createAnalyteSinglePointControlTable(null, true); analyteSinglePointControlTable.setContainerFilter(ContainerFilter.EVERYTHING); Double average = new TableSelector(analyteSinglePointControlTable, Collections.singleton("AverageFiBkgd"), filter, null).getObject(Double.class); diff --git a/luminex/src/org/labkey/luminex/query/AbstractCurveFitPivotTable.java b/luminex/src/org/labkey/luminex/query/AbstractCurveFitPivotTable.java index 6acb442e13..91987362c3 100644 --- a/luminex/src/org/labkey/luminex/query/AbstractCurveFitPivotTable.java +++ b/luminex/src/org/labkey/luminex/query/AbstractCurveFitPivotTable.java @@ -15,7 +15,9 @@ */ package org.labkey.luminex.query; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.query.LookupForeignKey; @@ -28,9 +30,9 @@ public abstract class AbstractCurveFitPivotTable extends AbstractLuminexTable private static final String CURVE_FIT_SUFFIX = "CurveFit"; private final String _primaryCurveFitJoinColumn; - public AbstractCurveFitPivotTable(TableInfo table, LuminexProtocolSchema schema, boolean filter, String primaryCurveFitJoinColumn) + public AbstractCurveFitPivotTable(TableInfo table, LuminexProtocolSchema schema, ContainerFilter cf, boolean filter, String primaryCurveFitJoinColumn) { - super(table, schema, filter); + super(table, schema, cf, filter); _primaryCurveFitJoinColumn = primaryCurveFitJoinColumn; } @@ -49,16 +51,16 @@ protected void addCurveTypeColumns() { for (final String curveType : _userSchema.getCurveTypes()) { - ColumnInfo curveTypeColumn = createCurveTypeColumn(curveType); + var curveTypeColumn = createCurveTypeColumn(curveType); addColumn(curveTypeColumn); } } - private ColumnInfo createCurveTypeColumn(final String curveType) + private BaseColumnInfo createCurveTypeColumn(final String curveType) { - ColumnInfo curveFitColumn = wrapColumn(curveType + "CurveFit", getRealTable().getColumn(_primaryCurveFitJoinColumn)); + var curveFitColumn = wrapColumn(curveType + "CurveFit", getRealTable().getColumn(_primaryCurveFitJoinColumn)); - LookupForeignKey fk = createCurveFitFK(curveType); + LookupForeignKey fk = createCurveFitFK(getContainerFilter(), curveType); // We need the prefix to distinguish between the different kinds of curve fits fk.setPrefixColumnCaption(true); curveFitColumn.setIsUnselectable(true); @@ -71,5 +73,5 @@ private ColumnInfo createCurveTypeColumn(final String curveType) return curveFitColumn; } - protected abstract LookupForeignKey createCurveFitFK(final String curveType); + protected abstract LookupForeignKey createCurveFitFK(ContainerFilter cf, final String curveType); } diff --git a/luminex/src/org/labkey/luminex/query/AbstractExclusionTable.java b/luminex/src/org/labkey/luminex/query/AbstractExclusionTable.java index 923b709efb..6c6edf501b 100644 --- a/luminex/src/org/labkey/luminex/query/AbstractExclusionTable.java +++ b/luminex/src/org/labkey/luminex/query/AbstractExclusionTable.java @@ -18,8 +18,8 @@ import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ForeignKey; import org.labkey.api.data.SqlExecutor; import org.labkey.api.data.Table; @@ -55,29 +55,29 @@ */ public abstract class AbstractExclusionTable extends AbstractLuminexTable { - protected AbstractExclusionTable(TableInfo realTable, LuminexProtocolSchema schema, boolean filter) + protected AbstractExclusionTable(TableInfo realTable, LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(realTable, schema, filter); + super(realTable, schema, cf, filter); wrapAllColumns(true); assert getRealTable().getPkColumnNames().size() == 1; - ColumnInfo analytesColumn = wrapColumn("Analytes", getRealTable().getColumn(getRealTable().getPkColumnNames().get(0))); + var analytesColumn = wrapColumn("Analytes", getRealTable().getColumn(getRealTable().getPkColumnNames().get(0))); analytesColumn.setKeyField(false); analytesColumn.setUserEditable(true); analytesColumn.setReadOnly(false); - ForeignKey userIdForeignKey = new UserIdQueryForeignKey(schema.getUser(), schema.getContainer(), true); - getColumn("ModifiedBy").setFk(userIdForeignKey); - getColumn("CreatedBy").setFk(userIdForeignKey); + ForeignKey userIdForeignKey = new UserIdQueryForeignKey(schema, true); + getMutableColumn("ModifiedBy").setFk(userIdForeignKey); + getMutableColumn("CreatedBy").setFk(userIdForeignKey); addColumn(analytesColumn); - getColumn("Created").setLabel("Excluded At"); - getColumn("CreatedBy").setLabel("Excluded By"); - getColumn("Comment").setLabel("Reason for Exclusion"); + getMutableColumn("Created").setLabel("Excluded At"); + getMutableColumn("CreatedBy").setLabel("Excluded By"); + getMutableColumn("Comment").setLabel("Reason for Exclusion"); //Needed to retain original creator of exclusions on reimport. - getColumn("CreatedBy").setReadOnly(false); + getMutableColumn("CreatedBy").setReadOnly(false); } @Override diff --git a/luminex/src/org/labkey/luminex/query/AbstractLuminexTable.java b/luminex/src/org/labkey/luminex/query/AbstractLuminexTable.java index 6ccbe4fd27..a404e5815e 100644 --- a/luminex/src/org/labkey/luminex/query/AbstractLuminexTable.java +++ b/luminex/src/org/labkey/luminex/query/AbstractLuminexTable.java @@ -37,9 +37,9 @@ public abstract class AbstractLuminexTable extends FilteredTable dataColumns = Arrays.asList(dataTable.getColumn("FlaggedAsExcluded"), dataTable.getColumn("FIBackground"), dataTable.getColumn("Description"), dataTable.getColumn("Data"), dataTable.getColumn("Analyte")); avgFiSQL.append(QueryService.get().getSelectSQL(dataTable, dataColumns, null, null, Table.ALL_ROWS, 0, false)); avgFiSQL.append(") dr, "); @@ -120,7 +119,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) addColumn(averageFiBkgdFlagEnabledColumn); // add LJ plot column - ColumnInfo ljPlots = addWrapColumn("L-J Plots", getRealTable().getColumn(FieldKey.fromParts("SinglePointControlId"))); + var ljPlots = addWrapColumn("L-J Plots", getRealTable().getColumn(FieldKey.fromParts("SinglePointControlId"))); ljPlots.setDisplayColumnFactory(new DisplayColumnFactory(){ @Override public DisplayColumn createRenderer(ColumnInfo colInfo) diff --git a/luminex/src/org/labkey/luminex/query/AnalyteTable.java b/luminex/src/org/labkey/luminex/query/AnalyteTable.java index e398266aed..102dcd2f79 100644 --- a/luminex/src/org/labkey/luminex/query/AnalyteTable.java +++ b/luminex/src/org/labkey/luminex/query/AnalyteTable.java @@ -16,7 +16,6 @@ package org.labkey.luminex.query; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; @@ -30,16 +29,13 @@ import org.labkey.api.exp.api.ExperimentService; import org.labkey.api.exp.property.Domain; import org.labkey.api.exp.property.DomainProperty; -import org.labkey.api.query.DuplicateKeyException; import org.labkey.api.query.ExprColumn; import org.labkey.api.query.FieldKey; import org.labkey.api.query.FilteredTable; import org.labkey.api.query.LookupForeignKey; import org.labkey.api.query.PropertyForeignKey; import org.labkey.api.query.QueryUpdateService; -import org.labkey.api.query.QueryUpdateServiceException; import org.labkey.api.query.RowIdQueryUpdateService; -import org.labkey.api.query.ValidationException; import org.labkey.api.security.User; import org.labkey.api.security.UserPrincipal; import org.labkey.api.security.permissions.Permission; @@ -50,7 +46,6 @@ import org.labkey.luminex.LuminexAssayProvider; import org.labkey.luminex.model.Analyte; -import java.sql.SQLException; import java.util.Map; import java.util.TreeMap; @@ -60,18 +55,18 @@ */ public class AnalyteTable extends AbstractLuminexTable { - public AnalyteTable(final LuminexProtocolSchema schema, boolean filter) + public AnalyteTable(final LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoAnalytes(), schema, filter); + super(LuminexProtocolSchema.getTableInfoAnalytes(), schema, cf, filter); setName(LuminexProtocolSchema.ANALYTE_TABLE_NAME); setPublicSchemaName(AssaySchema.NAME); addColumn(wrapColumn(getRealTable().getColumn("Name"))); - addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))).setFk(new LookupForeignKey("RowId") + addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))).setFk(new LookupForeignKey(cf,"RowId", null) { public TableInfo getLookupTableInfo() { - return _userSchema.createDataFileTable(); + return _userSchema.createDataFileTable(getLookupContainerFilter()); } }); addColumn(wrapColumn(getRealTable().getColumn("RowId"))).setHidden(true); @@ -82,31 +77,31 @@ public TableInfo getLookupTableInfo() addColumn(wrapColumn(getRealTable().getColumn("PositivityThreshold"))); addColumn(wrapColumn(getRealTable().getColumn("NegativeBead"))); - ColumnInfo titrationColumn = addColumn(wrapColumn("Standard", getRealTable().getColumn("RowId"))); - titrationColumn.setFk(new MultiValuedForeignKey(new LookupForeignKey("Analyte") + var titrationColumn = addColumn(wrapColumn("Standard", getRealTable().getColumn("RowId"))); + titrationColumn.setFk(new MultiValuedForeignKey(new LookupForeignKey(cf,"Analyte", null) { @Override public TableInfo getLookupTableInfo() { - FilteredTable result = new FilteredTable<>(LuminexProtocolSchema.getTableInfoAnalyteTitration(), schema); - ColumnInfo titrationColumn = result.addColumn(result.wrapColumn("Titration", result.getRealTable().getColumn("TitrationId"))); - titrationColumn.setFk(new LookupForeignKey("RowId") + final FilteredTable result = new FilteredTable<>(LuminexProtocolSchema.getTableInfoAnalyteTitration(), schema, getLookupContainerFilter()); + var titrationColumn = result.addColumn(result.wrapColumn("Titration", result.getRealTable().getColumn("TitrationId"))); + titrationColumn.setFk(new LookupForeignKey(cf,"RowId", null) { @Override public TableInfo getLookupTableInfo() { - TitrationTable titrationTable = _userSchema.createTitrationTable(false); + TitrationTable titrationTable = _userSchema.createTitrationTable(getLookupContainerFilter(), false); titrationTable.addCondition(new SimpleFilter(FieldKey.fromParts("Standard"), Boolean.TRUE)); return titrationTable; } }); - ColumnInfo analyteColumn = result.addColumn(result.wrapColumn("Analyte", result.getRealTable().getColumn("AnalyteId"))); - analyteColumn.setFk(new LookupForeignKey("RowId") + var analyteColumn = result.addColumn(result.wrapColumn("Analyte", result.getRealTable().getColumn("AnalyteId"))); + analyteColumn.setFk(new LookupForeignKey(cf,"RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createAnalyteTable(false); + return _userSchema.createAnalyteTable(getLookupContainerFilter(), false); } }); return result; @@ -114,19 +109,19 @@ public TableInfo getLookupTableInfo() }, "Titration")); titrationColumn.setHidden(false); - ColumnInfo lsidColumn = addColumn(wrapColumn(getRealTable().getColumn("LSID"))); + var lsidColumn = addColumn(wrapColumn(getRealTable().getColumn("LSID"))); lsidColumn.setHidden(true); lsidColumn.setShownInInsertView(false); lsidColumn.setShownInUpdateView(false); - ColumnInfo colProperty = wrapColumn("Properties", getRealTable().getColumn("LSID")); + var colProperty = wrapColumn("Properties", getRealTable().getColumn("LSID")); Domain analyteDomain = AbstractAssayProvider.getDomainByPrefix(_userSchema.getProtocol(), LuminexAssayProvider.ASSAY_DOMAIN_ANALYTE); Map map = new TreeMap<>(); for(DomainProperty pd : analyteDomain.getProperties()) { map.put(pd.getName(), pd.getPropertyDescriptor()); } - colProperty.setFk(new PropertyForeignKey(map, _userSchema)); + colProperty.setFk(new PropertyForeignKey(_userSchema, getContainerFilter(), map)); colProperty.setIsUnselectable(true); colProperty.setReadOnly(true); colProperty.setShownInInsertView(false); diff --git a/luminex/src/org/labkey/luminex/query/AnalyteTitrationTable.java b/luminex/src/org/labkey/luminex/query/AnalyteTitrationTable.java index ad85b437a2..e2c6fd9847 100644 --- a/luminex/src/org/labkey/luminex/query/AnalyteTitrationTable.java +++ b/luminex/src/org/labkey/luminex/query/AnalyteTitrationTable.java @@ -36,7 +36,6 @@ import org.labkey.api.query.LookupForeignKey; import org.labkey.api.query.QueryForeignKey; import org.labkey.api.query.QueryUpdateService; -import org.labkey.api.query.QueryUpdateServiceException; import org.labkey.api.query.ValidationException; import org.labkey.api.security.User; import org.labkey.api.security.UserPrincipal; @@ -68,34 +67,34 @@ */ public class AnalyteTitrationTable extends AbstractCurveFitPivotTable { - public AnalyteTitrationTable(final LuminexProtocolSchema schema, boolean filter) + public AnalyteTitrationTable(final LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoAnalyteTitration(), schema, filter, "AnalyteId"); + super(LuminexProtocolSchema.getTableInfoAnalyteTitration(), schema, cf, filter, "AnalyteId"); setName(LuminexProtocolSchema.ANALYTE_TITRATION_TABLE_NAME); - ColumnInfo analyteCol = addColumn(wrapColumn("Analyte", getRealTable().getColumn("AnalyteId"))); - analyteCol.setFk(new LookupForeignKey("RowId") + var analyteCol = addColumn(wrapColumn("Analyte", getRealTable().getColumn("AnalyteId"))); + analyteCol.setFk(new LookupForeignKey(cf, "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createAnalyteTable(false); + return _userSchema.createAnalyteTable(getLookupContainerFilter(),false); } }); setTitleColumn(analyteCol.getName()); - ColumnInfo titrationCol = addColumn(wrapColumn("Titration", getRealTable().getColumn("TitrationId"))); - LookupForeignKey titrationFk = new LookupForeignKey("RowId") + var titrationCol = addColumn(wrapColumn("Titration", getRealTable().getColumn("TitrationId"))); + LookupForeignKey titrationFk = new LookupForeignKey(cf,"RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createTitrationTable(false); + return _userSchema.createTitrationTable(getLookupContainerFilter(),false); } }; titrationFk.setPrefixColumnCaption(false); titrationCol.setFk(titrationFk); - ColumnInfo maxFiCol = wrapColumn(getRealTable().getColumn("MaxFI")); + var maxFiCol = wrapColumn(getRealTable().getColumn("MaxFI")); maxFiCol.setLabel("High MFI"); maxFiCol.setDisplayColumnFactory(new DisplayColumnFactory() { @@ -112,14 +111,14 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) maxFiFlagEnabledColumn.setHidden(true); addColumn(maxFiFlagEnabledColumn); - ColumnInfo guideSetCol = addColumn(wrapColumn("GuideSet", getRealTable().getColumn("GuideSetId"))); - guideSetCol.setFk(new QueryForeignKey(schema, null, "GuideSet", "RowId", "AnalyteName")); + var guideSetCol = addColumn(wrapColumn("GuideSet", getRealTable().getColumn("GuideSetId"))); + guideSetCol.setFk(QueryForeignKey.from(schema, getContainerFilter()).to("GuideSet", "RowId", "AnalyteName")); addColumn(wrapColumn(getRealTable().getColumn("IncludeInGuideSetCalculation"))); addCurveTypeColumns(); - ColumnInfo ljPlots = addWrapColumn("L-J Plots", getRealTable().getColumn(FieldKey.fromParts("TitrationId"))); + var ljPlots = addWrapColumn("L-J Plots", getRealTable().getColumn(FieldKey.fromParts("TitrationId"))); ljPlots.setTextAlign("left"); ljPlots.setDisplayColumnFactory(new DisplayColumnFactory(){ @Override @@ -195,14 +194,14 @@ public boolean isFilterable() setDefaultVisibleColumns(defaultCols); } - protected LookupForeignKey createCurveFitFK(final String curveType) + protected LookupForeignKey createCurveFitFK(ContainerFilter cf, final String curveType) { - LookupForeignKey fk = new LookupForeignKey("AnalyteId") + LookupForeignKey fk = new LookupForeignKey(cf,"AnalyteId", null) { @Override public TableInfo getLookupTableInfo() { - CurveFitTable result = _userSchema.createCurveFitTable(false); + CurveFitTable result = _userSchema.createCurveFitTable(getLookupContainerFilter(),false); result.addCondition(result.getRealTable().getColumn("CurveType"), curveType); return result; } @@ -235,7 +234,7 @@ public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class is analyteid/titrationid combo - return new AbstractLuminexControlUpdateService(this, AnalyteTitration.class) + return new AbstractLuminexControlUpdateService<>(this, AnalyteTitration.class) { @Override protected AnalyteTitration createNewBean() diff --git a/luminex/src/org/labkey/luminex/query/CurveFitTable.java b/luminex/src/org/labkey/luminex/query/CurveFitTable.java index 3c6a294a9b..0073baba90 100644 --- a/luminex/src/org/labkey/luminex/query/CurveFitTable.java +++ b/luminex/src/org/labkey/luminex/query/CurveFitTable.java @@ -34,34 +34,34 @@ */ public class CurveFitTable extends AbstractLuminexTable { - public CurveFitTable(LuminexProtocolSchema schema, boolean filterTable) + public CurveFitTable(LuminexProtocolSchema schema, ContainerFilter cf, boolean filterTable) { - super(LuminexProtocolSchema.getTableInfoCurveFit(), schema, filterTable); + super(LuminexProtocolSchema.getTableInfoCurveFit(), schema, cf, filterTable); setName(LuminexProtocolSchema.CURVE_FIT_TABLE_NAME); wrapAllColumns(true); - ColumnInfo titrationCol = getColumn("TitrationId"); + var titrationCol = getMutableColumn("TitrationId"); titrationCol.setLabel("Titration"); titrationCol.setFk(new LookupForeignKey("RowId") { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createTitrationTable(false); + return _userSchema.createTitrationTable(cf,false); } }); - ColumnInfo analyteCol = getColumn("AnalyteId"); + var analyteCol = getMutableColumn("AnalyteId"); analyteCol.setLabel("Analyte"); analyteCol.setFk(new LookupForeignKey("RowId") { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createAnalyteTable(false); + return _userSchema.createAnalyteTable(cf,false); } }); - ColumnInfo ec50Col = getColumn("EC50"); + var ec50Col = getMutableColumn("EC50"); ec50Col.setDisplayColumnFactory(new DisplayColumnFactory() { @Override @@ -76,7 +76,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) ec50FlagEnabledColumn.setHidden(true); addColumn(ec50FlagEnabledColumn); - ColumnInfo aucCol = getColumn("AUC"); + var aucCol = getMutableColumn("AUC"); aucCol.setDisplayColumnFactory(new DisplayColumnFactory() { @Override @@ -108,6 +108,5 @@ protected SQLFragment createContainerFilterSQL(ContainerFilter filter, Container } sql.append("))"); return sql; - } } diff --git a/luminex/src/org/labkey/luminex/query/GuideSetCurveFitTable.java b/luminex/src/org/labkey/luminex/query/GuideSetCurveFitTable.java index 557c54c202..f3b7f3f305 100644 --- a/luminex/src/org/labkey/luminex/query/GuideSetCurveFitTable.java +++ b/luminex/src/org/labkey/luminex/query/GuideSetCurveFitTable.java @@ -16,7 +16,7 @@ package org.labkey.luminex.query; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerFilterable; import org.labkey.api.data.JdbcType; @@ -36,52 +36,52 @@ public class GuideSetCurveFitTable extends VirtualTable i private @NotNull ContainerFilter _containerFilter = ContainerFilter.CURRENT; /** @param curveType the type of curve to filter the results to. Null means don't filter */ - public GuideSetCurveFitTable(LuminexProtocolSchema schema, String curveType) + public GuideSetCurveFitTable(LuminexProtocolSchema schema, ContainerFilter cf, String curveType) { - super(schema.getDbSchema(), LuminexProtocolSchema.GUIDE_SET_CURVE_FIT_TABLE_NAME, schema); + super(schema.getDbSchema(), LuminexProtocolSchema.GUIDE_SET_CURVE_FIT_TABLE_NAME, schema, cf); _curveType = curveType; setDescription("Contains one row per curve fit/guide set combination, and contains average and other statistics for all of the matching runs"); - ColumnInfo guideSetIdColumn = new ColumnInfo("GuideSetId", this, JdbcType.INTEGER); + var guideSetIdColumn = new BaseColumnInfo("GuideSetId", this, JdbcType.INTEGER); guideSetIdColumn.setLabel("Guide Set"); - guideSetIdColumn.setFk(new LookupForeignKey("RowId") + guideSetIdColumn.setFk(new LookupForeignKey(cf, "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createGuideSetTable(false); + return _userSchema.createGuideSetTable(getLookupContainerFilter(),false); } }); addColumn(guideSetIdColumn); - ColumnInfo runCountColumn = new ColumnInfo("RunCount", this, JdbcType.INTEGER); + var runCountColumn = new BaseColumnInfo("RunCount", this, JdbcType.INTEGER); addColumn(runCountColumn); - ColumnInfo aucAverageColumn = new ColumnInfo("AUCAverage", this, JdbcType.REAL); + var aucAverageColumn = new BaseColumnInfo("AUCAverage", this, JdbcType.REAL); aucAverageColumn.setFormat("0.00"); aucAverageColumn.setLabel("AUC Average"); aucAverageColumn.setDescription("Average of area under the curve values"); addColumn(aucAverageColumn); - ColumnInfo aucStdDevColumn = new ColumnInfo("AUCStdDev", this, JdbcType.REAL); + var aucStdDevColumn = new BaseColumnInfo("AUCStdDev", this, JdbcType.REAL); aucStdDevColumn.setFormat("0.00"); aucStdDevColumn.setLabel("AUC Std Dev"); aucStdDevColumn.setDescription("Standard deviation of area under the curve values"); addColumn(aucStdDevColumn); - ColumnInfo ec50AverageColumn = new ColumnInfo("EC50Average", this, JdbcType.REAL); + var ec50AverageColumn = new BaseColumnInfo("EC50Average", this, JdbcType.REAL); ec50AverageColumn.setFormat("0.00"); ec50AverageColumn.setLabel("EC50 Average"); ec50AverageColumn.setDescription("Average of EC50 values"); addColumn(ec50AverageColumn); - ColumnInfo ec50StdDevColumn = new ColumnInfo("EC50StdDev", this, JdbcType.REAL); + var ec50StdDevColumn = new BaseColumnInfo("EC50StdDev", this, JdbcType.REAL); ec50StdDevColumn.setFormat("0.00"); ec50StdDevColumn.setLabel("EC50 Std Dev"); ec50StdDevColumn.setDescription("Standard deviation of EC50 values"); addColumn(ec50StdDevColumn); - ColumnInfo curveTypeColumn = new ColumnInfo("CurveType", this, JdbcType.VARCHAR); + var curveTypeColumn = new BaseColumnInfo("CurveType", this, JdbcType.VARCHAR); addColumn(curveTypeColumn); } @@ -99,13 +99,11 @@ public SQLFragment getFromSQL() result.append("at.GuideSetId,\n"); result.append("cf.CurveType FROM \n"); - AnalyteTitrationTable analyteTitrationTable = (AnalyteTitrationTable)_userSchema.getTable(LuminexProtocolSchema.ANALYTE_TITRATION_TABLE_NAME); - analyteTitrationTable.setContainerFilter(ContainerFilter.EVERYTHING); + AnalyteTitrationTable analyteTitrationTable = (AnalyteTitrationTable)_userSchema.getTable(LuminexProtocolSchema.ANALYTE_TITRATION_TABLE_NAME, ContainerFilter.EVERYTHING); result.append(analyteTitrationTable, "at"); result.append(", "); - CurveFitTable curveFitTable = (CurveFitTable)_userSchema.getTable(LuminexProtocolSchema.CURVE_FIT_TABLE_NAME); - curveFitTable.setContainerFilter(ContainerFilter.EVERYTHING); + CurveFitTable curveFitTable = (CurveFitTable)_userSchema.getTable(LuminexProtocolSchema.CURVE_FIT_TABLE_NAME, ContainerFilter.EVERYTHING); result.append(curveFitTable, "cf"); result.append(" WHERE at.AnalyteId = cf.AnalyteId AND at.TitrationId = cf.TitrationId AND at.GuideSetId IS NOT NULL AND at.IncludeInGuideSetCalculation = ?\n"); diff --git a/luminex/src/org/labkey/luminex/query/GuideSetTable.java b/luminex/src/org/labkey/luminex/query/GuideSetTable.java index 6eeb1766e2..6ee3590795 100644 --- a/luminex/src/org/labkey/luminex/query/GuideSetTable.java +++ b/luminex/src/org/labkey/luminex/query/GuideSetTable.java @@ -37,13 +37,11 @@ import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.api.ExperimentService; import org.labkey.api.query.AliasedColumn; -import org.labkey.api.query.DuplicateKeyException; import org.labkey.api.query.ExprColumn; import org.labkey.api.query.FieldKey; import org.labkey.api.query.LookupForeignKey; import org.labkey.api.query.QueryService; import org.labkey.api.query.QueryUpdateService; -import org.labkey.api.query.QueryUpdateServiceException; import org.labkey.api.query.RowIdQueryUpdateService; import org.labkey.api.query.UserIdQueryForeignKey; import org.labkey.api.query.ValidationException; @@ -59,11 +57,9 @@ import java.io.IOException; import java.io.Writer; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -73,9 +69,9 @@ */ public class GuideSetTable extends AbstractCurveFitPivotTable { - public GuideSetTable(final LuminexProtocolSchema schema, boolean filter) + public GuideSetTable(final LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoGuideSet(), schema, filter, "RowId"); + super(LuminexProtocolSchema.getTableInfoGuideSet(), schema, cf, filter, "RowId"); setName(LuminexProtocolSchema.GUIDE_SET_TABLE_NAME); for (ColumnInfo col : getRealTable().getColumns()) @@ -83,14 +79,14 @@ public GuideSetTable(final LuminexProtocolSchema schema, boolean filter) // value-based average and std dev columns will be aliased and only editable via the Manage Guide Set UI if (col.getName().endsWith("Average") || col.getName().endsWith("StdDev")) { - ColumnInfo valueBasedCol = addWrapColumn(col); + var valueBasedCol = addWrapColumn(col); valueBasedCol.setJdbcType(JdbcType.DOUBLE); valueBasedCol.setHidden(true); valueBasedCol.setUserEditable(false); } else { - ColumnInfo wrapCol = addWrapColumn(col); + var wrapCol = addWrapColumn(col); wrapCol.setHidden(col.isHidden()); if (wrapCol.getName().equals("ValueBased")) @@ -98,7 +94,7 @@ public GuideSetTable(final LuminexProtocolSchema schema, boolean filter) } } - ColumnInfo protocolCol = getColumn("ProtocolId"); + var protocolCol = getMutableColumn("ProtocolId"); protocolCol.setLabel("Assay Design"); protocolCol.setHidden(true); protocolCol.setShownInDetailsView(false); @@ -168,7 +164,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep addColumn(valueBasedCol); addFIColumns(LuminexProtocolSchema.getTableInfoAnalyteTitration(), "MaxFI", "TitrationMax", "Titration Max", "GuideSetId"); - AnalyteSinglePointControlTable analyteSinglePointControlTable = schema.createAnalyteSinglePointControlTable(false); + AnalyteSinglePointControlTable analyteSinglePointControlTable = schema.createAnalyteSinglePointControlTable(cf, false); analyteSinglePointControlTable.setContainerFilter(ContainerFilter.EVERYTHING); addFIColumns(analyteSinglePointControlTable, "AverageFiBkgd", "SinglePointControl", "Single Point Control", "GuideSet"); @@ -178,11 +174,11 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep addRunCounts(); - ForeignKey userIdForeignKey = new UserIdQueryForeignKey(schema.getUser(), schema.getContainer(), true); - getColumn("ModifiedBy").setFk(userIdForeignKey); - getColumn("CreatedBy").setFk(userIdForeignKey); + ForeignKey userIdForeignKey = new UserIdQueryForeignKey(schema, true); + getMutableColumn("ModifiedBy").setFk(userIdForeignKey); + getMutableColumn("CreatedBy").setFk(userIdForeignKey); - getColumn("Created").setLabel("Guide Set Start Date"); + getMutableColumn("Created").setLabel("Guide Set Start Date"); addCurveTypeColumns(); @@ -318,14 +314,14 @@ private void addRunCounts() { addColumn(aucRunCounts); } - protected LookupForeignKey createCurveFitFK(final String curveType) + protected LookupForeignKey createCurveFitFK(ContainerFilter cf, final String curveType) { - return new LookupForeignKey("GuideSetId") + return new LookupForeignKey(cf, "GuideSetId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createGuideSetCurveFitTable(curveType); + return _userSchema.createGuideSetCurveFitTable(getLookupContainerFilter(), curveType); } }; } diff --git a/luminex/src/org/labkey/luminex/query/LuminexDataTable.java b/luminex/src/org/labkey/luminex/query/LuminexDataTable.java index 044892f88a..59d584d3f2 100644 --- a/luminex/src/org/labkey/luminex/query/LuminexDataTable.java +++ b/luminex/src/org/labkey/luminex/query/LuminexDataTable.java @@ -19,6 +19,7 @@ import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.collections.CaseInsensitiveHashSet; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerForeignKey; import org.labkey.api.data.DelegatingContainerFilter; import org.labkey.api.data.DisplayColumn; @@ -89,9 +90,9 @@ public class LuminexDataTable extends FilteredTable imple REMAPPED_SCHEMA_COLUMNS = Collections.unmodifiableMap(result); } - public LuminexDataTable(LuminexProtocolSchema schema) + public LuminexDataTable(LuminexProtocolSchema schema, ContainerFilter cf) { - super(LuminexProtocolSchema.getTableInfoDataRow(), schema); + super(LuminexProtocolSchema.getTableInfoDataRow(), schema, cf); final ExpProtocol protocol = schema.getProtocol(); setName(AssayProtocolSchema.DATA_TABLE_NAME); @@ -101,29 +102,28 @@ public LuminexDataTable(LuminexProtocolSchema schema) setDescription("Contains all the Luminex data rows for the " + protocol.getName() + " assay definition"); - ColumnInfo dataColumn = addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))); - dataColumn.setFk(new LookupForeignKey("RowId") + var dataColumn = addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))); + dataColumn.setFk(new LookupForeignKey(cf, "RowId", null) { public TableInfo getLookupTableInfo() { - ExpDataTable result = _userSchema.createDataFileTable(); - result.setContainerFilter(new DelegatingContainerFilter(LuminexDataTable.this)); + ExpDataTable result = _userSchema.createDataFileTable(getLookupContainerFilter()); return result; } }); - ColumnInfo rowIdColumn = addColumn(wrapColumn(getRealTable().getColumn("RowId"))); + var rowIdColumn = addColumn(wrapColumn(getRealTable().getColumn("RowId"))); rowIdColumn.setHidden(true); rowIdColumn.setKeyField(true); addColumn(wrapColumn(getRealTable().getColumn("LSID"))).setHidden(true); - ColumnInfo protocolColumn = addColumn(wrapColumn("Protocol", getRealTable().getColumn("ProtocolId"))); - protocolColumn.setFk(new ExpSchema(_userSchema.getUser(), _userSchema.getContainer()).getProtocolForeignKey("RowId")); + var protocolColumn = addColumn(wrapColumn("Protocol", getRealTable().getColumn("ProtocolId"))); + protocolColumn.setFk(new ExpSchema(_userSchema.getUser(), _userSchema.getContainer()).getProtocolForeignKey(cf,"RowId")); protocolColumn.setHidden(true); addColumn(wrapColumn(getRealTable().getColumn("WellRole"))); addColumn(wrapColumn(getRealTable().getColumn("Type"))); addColumn(wrapColumn(getRealTable().getColumn("Well"))); addColumn(wrapColumn(getRealTable().getColumn("Outlier"))); addColumn(wrapColumn(getRealTable().getColumn("Description"))); - ColumnInfo specimenColumn = wrapColumn(getRealTable().getColumn("SpecimenID")); + var specimenColumn = wrapColumn(getRealTable().getColumn("SpecimenID")); specimenColumn.setFk(new SpecimenForeignKey(_userSchema, AssayService.get().getProvider(_userSchema.getProtocol()), _userSchema.getProtocol())); addColumn(specimenColumn); addColumn(wrapColumn(getRealTable().getColumn("ExtraSpecimenInfo"))); @@ -145,7 +145,7 @@ public TableInfo getLookupTableInfo() addColumn(wrapColumn(getRealTable().getColumn("SamplingErrors"))); addColumn(wrapColumn(getRealTable().getColumn("BeadCount"))); - ColumnInfo cvCol = wrapColumn(getRealTable().getColumn("CV")); + var cvCol = wrapColumn(getRealTable().getColumn("CV")); cvCol.setDisplayColumnFactory(new DisplayColumnFactory() { @Override @@ -168,24 +168,24 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) addColumn(cvFlagEnabledColumn); addColumn(wrapColumn(getRealTable().getColumn("Summary"))); - ColumnInfo titrationColumn = addColumn(wrapColumn("Titration", getRealTable().getColumn("TitrationId"))); - titrationColumn.setFk(new LookupForeignKey("RowId") + var titrationColumn = addColumn(wrapColumn("Titration", getRealTable().getColumn("TitrationId"))); + titrationColumn.setFk(new LookupForeignKey(cf, "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createTitrationTable(false); + return _userSchema.createTitrationTable(getLookupContainerFilter(), false); } }); - ColumnInfo analyteTitrationColumn = wrapColumn("AnalyteTitration", getRealTable().getColumn("AnalyteId")); + var analyteTitrationColumn = wrapColumn("AnalyteTitration", getRealTable().getColumn("AnalyteId")); analyteTitrationColumn.setIsUnselectable(true); - LookupForeignKey atFK = new LookupForeignKey() + LookupForeignKey atFK = new LookupForeignKey(cf, null, null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createAnalyteTitrationTable(false); + return _userSchema.createAnalyteTitrationTable(getLookupContainerFilter(), false); } @Override @@ -200,16 +200,16 @@ protected ColumnInfo getPkColumn(TableInfo table) analyteTitrationColumn.setFk(atFK); addColumn(analyteTitrationColumn); - ColumnInfo singlePointControlCol = addColumn(wrapColumn("SinglePointControl", getRealTable().getColumn("SinglePointControlId"))); + var singlePointControlCol = addColumn(wrapColumn("SinglePointControl", getRealTable().getColumn("SinglePointControlId"))); singlePointControlCol.setHidden(true); - ColumnInfo analyteSinglePointControlColumn = wrapColumn("AnalyteSinglePointControl", getRealTable().getColumn("AnalyteId")); + var analyteSinglePointControlColumn = wrapColumn("AnalyteSinglePointControl", getRealTable().getColumn("AnalyteId")); analyteSinglePointControlColumn.setIsUnselectable(true); - LookupForeignKey aspcFK = new LookupForeignKey() + LookupForeignKey aspcFK = new LookupForeignKey(cf, null, null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createAnalyteSinglePointControlTable(false); + return _userSchema.createAnalyteSinglePointControlTable(getLookupContainerFilter(), false); } @Override @@ -226,7 +226,7 @@ protected ColumnInfo getPkColumn(TableInfo table) addColumn(wrapColumn("Analyte", getRealTable().getColumn("AnalyteId"))); - ColumnInfo containerColumn = addColumn(wrapColumn(getRealTable().getColumn("Container"))); + var containerColumn = addColumn(wrapColumn(getRealTable().getColumn("Container"))); containerColumn.setHidden(true); containerColumn.setFk(new ContainerForeignKey(_userSchema)); @@ -288,7 +288,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) } Domain domain = getDomain(); - for (ColumnInfo propertyCol : domain.getColumns(this, getColumn("LSID"), schema.getContainer(), schema.getUser())) + for (var propertyCol : domain.getColumns(this, getColumn("LSID"), schema.getContainer(), schema.getUser())) { addColumn(propertyCol); defaultCols.add(propertyCol.getFieldKey()); @@ -314,7 +314,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) setDefaultVisibleColumns(defaultCols); - getColumn("Analyte").setFk(new LuminexProtocolSchema.AnalyteForeignKey(_userSchema)); + getMutableColumn("Analyte").setFk(new LuminexProtocolSchema.AnalyteForeignKey(_userSchema, cf)); SQLFragment protocolIDFilter = new SQLFragment("ProtocolID = ?"); protocolIDFilter.add(_userSchema.getProtocol().getRowId()); diff --git a/luminex/src/org/labkey/luminex/query/LuminexProtocolSchema.java b/luminex/src/org/labkey/luminex/query/LuminexProtocolSchema.java index 17f265b24c..adbf2cf661 100644 --- a/luminex/src/org/labkey/luminex/query/LuminexProtocolSchema.java +++ b/luminex/src/org/labkey/luminex/query/LuminexProtocolSchema.java @@ -19,25 +19,7 @@ import org.apache.commons.lang3.math.NumberUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.labkey.api.data.AbstractTableInfo; -import org.labkey.api.data.ButtonBar; -import org.labkey.api.data.ColumnInfo; -import org.labkey.api.data.CompareType; -import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.DataColumn; -import org.labkey.api.data.DataRegion; -import org.labkey.api.data.DbSchema; -import org.labkey.api.data.DbSchemaType; -import org.labkey.api.data.DisplayColumn; -import org.labkey.api.data.DisplayColumnFactory; -import org.labkey.api.data.MenuButton; -import org.labkey.api.data.RenderContext; -import org.labkey.api.data.SQLFragment; -import org.labkey.api.data.SimpleFilter; -import org.labkey.api.data.Sort; -import org.labkey.api.data.TableInfo; -import org.labkey.api.data.TableSelector; +import org.labkey.api.data.*; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.api.ExperimentService; import org.labkey.api.exp.api.ExperimentUrls; @@ -161,28 +143,28 @@ public synchronized List getCurveTypes() } @Override - protected TableInfo createProviderTable(String tableType) + protected TableInfo createProviderTable(String tableType, ContainerFilter cf) { if (tableType != null) { if (ANALYTE_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createAnalyteTable(true); + return createAnalyteTable(cf, true); } if (TITRATION_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createTitrationTable(true); + return createTitrationTable(cf, true); } if (GUIDE_SET_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createGuideSetTable(true); + return createGuideSetTable(cf, true); } if (ANALYTE_TITRATION_TABLE_NAME.equalsIgnoreCase(tableType)) { - AnalyteTitrationTable result = createAnalyteTitrationTable(true); + AnalyteTitrationTable result = createAnalyteTitrationTable(cf, true); SQLFragment filter = new SQLFragment("AnalyteId IN (SELECT a.RowId FROM "); filter.append(getTableInfoAnalytes(), "a"); filter.append(" WHERE a.DataId "); @@ -194,7 +176,7 @@ protected TableInfo createProviderTable(String tableType) if (DATA_FILE_TABLE_NAME.equalsIgnoreCase(tableType)) { - ExpDataTable result = createDataFileTable(); + ExpDataTable result = createDataFileTable(cf); SQLFragment filter = new SQLFragment("RowId"); filter.append(createDataFilterInClause()); result.addCondition(filter, FieldKey.fromParts("RowId")); @@ -203,9 +185,9 @@ protected TableInfo createProviderTable(String tableType) if (WELL_EXCLUSION_TABLE_NAME.equalsIgnoreCase(tableType)) { - FilteredTable result = createWellExclusionTable(true); + FilteredTable result = createWellExclusionTable(cf, true); result.addCondition(new SimpleFilter(FieldKey.fromParts("Type"), null, CompareType.NONBLANK)); - result.removeColumn(new ColumnInfo("Dilution")); + result.removeColumn(new BaseColumnInfo("Dilution")); SQLFragment filter = new SQLFragment("DataId"); filter.append(createDataFilterInClause()); result.addCondition(filter, FieldKey.fromParts("DataId")); @@ -214,16 +196,16 @@ protected TableInfo createProviderTable(String tableType) if (TITRATION_EXCLUSION_TABLE_NAME.equalsIgnoreCase(tableType)) { - FilteredTable result = createWellExclusionTable(true); + FilteredTable result = createWellExclusionTable(cf, true); result.setName(TITRATION_EXCLUSION_TABLE_NAME); SimpleFilter exclusionFilter = new SimpleFilter(FieldKey.fromParts("Type"), null, CompareType.ISBLANK); exclusionFilter.addCondition(FieldKey.fromParts("Dilution"), null, CompareType.ISBLANK); result.addCondition(exclusionFilter); - result.removeColumn(new ColumnInfo("Dilution")); - result.removeColumn(new ColumnInfo("Type")); - result.removeColumn(new ColumnInfo("Well")); - result.removeColumn(new ColumnInfo("Wells")); - result.removeColumn(new ColumnInfo("Well Role")); + result.removeColumn(new BaseColumnInfo("Dilution")); + result.removeColumn(new BaseColumnInfo("Type")); + result.removeColumn(new BaseColumnInfo("Well")); + result.removeColumn(new BaseColumnInfo("Wells")); + result.removeColumn(new BaseColumnInfo("Well Role")); SQLFragment filter = new SQLFragment("DataId"); filter.append(createDataFilterInClause()); result.addCondition(filter, FieldKey.fromParts("DataId")); @@ -232,15 +214,15 @@ protected TableInfo createProviderTable(String tableType) if (SINGLEPOINT_UNKNOWN_EXCLUSION_TABLE_NAME.equalsIgnoreCase(tableType)) { - FilteredTable result = createWellExclusionTable(true); + FilteredTable result = createWellExclusionTable(cf, true); result.setName(SINGLEPOINT_UNKNOWN_EXCLUSION_TABLE_NAME); SimpleFilter exclusionFilter = new SimpleFilter(FieldKey.fromParts("Type"), null, CompareType.ISBLANK); exclusionFilter.addCondition(FieldKey.fromParts("Dilution"), null, CompareType.NONBLANK); result.addCondition(exclusionFilter); - result.removeColumn(new ColumnInfo("Type")); - result.removeColumn(new ColumnInfo("Well")); - result.removeColumn(new ColumnInfo("Wells")); - result.removeColumn(new ColumnInfo("Well Role")); + result.removeColumn(new BaseColumnInfo("Type")); + result.removeColumn(new BaseColumnInfo("Well")); + result.removeColumn(new BaseColumnInfo("Wells")); + result.removeColumn(new BaseColumnInfo("Well Role")); SQLFragment filter = new SQLFragment("DataId"); filter.append(createDataFilterInClause()); result.addCondition(filter, FieldKey.fromParts("DataId")); @@ -249,7 +231,7 @@ protected TableInfo createProviderTable(String tableType) if (CURVE_FIT_TABLE_NAME.equalsIgnoreCase(tableType)) { - CurveFitTable result = createCurveFitTable(true); + CurveFitTable result = createCurveFitTable(cf, true); SQLFragment filter = new SQLFragment("AnalyteId IN (SELECT a.RowId FROM "); filter.append(getTableInfoAnalytes(), "a"); filter.append(" WHERE a.DataId "); @@ -261,12 +243,12 @@ protected TableInfo createProviderTable(String tableType) if (GUIDE_SET_CURVE_FIT_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createGuideSetCurveFitTable(); + return createGuideSetCurveFitTable(cf); } if (RUN_EXCLUSION_TABLE_NAME.equalsIgnoreCase(tableType)) { - FilteredTable result = createRunExclusionTable(true); + FilteredTable result = createRunExclusionTable(cf, true); SQLFragment filter = new SQLFragment("RunId IN (SELECT pa.RunId FROM "); filter.append(ExperimentService.get().getTinfoProtocolApplication(), "pa"); filter.append(", "); @@ -280,67 +262,67 @@ protected TableInfo createProviderTable(String tableType) if (ANALYTE_TITRATION_QC_FLAG_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createAnalyteTitrationQCFlagTable(); + return createAnalyteTitrationQCFlagTable(cf); } if (ANALYTE_SINGLE_POONT_CONTROL_QC_FLAG_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createAnalyteSinglePointControlQCFlagTable(); + return createAnalyteSinglePointControlQCFlagTable(cf); } if (CV_QC_FLAG_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createCVQCFlagTable(); + return createCVQCFlagTable(cf); } if (SINGLE_POINT_CONTROL_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createSinglePointControlTable(true); + return createSinglePointControlTable(cf, true); } if (ANALYTE_SINGLE_POINT_CONTROL_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createAnalyteSinglePointControlTable(true); + return createAnalyteSinglePointControlTable(cf, true); } } - return super.createProviderTable(tableType); + return super.createProviderTable(tableType, cf); } - public AnalyteTitrationTable createAnalyteTitrationTable(boolean filter) + public AnalyteTitrationTable createAnalyteTitrationTable(ContainerFilter cf, boolean filter) { - return new AnalyteTitrationTable(this, filter); + return new AnalyteTitrationTable(this, cf, filter); } - public GuideSetTable createGuideSetTable(boolean filterTable) + public GuideSetTable createGuideSetTable(ContainerFilter cf, boolean filterTable) { - return new GuideSetTable(this, filterTable); + return new GuideSetTable(this, cf, filterTable); } - public CurveFitTable createCurveFitTable(boolean filterTable) + public CurveFitTable createCurveFitTable(ContainerFilter cf, boolean filterTable) { - return new CurveFitTable(this, filterTable); + return new CurveFitTable(this, cf, filterTable); } - public GuideSetCurveFitTable createGuideSetCurveFitTable() + public GuideSetCurveFitTable createGuideSetCurveFitTable(ContainerFilter cf) { - return new GuideSetCurveFitTable(this, null); + return new GuideSetCurveFitTable(this, cf, null); } /** @param curveType the type of curve to filter the results to */ - public GuideSetCurveFitTable createGuideSetCurveFitTable(String curveType) + public GuideSetCurveFitTable createGuideSetCurveFitTable(ContainerFilter cf, String curveType) { - return new GuideSetCurveFitTable(this, curveType); + return new GuideSetCurveFitTable(this, cf, curveType); } - private WellExclusionTable createWellExclusionTable(boolean filterTable) + private WellExclusionTable createWellExclusionTable(ContainerFilter cf, boolean filterTable) { - return new WellExclusionTable(this, filterTable); + return new WellExclusionTable(this, cf, filterTable); } - private SinglePointControlTable createSinglePointControlTable(boolean filterTable) + private SinglePointControlTable createSinglePointControlTable(ContainerFilter cf, boolean filterTable) { - SinglePointControlTable result = new SinglePointControlTable(this, filterTable); + SinglePointControlTable result = new SinglePointControlTable(this, cf, filterTable); if (filterTable) { SQLFragment sql = new SQLFragment("RunId IN (SELECT pa.RunId FROM "); @@ -355,9 +337,9 @@ private SinglePointControlTable createSinglePointControlTable(boolean filterTabl return result; } - public AnalyteSinglePointControlTable createAnalyteSinglePointControlTable(boolean filterTable) + public AnalyteSinglePointControlTable createAnalyteSinglePointControlTable(ContainerFilter cf, boolean filterTable) { - AnalyteSinglePointControlTable result = new AnalyteSinglePointControlTable(this, filterTable); + AnalyteSinglePointControlTable result = new AnalyteSinglePointControlTable(this, cf, filterTable); if (filterTable) { SQLFragment sql = new SQLFragment("SinglePointControlId IN (SELECT RowId FROM "); @@ -374,14 +356,14 @@ public AnalyteSinglePointControlTable createAnalyteSinglePointControlTable(boole return result; } - private RunExclusionTable createRunExclusionTable(boolean filterTable) + private RunExclusionTable createRunExclusionTable(ContainerFilter cf, boolean filterTable) { - return new RunExclusionTable(this, filterTable); + return new RunExclusionTable(this, cf, filterTable); } - public AnalyteTable createAnalyteTable(boolean filterTable) + public AnalyteTable createAnalyteTable(ContainerFilter cf, boolean filterTable) { - AnalyteTable result = new AnalyteTable(this, filterTable); + AnalyteTable result = new AnalyteTable(this, cf, filterTable); if (filterTable) { @@ -393,9 +375,9 @@ public AnalyteTable createAnalyteTable(boolean filterTable) return result; } - public TitrationTable createTitrationTable(boolean filter) + public TitrationTable createTitrationTable(ContainerFilter cf, boolean filter) { - TitrationTable result = new TitrationTable(this, filter); + TitrationTable result = new TitrationTable(this, cf, filter); if (filter) { SQLFragment sql = new SQLFragment("RunId IN (SELECT pa.RunId FROM "); @@ -410,9 +392,9 @@ public TitrationTable createTitrationTable(boolean filter) return result; } - public ExpDataTable createDataFileTable() + public ExpDataTable createDataFileTable(ContainerFilter cf) { - final ExpDataTable ret = ExperimentService.get().createDataTable(DATA_FILE_TABLE_NAME, this); + final ExpDataTable ret = ExperimentService.get().createDataTable(DATA_FILE_TABLE_NAME, this, cf); ret.addColumn(ExpDataTable.Column.RowId); ret.addColumn(ExpDataTable.Column.Name); ret.addColumn(ExpDataTable.Column.Flag); @@ -421,18 +403,18 @@ public ExpDataTable createDataFileTable() ret.addColumn(ExpDataTable.Column.DataFileUrl).setHidden(true); ret.addColumn(ExpDataTable.Column.SourceProtocolApplication).setHidden(true); ret.setTitleColumn("Name"); - ColumnInfo protocol = ret.addColumn(ExpDataTable.Column.Protocol); + var protocol = ret.addColumn(ExpDataTable.Column.Protocol); protocol.setHidden(true); - ColumnInfo runCol = ret.addColumn(ExpDataTable.Column.Run); + var runCol = ret.addColumn(ExpDataTable.Column.Run); if (getProtocol() != null) { - runCol.setFk(new LookupForeignKey("RowId") + runCol.setFk(new LookupForeignKey(ret.getContainerFilter(),"RowId", null) { public TableInfo getLookupTableInfo() { - ExpRunTable result = AssayService.get().createRunTable(getProtocol(), AssayService.get().getProvider(getProtocol()), _user, _container); - result.setContainerFilter(ret.getContainerFilter()); + ExpRunTable result = AssayService.get().createRunTable(getProtocol(), AssayService.get().getProvider(getProtocol()), _user, _container, null); + result.setContainerFilter(getLookupContainerFilter()); return result; } }); @@ -452,9 +434,9 @@ public TableInfo getLookupTableInfo() } @Override - public LuminexDataTable createDataTable(boolean includeCopiedToStudyColumns) + public LuminexDataTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - LuminexDataTable table = new LuminexDataTable(this); + LuminexDataTable table = new LuminexDataTable(this, cf); if (includeCopiedToStudyColumns) { addCopiedToStudyColumns(table, true); @@ -462,16 +444,16 @@ public LuminexDataTable createDataTable(boolean includeCopiedToStudyColumns) return table; } - public ExpQCFlagTable createAnalyteTitrationQCFlagTable() + public ExpQCFlagTable createAnalyteTitrationQCFlagTable(ContainerFilter cf) { - ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ANALYTE_TITRATION_QC_FLAG_TABLE_NAME, this); + ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ANALYTE_TITRATION_QC_FLAG_TABLE_NAME, this, cf); result.populate(); result.setAssayProtocol(getProtocol()); - ColumnInfo analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); - analyteColumn.setFk(new AnalyteForeignKey(this)); - ColumnInfo titrationColumn = result.addColumn("Titration", ExpQCFlagTable.Column.IntKey2); - titrationColumn.setFk(new TitrationForeignKey(this)); + var analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); + analyteColumn.setFk(new AnalyteForeignKey(this, cf)); + var titrationColumn = result.addColumn("Titration", ExpQCFlagTable.Column.IntKey2); + titrationColumn.setFk(new TitrationForeignKey(this, cf)); result.setDescription("Contains Run QC Flags that are associated with an analyte/titration combination"); SQLFragment nonCVFlagFilter = new SQLFragment(" Key1 IS NULL AND Key2 IS NULL AND FlagType != ?"); @@ -486,16 +468,16 @@ public ExpQCFlagTable createAnalyteTitrationQCFlagTable() return result; } - public ExpQCFlagTable createAnalyteSinglePointControlQCFlagTable() + public ExpQCFlagTable createAnalyteSinglePointControlQCFlagTable(ContainerFilter cf) { - ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ANALYTE_SINGLE_POONT_CONTROL_QC_FLAG_TABLE_NAME, this); + ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ANALYTE_SINGLE_POONT_CONTROL_QC_FLAG_TABLE_NAME, this, cf); result.populate(); result.setAssayProtocol(getProtocol()); - ColumnInfo analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); - analyteColumn.setFk(new AnalyteForeignKey(this)); - ColumnInfo titrationColumn = result.addColumn("SinglePointControl", ExpQCFlagTable.Column.IntKey2); - titrationColumn.setFk(new SinglePointControlForeignKey(this)); + var analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); + analyteColumn.setFk(new AnalyteForeignKey(this, cf)); + var titrationColumn = result.addColumn("SinglePointControl", ExpQCFlagTable.Column.IntKey2); + titrationColumn.setFk(new SinglePointControlForeignKey(this, cf)); result.setDescription("Contains Run QC Flags that are associated with an analyte/single point control combination"); SQLFragment nonCVFlagFilter = new SQLFragment(" Key1 IS NULL AND Key2 IS NULL AND FlagType = ?"); @@ -510,18 +492,18 @@ public ExpQCFlagTable createAnalyteSinglePointControlQCFlagTable() return result; } - public ExpQCFlagTable createCVQCFlagTable() + public ExpQCFlagTable createCVQCFlagTable(ContainerFilter cf) { - ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ExpSchema.TableType.QCFlags.toString(), this); + ExpQCFlagTable result = ExperimentService.get().createQCFlagsTable(ExpSchema.TableType.QCFlags.toString(), this, cf); result.populate(); result.setAssayProtocol(getProtocol()); - ColumnInfo analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); - analyteColumn.setFk(new AnalyteForeignKey(this)); + var analyteColumn = result.addColumn("Analyte", ExpQCFlagTable.Column.IntKey1); + analyteColumn.setFk(new AnalyteForeignKey(this, cf)); result.addColumn("DataId", ExpQCFlagTable.Column.IntKey2); - ColumnInfo wellTypeColumn = result.addColumn("WellType", ExpQCFlagTable.Column.Key1); + var wellTypeColumn = result.addColumn("WellType", ExpQCFlagTable.Column.Key1); wellTypeColumn.setLabel("Well Type"); - ColumnInfo wellDescriptionColumn = result.addColumn("WellDescription", ExpQCFlagTable.Column.Key2); + var wellDescriptionColumn = result.addColumn("WellDescription", ExpQCFlagTable.Column.Key2); wellDescriptionColumn.setLabel("Well Description"); result.setDescription("Contains %CV QC Flags that are associated with well replicates"); @@ -627,29 +609,29 @@ public static TableInfo getTableInfoRunExclusionAnalyte() return getSchema().getTable(RUN_EXCLUSION_ANALYTE_TABLE_NAME); } - public TableInfo createWellExclusionAnalyteTable() + public TableInfo createWellExclusionAnalyteTable(ContainerFilter cf) { - FilteredTable result = new FilteredTable<>(getTableInfoWellExclusionAnalyte(), this); + FilteredTable result = new FilteredTable<>(getTableInfoWellExclusionAnalyte(), this, cf); result.wrapAllColumns(true); - result.getColumn("AnalyteId").setFk(new AnalyteForeignKey(this)); + result.getMutableColumn("AnalyteId").setFk(new AnalyteForeignKey(this, cf)); return result; } - public TableInfo createRunExclusionAnalyteTable() + public TableInfo createRunExclusionAnalyteTable(ContainerFilter cf) { - FilteredTable result = new FilteredTable<>(getTableInfoRunExclusionAnalyte(), this); + FilteredTable result = new FilteredTable<>(getTableInfoRunExclusionAnalyte(), this, cf); result.wrapAllColumns(true); - result.getColumn("AnalyteId").setFk(new AnalyteForeignKey(this)); + result.getMutableColumn("AnalyteId").setFk(new AnalyteForeignKey(this, cf)); return result; } @Override - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { - final ExpRunTable result = super.createRunsTable(); + final ExpRunTable result = super.createRunsTable(cf); // Render any PDF outputs we found as direct download links since they should be plots of standard curves - ColumnInfo curvesColumn = result.addColumn("Curves", ExpRunTable.Column.Name); + var curvesColumn = result.addColumn("Curves", ExpRunTable.Column.Name); curvesColumn.setWidth("30"); curvesColumn.setReadOnly(true); curvesColumn.setShownInInsertView(false); @@ -745,16 +727,16 @@ public static class AnalyteForeignKey extends LookupForeignKey { private final LuminexProtocolSchema _schema; - public AnalyteForeignKey(LuminexProtocolSchema schema) + public AnalyteForeignKey(LuminexProtocolSchema schema, ContainerFilter cf) { - super("RowId"); + super(cf,"RowId", null); _schema = schema; } @Override public TableInfo getLookupTableInfo() { - return _schema.createAnalyteTable(false); + return _schema.createAnalyteTable(getLookupContainerFilter(),false); } } @@ -762,16 +744,16 @@ public static class TitrationForeignKey extends LookupForeignKey { private final LuminexProtocolSchema _schema; - public TitrationForeignKey(LuminexProtocolSchema schema) + public TitrationForeignKey(LuminexProtocolSchema schema, ContainerFilter cf) { - super("RowId"); + super(cf,"RowId", null); _schema = schema; } @Override public TableInfo getLookupTableInfo() { - return _schema.createTitrationTable(false); + return _schema.createTitrationTable(getLookupContainerFilter(), false); } } @@ -779,16 +761,16 @@ public static class SinglePointControlForeignKey extends LookupForeignKey { private final LuminexProtocolSchema _schema; - public SinglePointControlForeignKey(LuminexProtocolSchema schema) + public SinglePointControlForeignKey(LuminexProtocolSchema schema, ContainerFilter cf) { - super("RowId"); + super(cf,"RowId", null); _schema = schema; } @Override public TableInfo getLookupTableInfo() { - return _schema.createSinglePointControlTable(false); + return _schema.createSinglePointControlTable(getLookupContainerFilter(), false); } } @@ -827,7 +809,7 @@ public DataView createDataView() SimpleFilter f = new SimpleFilter(); f.addCondition(FieldKey.fromParts("Standard"), false, CompareType.EQUAL); f.addCondition(FieldKey.fromParts("Run"), Integer.parseInt(runId), CompareType.EQUAL); - TableSelector tbs = new TableSelector(getSchema().getTable("Titration"), f, null); + TableSelector tbs = new TableSelector(getSchema().getTable("Titration", getContainerFilter()), f, null); long rows = tbs.getRowCount(); if (rows > 0) { diff --git a/luminex/src/org/labkey/luminex/query/RunExclusionTable.java b/luminex/src/org/labkey/luminex/query/RunExclusionTable.java index f621313d6a..3fb188843e 100644 --- a/luminex/src/org/labkey/luminex/query/RunExclusionTable.java +++ b/luminex/src/org/labkey/luminex/query/RunExclusionTable.java @@ -41,26 +41,26 @@ */ public class RunExclusionTable extends AbstractExclusionTable { - public RunExclusionTable(LuminexProtocolSchema schema, boolean filter) + public RunExclusionTable(LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoRunExclusion(), schema, filter); + super(LuminexProtocolSchema.getTableInfoRunExclusion(), schema, cf, filter); - getColumn("RunId").setLabel("Assay ID"); - getColumn("RunId").setFk(new LookupForeignKey("RowId") + getMutableColumn("RunId").setLabel("Assay ID"); + getMutableColumn("RunId").setFk(new LookupForeignKey(cf, "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createRunsTable(); + return _userSchema.createRunsTable(getLookupContainerFilter()); } }); - getColumn("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey("RunId") + getMutableColumn("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey(cf, "RunId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createRunExclusionAnalyteTable(); + return _userSchema.createRunExclusionAnalyteTable(getLookupContainerFilter()); } }, "AnalyteId")); diff --git a/luminex/src/org/labkey/luminex/query/SinglePointControlTable.java b/luminex/src/org/labkey/luminex/query/SinglePointControlTable.java index 467972f71b..8b27e89fca 100644 --- a/luminex/src/org/labkey/luminex/query/SinglePointControlTable.java +++ b/luminex/src/org/labkey/luminex/query/SinglePointControlTable.java @@ -15,7 +15,6 @@ */ package org.labkey.luminex.query; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.SQLFragment; @@ -29,17 +28,17 @@ */ public class SinglePointControlTable extends AbstractLuminexTable { - public SinglePointControlTable(LuminexProtocolSchema schema, boolean filterTable) + public SinglePointControlTable(LuminexProtocolSchema schema, ContainerFilter cf, boolean filterTable) { // expose the actual columns in the table - super(LuminexProtocolSchema.getTableInfoSinglePointControl(), schema, filterTable); + super(LuminexProtocolSchema.getTableInfoSinglePointControl(), schema, cf, filterTable); setName(LuminexProtocolSchema.SINGLE_POINT_CONTROL_TABLE_NAME); addWrapColumn(getRealTable().getColumn("RowId")); addWrapColumn(getRealTable().getColumn("Name")); // Alias the RunId column to be consistent with other Schema columns - ColumnInfo runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); - runColumn.setFk(new QueryForeignKey(schema, null, AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name")); + var runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); + runColumn.setFk( QueryForeignKey.from(schema, cf).to(AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name") ); } @Override diff --git a/luminex/src/org/labkey/luminex/query/TitrationTable.java b/luminex/src/org/labkey/luminex/query/TitrationTable.java index 1885076ce9..127bbc0df6 100644 --- a/luminex/src/org/labkey/luminex/query/TitrationTable.java +++ b/luminex/src/org/labkey/luminex/query/TitrationTable.java @@ -15,7 +15,6 @@ */ package org.labkey.luminex.query; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; @@ -34,13 +33,13 @@ */ public class TitrationTable extends AbstractLuminexTable { - public TitrationTable(LuminexProtocolSchema schema, boolean filter) + public TitrationTable(LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoTitration(), schema, filter); + super(LuminexProtocolSchema.getTableInfoTitration(), schema, cf, filter); setName(LuminexProtocolSchema.TITRATION_TABLE_NAME); addColumn(wrapColumn(getRealTable().getColumn("RowId"))).setHidden(true); - ColumnInfo nameColumn = addColumn(wrapColumn(getRealTable().getColumn("Name"))); + var nameColumn = addColumn(wrapColumn(getRealTable().getColumn("Name"))); ActionURL url = new ActionURL(LuminexController.LeveyJenningsReportAction.class, schema.getContainer()); nameColumn.setURL(StringExpressionFactory.createURL(url + "rowId=${Run/Protocol/RowId}" + "&titration=${Name}")); @@ -62,8 +61,8 @@ public TitrationTable(LuminexProtocolSchema schema, boolean filter) qcReportSQL.append(" THEN ").append(bTRUE).append(" ELSE ").append(bFALSE).append(" END)"); addColumn(new ExprColumn(this, "IncludeInQcReport", qcReportSQL, JdbcType.BOOLEAN)); - ColumnInfo runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); - QueryForeignKey runFk = new QueryForeignKey(schema, null, AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name"); + var runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); + var runFk = QueryForeignKey.from(schema, cf).to(AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name"); runColumn.setFk(runFk); setTitleColumn("Name"); } diff --git a/luminex/src/org/labkey/luminex/query/WellExclusionTable.java b/luminex/src/org/labkey/luminex/query/WellExclusionTable.java index 1d27438795..d3de6972b3 100644 --- a/luminex/src/org/labkey/luminex/query/WellExclusionTable.java +++ b/luminex/src/org/labkey/luminex/query/WellExclusionTable.java @@ -70,22 +70,22 @@ */ public class WellExclusionTable extends AbstractExclusionTable { - public WellExclusionTable(LuminexProtocolSchema schema, boolean filter) + public WellExclusionTable(LuminexProtocolSchema schema, ContainerFilter cf, boolean filter) { - super(LuminexProtocolSchema.getTableInfoWellExclusion(), schema, filter); + super(LuminexProtocolSchema.getTableInfoWellExclusion(), schema, cf, filter); - getColumn("DataId").setLabel("Data File"); - getColumn("DataId").setFk(new ExpSchema(schema.getUser(), schema.getContainer()).getDataIdForeignKey()); - - getColumn("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey("WellExclusionId") + getMutableColumn("DataId").setLabel("Data File"); + getMutableColumn("DataId").setFk(new ExpSchema(schema.getUser(), schema.getContainer()).getDataIdForeignKey()); + + getMutableColumn("Analytes").setFk(new MultiValuedForeignKey(new LookupForeignKey(cf, "WellExclusionId", null) { @Override public TableInfo getLookupTableInfo() { - return _userSchema.createWellExclusionAnalyteTable(); + return _userSchema.createWellExclusionAnalyteTable(getLookupContainerFilter()); } }, "AnalyteId")); - getColumn("Analytes").setUserEditable(false); + getMutableColumn("Analytes").setUserEditable(false); SQLFragment joinSQL = new SQLFragment(" FROM "); joinSQL.append(LuminexProtocolSchema.getTableInfoDataRow(), "dr"); diff --git a/microarray/src/org/labkey/microarray/PendingMageMLFilesView.java b/microarray/src/org/labkey/microarray/PendingMageMLFilesView.java index f0484937db..5231530d2e 100644 --- a/microarray/src/org/labkey/microarray/PendingMageMLFilesView.java +++ b/microarray/src/org/labkey/microarray/PendingMageMLFilesView.java @@ -142,7 +142,7 @@ protected void populateButtonBar(DataView view, ButtonBar bar) protected TableInfo createTable() { - ExpDataTable table = ExperimentService.get().createDataTable("pendingFile", getSchema()); + ExpDataTable table = ExperimentService.get().createDataTable("pendingFile", getSchema(), getContainerFilter()); table.setRun(null); table.setDataType(MicroarrayModule.MAGE_ML_INPUT_TYPE); table.populate(); diff --git a/microarray/src/org/labkey/microarray/affy/AffymetrixProtocolSchema.java b/microarray/src/org/labkey/microarray/affy/AffymetrixProtocolSchema.java index f1170c800c..61996f688a 100644 --- a/microarray/src/org/labkey/microarray/affy/AffymetrixProtocolSchema.java +++ b/microarray/src/org/labkey/microarray/affy/AffymetrixProtocolSchema.java @@ -17,11 +17,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; -import org.labkey.api.data.ContainerFilterable; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.DisplayColumnFactory; +import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.security.User; import org.labkey.api.study.assay.AssayProtocolSchema; @@ -37,23 +39,23 @@ public class AffymetrixProtocolSchema extends AssayProtocolSchema @Nullable @Override - public ContainerFilterable createDataTable(boolean includeCopiedToStudyColumns) + public TableInfo createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - return new AssayResultTable(this, includeCopiedToStudyColumns); + return new AssayResultTable(this, cf, includeCopiedToStudyColumns); } @Nullable @Override - public final ContainerFilterable createDataTable() + public final TableInfo createDataTable(ContainerFilter cf) { - ContainerFilterable table = super.createDataTable(); + TableInfo table = super.createDataTable(cf); if (null != table) { ColumnInfo columnInfo = table.getColumn(AffymetrixAssayProvider.SAMPLE_NAME_COLUMN); if (columnInfo != null) { - columnInfo.setDisplayColumnFactory(new DisplayColumnFactory() + ((BaseColumnInfo)columnInfo).setDisplayColumnFactory(new DisplayColumnFactory() { @Override public DisplayColumn createRenderer(ColumnInfo colInfo) diff --git a/microarray/src/org/labkey/microarray/assay/MicroarrayProtocolSchema.java b/microarray/src/org/labkey/microarray/assay/MicroarrayProtocolSchema.java index 3a863b2f25..c902a6348b 100644 --- a/microarray/src/org/labkey/microarray/assay/MicroarrayProtocolSchema.java +++ b/microarray/src/org/labkey/microarray/assay/MicroarrayProtocolSchema.java @@ -20,6 +20,7 @@ import org.labkey.api.data.ActionButton; import org.labkey.api.data.ButtonBar; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.exp.query.ExpRunTable; import org.labkey.api.query.FieldKey; @@ -54,9 +55,9 @@ public MicroarrayProtocolSchema(User user, Container container, @NotNull Microar } @Override - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { - ExpRunTable result = super.createRunsTable(); + ExpRunTable result = super.createRunsTable(cf); new MicroarrayUserSchema(getUser(), getContainer()).configureRunsTable(result); if (getProvider().isEditableRuns(getProtocol())) @@ -68,9 +69,9 @@ public ExpRunTable createRunsTable() } @Override - public AssayResultTable createDataTable(boolean includeCopiedToStudyColumns) + public AssayResultTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - AssayResultTable result = new AssayResultTable(this, includeCopiedToStudyColumns); + AssayResultTable result = new AssayResultTable(this, cf, includeCopiedToStudyColumns); if (!AbstractAssayProvider.getDomainByPrefix(getProtocol(), ExpProtocol.ASSAY_DOMAIN_DATA).getProperties().isEmpty()) { List cols = new ArrayList<>(result.getDefaultVisibleColumns()); diff --git a/microarray/src/org/labkey/microarray/matrix/ExpressionMatrixProtocolSchema.java b/microarray/src/org/labkey/microarray/matrix/ExpressionMatrixProtocolSchema.java index a67ef5bf72..73219559a1 100644 --- a/microarray/src/org/labkey/microarray/matrix/ExpressionMatrixProtocolSchema.java +++ b/microarray/src/org/labkey/microarray/matrix/ExpressionMatrixProtocolSchema.java @@ -15,10 +15,10 @@ */ package org.labkey.microarray.matrix; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.query.FilteredTable; @@ -28,7 +28,6 @@ import org.labkey.microarray.MicroarrayManager; import org.labkey.microarray.query.MicroarrayUserSchema; -import java.sql.SQLException; import java.util.List; import java.util.Map; @@ -47,17 +46,17 @@ public ExpressionMatrixProtocolSchema(User user, Container container, @NotNull E } @Override - public FilteredTable createDataTable(boolean includeCopiedToStudyColumns) + public FilteredTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - FeatureDataTable result = new FeatureDataTable(this); + FeatureDataTable result = new FeatureDataTable(this, cf); result.setName(AssayProtocolSchema.DATA_TABLE_NAME); return result; } @Override - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { - return super.createTable(name, FEATURE_ID, SAMPLE_ID, VALUE_MEASURE_ID, TITLE); //TODO: Looks a bit funny, modify? + return super.createTable(name, cf, FEATURE_ID, SAMPLE_ID, VALUE_MEASURE_ID, TITLE); //TODO: Looks a bit funny, modify? } @Override @@ -69,9 +68,9 @@ public List getDistinctSampleIds() } @Override - public TableInfo getDataTableInfo() + public TableInfo getDataTableInfo(ContainerFilter cf) { - return new FeatureDataTable(this); + return new FeatureDataTable(this, cf); } public static TableInfo getTableInfoFeatureData() diff --git a/microarray/src/org/labkey/microarray/matrix/FeatureDataTable.java b/microarray/src/org/labkey/microarray/matrix/FeatureDataTable.java index 9d12fd29fe..794c9654e7 100644 --- a/microarray/src/org/labkey/microarray/matrix/FeatureDataTable.java +++ b/microarray/src/org/labkey/microarray/matrix/FeatureDataTable.java @@ -16,7 +16,6 @@ package org.labkey.microarray.matrix; import org.labkey.api.data.AbstractTableInfo; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; @@ -34,48 +33,56 @@ public class FeatureDataTable extends FilteredTable { - public FeatureDataTable(ExpressionMatrixProtocolSchema schema) + public FeatureDataTable(ExpressionMatrixProtocolSchema schema, ContainerFilter cf) { - super(ExpressionMatrixProtocolSchema.getTableInfoFeatureData(), schema); + super(ExpressionMatrixProtocolSchema.getTableInfoFeatureData(), schema, cf); setDetailsURL(AbstractTableInfo.LINK_DISABLER); setImportURL(AbstractTableInfo.LINK_DISABLER); addColumn(wrapColumn(getRealTable().getColumn("RowId"))).setHidden(true); - ColumnInfo valueColumn = addColumn(wrapColumn(getRealTable().getColumn("Value"))); + var valueColumn = addColumn(wrapColumn(getRealTable().getColumn("Value"))); valueColumn.setHidden(false); valueColumn.setLabel("Value"); valueColumn.setFormat("0.000000"); - ColumnInfo featureIdColumn = addColumn(wrapColumn(getRealTable().getColumn("FeatureId"))); + var featureIdColumn = addColumn(wrapColumn(getRealTable().getColumn("FeatureId"))); featureIdColumn.setHidden(false); featureIdColumn.setLabel("Probe Id"); - featureIdColumn.setFk(new QueryForeignKey(MicroarrayUserSchema.SCHEMA_NAME, schema.getContainer(), null, - schema.getUser(), MicroarrayUserSchema.TABLE_FEATURE_ANNOTATION, "RowId", "FeatureId")); + featureIdColumn.setFk(QueryForeignKey + .from(schema, cf) + .schema(MicroarrayUserSchema.SCHEMA_NAME) + .to(MicroarrayUserSchema.TABLE_FEATURE_ANNOTATION, "RowId", "FeatureId")); - ColumnInfo sampleIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SampleId"))); + var sampleIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SampleId"))); sampleIdColumn.setHidden(false); sampleIdColumn.setLabel("Sample Id"); // Lookup to exp.materials since we don't know the sample set - sampleIdColumn.setFk(new QueryForeignKey(ExpSchema.SCHEMA_NAME, schema.getContainer(), null, schema.getUser(), - "materials","RowId","Name")); + sampleIdColumn.setFk(QueryForeignKey + .from(schema, cf) + .schema(ExpSchema.SCHEMA_NAME) + .to("materials", "RowId", "Name")); SQLFragment runSQL = new SQLFragment("(SELECT d.RunId FROM "); runSQL.append(ExperimentService.get().getTinfoData(), "d"); runSQL.append(" WHERE d.RowId = "); runSQL.append(ExprColumn.STR_TABLE_ALIAS); runSQL.append(".DataId)"); - ColumnInfo runIdColumn = new ExprColumn(this, "Run", runSQL, JdbcType.INTEGER); + var runIdColumn = new ExprColumn(this, "Run", runSQL, JdbcType.INTEGER); addColumn(runIdColumn); - runIdColumn.setFk(new QueryForeignKey(getUserSchema(), null, AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name")); + runIdColumn.setFk(QueryForeignKey + .from(getUserSchema(), getContainerFilter()) + .to(AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name")); - ColumnInfo dataIdColumn = addColumn(wrapColumn(getRealTable().getColumn("DataId"))); + var dataIdColumn = addColumn(wrapColumn(getRealTable().getColumn("DataId"))); dataIdColumn.setHidden(false); dataIdColumn.setLabel("Data Id"); - dataIdColumn.setFk(new QueryForeignKey(ExpSchema.SCHEMA_NAME, schema.getContainer(), null, schema.getUser(), ExpSchema.TableType.Data.toString(), - "RowId", "Name")); + dataIdColumn.setFk(QueryForeignKey + .from(getUserSchema(), getContainerFilter()) + .schema(ExpSchema.SCHEMA_NAME, schema.getContainer()) + .to( ExpSchema.TableType.Data.name(),"RowId", "Name")); List columns = new ArrayList<>(getDefaultVisibleColumns()); columns.remove(dataIdColumn.getFieldKey()); diff --git a/microarray/src/org/labkey/microarray/query/FeatureAnnotationSetTable.java b/microarray/src/org/labkey/microarray/query/FeatureAnnotationSetTable.java index 443fc60727..b0147a590a 100644 --- a/microarray/src/org/labkey/microarray/query/FeatureAnnotationSetTable.java +++ b/microarray/src/org/labkey/microarray/query/FeatureAnnotationSetTable.java @@ -33,10 +33,15 @@ public class FeatureAnnotationSetTable extends SimpleUserSchema.SimpleTable { - FeatureAnnotationSetTable(MicroarrayUserSchema s, TableInfo t) + @Override + protected ContainerFilter getDefaultContainerFilter() + { + return new ContainerFilter.CurrentPlusProjectAndShared(getUserSchema().getUser()); + } + + FeatureAnnotationSetTable(MicroarrayUserSchema s, TableInfo t, ContainerFilter cf) { - super(s, t); - setContainerFilter(new ContainerFilter.CurrentPlusProjectAndShared(s.getUser())); + super(s, t, cf); } @Override diff --git a/microarray/src/org/labkey/microarray/query/MicroarrayUserSchema.java b/microarray/src/org/labkey/microarray/query/MicroarrayUserSchema.java index ba94119363..1161daf88f 100644 --- a/microarray/src/org/labkey/microarray/query/MicroarrayUserSchema.java +++ b/microarray/src/org/labkey/microarray/query/MicroarrayUserSchema.java @@ -99,11 +99,11 @@ public Set getTableNames() return hs; } - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { if (TABLE_RUNS.equalsIgnoreCase(name)) { - return createRunsTable(); + return createRunsTable(cf); } if (getTableNames().contains(name)) @@ -111,17 +111,17 @@ public TableInfo createTable(String name) SchemaTableInfo tableInfo = getSchema().getTable(name); if (name.equalsIgnoreCase(TABLE_FEATURE_ANNOTATION_SET)) { - SimpleTable table = new FeatureAnnotationSetTable(this, tableInfo).init(); + SimpleTable table = new FeatureAnnotationSetTable(this, tableInfo, cf).init(); return table; } if (name.equalsIgnoreCase(TABLE_FEATURE_ANNOTATION)) { - SimpleTable table = new FeatureAnnotationSetTable(this, tableInfo).init(); + SimpleTable table = new FeatureAnnotationSetTable(this, tableInfo, cf).init(); return table; } else { - SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, tableInfo).init(); + SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, tableInfo, cf).init(); return table; } } @@ -160,9 +160,12 @@ public TableInfo getAnnotationTable() return getTable(TABLE_FEATURE_ANNOTATION); } - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { - ExpRunTable result = _expSchema.getRunsTable(); + ExpRunTable result = _expSchema.getRunsTable(true); + // CONSIDER: wrap with FilteredTable instead of hacking on the ExpRunTable? + cf = null==cf ? getDefaultContainerFilter() : cf; + result.setContainerFilter(cf); configureRunsTable(result); return result; @@ -170,14 +173,14 @@ public ExpRunTable createRunsTable() public void configureRunsTable(ExpRunTable result) { - result.getColumn(ExpRunTable.Column.Name).setURL(new DetailsURL(new ActionURL(AssayDetailRedirectAction.class, _expSchema.getContainer()), Collections.singletonMap("runId", "rowId"))); + result.getMutableColumn(ExpRunTable.Column.Name).setURL(new DetailsURL(new ActionURL(AssayDetailRedirectAction.class, _expSchema.getContainer()), Collections.singletonMap("runId", "rowId"))); result.setProtocolPatterns("urn:lsid:%:" + MicroarrayAssayProvider.PROTOCOL_PREFIX + ".%"); SQLFragment thumbnailSQL = new SQLFragment("(SELECT MIN(d.RowId)\n" + "\nFROM " + ExperimentService.get().getTinfoData() + " d " + "\nWHERE d.RunId = " + ExprColumn.STR_TABLE_ALIAS + ".RowId AND d.LSID LIKE '%:" + MicroarrayModule.THUMBNAIL_INPUT_TYPE.getNamespacePrefix() + "%')"); - ColumnInfo thumbnailColumn = new ExprColumn(result, THUMBNAIL_IMAGE_COLUMN_NAME, thumbnailSQL, JdbcType.INTEGER); + var thumbnailColumn = new ExprColumn(result, THUMBNAIL_IMAGE_COLUMN_NAME, thumbnailSQL, JdbcType.INTEGER); thumbnailColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -191,7 +194,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) SQLFragment qcReportSQL = new SQLFragment("(SELECT MIN(d.RowId)\n" + "\nFROM " + ExperimentService.get().getTinfoData() + " d " + "\nWHERE d.RunId = " + ExprColumn.STR_TABLE_ALIAS + ".RowId AND d.LSID LIKE '%:" + MicroarrayModule.QC_REPORT_INPUT_TYPE.getNamespacePrefix() + "%')"); - ColumnInfo qcReportColumn = new ExprColumn(result, QC_REPORT_COLUMN_NAME, qcReportSQL, JdbcType.INTEGER); + var qcReportColumn = new ExprColumn(result, QC_REPORT_COLUMN_NAME, qcReportSQL, JdbcType.INTEGER); qcReportColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) diff --git a/ms1/src/org/labkey/ms1/MS1ServiceImpl.java b/ms1/src/org/labkey/ms1/MS1ServiceImpl.java index 075cf85803..e060489cb2 100644 --- a/ms1/src/org/labkey/ms1/MS1ServiceImpl.java +++ b/ms1/src/org/labkey/ms1/MS1ServiceImpl.java @@ -37,6 +37,6 @@ public TableInfo createFeaturesTableInfo(User user, Container container) public TableInfo createFeaturesTableInfo(User user, Container container, boolean includePepFk) { - return new MS1Schema(user, container).getFeaturesTableInfo(includePepFk); + return new MS1Schema(user, container).getFeaturesTableInfo(null, includePepFk); } } diff --git a/ms1/src/org/labkey/ms1/query/FeaturesTableInfo.java b/ms1/src/org/labkey/ms1/query/FeaturesTableInfo.java index 9fefebd9e8..f32ed80faa 100644 --- a/ms1/src/org/labkey/ms1/query/FeaturesTableInfo.java +++ b/ms1/src/org/labkey/ms1/query/FeaturesTableInfo.java @@ -50,14 +50,14 @@ public class FeaturesTableInfo extends VirtualTable private List _filters = null; private boolean _includeDeleted = false; - public FeaturesTableInfo(MS1Schema schema, boolean includePepFk) + public FeaturesTableInfo(MS1Schema schema, ContainerFilter cf, boolean includePepFk) { - this(schema, includePepFk, null); + this(schema, cf, includePepFk, null); } - public FeaturesTableInfo(MS1Schema schema, boolean includePepFk, Boolean peaksAvailable) + public FeaturesTableInfo(MS1Schema schema, ContainerFilter cf, boolean includePepFk, Boolean peaksAvailable) { - super(schema.getDbSchema(), "Features", schema); + super(schema.getDbSchema(), "Features", schema, cf); setDescription("Contains all features from all MS1 experiment runs loaded into this folder."); _sourceTable = MS1Manager.get().getTable(MS1Service.Tables.Features.name()); @@ -66,12 +66,13 @@ public FeaturesTableInfo(MS1Schema schema, boolean includePepFk, Boolean peaksAv //wrap all the columns wrapAllColumns(true); + // TODO use QueryForeignKey //tell query that FileId is an FK to the Files user table info - getColumn("FileId").setFk(new LookupForeignKey("FileId") + getMutableColumn("FileId").setFk(new LookupForeignKey("FileId") { public TableInfo getLookupTableInfo() { - return getUserSchema().getFilesTableInfo(); + return getUserSchema().getFilesTableInfo(cf); } }); @@ -91,7 +92,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) if(includePepFk) { - ColumnInfo ciPepId = addColumn(new ExprColumn(this, COLUMN_PEPTIDE_INFO, + var ciPepId = addColumn(new ExprColumn(this, COLUMN_PEPTIDE_INFO, new SQLFragment(COLUMN_PEPTIDE_INFO), JdbcType.INTEGER)); //tell query that this new column is an FK to the peptides data table @@ -109,7 +110,7 @@ public TableInfo getLookupTableInfo() } //if(includePepFk) //make the ms2 scan a hyperlink to showPeptide view - ColumnInfo ciMS2Scan = getColumn("MS2Scan"); + var ciMS2Scan = getMutableColumn("MS2Scan"); ciMS2Scan.setURL(StringExpressionFactory.createURL(urlPep)); ciMS2Scan.setDisplayColumnFactory(dcfPep); @@ -120,7 +121,7 @@ public TableInfo getLookupTableInfo() addColumn(new PeaksAvailableColumnInfo(this)); //add a column for the find similar link - ColumnInfo similarLinkCol = addColumn(wrapColumn(COLUMN_FIND_SIMILAR_LINK, getSourceTable().getColumn("FeatureId"))); + var similarLinkCol = addColumn(wrapColumn(COLUMN_FIND_SIMILAR_LINK, getSourceTable().getColumn("FeatureId"))); similarLinkCol.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -280,14 +281,14 @@ protected void wrapAllColumns(boolean preserveHidden) { for (ColumnInfo col : getSourceTable().getColumns()) { - ColumnInfo newCol = new AliasedColumn(this, col.getName(), col); + var newCol = new AliasedColumn(this, col.getName(), col); addColumn(newCol); if (preserveHidden && col.isHidden()) newCol.setHidden(col.isHidden()); } } - public ColumnInfo wrapColumn(String alias, ColumnInfo underlyingColumn) + public BaseColumnInfo wrapColumn(String alias, ColumnInfo underlyingColumn) { assert underlyingColumn.getParentTable() == getSourceTable(); ExprColumn ret = new ExprColumn(this, alias, underlyingColumn.getValueSql(ExprColumn.STR_TABLE_ALIAS), underlyingColumn.getJdbcType()); diff --git a/ms1/src/org/labkey/ms1/query/FilesTableInfo.java b/ms1/src/org/labkey/ms1/query/FilesTableInfo.java index e4567768f0..e5c2825907 100644 --- a/ms1/src/org/labkey/ms1/query/FilesTableInfo.java +++ b/ms1/src/org/labkey/ms1/query/FilesTableInfo.java @@ -16,7 +16,6 @@ package org.labkey.ms1.query; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; @@ -41,8 +40,8 @@ public FilesTableInfo(ExpSchema expSchema, ContainerFilter filter) wrapAllColumns(true); - getColumn("FileId").setHidden(true); - ColumnInfo edfid = getColumn("ExpDataFileId"); + getMutableColumn("FileId").setHidden(true); + var edfid = getMutableColumn("ExpDataFileId"); edfid.setFk(new LookupForeignKey("RowId") { public TableInfo getLookupTableInfo() diff --git a/ms1/src/org/labkey/ms1/query/MS1Schema.java b/ms1/src/org/labkey/ms1/query/MS1Schema.java index 4a6e296fc2..9a88211997 100644 --- a/ms1/src/org/labkey/ms1/query/MS1Schema.java +++ b/ms1/src/org/labkey/ms1/query/MS1Schema.java @@ -16,6 +16,7 @@ package org.labkey.ms1.query; +import org.jetbrains.annotations.NotNull; import org.labkey.api.module.Module; import org.labkey.api.protein.ProteinService; import org.labkey.api.data.*; @@ -85,6 +86,12 @@ public MS1Schema(User user, Container container, boolean restrictContainer) } } + @Override + public @NotNull ContainerFilter getDefaultContainerFilter() + { + return _containerFilter; + } + public boolean isRestrictContainer() { return _restrictContainer; @@ -102,29 +109,29 @@ public Set getTableNames() return ret; } - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { if (TABLE_FEATURE_RUNS.equalsIgnoreCase(name)) - return getMS1ExpRunsTableInfo(); + return getMS1ExpRunsTableInfo(cf); else if(TABLE_FEATURES.equalsIgnoreCase(name)) - return getFeaturesTableInfo(); + return getFeaturesTableInfo(cf); else if(TABLE_FEATURES_SEARCH.equalsIgnoreCase(name)) - return getFeaturesTableInfoSearch(); + return getFeaturesTableInfoSearch(cf); else if(TABLE_PEAKS.equalsIgnoreCase(name)) - return getPeaksTableInfo(); + return getPeaksTableInfo(cf); else if(TABLE_FILES.equalsIgnoreCase(name)) - return getFilesTableInfo(); + return getFilesTableInfo(cf); else if(TABLE_SCANS.equalsIgnoreCase(name)) - return getScansTableInfo(); + return getScansTableInfo(cf); else if(TABLE_COMPARE_PEP.equalsIgnoreCase(name)) - return getComparePeptideTableInfo(null); + return getComparePeptideTableInfo(cf, null); return null; } //getTable() - public CrosstabTableInfo getComparePeptideTableInfo(int[] runIds) + public CrosstabTableInfo getComparePeptideTableInfo(ContainerFilter cf, int[] runIds) { - FeaturesTableInfo tinfo = getFeaturesTableInfo(true, true); + FeaturesTableInfo tinfo = getFeaturesTableInfo(cf, true, true); ArrayList filters = new ArrayList<>(); //OK if runIds is null RunFilter runFilter = new RunFilter(runIds); @@ -147,12 +154,12 @@ public CrosstabTableInfo getComparePeptideTableInfo(int[] runIds) //setup the feature id column as an FK to itself so that the first feature measure will allow //users to add other info from the features table. - ColumnInfo featureIdCol = tinfo.getColumn("FeatureId"); + var featureIdCol = tinfo.getMutableColumn("FeatureId"); featureIdCol.setFk(new LookupForeignKey("FeatureId", "FeatureId") { public TableInfo getLookupTableInfo() { - FeaturesTableInfo table = getFeaturesTableInfo(false, Boolean.TRUE); + FeaturesTableInfo table = getFeaturesTableInfo(cf,false, Boolean.TRUE); //set include deleted true so that we don't include the files table in the join //without it, we get a too many tables exception from SQL Server table.setIncludeDeleted(true); @@ -198,14 +205,14 @@ public TableInfo getLookupTableInfo() return cti; } - public FeaturesTableInfo getFeaturesTableInfo() + public FeaturesTableInfo getFeaturesTableInfo(ContainerFilter cf) { - return getFeaturesTableInfo(true); + return getFeaturesTableInfo(cf,true); } //getFeaturesTableInfo() - public FeaturesTableInfo getFeaturesTableInfoSearch() + public FeaturesTableInfo getFeaturesTableInfoSearch(ContainerFilter cf) { - FeaturesTableInfo table = getFeaturesTableInfo(true); + FeaturesTableInfo table = getFeaturesTableInfo(cf,true); //change the default visible columnset ArrayList visibleColumns = new ArrayList<>(table.getDefaultVisibleColumns()); @@ -219,35 +226,37 @@ public FeaturesTableInfo getFeaturesTableInfoSearch() return table; } //getFeaturesTableInfo() - public FeaturesTableInfo getFeaturesTableInfo(boolean includePepFk) + public FeaturesTableInfo getFeaturesTableInfo(ContainerFilter cf, boolean includePepFk) { - return new FeaturesTableInfo(this, includePepFk); + return new FeaturesTableInfo(this, cf, includePepFk); } //getFeaturesTableInfo() - public FeaturesTableInfo getFeaturesTableInfo(boolean includePepFk, Boolean peaksAvailable) + public FeaturesTableInfo getFeaturesTableInfo(ContainerFilter cf, boolean includePepFk, Boolean peaksAvailable) { - return new FeaturesTableInfo(this, includePepFk, peaksAvailable); + return new FeaturesTableInfo(this, cf, includePepFk, peaksAvailable); } //getFeaturesTableInfo() - public PeaksTableInfo getPeaksTableInfo() + public PeaksTableInfo getPeaksTableInfo(ContainerFilter cf) { - return new PeaksTableInfo(this); + return new PeaksTableInfo(this, cf); } - public FilesTableInfo getFilesTableInfo() + public FilesTableInfo getFilesTableInfo(ContainerFilter cf) { return new FilesTableInfo(_expSchema, _containerFilter); } - public ScansTableInfo getScansTableInfo() + public ScansTableInfo getScansTableInfo(ContainerFilter cf) { - return new ScansTableInfo(this); + return new ScansTableInfo(this, cf); } - public ExpRunTable getMS1ExpRunsTableInfo() + public ExpRunTable getMS1ExpRunsTableInfo(ContainerFilter cf) { // Start with a standard experiment run table - ExpRunTable result = _expSchema.getRunsTable(); + ExpRunTable result = _expSchema.getRunsTable(true); + if (null != cf) + result.setContainerFilter(cf); result.setDescription("Contains a row per MS1 experiment run imported into this folder."); // Filter to just the runs with the MS1 protocol @@ -258,7 +267,7 @@ public ExpRunTable getMS1ExpRunsTableInfo() ColumnInfo rowIdCol = result.getColumn("RowId"); if(rowIdCol != null) { - ColumnInfo featuresLinkCol = result.addColumn(new ExprColumn(result, "Features Link", + var featuresLinkCol = result.addColumn(new ExprColumn(result, "Features Link", new SQLFragment(rowIdCol.getValueSql(ExprColumn.STR_TABLE_ALIAS)), rowIdCol.getJdbcType(), rowIdCol)); featuresLinkCol.setDescription("Link to the msInspect features found in each run"); featuresLinkCol.setDisplayColumnFactory(new DisplayColumnFactory() @@ -271,7 +280,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) } //reset the URL on the name column to jump to our feature details view - ColumnInfo nameCol = result.getColumn("Name"); + var nameCol = result.getMutableColumn(ExpRunTable.Column.Name ); if(null != nameCol) { ActionURL featuresUrl = new ActionURL(MS1Controller.ShowFeaturesAction.class, getContainer()); diff --git a/ms1/src/org/labkey/ms1/query/PeaksTableInfo.java b/ms1/src/org/labkey/ms1/query/PeaksTableInfo.java index 65b40b9614..72f6e8c32b 100644 --- a/ms1/src/org/labkey/ms1/query/PeaksTableInfo.java +++ b/ms1/src/org/labkey/ms1/query/PeaksTableInfo.java @@ -16,7 +16,7 @@ package org.labkey.ms1.query; -import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; import org.labkey.api.data.Container; @@ -36,15 +36,15 @@ */ public class PeaksTableInfo extends FilteredTable { - public PeaksTableInfo(MS1Schema schema) + public PeaksTableInfo(MS1Schema schema, ContainerFilter cf) { - super(MS1Manager.get().getTable(MS1Manager.TABLE_PEAKS), schema); + super(MS1Manager.get().getTable(MS1Manager.TABLE_PEAKS), schema, cf); //wrap all the columns wrapAllColumns(true); //tell query that Peaks joins to PeaksToFamilies so we can add the PeakFamily columns - ColumnInfo peakFamCol = wrapColumn("PeakFamilies", getRealTable().getColumn("PeakId")); + var peakFamCol = wrapColumn("PeakFamilies", getRealTable().getColumn("PeakId")); peakFamCol.setIsUnselectable(true); peakFamCol.setDescription("Link to the Peak Family information"); peakFamCol.setFk(new LookupForeignKey("PeakId") @@ -58,13 +58,13 @@ public TableInfo getLookupTableInfo() addColumn(peakFamCol); //tell query to use our user schema for scans - ColumnInfo scanCol = getColumn("ScanId"); + var scanCol = getMutableColumn("ScanId"); scanCol.setFk(new LookupForeignKey("ScanId") { public TableInfo getLookupTableInfo() { setPrefixColumnCaption(false); - return _userSchema.getScansTableInfo(); + return _userSchema.getScansTableInfo(cf); } }); @@ -78,7 +78,7 @@ public TableInfo getLookupTableInfo() setDefaultVisibleColumns(visibleColumns); //mark the PeakId column as hidden - getColumn("PeakId").setHidden(true); + getMutableColumn("PeakId").setHidden(true); //add a condition that limits the features returned to just those existing in the //current container. The FilteredTable class supports this automatically only if diff --git a/ms1/src/org/labkey/ms1/query/ScansTableInfo.java b/ms1/src/org/labkey/ms1/query/ScansTableInfo.java index 0adf9f6d81..43c195eb0e 100644 --- a/ms1/src/org/labkey/ms1/query/ScansTableInfo.java +++ b/ms1/src/org/labkey/ms1/query/ScansTableInfo.java @@ -16,7 +16,7 @@ package org.labkey.ms1.query; -import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; import org.labkey.api.query.FieldKey; @@ -32,17 +32,17 @@ */ public class ScansTableInfo extends FilteredTable { - public ScansTableInfo(MS1Schema schema) + public ScansTableInfo(MS1Schema schema, ContainerFilter cf) { - super(MS1Manager.get().getTable(MS1Manager.TABLE_SCANS), schema); + super(MS1Manager.get().getTable(MS1Manager.TABLE_SCANS), schema, cf); wrapAllColumns(true); - ColumnInfo fid = getColumn("FileId"); + var fid = getMutableColumn("FileId"); fid.setFk(new LookupForeignKey("FileId") { public TableInfo getLookupTableInfo() { - return _userSchema.getFilesTableInfo(); + return _userSchema.getFilesTableInfo(cf); } }); diff --git a/ms1/src/org/labkey/ms1/view/CompareRunsView.java b/ms1/src/org/labkey/ms1/view/CompareRunsView.java index 637d4108b7..b1dcdf89bf 100644 --- a/ms1/src/org/labkey/ms1/view/CompareRunsView.java +++ b/ms1/src/org/labkey/ms1/view/CompareRunsView.java @@ -54,7 +54,7 @@ public CompareRunsView(MS1Schema schema, int[] runIds, ActionURL url) protected TableInfo createTable() { - return _schema.getComparePeptideTableInfo(_runIds); + return _schema.getComparePeptideTableInfo(getContainerFilter(), _runIds); } public DataView createDataView() diff --git a/ms1/src/org/labkey/ms1/view/FeaturesView.java b/ms1/src/org/labkey/ms1/view/FeaturesView.java index 39fb4779ae..31c1662fda 100644 --- a/ms1/src/org/labkey/ms1/view/FeaturesView.java +++ b/ms1/src/org/labkey/ms1/view/FeaturesView.java @@ -148,7 +148,9 @@ protected TableInfo createTable() { assert null != _ms1Schema : "MS1 Schema was not set in FeaturesView class!"; - FeaturesTableInfo tinfo = _forSearch ? _ms1Schema.getFeaturesTableInfoSearch() : _ms1Schema.getFeaturesTableInfo(true, _peaksAvailable); + FeaturesTableInfo tinfo = _forSearch ? + _ms1Schema.getFeaturesTableInfoSearch(getContainerFilter()) : + _ms1Schema.getFeaturesTableInfo(getContainerFilter(), true, _peaksAvailable); tinfo.setBaseFilters(_baseFilters); return tinfo; } diff --git a/ms1/src/org/labkey/ms1/view/PeaksView.java b/ms1/src/org/labkey/ms1/view/PeaksView.java index b5fd1a9dab..c5e02d4f43 100644 --- a/ms1/src/org/labkey/ms1/view/PeaksView.java +++ b/ms1/src/org/labkey/ms1/view/PeaksView.java @@ -44,11 +44,6 @@ */ public class PeaksView extends QueryView { - public PeaksView(ViewContext ctx, MS1Schema schema, ExpRun run, Feature feature) - { - this(ctx, schema, run, feature, feature.getScanFirst().intValue(), feature.getScanLast().intValue()); - } - public PeaksView(ViewContext ctx, MS1Schema schema, ExpRun run, Feature feature, int scanFirst, int scanLast) { super(schema); @@ -80,7 +75,7 @@ public boolean accept(String type, String label) protected TableInfo createTable() { - PeaksTableInfo tinfo = _schema.getPeaksTableInfo(); + PeaksTableInfo tinfo = _schema.getPeaksTableInfo(getContainerFilter()); tinfo.addScanRangeCondition(_expRun.getRowId(), _scanFirst, _scanLast, getContainer()); return tinfo; } diff --git a/ms2/src/org/labkey/ms2/MS2Controller.java b/ms2/src/org/labkey/ms2/MS2Controller.java index 9fa29e45eb..7ee2eb6bbf 100644 --- a/ms2/src/org/labkey/ms2/MS2Controller.java +++ b/ms2/src/org/labkey/ms2/MS2Controller.java @@ -1570,7 +1570,7 @@ public ModelAndView getView(ProteinDisambiguationForm form, BindException errors } MS2Schema schema = new MS2Schema(getUser(), getContainer()); - SequencesTableInfo tableInfo = schema.createSequencesTable(); + SequencesTableInfo tableInfo = schema.createSequencesTable(null); MatchCriteria matchCriteria = MatchCriteria.getMatchCriteria(form.getTargetProteinMatchCriteria()); tableInfo.addProteinNameFilter(form.getTargetProtein(), matchCriteria == null ? MatchCriteria.PREFIX : matchCriteria); @@ -2968,7 +2968,16 @@ private QueryView createProteinSearchView(ProbabilityProteinSearchForm form, Bin } QuerySettings proteinsSettings = schema.getSettings(getViewContext(), POTENTIAL_PROTEIN_DATA_REGION); proteinsSettings.setQueryName(MS2Schema.TableType.Sequences.toString()); - QueryView proteinsView = new QueryView(schema, proteinsSettings, errors); + QueryView proteinsView = new QueryView(schema, proteinsSettings, errors) + { + @Override + protected TableInfo createTable() + { + MS2Schema schema = (MS2Schema)getSchema(); + SequencesTableInfo tableInfo = schema.createSequencesTable(null); + return tableInfo; + } + }; // Disable R and other reporting until there's an implementation that respects the search criteria proteinsView.setViewItemFilter(ReportService.EMPTY_ITEM_LIST); @@ -2999,7 +3008,7 @@ private QueryView createProteinGroupSearchView(final ProbabilityProteinSearchFor { protected TableInfo createTable() { - ProteinGroupTableInfo table = ((MS2Schema)getSchema()).createProteinGroupsForSearchTable(); + ProteinGroupTableInfo table = ((MS2Schema)getSchema()).createProteinGroupsForSearchTable(null); table.addPeptideFilter(form, getViewContext()); int[] seqIds = form.getSeqId(); if (seqIds.length <= 500) @@ -3204,7 +3213,7 @@ public int[] getSeqId() if (_seqId == null) { MS2Schema schema = new MS2Schema(_context.getUser(), _context.getContainer()); - SequencesTableInfo tableInfo = schema.createSequencesTable(); + SequencesTableInfo tableInfo = schema.createSequencesTable(null); tableInfo.addProteinNameFilter(getIdentifier(), isExactMatch() ? MatchCriteria.EXACT : MatchCriteria.PREFIX); if (isRestrictProteins()) { diff --git a/ms2/src/org/labkey/ms2/MS2ServiceImpl.java b/ms2/src/org/labkey/ms2/MS2ServiceImpl.java index 9af373fb6f..ba6c197a7f 100644 --- a/ms2/src/org/labkey/ms2/MS2ServiceImpl.java +++ b/ms2/src/org/labkey/ms2/MS2ServiceImpl.java @@ -60,12 +60,12 @@ public MS2Schema createSchema(User user, Container container) public TableInfo createPeptidesTableInfo(User user, Container container, boolean includeFeatureFk, ContainerFilter containerFilter, SimpleFilter filter, Iterable defaultColumns) { // Go through the schema so we get metadata applied correctly - PeptidesTableInfo table = (PeptidesTableInfo)createSchema(user, container).getTable(MS2Schema.TableType.Peptides.name()); - table.setContainerFilter(containerFilter); - if(null != filter) + PeptidesTableInfo table = (PeptidesTableInfo)createSchema(user, container).getTable(MS2Schema.TableType.Peptides.name(), containerFilter, true, true); + if (null != filter) table.addCondition(filter); - if(null != defaultColumns) + if (null != defaultColumns) table.setDefaultVisibleColumns(defaultColumns); + table.setLocked(true); return table; } } diff --git a/ms2/src/org/labkey/ms2/compare/CompareQuery.java b/ms2/src/org/labkey/ms2/compare/CompareQuery.java index 5af224495b..d5277139e8 100644 --- a/ms2/src/org/labkey/ms2/compare/CompareQuery.java +++ b/ms2/src/org/labkey/ms2/compare/CompareQuery.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.labkey.api.action.LabKeyError; import org.labkey.api.data.ActionButton; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ButtonBar; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.DataColumn; @@ -398,7 +399,7 @@ protected DisplayColumn createColumn(ActionURL linkURL, RunColumn column, String throws SQLException { String columnFilter = setupComparisonColumnLink(linkURL, column.getLabel(), runPrefix); - ColumnInfo ci = new ColumnInfo(columnName); + var ci = new BaseColumnInfo(columnName); ci.setParentTable(ti); ci.setSqlTypeName(md.getColumnTypeName(rgn.getResultSet().findColumn(columnName))); ci.setLabel(column.getLabel()); diff --git a/ms2/src/org/labkey/ms2/matrix/ProteinExpressionMatrixProtocolSchema.java b/ms2/src/org/labkey/ms2/matrix/ProteinExpressionMatrixProtocolSchema.java index ba54b98eee..69a3dc8f64 100644 --- a/ms2/src/org/labkey/ms2/matrix/ProteinExpressionMatrixProtocolSchema.java +++ b/ms2/src/org/labkey/ms2/matrix/ProteinExpressionMatrixProtocolSchema.java @@ -1,23 +1,24 @@ -/* - * Copyright (c) 2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright (c) 2015 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.labkey.ms2.matrix; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.api.ExpProtocol; import org.labkey.api.query.FilteredTable; @@ -44,17 +45,17 @@ public ProteinExpressionMatrixProtocolSchema(User user, Container container, @No } @Override - public FilteredTable createDataTable(boolean includeCopiedToStudyColumns) + public FilteredTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - ProteinSequenceDataTable result = new ProteinSequenceDataTable(this); + ProteinSequenceDataTable result = new ProteinSequenceDataTable(this, cf); result.setName(AssayProtocolSchema.DATA_TABLE_NAME); return result; } @Override - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { - return super.createTable(name, SEQUENCE_ID, SAMPLE_ID, VALUE_MEASURE_ID, TITLE); + return super.createTable(name, cf, SEQUENCE_ID, SAMPLE_ID, VALUE_MEASURE_ID, TITLE); } @Override @@ -67,15 +68,14 @@ public List getDistinctSampleIds() } @Override - public TableInfo getDataTableInfo() + public TableInfo getDataTableInfo(ContainerFilter cf) { - return new ProteinSequenceDataTable(this); + return new ProteinSequenceDataTable(this, cf); } public static TableInfo getTableInfoSequenceData() { return MS2Manager.getSchema().getTable(PROTEIN_SEQ_DATA_TABLE_NAME); } - } diff --git a/ms2/src/org/labkey/ms2/matrix/ProteinSequenceDataTable.java b/ms2/src/org/labkey/ms2/matrix/ProteinSequenceDataTable.java index 14e6d76ac1..e4c4c973be 100644 --- a/ms2/src/org/labkey/ms2/matrix/ProteinSequenceDataTable.java +++ b/ms2/src/org/labkey/ms2/matrix/ProteinSequenceDataTable.java @@ -1,22 +1,21 @@ -/* - * Copyright (c) 2015 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright (c) 2015 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.labkey.ms2.matrix; import org.labkey.api.data.AbstractTableInfo; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; @@ -34,47 +33,50 @@ public class ProteinSequenceDataTable extends FilteredTable { - public ProteinSequenceDataTable(ProteinExpressionMatrixProtocolSchema schema) + public ProteinSequenceDataTable(ProteinExpressionMatrixProtocolSchema schema, ContainerFilter cf) { - super(ProteinExpressionMatrixProtocolSchema.getTableInfoSequenceData(), schema); + super(ProteinExpressionMatrixProtocolSchema.getTableInfoSequenceData(), schema, cf); setDetailsURL(AbstractTableInfo.LINK_DISABLER); setImportURL(AbstractTableInfo.LINK_DISABLER); addColumn(wrapColumn(getRealTable().getColumn("RowId"))).setHidden(true); - ColumnInfo valueColumn = addColumn(wrapColumn(getRealTable().getColumn("Value"))); + var valueColumn = addColumn(wrapColumn(getRealTable().getColumn("Value"))); valueColumn.setHidden(false); valueColumn.setLabel("Value"); valueColumn.setFormat("0.000000"); - ColumnInfo seqIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SeqId"))); + var seqIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SeqId"))); seqIdColumn.setHidden(false); seqIdColumn.setLabel("Protein"); - seqIdColumn.setFk(new QueryForeignKey(ProteinUserSchema.NAME, schema.getContainer(), null, - schema.getUser(), ProteinUserSchema.SEQUENCES_TABLE_NAME, "SeqId", "BestName")); + seqIdColumn.setFk( QueryForeignKey.from(getUserSchema(), cf) + .schema(ProteinUserSchema.NAME) + .to(ProteinUserSchema.SEQUENCES_TABLE_NAME, "SeqId", "BestName") ); - ColumnInfo sampleIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SampleId"))); + var sampleIdColumn = addColumn(wrapColumn(getRealTable().getColumn("SampleId"))); sampleIdColumn.setHidden(false); sampleIdColumn.setLabel("Sample Id"); - sampleIdColumn.setFk(new QueryForeignKey(ExpSchema.SCHEMA_NAME, schema.getContainer(), null, schema.getUser(), - ExpSchema.TableType.Materials.toString(),"RowId","Name")); + sampleIdColumn.setFk( QueryForeignKey.from(getUserSchema(), getContainerFilter()) + .schema(ExpSchema.SCHEMA_NAME) + .to(ExpSchema.TableType.Materials.toString(),"RowId","Name")); SQLFragment runSQL = new SQLFragment("(SELECT d.RunId FROM "); runSQL.append(ExperimentService.get().getTinfoData(), "d"); runSQL.append(" WHERE d.RowId = "); runSQL.append(ExprColumn.STR_TABLE_ALIAS); runSQL.append(".DataId)"); - ColumnInfo runIdColumn = new ExprColumn(this, "Run", runSQL, JdbcType.INTEGER); + var runIdColumn = new ExprColumn(this, "Run", runSQL, JdbcType.INTEGER); addColumn(runIdColumn); - runIdColumn.setFk(new QueryForeignKey(getUserSchema(), null, AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name")); + runIdColumn.setFk( QueryForeignKey.from(getUserSchema(), getContainerFilter()).to(AssayProtocolSchema.RUNS_TABLE_NAME, "RowId", "Name") ); - ColumnInfo dataIdColumn = addColumn(wrapColumn(getRealTable().getColumn("DataId"))); + var dataIdColumn = addColumn(wrapColumn(getRealTable().getColumn("DataId"))); dataIdColumn.setHidden(false); dataIdColumn.setLabel("Data Id"); - dataIdColumn.setFk(new QueryForeignKey(ExpSchema.SCHEMA_NAME, schema.getContainer(), null, schema.getUser(), ExpSchema.TableType.Data.toString(), - "RowId", "Name")); + dataIdColumn.setFk( QueryForeignKey.from(getUserSchema(), getContainerFilter()) + .schema(ExpSchema.SCHEMA_NAME) + .to(ExpSchema.TableType.Data.toString(), "RowId", "Name")); List columns = new ArrayList<>(getDefaultVisibleColumns()); columns.remove(dataIdColumn.getFieldKey()); diff --git a/ms2/src/org/labkey/ms2/metadata/FractionsDisplayColumn.java b/ms2/src/org/labkey/ms2/metadata/FractionsDisplayColumn.java index ce077a3d8d..1dac24637e 100644 --- a/ms2/src/org/labkey/ms2/metadata/FractionsDisplayColumn.java +++ b/ms2/src/org/labkey/ms2/metadata/FractionsDisplayColumn.java @@ -15,6 +15,7 @@ */ package org.labkey.ms2.metadata; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.RenderContext; import org.labkey.api.data.SimpleDisplayColumn; @@ -38,8 +39,8 @@ public FractionsDisplayColumn(MassSpecMetadataAssayForm form) _form = form; setCaption("Fractions"); - _col = new ColumnInfo("Fractions"); - _col.setInputType("file"); + _col = new BaseColumnInfo("Fractions"); + ((BaseColumnInfo)_col).setInputType("file"); setWidth("100%"); } diff --git a/ms2/src/org/labkey/ms2/metadata/MassSpecMetadataProtocolSchema.java b/ms2/src/org/labkey/ms2/metadata/MassSpecMetadataProtocolSchema.java index 2080b52749..c91996b39c 100644 --- a/ms2/src/org/labkey/ms2/metadata/MassSpecMetadataProtocolSchema.java +++ b/ms2/src/org/labkey/ms2/metadata/MassSpecMetadataProtocolSchema.java @@ -20,8 +20,6 @@ import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; -import org.labkey.api.data.DisplayColumn; -import org.labkey.api.data.DisplayColumnFactory; import org.labkey.api.data.IconDisplayColumn; import org.labkey.api.data.JdbcType; import org.labkey.api.data.RenderContext; @@ -69,25 +67,19 @@ public MassSpecMetadataProtocolSchema(User user, Container container, @NotNull M } @Override - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { - ExpRunTable result = super.createRunsTable(); + ExpRunTable result = super.createRunsTable(cf); SQLFragment searchCountSQL = new SQLFragment(); searchCountSQL.append(getSearchRunSQL(getContainer(), result.getContainerFilter(), ExprColumn.STR_TABLE_ALIAS + ".RowId", "COUNT(DISTINCT(er.RowId))")); ExprColumn searchCountCol = new ExprColumn(result, SEARCH_COUNT_COLUMN, searchCountSQL, JdbcType.INTEGER); searchCountCol.setLabel("MS2 Search Count"); result.addColumn(searchCountCol); - ColumnInfo searchLinkCol = result.addColumn(SEARCHES_COLUMN, ExpRunTable.Column.RowId); + var searchLinkCol = result.addColumn(SEARCHES_COLUMN, ExpRunTable.Column.RowId); searchLinkCol.setHidden(false); searchLinkCol.setLabel("MS2 Search Results"); - searchLinkCol.setDisplayColumnFactory(new DisplayColumnFactory() - { - public DisplayColumn createRenderer(ColumnInfo colInfo) - { - return new LinkDisplayColumn(colInfo, getContainer()); - } - }); + searchLinkCol.setDisplayColumnFactory(colInfo -> new LinkDisplayColumn(colInfo, getContainer())); List defaultCols = new ArrayList<>(result.getDefaultVisibleColumns()); defaultCols.add(2, FieldKey.fromParts(searchLinkCol.getName())); @@ -159,20 +151,19 @@ public static SQLFragment getSearchRunSQL(Container container, ContainerFilter c } @Override - public FilteredTable createDataTable(boolean includeCopiedToStudyColumns) + public FilteredTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - final ExpDataTable result = new ExpSchema(getUser(), getContainer()).getDatasTable(); + final ExpDataTable result = new ExpSchema(getUser(), getContainer()).getDatasTable(true); SQLFragment runConditionSQL = new SQLFragment("RunId IN (SELECT RowId FROM " + ExperimentService.get().getTinfoExperimentRun() + " WHERE ProtocolLSID = ?)"); runConditionSQL.add(getProtocol().getLSID()); result.addCondition(runConditionSQL, FieldKey.fromParts("RunId")); - result.getColumn(ExpDataTable.Column.Run).setFk(new LookupForeignKey("RowId") + result.getMutableColumn(ExpDataTable.Column.Run).setFk(new LookupForeignKey(cf, "RowId", null) { + @Override public TableInfo getLookupTableInfo() { - ExpRunTable expRunTable = createRunsTable(); - expRunTable.setContainerFilter(result.getContainerFilter()); - return expRunTable; + return createRunsTable(getLookupContainerFilter()); } }); diff --git a/ms2/src/org/labkey/ms2/peptideview/QueryProteinGroupMS2RunView.java b/ms2/src/org/labkey/ms2/peptideview/QueryProteinGroupMS2RunView.java index a060895e82..6416ef00cd 100644 --- a/ms2/src/org/labkey/ms2/peptideview/QueryProteinGroupMS2RunView.java +++ b/ms2/src/org/labkey/ms2/peptideview/QueryProteinGroupMS2RunView.java @@ -127,7 +127,7 @@ protected Sort getBaseSort() public ProteinGroupTableInfo createTable() { - ProteinGroupTableInfo result = ((MS2Schema)getSchema()).createProteinGroupsForRunTable(false); + ProteinGroupTableInfo result = ((MS2Schema)getSchema()).createProteinGroupsForRunTable(getContainerFilter(), false); result.setRunFilter(Arrays.asList(_runs)); return result; } diff --git a/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationSchema.java b/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationSchema.java index eddd6f74cc..e6850707f5 100644 --- a/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationSchema.java +++ b/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationSchema.java @@ -16,6 +16,7 @@ package org.labkey.ms2.protein.query; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.module.Module; import org.labkey.api.query.UserSchema; import org.labkey.api.query.DefaultSchema; @@ -76,11 +77,11 @@ public Set getTableNames() return getAnnotationSets().keySet(); } - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { CustomAnnotationSet annotationSet = getAnnotationSets().get(name); if (annotationSet != null) - return new CustomAnnotationTable(annotationSet, this, _includeSequences); + return new CustomAnnotationTable(annotationSet, this, cf, _includeSequences); return null; } diff --git a/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationTable.java b/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationTable.java index 4d88508532..55644fe1ad 100644 --- a/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationTable.java +++ b/ms2/src/org/labkey/ms2/protein/query/CustomAnnotationTable.java @@ -17,7 +17,8 @@ package org.labkey.ms2.protein.query; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.BaseColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; @@ -50,21 +51,22 @@ public class CustomAnnotationTable extends FilteredTable public CustomAnnotationTable(CustomAnnotationSet annotationSet, CustomAnnotationSchema schema) { - this(annotationSet, schema, false); + this(annotationSet, schema, null, false); } - public CustomAnnotationTable(CustomAnnotationSet annotationSet, CustomAnnotationSchema schema, boolean includeSeqId) + public CustomAnnotationTable(CustomAnnotationSet annotationSet, CustomAnnotationSchema schema, ContainerFilter cf, boolean includeSeqId) { - super(ProteinManager.getTableInfoCustomAnnotation(), schema); + super(ProteinManager.getTableInfoCustomAnnotation(), schema, cf); _includeSeqId = includeSeqId; wrapAllColumns(true); _annotationSet = annotationSet; - ColumnInfo propertyCol = addColumn(createPropertyColumn("Property")); + var propertyCol = addColumn(createPropertyColumn("Property")); _domain = PropertyService.get().getDomain(_annotationSet.lookupContainer(), _annotationSet.getLsid()); if (_domain != null) { - propertyCol.setFk(new PropertyForeignKey(_domain, schema)); + // TODO ContainerFilter + propertyCol.setFk(new PropertyForeignKey(schema, null, _domain)); } List defaultCols = new ArrayList<>(); @@ -98,22 +100,22 @@ public Domain getDomain() private void addProteinDetailsColumn() { SQLFragment sql = new SQLFragment(getName() + ".SeqId"); - ColumnInfo col = new ExprColumn(this, "Protein", sql, JdbcType.INTEGER); + var col = new ExprColumn(this, "Protein", sql, JdbcType.INTEGER); col.setFk(new LookupForeignKey("SeqId") { public TableInfo getLookupTableInfo() { MS2Schema schema = new MS2Schema(_userSchema.getUser(), _userSchema.getContainer()); - return schema.createSequencesTable(); + return schema.createSequencesTable(null); } }); addColumn(col); } - public ColumnInfo createPropertyColumn(String name) + public BaseColumnInfo createPropertyColumn(String name) { String sql = ExprColumn.STR_TABLE_ALIAS + ".objecturi"; - ColumnInfo ret = new ExprColumn(this, name, new SQLFragment(sql), JdbcType.VARCHAR); + var ret = new ExprColumn(this, name, new SQLFragment(sql), JdbcType.VARCHAR); ret.setIsUnselectable(true); return ret; } diff --git a/ms2/src/org/labkey/ms2/protein/query/ProteinUserSchema.java b/ms2/src/org/labkey/ms2/protein/query/ProteinUserSchema.java index 1f1aa0cce3..a83bbdb662 100644 --- a/ms2/src/org/labkey/ms2/protein/query/ProteinUserSchema.java +++ b/ms2/src/org/labkey/ms2/protein/query/ProteinUserSchema.java @@ -20,6 +20,7 @@ import org.labkey.api.collections.Sets; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.DataColumn; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.DisplayColumnFactory; @@ -73,7 +74,6 @@ public boolean isAvailable(DefaultSchema schema, Module module) return false; } - @Nullable @Override public QuerySchema createSchema(DefaultSchema schema, Module module) { @@ -188,42 +188,43 @@ public TableInfo createTable(ProteinUserSchema schema, String name) private TableInfo createFastaSequencesTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoFastaSequences()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoFastaSequences(), null); table.init(); table.setReadOnly(true); - table.getColumn("SeqId").setFk(new QueryForeignKey(this, null, TableType.Sequences.name(), null, null)); - table.getColumn("FastaId").setFk(new QueryForeignKey(this, null, TableType.FastaFiles.name(), null, null)); + table.getMutableColumn("SeqId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.Sequences.name()) ); + table.getMutableColumn("FastaId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.FastaFiles.name()) ); return table; } private TableInfo createIdentifiersTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoIdentifiers()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoIdentifiers(), null); table.init(); table.setReadOnly(true); - table.getColumn("SeqId").setFk(new QueryForeignKey(this, null, TableType.Sequences.name(), null, null)); - table.getColumn("IdentTypeId").setFk(new QueryForeignKey(this, null, TableType.IdentTypes.name(), null, null)); - table.getColumn("SourceId").setFk(new QueryForeignKey(this, null, TableType.InfoSources.name(), null, null)); + table.getMutableColumn("SeqId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.Sequences.name()) ); + table.getMutableColumn("IdentTypeId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.IdentTypes.name()) ); + table.getMutableColumn("SourceId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.InfoSources.name()) ); return table; } private TableInfo createIdentTypesTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoIdentTypes()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoIdentTypes(), null); table.init(); table.setReadOnly(true); - table.getColumn("CannonicalSourceId").setFk(new QueryForeignKey(this, null, TableType.InfoSources.name(), null, null)); + table.getMutableColumn("CannonicalSourceId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.InfoSources.name()) ); return table; } @Nullable @Override - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { for (TableType tableType : TableType.values()) { if (tableType.name().equalsIgnoreCase(name)) { + // ContainerFilter is not used return tableType.createTable(this, tableType.name()); } } @@ -244,16 +245,16 @@ public Set getTableNames() private SimpleUserSchema.SimpleTable createAnnotationTypesTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoAnnotationTypes()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoAnnotationTypes(), null); table.init(); table.setReadOnly(true); - table.getColumn("SourceId").setFk(new QueryForeignKey(this, null, TableType.InfoSources.name(), null, null)); + table.getMutableColumn("SourceId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.InfoSources.name()) ); return table; } private SimpleUserSchema.SimpleTable createInfoSourcesTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoInfoSources()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoInfoSources(), null); table.init(); table.setReadOnly(true); return table; @@ -261,19 +262,19 @@ private SimpleUserSchema.SimpleTable createInfoSourcesTable() protected TableInfo createAnnotationsTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoAnnotations()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoAnnotations(), null); table.init(); table.setReadOnly(true); - table.getColumn("AnnotTypeId").setFk(new QueryForeignKey(this, null, TableType.AnnotationTypes.name(), null, null)); - table.getColumn("AnnotSourceId").setFk(new QueryForeignKey(this, null, TableType.InfoSources.name(), null, null)); - table.getColumn("AnnotIdent").setFk(new QueryForeignKey(this, null, TableType.Identifiers.name(), null, null)); - table.getColumn("SeqId").setFk(new QueryForeignKey(this, null, TableType.Sequences.name(), null, null)); + table.getMutableColumn("AnnotTypeId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.AnnotationTypes.name()) ); + table.getMutableColumn("AnnotSourceId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.InfoSources.name()) ); + table.getMutableColumn("AnnotIdent").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.Identifiers.name()) ); + table.getMutableColumn("SeqId").setFk( QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.Sequences.name()) ); return table; } protected TableInfo createGoGraphPath() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoGraphPath()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoGraphPath(), null); table.init(); table.setReadOnly(true); return table; @@ -281,7 +282,7 @@ protected TableInfo createGoGraphPath() protected TableInfo createGoTerm() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTerm()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTerm(), null); table.init(); table.setReadOnly(true); return table; @@ -289,17 +290,17 @@ protected TableInfo createGoTerm() protected TableInfo createGoTerm2Term() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTerm2Term()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTerm2Term(), null); table.init(); table.setReadOnly(true); - table.getColumn("term1id").setFk(new QueryForeignKey(this, null, TableType.GoTerm.name(), null, null)); - table.getColumn("term2id").setFk(new QueryForeignKey(this, null, TableType.GoTerm.name(), null, null)); + table.getMutableColumn("term1id").setFk(QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.GoTerm.name()) ); + table.getMutableColumn("term2id").setFk(QueryForeignKey.from(this, table.getContainerFilter()).table(TableType.GoTerm.name()) ); return table; } protected TableInfo createGoTermDefinition() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTermDefinition()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTermDefinition(), null); table.init(); table.setReadOnly(true); return table; @@ -307,7 +308,7 @@ protected TableInfo createGoTermDefinition() protected TableInfo createGoTermSynonym() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTermSynonym()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoGoTermSynonym(), null); table.init(); table.setReadOnly(true); return table; @@ -320,15 +321,16 @@ protected TableInfo createOrganisms() protected SequencesTableInfo createSequences() { - return new SequencesTableInfo<>(this); + // TODO ContainerFilter + return new SequencesTableInfo<>(this, null); } protected TableInfo createFastaFileTable() { - SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoFastaFiles()); + SimpleUserSchema.SimpleTable table = new SimpleUserSchema.SimpleTable<>(this, ProteinManager.getTableInfoFastaFiles(), null); table.init(); table.setReadOnly(true); - ColumnInfo shortName = table.addWrapColumn("ShortName", table.getRealTable().getColumn("FileName")); + var shortName = table.addWrapColumn("ShortName", table.getRealTable().getColumn("FileName")); shortName.setLabel("FASTA Name"); shortName.setDisplayColumnFactory(new DisplayColumnFactory() diff --git a/ms2/src/org/labkey/ms2/query/CompareProteinProphetTableInfo.java b/ms2/src/org/labkey/ms2/query/CompareProteinProphetTableInfo.java index 76ce57a209..74fcf1fa46 100644 --- a/ms2/src/org/labkey/ms2/query/CompareProteinProphetTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/CompareProteinProphetTableInfo.java @@ -45,7 +45,7 @@ public class CompareProteinProphetTableInfo extends SequencesTableInfo runs, boolean forExport, HttpServletRequest request, String peptideViewName) { - super(MS2Schema.HiddenTableType.CompareProteinProphet.toString(), schema); + super(MS2Schema.HiddenTableType.CompareProteinProphet.toString(), schema, null); _runs = runs; _forExport = forExport; @@ -91,7 +91,7 @@ public CompareProteinProphetTableInfo(MS2Schema schema, List runs, boole { public TableInfo getLookupTableInfo() { - return new ProteinGroupTableInfo(_userSchema, false); + return new ProteinGroupTableInfo(_userSchema, getLookupContainerFilter(), false); } }; if (!_forExport) @@ -111,7 +111,7 @@ public TableInfo getLookupTableInfo() { public TableInfo getLookupTableInfo() { - return new ProteinGroupTableInfo(_userSchema, false); + return new ProteinGroupTableInfo(_userSchema, getLookupContainerFilter(), false); } }); addColumn(proteinGroupIdColumn); diff --git a/ms2/src/org/labkey/ms2/query/FastaRunMappingTable.java b/ms2/src/org/labkey/ms2/query/FastaRunMappingTable.java index d3e974237b..0950c7d1ee 100644 --- a/ms2/src/org/labkey/ms2/query/FastaRunMappingTable.java +++ b/ms2/src/org/labkey/ms2/query/FastaRunMappingTable.java @@ -31,14 +31,19 @@ public class FastaRunMappingTable extends FilteredTable { private static final FieldKey CONTAINER_FIELD_KEY = FieldKey.fromParts("Container"); - public FastaRunMappingTable(MS2Schema schema) + public FastaRunMappingTable(MS2Schema schema, ContainerFilter cf) { - super(MS2Manager.getTableInfoFastaRunMapping(), schema); + super(MS2Manager.getTableInfoFastaRunMapping(), schema, cf); wrapAllColumns(true); setDescription("Contains a row for each FASTA file used for a given imported MS2 search"); - getColumn("FastaId").setFk(new QueryForeignKey(ProteinUserSchema.NAME, schema.getContainer(), null, schema.getUser(), ProteinUserSchema.FASTA_FILE_TABLE_NAME, null, null, false)); - getColumn("Run").setFk(new QueryForeignKey(schema, null, MS2Schema.TableType.MS2RunDetails.name(), null, "Description")); + getMutableColumn("FastaId").setFk( QueryForeignKey + .from(schema, getContainerFilter()) + .schema(ProteinUserSchema.NAME, schema.getContainer()) + .table(ProteinUserSchema.FASTA_FILE_TABLE_NAME)); + getMutableColumn("Run").setFk( QueryForeignKey + .from(schema, getContainerFilter()) + .to(MS2Schema.TableType.MS2RunDetails.name(), null, "Description")); } @Override diff --git a/ms2/src/org/labkey/ms2/query/ITraqProteinQuantitationTable.java b/ms2/src/org/labkey/ms2/query/ITraqProteinQuantitationTable.java index f89e5c6bd9..afc295cc4a 100644 --- a/ms2/src/org/labkey/ms2/query/ITraqProteinQuantitationTable.java +++ b/ms2/src/org/labkey/ms2/query/ITraqProteinQuantitationTable.java @@ -29,6 +29,6 @@ public ITraqProteinQuantitationTable(MS2Schema schema) { super(MS2Manager.getTableInfoITraqProteinQuantitation(), schema); wrapAllColumns(true); - getColumn("ProteinGroupId").setHidden(true); + getMutableColumn("ProteinGroupId").setHidden(true); } } diff --git a/ms2/src/org/labkey/ms2/query/MS2Schema.java b/ms2/src/org/labkey/ms2/query/MS2Schema.java index 585541a910..742e7252de 100644 --- a/ms2/src/org/labkey/ms2/query/MS2Schema.java +++ b/ms2/src/org/labkey/ms2/query/MS2Schema.java @@ -143,9 +143,9 @@ public enum TableType { SamplePrepRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable result = ExperimentService.get().createRunTable(SamplePrepRuns.toString(), ms2Schema); + ExpRunTable result = ExperimentService.get().createRunTable(SamplePrepRuns.toString(), ms2Schema, cf); result.populate(); // Include the old XAR-based and the new assay-based result.setDescription("Contains one row per experimental metadata attached to source spectra files."); @@ -155,72 +155,72 @@ public ExpRunTable createTable(MS2Schema ms2Schema) }, ImportedSearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(ImportedSearchRuns.toString(), ContainerFilter.CURRENT, IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(ImportedSearchRuns.toString(), cf, IMPORTED_SEARCH_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per externally-generated MS2 search result imported in this folder."); return searchTable; } }, XTandemSearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(XTandemSearchRuns.toString(), ContainerFilter.CURRENT, XTANDEM_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(XTandemSearchRuns.toString(), cf, XTANDEM_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per X!Tandem search result loaded in this folder."); return searchTable; } }, MascotSearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(MascotSearchRuns.toString(), ContainerFilter.CURRENT, MASCOT_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(MascotSearchRuns.toString(), cf, MASCOT_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per Mascot search results loaded in this folder."); return searchTable; } }, CometSearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(CometSearchRuns.toString(), ContainerFilter.CURRENT, COMET_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(CometSearchRuns.toString(), cf, COMET_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per Comet search results loaded in this folder."); return searchTable; } }, SequestSearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(SequestSearchRuns.toString(), ContainerFilter.CURRENT, SEQUEST_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(SequestSearchRuns.toString(), cf, SEQUEST_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per Sequest search result loaded in this folder."); return searchTable; } }, FractionRollupsRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable searchTable = ms2Schema.createSearchTable(FractionRollupsRuns.toString(), ContainerFilter.CURRENT, FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX); + ExpRunTable searchTable = ms2Schema.createSearchTable(FractionRollupsRuns.toString(), cf, FRACTION_ROLLUP_PROTOCOL_OBJECT_PREFIX); searchTable.setDescription("Contains one row per fraction rollup analysis result loaded in this folder."); return searchTable; } }, MS2SearchRuns { - public ExpRunTable createTable(MS2Schema ms2Schema) + public ExpRunTable createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ExpRunTable runsTable = ms2Schema.createRunsTable(MS2SearchRuns.toString(), ContainerFilter.CURRENT); + ExpRunTable runsTable = ms2Schema.createRunsTable(MS2SearchRuns.toString(), cf); runsTable.setDescription("Contains one row per MS2 search result, regardless of source, loaded in this folder."); return runsTable; } }, MS2RunDetails { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2, ContainerFilter cf) { - FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoRuns(), ms2Schema); + FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoRuns(), ms2, cf); result.setName(MS2RunDetails.name()); result.addWrapColumn(result.getRealTable().getColumn("Run")); result.addWrapColumn(result.getRealTable().getColumn("Description")); @@ -244,9 +244,9 @@ public TableInfo createTable(MS2Schema ms2Schema) result.addColumn(new ExprColumn(result, "MS3ScanCount", getScanCountSqlFragment(3), JdbcType.INTEGER)); result.addColumn(new ExprColumn(result, "MS4ScanCount", getScanCountSqlFragment(4), JdbcType.INTEGER)); - ColumnInfo fastaColumnInfo = result.wrapColumn("FastaId", result.getRealTable().getColumn("Run")); + var fastaColumnInfo = result.wrapColumn("FastaId", result.getRealTable().getColumn("Run")); fastaColumnInfo.setKeyField(false); - fastaColumnInfo.setFk(new MultiValuedForeignKey(new QueryForeignKey(ms2Schema, null, FastaRunMapping.name(), "Run", null), "FastaId")); + fastaColumnInfo.setFk(new MultiValuedForeignKey(QueryForeignKey.from(ms2,cf).to(FastaRunMapping.name(), "Run", null).build(), "FastaId")); fastaColumnInfo.setLabel("FASTA"); result.addColumn(fastaColumnInfo); result.addWrapColumn(result.getRealTable().getColumn("SearchEnzyme")); @@ -257,12 +257,12 @@ public TableInfo createTable(MS2Schema ms2Schema) result.addWrapColumn(result.getRealTable().getColumn("MascotFile")); result.addWrapColumn(result.getRealTable().getColumn("DistillerRawFile")); - ColumnInfo iconColumn = result.wrapColumn("Links", result.getRealTable().getColumn("Run")); + var iconColumn = result.wrapColumn("Links", result.getRealTable().getColumn("Run")); iconColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) { - ActionURL linkURL = MS2Controller.getShowRunURL(ms2Schema.getUser(), ms2Schema.getContainer()); + ActionURL linkURL = MS2Controller.getShowRunURL(ms2.getUser(), ms2.getContainer()); return new IconDisplayColumn(colInfo, 18, 18, linkURL, "run", AppProps.getInstance().getContextPath() + "/MS2/images/runIcon.gif"); } }); @@ -285,114 +285,114 @@ public SQLFragment getScanCountSqlFragment(int msLevel) }, Peptides { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createPeptidesTable(ContainerFilter.CURRENT, MS2RunType.values()); + return ms2Schema.createPeptidesTable(cf, MS2RunType.values()); } }, Fractions { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createFractionsTable(); + return ms2Schema.createFractionsTable(cf); } }, ProteinGroups { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - ProteinGroupTableInfo result = new ProteinGroupTableInfo(ms2Schema); - result.addContainerCondition(ms2Schema.getContainer(), ms2Schema.getUser(), false); + ProteinGroupTableInfo result = new ProteinGroupTableInfo(ms2Schema, cf); return result; } }, Sequences { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createSequencesTable(); + + return ms2Schema.createSequencesTable(cf); } }, FastaRunMapping { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createFastaRunMappingTable(); + return ms2Schema.createFastaRunMappingTable(cf); } }; - public abstract TableInfo createTable(MS2Schema ms2Schema); + public abstract TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf); } public enum HiddenTableType { PeptidesFilter { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - PeptidesTableInfo peptidesTable = (PeptidesTableInfo)ms2Schema.createPeptidesTable(ContainerFilter.CURRENT, MS2RunType.values()); + PeptidesTableInfo peptidesTable = (PeptidesTableInfo)ms2Schema.createPeptidesTable(cf, MS2RunType.values()); peptidesTable.setName(this.toString()); return peptidesTable; } }, ProteinGroupsFilter { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createProteinGroupsForRunTable(null); + return ms2Schema.createProteinGroupsForRunTable(cf, null); } }, ProteinGroupsForSearch { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createProteinGroupsForSearchTable(); + return ms2Schema.createProteinGroupsForSearchTable(cf); } }, ProteinGroupsForRun { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { - return ms2Schema.createProteinGroupsForRunTable(false); + return ms2Schema.createProteinGroupsForRunTable(cf, false); } }, CompareProteinProphet { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { return ms2Schema.createProteinProphetCompareTable(null, null); } }, ComparePeptides { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { return ms2Schema.createPeptidesCompareTable(false, null, null); } }, ProteinProphetCrosstab { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { return ms2Schema.createProteinProphetCrosstabTable(null, null); } }, ProteinProphetNormalizedCrosstab { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { return ms2Schema.createNormalizedProteinProphetComparisonTable(null, null); } }, PeptideCrosstab { - public TableInfo createTable(MS2Schema ms2Schema) + public TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf) { return ms2Schema.createPeptideCrosstabTable(null, null); } } ; - public abstract TableInfo createTable(MS2Schema ms2Schema); + public abstract TableInfo createTable(MS2Schema ms2Schema, ContainerFilter cf); } @@ -406,20 +406,20 @@ public ProteinGroupProteins getProteinGroupProteins() return _proteinGroupProteins; } - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { for (TableType tableType : TableType.values()) { if (tableType.toString().equalsIgnoreCase(name)) { - return tableType.createTable(this); + return tableType.createTable(this, cf); } } for (HiddenTableType tableType : HiddenTableType.values()) { if (tableType.toString().equalsIgnoreCase(name)) { - return tableType.createTable(this); + return tableType.createTable(this, cf); } } for (MS2RunType runType : MS2RunType.values()) @@ -478,9 +478,9 @@ public SpectraCountTableInfo createSpectraCountTable(SpectraCountConfiguration c return new SpectraCountTableInfo(this, config, context, form); } - public ProteinGroupTableInfo createProteinGroupsForSearchTable() + public ProteinGroupTableInfo createProteinGroupsForSearchTable(ContainerFilter cf) { - ProteinGroupTableInfo result = new ProteinGroupTableInfo(this); + ProteinGroupTableInfo result = new ProteinGroupTableInfo(this, cf); List defaultColumns = new ArrayList<>(result.getDefaultVisibleColumns()); defaultColumns.add(0, FieldKey.fromParts("ProteinProphet","Run")); defaultColumns.add(0, FieldKey.fromParts("ProteinProphet", "Run", "Folder")); @@ -488,14 +488,14 @@ public ProteinGroupTableInfo createProteinGroupsForSearchTable() return result; } - public ProteinGroupTableInfo createProteinGroupsForRunTable(String alias) + public ProteinGroupTableInfo createProteinGroupsForRunTable(ContainerFilter cf, String alias) { - return createProteinGroupsForRunTable(true); + return createProteinGroupsForRunTable(cf, true); } - public ProteinGroupTableInfo createProteinGroupsForRunTable(boolean includeFirstProteinColumn) + public ProteinGroupTableInfo createProteinGroupsForRunTable(ContainerFilter cf, boolean includeFirstProteinColumn) { - ProteinGroupTableInfo result = new ProteinGroupTableInfo(this, includeFirstProteinColumn); + ProteinGroupTableInfo result = new ProteinGroupTableInfo(this, cf, includeFirstProteinColumn); result.addProteinsColumn(); List defaultColumns = new ArrayList<>(result.getDefaultVisibleColumns()); defaultColumns.add(FieldKey.fromParts("Proteins", "Protein")); @@ -511,11 +511,11 @@ protected FilteredTable createProteinGroupMembershipTable(final MS2Controller.Pe FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoProteinGroupMemberships(), this); result.wrapAllColumns(true); - result.getColumn("ProteinGroupId").setFk(new LookupForeignKey("RowId") + result.getMutableColumn("ProteinGroupId").setFk(new LookupForeignKey(result.getContainerFilter(), "RowId", null) { public TableInfo getLookupTableInfo() { - ProteinGroupTableInfo result = createProteinGroupsForRunTable(null); + ProteinGroupTableInfo result = createProteinGroupsForRunTable(getLookupContainerFilter(), null); result.removeColumn(result.getColumn("Proteins")); result.removeColumn(result.getColumn("FirstProtein")); @@ -561,8 +561,8 @@ else if (form != null && form.isCustomViewPeptideFilter()) } }); - result.getColumn("SeqId").setLabel("Protein"); - result.getColumn("SeqId").setFk(createSequencesLookup()); + result.getMutableColumn("SeqId").setLabel("Protein"); + result.getMutableColumn("SeqId").setFk(createSequencesLookup()); if (_runs != null && filterByRuns) { @@ -594,12 +594,12 @@ else if (form.isCustomViewProteinGroupFilter()) } } - ColumnInfo peptideMembershipsColumn = result.wrapColumn("PeptideMemberships", result.getRealTable().getColumn("ProteinGroupId")); - peptideMembershipsColumn.setFk(new LookupForeignKey("ProteinGroupId") + var peptideMembershipsColumn = result.wrapColumn("PeptideMemberships", result.getRealTable().getColumn("ProteinGroupId")); + peptideMembershipsColumn.setFk(new LookupForeignKey(result.getContainerFilter(), "ProteinGroupId", null) { public TableInfo getLookupTableInfo() { - return createPeptideMembershipsTable(); + return createPeptideMembershipsTable(getLookupContainerFilter()); } }); result.addColumn(peptideMembershipsColumn); @@ -618,7 +618,7 @@ public void getProteinGroupSelectSQL(MS2Controller.PeptideFilteringComparisonFor view.applyFilterAndSortToURL(url, "InternalName"); filter.addUrlFilters(url, "InternalName"); } - ProteinGroupTableInfo tableInfo = new ProteinGroupTableInfo(this, false); + ProteinGroupTableInfo tableInfo = new ProteinGroupTableInfo(this, null, false); tableInfo.setContainerFilter(ContainerFilter.EVERYTHING); sql.append(getSelectSQL(tableInfo, filter, Collections.singleton(FieldKey.fromParts("RowId")))); } @@ -643,27 +643,27 @@ public void appendRunInClause(SQLFragment sql) sql.append(")"); } - protected TableInfo createPeptideMembershipsTable() + protected TableInfo createPeptideMembershipsTable(ContainerFilter cf) { FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoPeptideMemberships(), this); result.wrapAllColumns(false); - LookupForeignKey fk = new LookupForeignKey("RowId") + LookupForeignKey fk = new LookupForeignKey(cf, "RowId", null) { public TableInfo getLookupTableInfo() { - ProteinGroupTableInfo result = new ProteinGroupTableInfo(MS2Schema.this); - result.getColumn("ProteinProphet").setHidden(true); + ProteinGroupTableInfo result = new ProteinGroupTableInfo(MS2Schema.this, getLookupContainerFilter()); + result.getMutableColumn("ProteinProphet").setHidden(true); result.addProteinDetailColumns(); return result; } }; fk.setPrefixColumnCaption(false); - result.getColumn("ProteinGroupId").setFk(fk); + result.getMutableColumn("ProteinGroupId").setFk(fk); - result.getColumn("PeptideId").setHidden(true); - result.getColumn("PeptideId").setFk(new LookupForeignKey("RowId") + result.getMutableColumn("PeptideId").setHidden(true); + result.getMutableColumn("PeptideId").setFk(new LookupForeignKey("RowId") { public TableInfo getLookupTableInfo() { @@ -674,10 +674,10 @@ public TableInfo getLookupTableInfo() return result; } - protected TableInfo createFractionsTable() + protected TableInfo createFractionsTable(ContainerFilter cf) { SqlDialect dialect = MS2Manager.getSqlDialect(); - FilteredTable result = new FilteredTable(MS2Manager.getTableInfoFractions(), this) + FilteredTable result = new FilteredTable(MS2Manager.getTableInfoFractions(), this, cf) { @Override protected void applyContainerFilter(ContainerFilter filter) @@ -706,7 +706,7 @@ protected void applyContainerFilter(ContainerFilter filter) .append(" THEN ").append(dialect.getSubstringFunction(new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".FileName"), new SQLFragment("1"), dialect.getStringIndexOfFunction(new SQLFragment("'.'"), new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".FileName")).append("- 1"))) .append(" ELSE " + ExprColumn.STR_TABLE_ALIAS + ".FileName END"); - ColumnInfo fractionName = new ExprColumn(result, "FractionName", fractionNameSQL, JdbcType.VARCHAR); + var fractionName = new ExprColumn(result, "FractionName", fractionNameSQL, JdbcType.VARCHAR); fractionName.setLabel("Name"); fractionName.setWidth("200"); result.addColumn(fractionName); @@ -720,7 +720,7 @@ protected void applyContainerFilter(ContainerFilter filter) result.addColumn(dataColumn); ActionURL url = MS2Controller.getShowRunURL(getUser(), getContainer()); - result.getColumn("Run").setFk(new LookupForeignKey(url, "run", "Run", "Description") + result.getMutableColumn("Run").setFk(new LookupForeignKey(url, "run", "Run", "Description") { public TableInfo getLookupTableInfo() { @@ -731,14 +731,14 @@ public TableInfo getLookupTableInfo() return result; } - public SequencesTableInfo createSequencesTable() + public SequencesTableInfo createSequencesTable(ContainerFilter cf) { - return new SequencesTableInfo<>(this); + return new SequencesTableInfo<>(this, cf); } - private TableInfo createFastaRunMappingTable() + private TableInfo createFastaRunMappingTable(ContainerFilter cf) { - return new FastaRunMappingTable(this); + return new FastaRunMappingTable(this, cf); } public TableInfo createPeptidesTable(ContainerFilter containerFilter, MS2RunType... runTypes) @@ -748,8 +748,7 @@ public TableInfo createPeptidesTable(ContainerFilter containerFilter, MS2RunType private ExpRunTable createSearchTable(String name, ContainerFilter filter, String... protocolObjectPrefix) { - final ExpRunTable result = ExperimentService.get().createRunTable(name, this); - result.setContainerFilter(filter); + final ExpRunTable result = ExperimentService.get().createRunTable(name, this, filter); result.populate(); String[] protocolPatterns = new String[protocolObjectPrefix.length]; for (int i = 0; i < protocolObjectPrefix.length; i++) @@ -762,14 +761,14 @@ private ExpRunTable createSearchTable(String name, ContainerFilter filter, Strin "\nFROM " + MS2Manager.getTableInfoRuns() + " ms2Runs " + "\nWHERE ms2Runs.ExperimentRunLSID = " + ExprColumn.STR_TABLE_ALIAS + ".LSID AND ms2Runs.Deleted = ?)"); sql.add(Boolean.FALSE); - ColumnInfo ms2DetailsColumn = new ExprColumn(result, "MS2Details", sql, JdbcType.INTEGER); + var ms2DetailsColumn = new ExprColumn(result, "MS2Details", sql, JdbcType.INTEGER); ActionURL url = MS2Controller.getShowRunURL(getUser(), getContainer()); DetailsURL detailsURL = new DetailsURL(url, Collections.singletonMap("Run", ms2DetailsColumn.getFieldKey())); ms2DetailsColumn.setURL(detailsURL); - ms2DetailsColumn.setFk(new QueryForeignKey(this, null, TableType.MS2RunDetails.name(), "Run", "Description")); + ms2DetailsColumn.setFk( QueryForeignKey.from(this,filter).to(TableType.MS2RunDetails.name(), "Run", "Description" ) ); result.addColumn(ms2DetailsColumn); - result.getColumn("Name").setDisplayColumnFactory(new DisplayColumnFactory() + result.getMutableColumn(ExpRunTable.Column.Name).setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) { @@ -859,8 +858,7 @@ public List getRuns() protected SQLFragment getPeptideSelectSQL(SimpleFilter filter, Collection fieldKeys) { - FilteredTable tiFiltered = (FilteredTable) getTable(HiddenTableType.PeptidesFilter.name(), true); - tiFiltered.setContainerFilter(ContainerFilter.EVERYTHING); + TableInfo tiFiltered = getTable(HiddenTableType.PeptidesFilter.name(), ContainerFilter.EVERYTHING, true, false); return getSelectSQL(tiFiltered, filter, fieldKeys); } @@ -920,15 +918,15 @@ public CrosstabTableInfo createNormalizedProteinProphetComparisonTable(final MS2 { VirtualTable rawTable; - ColumnInfo normalizedIdCol = new ColumnInfo("NormalizedId", JdbcType.INTEGER); + var normalizedIdCol = new BaseColumnInfo("NormalizedId", JdbcType.INTEGER); normalizedIdCol.setHidden(true); - ColumnInfo proteinGroupIdCol = new ColumnInfo("ProteinGroupId", JdbcType.INTEGER); - proteinGroupIdCol.setFk(new LookupForeignKey("RowId") + var proteinGroupIdCol = new BaseColumnInfo("ProteinGroupId", JdbcType.INTEGER); + proteinGroupIdCol.setFk(new LookupForeignKey((ContainerFilter)null, "RowId", null) { public TableInfo getLookupTableInfo() { - return new ProteinGroupTableInfo(MS2Schema.this, true); + return new ProteinGroupTableInfo(MS2Schema.this, getLookupContainerFilter(), true); } @Override @@ -971,14 +969,14 @@ public SQLFragment getFromSQL() rawTable.addColumn(proteinGroupIdCol); proteinGroupIdCol.setParentTable(rawTable); - FilteredTable baseTable = new FilteredTable<>(rawTable, this); + FilteredTable baseTable = new FilteredTable<>(rawTable, this, null); baseTable.wrapAllColumns(true); - ColumnInfo peptideMembershipsColumn = baseTable.wrapColumn("PeptideMemberships", rawTable.getColumn("ProteinGroupId")); - peptideMembershipsColumn.setFk(new LookupForeignKey("ProteinGroupId") + var peptideMembershipsColumn = baseTable.wrapColumn("PeptideMemberships", rawTable.getColumn("ProteinGroupId")); + peptideMembershipsColumn.setFk(new LookupForeignKey((ContainerFilter)null, "ProteinGroupId", null) { public TableInfo getLookupTableInfo() { - return createPeptideMembershipsTable(); + return createPeptideMembershipsTable(getLookupContainerFilter()); } }); baseTable.addColumn(peptideMembershipsColumn); @@ -989,7 +987,7 @@ public TableInfo getLookupTableInfo() ExprColumn normalizedProteinCountCol = new ExprColumn(baseTable, "ProteinCount", new SQLFragment("(SELECT COUNT (DISTINCT SeqId) FROM " + name + " n, " + MS2Manager.getTableInfoProteinGroupMemberships() + " pgm WHERE n.ProteinGroupId = pgm.ProteinGroupId and n.NormalizedId = " + ExprColumn.STR_TABLE_ALIAS + ".NormalizedId)"), JdbcType.INTEGER); baseTable.addColumn(normalizedProteinCountCol); - ColumnInfo proteinsCol = baseTable.wrapColumn("Proteins", rawTable.getColumn("NormalizedId")); + var proteinsCol = baseTable.wrapColumn("Proteins", rawTable.getColumn("NormalizedId")); proteinsCol.setHidden(false); baseTable.addColumn(proteinsCol); LookupForeignKey proteinsFK = new LookupForeignKey("NormalizedId") @@ -1006,14 +1004,14 @@ public SQLFragment getFromSQL() return new SQLFragment("SELECT DISTINCT NormalizedId, SeqId FROM " + name + " n, " + MS2Manager.getTableInfoProteinGroupMemberships() + " pgm WHERE n.ProteinGroupId = pgm.ProteinGroupId"); } }; - ColumnInfo normalizedIdCol = new ColumnInfo("NormalizedId", result, JdbcType.INTEGER); + var normalizedIdCol = new BaseColumnInfo("NormalizedId", result, JdbcType.INTEGER); result.addColumn(normalizedIdCol); - ColumnInfo seqIdCol = new ColumnInfo("SeqId", result, JdbcType.INTEGER); + var seqIdCol = new BaseColumnInfo("SeqId", result, JdbcType.INTEGER); LookupForeignKey seqFK = new LookupForeignKey("SeqId") { public TableInfo getLookupTableInfo() { - return MS2Schema.this.createSequencesTable(); + return MS2Schema.this.createSequencesTable(getLookupContainerFilter()); } }; seqFK.setPrefixColumnCaption(false); @@ -1219,7 +1217,7 @@ public CrosstabTableInfo createProteinProphetCrosstabTable(MS2Controller.Peptide CrosstabDimension rowDim = settings.getRowAxis().addDimension(FieldKey.fromParts("SeqId")); ActionURL showProteinURL = new ActionURL(MS2Controller.ShowProteinAction.class, getContainer()); rowDim.setUrl(showProteinURL.getLocalURIString() + "&seqId=${SeqId}"); - rowDim.getSourceColumn().setDisplayColumnFactory(new DisplayColumnFactory() + ((BaseColumnInfo)rowDim.getSourceColumn()).setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) { @@ -1398,7 +1396,7 @@ else if (form.isPeptideProphetFilter() && form.getPeptideProphetProbability() != parameters.put("run", CrosstabMember.VALUE_NAME); parameters.put(MS2Manager.getDataRegionNamePeptides() + ".Peptide~eq", FieldKey.fromParts("peptide")); scansMeasure.setUrl(new DetailsURL(new ActionURL(MS2Controller.ShowPeptidePopupAction.class, getContainer()), parameters)); - scansMeasure.getSourceColumn().setDisplayColumnFactory(new DisplayColumnFactory(){ + ((BaseColumnInfo)scansMeasure.getSourceColumn()).setDisplayColumnFactory(new DisplayColumnFactory(){ public DisplayColumn createRenderer(ColumnInfo colInfo) { DisplayColumn dc = new DataColumn(colInfo); @@ -1462,8 +1460,8 @@ else if (form != null && form.isCustomViewPeptideFilter()) filt = ProteinManager.getSequencesFilter(form.getTargetSeqIds()); baseTable.addCondition(filt.toSQLFragment(null, this.getDbSchema().getSqlDialect())); } - baseTable.getColumn("SeqId").setLabel("Search Engine Protein"); - baseTable.getColumn("SeqId").setFk(createSequencesLookup()); + baseTable.getMutableColumn("SeqId").setLabel("Search Engine Protein"); + baseTable.getMutableColumn("SeqId").setFk(createSequencesLookup()); return baseTable; } @@ -1474,7 +1472,7 @@ private ForeignKey createSequencesLookup() { public TableInfo getLookupTableInfo() { - SequencesTableInfo result = createSequencesTable(); + SequencesTableInfo result = createSequencesTable(getLookupContainerFilter()); // This is a horrible hack to try to deal with https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=5237 // Performance on a SQLServer installation with a large number of runs and sequences is much better with // this condition because it causes the query plan to flip to something that does a much more efficient diff --git a/ms2/src/org/labkey/ms2/query/PeptidesTableInfo.java b/ms2/src/org/labkey/ms2/query/PeptidesTableInfo.java index 855d437e4c..8713d77af1 100644 --- a/ms2/src/org/labkey/ms2/query/PeptidesTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/PeptidesTableInfo.java @@ -78,14 +78,14 @@ public PeptidesTableInfo(MS2Schema schema, boolean includeFeatureFk, ContainerFi public PeptidesTableInfo(MS2Schema schema, ActionURL url, boolean includeFeatureFk, ContainerFilter containerFilter, MS2RunType[] runTypes, boolean highestScore) { - super(MS2Manager.getTableInfoPeptidesData(), schema); + super(MS2Manager.getTableInfoPeptidesData(), schema, containerFilter); setName(MS2Schema.TableType.Peptides.name()); if (runTypes != null && runTypes.length == 1) { setName(runTypes[0].getPeptideTableName()); } _runTypes = runTypes; - setContainerFilter(containerFilter); + addRunFilter(); if (highestScore) { addHighestScoreFilter(); @@ -113,20 +113,20 @@ public PeptidesTableInfo(MS2Schema schema, ActionURL url, boolean includeFeature addMassColumns(dialect); SQLFragment mzSQL = new SQLFragment("CASE WHEN " + ExprColumn.STR_TABLE_ALIAS + ".Charge = 0.0 THEN 0.0 ELSE (" + ExprColumn.STR_TABLE_ALIAS + ".Mass + " + ExprColumn.STR_TABLE_ALIAS + ".DeltaMass + (" + ExprColumn.STR_TABLE_ALIAS + ".Charge - 1.0) * 1.007276) / " + ExprColumn.STR_TABLE_ALIAS + ".Charge END"); - ColumnInfo mz = new ExprColumn(this, "MZ", mzSQL, JdbcType.REAL); + var mz = new ExprColumn(this, "MZ", mzSQL, JdbcType.REAL); mz.setFormat("0.0000"); mz.setWidth("55"); mz.setLabel("ObsMZ"); addColumn(mz); SQLFragment strippedPeptideSQL = new SQLFragment("LTRIM(RTRIM(" + dialect.concatenate(ExprColumn.STR_TABLE_ALIAS + ".PrevAA", ExprColumn.STR_TABLE_ALIAS + ".TrimmedPeptide", ExprColumn.STR_TABLE_ALIAS + ".NextAA") + "))"); - ColumnInfo strippedPeptide = new ExprColumn(this, "StrippedPeptide", strippedPeptideSQL, JdbcType.VARCHAR); + var strippedPeptide = new ExprColumn(this, "StrippedPeptide", strippedPeptideSQL, JdbcType.VARCHAR); strippedPeptide.setWidth("320"); addColumn(strippedPeptide); TableInfo info = getRealTable(); - ColumnInfo quantitation = wrapColumn("Quantitation", info.getColumn("RowId")); + var quantitation = wrapColumn("Quantitation", info.getColumn("RowId")); quantitation.setIsUnselectable(true); quantitation.setFk(new LookupForeignKey("PeptideId") { @@ -134,15 +134,15 @@ public TableInfo getLookupTableInfo() { FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoQuantitation(), getUserSchema()); result.wrapAllColumns(true); - result.getColumn("PeptideId").setHidden(true); - result.getColumn("QuantId").setHidden(true); + result.getMutableColumn("PeptideId").setHidden(true); + result.getMutableColumn("QuantId").setHidden(true); return result; } }); quantitation.setKeyField(false); addColumn(quantitation); - ColumnInfo iTraqQuantitation = wrapColumn("iTRAQQuantitation", info.getColumn("RowId")); + var iTraqQuantitation = wrapColumn("iTRAQQuantitation", info.getColumn("RowId")); iTraqQuantitation.setLabel("iTRAQ Quantitation"); iTraqQuantitation.setIsUnselectable(true); iTraqQuantitation.setFk(new LookupForeignKey("PeptideId") @@ -151,7 +151,7 @@ public TableInfo getLookupTableInfo() { FilteredTable result = new FilteredTable<>(MS2Manager.getTableInfoITraqPeptideQuantitation(), getUserSchema()); result.wrapAllColumns(true); - result.getColumn("PeptideId").setHidden(true); + result.getMutableColumn("PeptideId").setHidden(true); SQLFragment sumSQL = new SQLFragment( "(COALESCE (" + ExprColumn.STR_TABLE_ALIAS + ".AbsoluteIntensity1, 0) + " + @@ -187,19 +187,19 @@ public TableInfo getLookupTableInfo() iTraqQuantitation.setKeyField(false); addColumn(iTraqQuantitation); - ColumnInfo proteinGroup = wrapColumn("ProteinProphetData", info.getColumn("RowId")); + var proteinGroup = wrapColumn("ProteinProphetData", info.getColumn("RowId")); proteinGroup.setIsUnselectable(true); proteinGroup.setFk(new LookupForeignKey("PeptideId") { public TableInfo getLookupTableInfo() { - return _userSchema.createPeptideMembershipsTable(); + return _userSchema.createPeptideMembershipsTable(getLookupContainerFilter()); } }); proteinGroup.setKeyField(false); addColumn(proteinGroup); - ColumnInfo peptideProphetData = wrapColumn("PeptideProphetDetails", info.getColumn("RowId")); + var peptideProphetData = wrapColumn("PeptideProphetDetails", info.getColumn("RowId")); peptideProphetData.setIsUnselectable(true); peptideProphetData.setFk(new LookupForeignKey("PeptideId") { @@ -207,7 +207,7 @@ public TableInfo getLookupTableInfo() { FilteredTable table = new FilteredTable<>(MS2Manager.getTableInfoPeptideProphetData(), getUserSchema()); table.wrapAllColumns(true); - table.getColumn("PeptideId").setHidden(true); + table.getMutableColumn("PeptideId").setHidden(true); return table; } }); @@ -235,18 +235,18 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) return dataColumn; } }; - getColumn("Scan").setURL(StringExpressionFactory.createURL(showPeptideURLString)); - getColumn("Scan").setDisplayColumnFactory(factory); - getColumn("Peptide").setURL(StringExpressionFactory.createURL(showPeptideURLString)); - getColumn("Peptide").setDisplayColumnFactory(factory); + getMutableColumn("Scan").setURL(StringExpressionFactory.createURL(showPeptideURLString)); + getMutableColumn("Scan").setDisplayColumnFactory(factory); + getMutableColumn("Peptide").setURL(StringExpressionFactory.createURL(showPeptideURLString)); + getMutableColumn("Peptide").setDisplayColumnFactory(factory); addScoreColumns(); - getColumn("Fraction").setFk(new LookupForeignKey("Fraction") + getMutableColumn("Fraction").setFk(new LookupForeignKey("Fraction") { public TableInfo getLookupTableInfo() { - return _userSchema.createFractionsTable(); + return _userSchema.createFractionsTable(getLookupContainerFilter()); } }); @@ -286,13 +286,6 @@ public TableInfo getLookupTableInfo() addFeatureInfoColumn(); } - @Override - public void setContainerFilter(@NotNull ContainerFilter filter) - { - super.setContainerFilter(filter); - addRunFilter(); - } - private void addRunFilter() { FieldKey fractionRunFieldKey = FieldKey.fromParts("Fraction", "Run"); @@ -406,7 +399,7 @@ private void addFeatureInfoColumn() "INNER JOIN ms2.PeptidesData AS pd ON (pd.Fraction=fr.Fraction AND pd.scan=fe.MS2Scan AND pd.Charge=fe.MS2Charge)\n" + "WHERE pd.RowId=" + ExprColumn.STR_TABLE_ALIAS + ".RowId)"); - ColumnInfo ciFeatureId = addColumn(new ExprColumn(this, "MS1 Feature", sqlFeatureJoin, JdbcType.INTEGER, getColumn("RowId"))); + var ciFeatureId = addColumn(new ExprColumn(this, "MS1 Feature", sqlFeatureJoin, JdbcType.INTEGER, getColumn("RowId"))); //tell query that this new column is an FK to the features table info ciFeatureId.setFk(new LookupForeignKey("FeatureId") @@ -439,13 +432,13 @@ public TableInfo getLookupTableInfo() } }; fk.setPrefixColumnCaption(false); - getColumn("SeqId").setFk(fk); + getMutableColumn("SeqId").setFk(fk); - getColumn("SeqId").setURL(StringExpressionFactory.createURL(showProteinURLString)); - getColumn("SeqId").setDisplayColumnFactory(new ProteinDisplayColumnFactory(_userSchema.getContainer())); - getColumn("SeqId").setLabel("Search Engine Protein"); - getColumn("Protein").setURL(StringExpressionFactory.createURL(showProteinURLString)); - getColumn("Protein").setDisplayColumnFactory(new ProteinDisplayColumnFactory(_userSchema.getContainer())); + getMutableColumn("SeqId").setURL(StringExpressionFactory.createURL(showProteinURLString)); + getMutableColumn("SeqId").setDisplayColumnFactory(new ProteinDisplayColumnFactory(_userSchema.getContainer())); + getMutableColumn("SeqId").setLabel("Search Engine Protein"); + getMutableColumn("Protein").setURL(StringExpressionFactory.createURL(showProteinURLString)); + getMutableColumn("Protein").setDisplayColumnFactory(new ProteinDisplayColumnFactory(_userSchema.getContainer())); } private void addScoreColumns() @@ -490,7 +483,7 @@ private void addScoreColumns() } sql.append(" ELSE NULL END"); - ColumnInfo newCol = addColumn(new ExprColumn(this, entry.getKey(), sql, JdbcType.DOUBLE)); + var newCol = addColumn(new ExprColumn(this, entry.getKey(), sql, JdbcType.DOUBLE)); newCol.setFormat(realScoreCol.getFormat()); newCol.setWidth(realScoreCol.getWidth()); } @@ -526,14 +519,14 @@ private Collection getRunTypes() private void addMassColumns(SqlDialect dialect) { SQLFragment precursorMassSQL = new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".mass + " + ExprColumn.STR_TABLE_ALIAS + ".deltamass"); - ColumnInfo precursorMass = new ExprColumn(this, "PrecursorMass", precursorMassSQL, JdbcType.REAL); + var precursorMass = new ExprColumn(this, "PrecursorMass", precursorMassSQL, JdbcType.REAL); precursorMass.setFormat("0.0000"); precursorMass.setWidth("65"); precursorMass.setLabel("ObsMH+"); addColumn(precursorMass); SQLFragment fractionalDeltaMassSQL = new SQLFragment("ABS(" + ExprColumn.STR_TABLE_ALIAS + ".deltamass - " + dialect.getRoundFunction(ExprColumn.STR_TABLE_ALIAS + ".deltamass") + ")"); - ColumnInfo fractionalDeltaMass = new ExprColumn(this, "FractionalDeltaMass", fractionalDeltaMassSQL, JdbcType.REAL); + var fractionalDeltaMass = new ExprColumn(this, "FractionalDeltaMass", fractionalDeltaMassSQL, JdbcType.REAL); fractionalDeltaMass.setFormat("0.0000"); fractionalDeltaMass.setWidth("55"); fractionalDeltaMass.setLabel("fdMass"); @@ -543,7 +536,7 @@ private void addMassColumns(SqlDialect dialect) " WHEN " + ExprColumn.STR_TABLE_ALIAS + ".mass = 0.0 THEN 0.0\n" + " ELSE abs(1000000.0 * abs(" + ExprColumn.STR_TABLE_ALIAS + ".deltamass - " + dialect.getRoundFunction(ExprColumn.STR_TABLE_ALIAS + ".deltamass") + ") / (" + ExprColumn.STR_TABLE_ALIAS + ".mass + ((" + ExprColumn.STR_TABLE_ALIAS + ".charge - 1.0) * 1.007276)))\n" + " END"); - ColumnInfo fractionalDeltaMassPPM = new ExprColumn(this, "FractionalDeltaMassPPM", fractionalSQL, JdbcType.REAL); + var fractionalDeltaMassPPM = new ExprColumn(this, "FractionalDeltaMassPPM", fractionalSQL, JdbcType.REAL); fractionalDeltaMassPPM.setFormat("0.0"); fractionalDeltaMassPPM.setWidth("80"); fractionalDeltaMassPPM.setLabel("fdMassPPM"); @@ -553,7 +546,7 @@ private void addMassColumns(SqlDialect dialect) " WHEN " + ExprColumn.STR_TABLE_ALIAS + ".mass = 0.0 THEN 0.0\n" + " ELSE abs(1000000.0 * " + ExprColumn.STR_TABLE_ALIAS + ".deltamass / (" + ExprColumn.STR_TABLE_ALIAS + ".mass + ((" + ExprColumn.STR_TABLE_ALIAS + ".charge - 1.0) * 1.007276)))\n" + " END"); - ColumnInfo deltaMassPPM = new ExprColumn(this, "DeltaMassPPM", deltaSQL, JdbcType.REAL); + var deltaMassPPM = new ExprColumn(this, "DeltaMassPPM", deltaSQL, JdbcType.REAL); deltaMassPPM.setFormat("0.0"); deltaMassPPM.setWidth("75"); deltaMassPPM.setLabel("dMassPPM"); @@ -596,7 +589,7 @@ public String getPublicName() public static void addCalculatedColumns(FilteredTable table) { - ColumnInfo hColumn = table.wrapColumn("H", table.getRealTable().getColumn("Peptide")); + var hColumn = table.wrapColumn("H", table.getRealTable().getColumn("Peptide")); hColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -606,7 +599,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) }); table.addColumn(hColumn); - ColumnInfo deltaScanColumn = table.wrapColumn("DeltaScan", table.getRealTable().getColumn("Fraction")); + var deltaScanColumn = table.wrapColumn("DeltaScan", table.getRealTable().getColumn("Fraction")); deltaScanColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -614,7 +607,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) return new DeltaScanColumn(colInfo); } }); - deltaScanColumn.setFk(null); + deltaScanColumn.clearFk(); table.addColumn(deltaScanColumn); } diff --git a/ms2/src/org/labkey/ms2/query/ProteinGroupTableInfo.java b/ms2/src/org/labkey/ms2/query/ProteinGroupTableInfo.java index f67a1e0e3a..7e0d33e0f7 100644 --- a/ms2/src/org/labkey/ms2/query/ProteinGroupTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/ProteinGroupTableInfo.java @@ -20,6 +20,7 @@ import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.CompareType; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.DataColumn; import org.labkey.api.data.DisplayColumn; @@ -59,16 +60,16 @@ public class ProteinGroupTableInfo extends FilteredTable private static final Set HIDDEN_PROTEIN_GROUP_MEMBERSHIPS_COLUMN_NAMES = new CaseInsensitiveHashSet("ProteinGroupId", "SeqId"); private List _runs; - public ProteinGroupTableInfo(MS2Schema schema) + public ProteinGroupTableInfo(MS2Schema schema, ContainerFilter cf) { - this(schema, true); + this(schema, cf, true); } - public ProteinGroupTableInfo(MS2Schema schema, boolean includeFirstProteinColumn) + public ProteinGroupTableInfo(MS2Schema schema, ContainerFilter cf, boolean includeFirstProteinColumn) { - super(MS2Manager.getTableInfoProteinGroups(), schema); + super(MS2Manager.getTableInfoProteinGroups(), schema, cf); - ColumnInfo groupNumberColumn = wrapColumn("Group", getRealTable().getColumn("GroupNumber")); + var groupNumberColumn = wrapColumn("Group", getRealTable().getColumn("GroupNumber")); groupNumberColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -83,34 +84,36 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) setTitleColumn("Group"); addColumn(wrapColumn("ProteinProphet", getRealTable().getColumn("ProteinProphetFileId"))); - getColumn("ProteinProphetFileId").setHidden(true); + getMutableColumn("ProteinProphetFileId").setHidden(true); - ColumnInfo quantitation = wrapColumn("Quantitation", getRealTable().getColumn("RowId")); + var quantitation = wrapColumn("Quantitation", getRealTable().getColumn("RowId")); quantitation.setIsUnselectable(true); quantitation.setFk(new LookupForeignKey("ProteinGroupId") { public TableInfo getLookupTableInfo() { + // TODO ContainerFilter return new ProteinQuantitationTable(_userSchema); } }); quantitation.setKeyField(false); addColumn(quantitation); - ColumnInfo iTraqQuantitation = wrapColumn("iTRAQQuantitation", getRealTable().getColumn("RowId")); + var iTraqQuantitation = wrapColumn("iTRAQQuantitation", getRealTable().getColumn("RowId")); iTraqQuantitation.setLabel("iTRAQ Quantitation"); iTraqQuantitation.setIsUnselectable(true); iTraqQuantitation.setFk(new LookupForeignKey("ProteinGroupId") { public TableInfo getLookupTableInfo() { + // TODO ContainerFilter return new ITraqProteinQuantitationTable(_userSchema); } }); iTraqQuantitation.setKeyField(false); addColumn(iTraqQuantitation); - for (ColumnInfo col : getColumns()) + for (var col : getMutableColumns()) { if (HIDDEN_PROTEIN_GROUP_COLUMN_NAMES.contains(col.getName())) { @@ -122,12 +125,13 @@ public TableInfo getLookupTableInfo() { public TableInfo getLookupTableInfo() { + // TODO ContainerFilter return new ProteinProphetFileTableInfo(_userSchema); } }; foreignKey.setPrefixColumnCaption(false); - getColumn("ProteinProphetFileId").setFk(foreignKey); - getColumn("ProteinProphet").setFk(foreignKey); + getMutableColumn("ProteinProphetFileId").setFk(foreignKey); + getMutableColumn("ProteinProphet").setFk(foreignKey); if (includeFirstProteinColumn) { @@ -144,11 +148,11 @@ public TableInfo getLookupTableInfo() firstProteinSQL.append(")"); ExprColumn firstProteinColumn = new ExprColumn(this, "FirstProtein", firstProteinSQL, JdbcType.INTEGER); - firstProteinColumn.setFk(new LookupForeignKey("SeqId") + firstProteinColumn.setFk(new LookupForeignKey(cf, "SeqId", null) { public TableInfo getLookupTableInfo() { - return new SequencesTableInfo(null, _userSchema); + return new SequencesTableInfo(null, _userSchema, getLookupContainerFilter()); } }); addColumn(firstProteinColumn); @@ -205,23 +209,24 @@ public void addPeptideFilter(MS2Controller.ProbabilityProteinSearchForm form, Vi public void addProteinsColumn() { - ColumnInfo proteinGroup = wrapColumn("Proteins", getRealTable().getColumn("RowId")); - LookupForeignKey fk = new LookupForeignKey("ProteinGroupId") + var proteinGroup = wrapColumn("Proteins", getRealTable().getColumn("RowId")); + LookupForeignKey fk = new LookupForeignKey(getContainerFilter(), "ProteinGroupId", null) { public TableInfo getLookupTableInfo() { + // TODO ContainerFilter TableInfo info = MS2Manager.getTableInfoProteinGroupMemberships(); FilteredTable result = new FilteredTable<>(info, getUserSchema()); for (ColumnInfo col : info.getColumns()) { - ColumnInfo newColumn = result.addWrapColumn(col); + var newColumn = result.addWrapColumn(col); if (HIDDEN_PROTEIN_GROUP_MEMBERSHIPS_COLUMN_NAMES.contains(newColumn.getName())) { newColumn.setHidden(true); } } - ColumnInfo proteinColumn = result.wrapColumn("Protein", info.getColumn("SeqId")); + var proteinColumn = result.wrapColumn("Protein", info.getColumn("SeqId")); proteinColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -240,11 +245,11 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) }); result.addColumn(proteinColumn); - proteinColumn.setFk(new LookupForeignKey("SeqId", "DatabaseSequenceName") + proteinColumn.setFk(new LookupForeignKey(getContainerFilter(), "SeqId", "DatabaseSequenceName") { public TableInfo getLookupTableInfo() { - SequencesTableInfo result = new SequencesTableInfo(null, _userSchema); + SequencesTableInfo result = new SequencesTableInfo(_userSchema, getLookupContainerFilter()); ExprColumn col = new ExprColumn(result, "DatabaseSequenceName", new SQLFragment("#PLACEHOLDER#"), JdbcType.VARCHAR) { @Override @@ -304,28 +309,28 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) } }; - ColumnInfo proteinNameColumn = wrapColumn("Protein", rowIdColumn); + var proteinNameColumn = wrapColumn("Protein", rowIdColumn); proteinNameColumn.setDisplayColumnFactory(factory); addColumn(proteinNameColumn); - ColumnInfo bestNameColumn = wrapColumn("BestName", rowIdColumn); + var bestNameColumn = wrapColumn("BestName", rowIdColumn); bestNameColumn.setDisplayColumnFactory(factory); addColumn(bestNameColumn); - ColumnInfo bestGeneNameColumn = wrapColumn("BestGeneName", rowIdColumn); + var bestGeneNameColumn = wrapColumn("BestGeneName", rowIdColumn); bestGeneNameColumn.setDisplayColumnFactory(factory); addColumn(bestGeneNameColumn); - ColumnInfo massColumn = wrapColumn("SequenceMass", rowIdColumn); + var massColumn = wrapColumn("SequenceMass", rowIdColumn); massColumn.setDisplayColumnFactory(factory); addColumn(massColumn); - ColumnInfo descriptionColumn = wrapColumn("Description", rowIdColumn); + var descriptionColumn = wrapColumn("Description", rowIdColumn); descriptionColumn.setDisplayColumnFactory(factory); addColumn(descriptionColumn); - ColumnInfo totalCount = wrapColumn("TotalFilteredPeptides", rowIdColumn); + var totalCount = wrapColumn("TotalFilteredPeptides", rowIdColumn); totalCount.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -336,7 +341,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) }); addColumn(totalCount); - ColumnInfo uniqueCount = wrapColumn("UniqueFilteredPeptides", rowIdColumn); + var uniqueCount = wrapColumn("UniqueFilteredPeptides", rowIdColumn); uniqueCount.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) diff --git a/ms2/src/org/labkey/ms2/query/ProteinProphetFileTableInfo.java b/ms2/src/org/labkey/ms2/query/ProteinProphetFileTableInfo.java index ad17079635..3ecce10209 100644 --- a/ms2/src/org/labkey/ms2/query/ProteinProphetFileTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/ProteinProphetFileTableInfo.java @@ -35,7 +35,7 @@ public ProteinProphetFileTableInfo(MS2Schema schema) wrapAllColumns(true); ActionURL url = MS2Controller.getShowRunURL(_userSchema.getUser(), getContainer()); - getColumn("Run").setFk(new LookupForeignKey(url, "run", "Run", "Description") + getMutableColumn("Run").setFk(new LookupForeignKey(url, "run", "Run", "Description") { public TableInfo getLookupTableInfo() { diff --git a/ms2/src/org/labkey/ms2/query/ProteinQuantitationTable.java b/ms2/src/org/labkey/ms2/query/ProteinQuantitationTable.java index 6b45cb29de..bc2d5cea0a 100644 --- a/ms2/src/org/labkey/ms2/query/ProteinQuantitationTable.java +++ b/ms2/src/org/labkey/ms2/query/ProteinQuantitationTable.java @@ -29,6 +29,6 @@ public ProteinQuantitationTable(MS2Schema schema) { super(MS2Manager.getTableInfoProteinQuantitation(), schema); wrapAllColumns(true); - getColumn("ProteinGroupId").setHidden(true); + getMutableColumn("ProteinGroupId").setHidden(true); } } diff --git a/ms2/src/org/labkey/ms2/query/RunTableInfo.java b/ms2/src/org/labkey/ms2/query/RunTableInfo.java index d4f302bd34..05f7909883 100644 --- a/ms2/src/org/labkey/ms2/query/RunTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/RunTableInfo.java @@ -16,7 +16,6 @@ package org.labkey.ms2.query; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.ContainerForeignKey; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.query.ExpSchema; @@ -43,18 +42,18 @@ public RunTableInfo(MS2Schema schema) DetailsURL url = new DetailsURL(new ActionURL(MS2Controller.ShowListAction.class, getContainer())); url.setContainerContext(new ContainerContext.FieldKeyContext(FieldKey.fromParts("Container"))); - ColumnInfo containerColumn = getColumn("Container"); + var containerColumn = getMutableColumn("Container"); ContainerForeignKey.initColumn(containerColumn, _userSchema, null); containerColumn.setURL(url); containerColumn.setHidden(true); - ColumnInfo folderColumn = wrapColumn("Folder", getRealTable().getColumn("Container")); + var folderColumn = wrapColumn("Folder", getRealTable().getColumn("Container")); folderColumn.setHidden(false); ContainerForeignKey.initColumn(folderColumn, _userSchema, null); folderColumn.setURL(url); addColumn(folderColumn); - ColumnInfo erLSIDColumn = getColumn("ExperimentRunLSID"); + var erLSIDColumn = getMutableColumn("ExperimentRunLSID"); erLSIDColumn.setLabel("Experiment Run"); erLSIDColumn.setFk(new LookupForeignKey("LSID") { diff --git a/ms2/src/org/labkey/ms2/query/SequencesTableInfo.java b/ms2/src/org/labkey/ms2/query/SequencesTableInfo.java index b027fd90aa..90b7001572 100644 --- a/ms2/src/org/labkey/ms2/query/SequencesTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/SequencesTableInfo.java @@ -20,6 +20,7 @@ import org.labkey.api.data.AbstractForeignKey; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.DisplayColumnFactory; @@ -61,36 +62,44 @@ */ public class SequencesTableInfo extends FilteredTable { + // TODO ContainerFilter + @Deprecated protected SequencesTableInfo(String name, SchemaType schema) { - this(schema); + this(schema, null); setName(name); } - public SequencesTableInfo(SchemaType schema) + protected SequencesTableInfo(String name, SchemaType schema, ContainerFilter cf) { - super(ProteinManager.getTableInfoSequences(), schema); + this(schema, cf); + setName(name); + } + + public SequencesTableInfo(SchemaType schema, ContainerFilter cf) + { + super(ProteinManager.getTableInfoSequences(), schema, cf); setPublicSchemaName(ProteinUserSchema.NAME); setTitleColumn("BestName"); wrapAllColumns(true); - getColumn("OrgId").setFk(new QueryForeignKey(ProteinUserSchema.NAME, schema.getContainer(), null, schema.getUser(), ProteinUserSchema.TableType.Organisms.name(), null, null)); + getMutableColumn("OrgId").setFk( QueryForeignKey.from(schema, getContainerFilter()).schema(ProteinUserSchema.NAME).table(ProteinUserSchema.TableType.Organisms.name()) ); addColumn(wrapColumn("Source", getRealTable().getColumn("SourceId"))); - getColumn("Source").setFk(new QueryForeignKey(schema, null, ProteinUserSchema.TableType.InfoSources.name(), null, null)); + getMutableColumn("Source").setFk( QueryForeignKey.from(schema, getContainerFilter()).to(ProteinUserSchema.TableType.InfoSources.name(), null, null) ); removeColumn(getColumn("SourceId")); ActionURL url = new ActionURL(MS2Controller.ShowProteinAction.class, _userSchema.getContainer()); url.addParameter("seqId", "${SeqId}"); - ColumnInfo bnColumn = getColumn("BestName"); + var bnColumn = getMutableColumn("BestName"); bnColumn.setURL(StringExpressionFactory.createURL(url)); bnColumn.setURLTargetWindow("prot"); setDetailsURL(new DetailsURL(url)); - ColumnInfo annotationColumn = wrapColumn("CustomAnnotations", _rootTable.getColumn("SeqId")); + var annotationColumn = wrapColumn("CustomAnnotations", _rootTable.getColumn("SeqId")); annotationColumn.setIsUnselectable(true); - annotationColumn.setFk(new AbstractForeignKey() + annotationColumn.setFk(new AbstractForeignKey(schema, cf) { public StringExpression getURL(ColumnInfo parent) { @@ -122,6 +131,7 @@ public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) { public TableInfo getLookupTableInfo() { + // TODO ContainerFilter return new CustomAnnotationTable(annotationSet, new CustomAnnotationSchema(_userSchema.getUser(), _userSchema.getContainer(), false)); } }); @@ -139,19 +149,19 @@ public TableInfo getLookupTableInfo() }); addColumn(annotationColumn); - ColumnInfo goMPColumn = wrapColumn("GOMetabolicProcesses", getRealTable().getColumn("SeqId")); + var goMPColumn = wrapColumn("GOMetabolicProcesses", getRealTable().getColumn("SeqId")); goMPColumn.setLabel("GO Metabolic Processes"); - goMPColumn.setFk(new MultiValuedForeignKey(new QueryForeignKey(ProteinUserSchema.NAME, getUserSchema().getContainer(), null, getUserSchema().getUser(), "GOMetabolicProcess", "SeqId", "BestName"), "GOMPAnnotId")); + goMPColumn.setFk(new MultiValuedForeignKey(QueryForeignKey.from(schema, cf).schema(ProteinUserSchema.NAME).to("GOMetabolicProcess", "SeqId", "BestName"), "GOMPAnnotId")); addColumn(goMPColumn); - ColumnInfo goCLColumn = wrapColumn("GOCellularLocations", getRealTable().getColumn("SeqId")); + var goCLColumn = wrapColumn("GOCellularLocations", getRealTable().getColumn("SeqId")); goCLColumn.setLabel("GO Cellular Locations"); - goCLColumn.setFk(new MultiValuedForeignKey(new QueryForeignKey(ProteinUserSchema.NAME, getUserSchema().getContainer(), null, getUserSchema().getUser(), "GOCellularLocation", "SeqId", "BestName"), "GOCLAnnotId")); + goCLColumn.setFk(new MultiValuedForeignKey(QueryForeignKey.from(schema, cf).schema(ProteinUserSchema.NAME).to("GOCellularLocation", "SeqId", "BestName"), "GOCLAnnotId")); addColumn(goCLColumn); - ColumnInfo goMFColumn = wrapColumn("GOMolecularFunctions", getRealTable().getColumn("SeqId")); + var goMFColumn = wrapColumn("GOMolecularFunctions", getRealTable().getColumn("SeqId")); goMFColumn.setLabel("GO Molecular Functions"); - goMFColumn.setFk(new MultiValuedForeignKey(new QueryForeignKey(ProteinUserSchema.NAME, getUserSchema().getContainer(), null, getUserSchema().getUser(), "GOMolecularFunction", "SeqId", "BestName"), "GOMFAnnotId")); + goMFColumn.setFk(new MultiValuedForeignKey(QueryForeignKey.from(schema, cf).schema(ProteinUserSchema.NAME).to("GOMolecularFunction", "SeqId", "BestName"), "GOMFAnnotId")); addColumn(goMFColumn); for (CustomAnnotationType type : CustomAnnotationType.values()) @@ -188,7 +198,7 @@ protected ColumnInfo resolveColumn(String name) public void addPeptideAggregationColumns() { - ColumnInfo aaColumn = wrapColumn("AACoverage", getRealTable().getColumn("ProtSequence")); + var aaColumn = wrapColumn("AACoverage", getRealTable().getColumn("ProtSequence")); aaColumn.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -200,7 +210,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) }); addColumn(aaColumn); - ColumnInfo totalCount = wrapColumn("Peptides", getRealTable().getColumn("SeqId")); + var totalCount = wrapColumn("Peptides", getRealTable().getColumn("SeqId")); totalCount.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) @@ -211,7 +221,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) }); addColumn(totalCount); - ColumnInfo uniqueCount = wrapColumn("UniquePeptides", getRealTable().getColumn("SeqId")); + var uniqueCount = wrapColumn("UniquePeptides", getRealTable().getColumn("SeqId")); uniqueCount.setDisplayColumnFactory(new DisplayColumnFactory() { public DisplayColumn createRenderer(ColumnInfo colInfo) diff --git a/ms2/src/org/labkey/ms2/query/SpectraCountTableInfo.java b/ms2/src/org/labkey/ms2/query/SpectraCountTableInfo.java index d30b6bc9f6..dcd1ff0ecc 100644 --- a/ms2/src/org/labkey/ms2/query/SpectraCountTableInfo.java +++ b/ms2/src/org/labkey/ms2/query/SpectraCountTableInfo.java @@ -17,7 +17,6 @@ package org.labkey.ms2.query; import org.jetbrains.annotations.NotNull; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.CompareType; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerManager; @@ -136,11 +135,11 @@ public SpectraCountTableInfo(MS2Schema ms2Schema, SpectraCountConfiguration conf List defaultCols = new ArrayList<>(); ExprColumn runColumn = new ExprColumn(this, "Run", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".Run"), JdbcType.INTEGER); - runColumn.setFk(new LookupForeignKey(MS2Controller.getShowRunURL(_userSchema.getUser(), _userSchema.getContainer()), "run", "MS2Details", "Name") + runColumn.setFk(new LookupForeignKey(/*TODO ContainerFilter,*/ MS2Controller.getShowRunURL(_userSchema.getUser(), _userSchema.getContainer()), "run", "MS2Details", "Name") { public TableInfo getLookupTableInfo() { - ExpRunTable result = (ExpRunTable)MS2Schema.TableType.MS2SearchRuns.createTable(_userSchema); + ExpRunTable result = (ExpRunTable)MS2Schema.TableType.MS2SearchRuns.createTable(_userSchema, getLookupContainerFilter()); result.setContainerFilter(ContainerFilter.EVERYTHING); return result; } @@ -157,7 +156,7 @@ public TableInfo getLookupTableInfo() if (config.isGroupedByPeptide()) { - ColumnInfo indexColumn; + ExprColumn indexColumn; if (form != null && form.hasTargetSeqIds()) { SQLFragment indexSQL = new SQLFragment(getSqlDialect().getStringIndexOfFunction(new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".TrimmedPeptide"), new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".ProtSequence"))); @@ -189,11 +188,11 @@ public TableInfo getLookupTableInfo() } proteinColumn.setDescription("The protein associated with the peptide identification. Only available if a grouping by protein information, or a target protein has been specified."); addColumn(proteinColumn); - proteinColumn.setFk(new LookupForeignKey(new ActionURL(MS2Controller.ShowProteinAction.class, ContainerManager.getRoot()), "seqId", "SeqId", "BestName") + proteinColumn.setFk(new LookupForeignKey(/*TODO ContainerFilter,*/ new ActionURL(MS2Controller.ShowProteinAction.class, ContainerManager.getRoot()), "seqId", "SeqId", "BestName") { public TableInfo getLookupTableInfo() { - return _userSchema.createSequencesTable(); + return _userSchema.createSequencesTable(getLookupContainerFilter()); } }); diff --git a/nab/src/org/labkey/nab/NabAssayRun.java b/nab/src/org/labkey/nab/NabAssayRun.java index 162dec7df6..870bb680f9 100644 --- a/nab/src/org/labkey/nab/NabAssayRun.java +++ b/nab/src/org/labkey/nab/NabAssayRun.java @@ -120,7 +120,7 @@ else if (null != dataWithHandlerType) throw new IllegalStateException("Expected a single data file output for this NAb run, but none matching the expected datatype found. Found a total of " + outputDatas.size()); AssayProtocolSchema schema = _provider.createProtocolSchema(_user, _run.getContainer(), _protocol, null); - TableInfo virusTable = schema.createTable(DilutionManager.VIRUS_TABLE_NAME); + TableInfo virusTable = schema.createTable(DilutionManager.VIRUS_TABLE_NAME, null); Map> samplePropertiesMap = getSampleProperties(); DilutionSummary[] dilutionSummaries = getSummaries(); diff --git a/nab/src/org/labkey/nab/SinglePlateNabAssayRun.java b/nab/src/org/labkey/nab/SinglePlateNabAssayRun.java index b81942647f..902c042eee 100644 --- a/nab/src/org/labkey/nab/SinglePlateNabAssayRun.java +++ b/nab/src/org/labkey/nab/SinglePlateNabAssayRun.java @@ -326,7 +326,7 @@ protected String getVirusName(String virusWellGroupName) { Lsid virusLsid = DilutionDataHandler.createVirusWellGroupLsid(outputDatas.get(0), virusWellGroupName); AssayProtocolSchema schema = _provider.createProtocolSchema(_user, _run.getContainer(), _protocol, null); - TableInfo virusTable = schema.createTable(DilutionManager.VIRUS_TABLE_NAME); + TableInfo virusTable = schema.createTable(DilutionManager.VIRUS_TABLE_NAME, null); if (null != virusTable) { ColumnInfo columnInfo = virusTable.getColumn(AbstractPlateBasedAssayProvider.VIRUS_NAME_PROPERTY_NAME); diff --git a/nab/src/org/labkey/nab/SinglePlateNabDataHandler.java b/nab/src/org/labkey/nab/SinglePlateNabDataHandler.java index bb76af4d54..c6cd894220 100644 --- a/nab/src/org/labkey/nab/SinglePlateNabDataHandler.java +++ b/nab/src/org/labkey/nab/SinglePlateNabDataHandler.java @@ -357,7 +357,7 @@ public void beforeDeleteData(List datas) throws ExperimentException ExpProtocol protocol = data.getRun().getProtocol(); AssayProvider provider = AssayService.get().getProvider(protocol); AssayProtocolSchema protocolSchema = provider.createProtocolSchema(null, protocol.getContainer(), protocol, null); - TableInfo virusTable = protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME); + TableInfo virusTable = protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME, null); if (virusTable instanceof FilteredTable) { if (virusTable.getColumn(FieldKey.fromParts(NabVirusDomainKind.DATLSID_COLUMN_NAME)) != null) diff --git a/nab/src/org/labkey/nab/query/NabBaseTable.java b/nab/src/org/labkey/nab/query/NabBaseTable.java index 98d0591765..a61fe01c25 100644 --- a/nab/src/org/labkey/nab/query/NabBaseTable.java +++ b/nab/src/org/labkey/nab/query/NabBaseTable.java @@ -16,6 +16,7 @@ package org.labkey.nab.query; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; @@ -33,7 +34,6 @@ import org.labkey.api.study.assay.AbstractPlateBasedAssayProvider; import org.labkey.api.study.assay.AssayProtocolSchema; import org.labkey.api.study.assay.AssayProvider; -import org.labkey.api.study.assay.AssaySchema; import org.labkey.api.study.assay.AssayService; import org.labkey.api.study.assay.SpecimenPropertyColumnDecorator; import org.labkey.api.util.StringExpression; @@ -49,9 +49,9 @@ public abstract class NabBaseTable extends FilteredTable protected final NabProtocolSchema _schema; protected final ExpProtocol _protocol; - public NabBaseTable(final NabProtocolSchema schema, TableInfo table, final ExpProtocol protocol) + public NabBaseTable(final NabProtocolSchema schema, TableInfo table, ContainerFilter cf, final ExpProtocol protocol) { - super(table, schema); + super(table, schema, cf); _schema = schema; _protocol = protocol; } @@ -62,23 +62,21 @@ protected void addSpecimenColumn() String sampleDomainURI = AbstractAssayProvider.getDomainURIForPrefix(_protocol, AbstractPlateBasedAssayProvider.ASSAY_DOMAIN_SAMPLE_WELLGROUP); final ExpSampleSet sampleSet = ExperimentService.get().getSampleSet(sampleDomainURI); - ColumnInfo specimenColumn = wrapColumn(getInputMaterialPropertyName(), _rootTable.getColumn("SpecimenLsid")); + var specimenColumn = wrapColumn(getInputMaterialPropertyName(), _rootTable.getColumn("SpecimenLsid")); specimenColumn.setLabel("Specimen"); specimenColumn.setKeyField(false); specimenColumn.setIsUnselectable(true); - LookupForeignKey lfkSpecimen = new LookupForeignKey("LSID") + LookupForeignKey lfkSpecimen = new LookupForeignKey(getContainerFilter(), "LSID", null) { @Override public TableInfo getLookupTableInfo() { - ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), _schema); - // Make sure we are filtering to the same set of containers - materials.setContainerFilter(getContainerFilter()); + ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), _schema, getLookupContainerFilter()); if (sampleSet != null) { materials.setSampleSet(sampleSet, true); } - ColumnInfo propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); + var propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); if (propertyCol.getFk() instanceof PropertyForeignKey) { ((PropertyForeignKey) propertyCol.getFk()).addDecorator(new SpecimenPropertyColumnDecorator(provider, _protocol, _schema)); @@ -96,13 +94,12 @@ protected void addRunColumn() { final AssayProvider provider = AssayService.get().getProvider(_protocol); ExprColumn runColumn = new ExprColumn(this, "Run", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".RunID"), JdbcType.INTEGER); - runColumn.setFk(new LookupForeignKey("RowID") + runColumn.setFk(new LookupForeignKey(getContainerFilter(), "RowID", null) { @Override public TableInfo getLookupTableInfo() { - ExpRunTable expRunTable = AssayService.get().createRunTable(_protocol, provider, _schema.getUser(), _schema.getContainer()); - expRunTable.setContainerFilter(getContainerFilter()); + ExpRunTable expRunTable = AssayService.get().createRunTable(_protocol, provider, _schema.getUser(), _schema.getContainer(), getLookupContainerFilter()); return expRunTable; } diff --git a/nab/src/org/labkey/nab/query/NabDilutionDataTable.java b/nab/src/org/labkey/nab/query/NabDilutionDataTable.java index 07076f5cd1..92fc0bf579 100644 --- a/nab/src/org/labkey/nab/query/NabDilutionDataTable.java +++ b/nab/src/org/labkey/nab/query/NabDilutionDataTable.java @@ -17,6 +17,7 @@ import org.labkey.api.assay.dilution.DilutionManager; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.exp.api.ExpProtocol; /** @@ -25,9 +26,9 @@ */ public class NabDilutionDataTable extends NabBaseTable { - public NabDilutionDataTable(final NabProtocolSchema schema, ExpProtocol protocol) + public NabDilutionDataTable(final NabProtocolSchema schema, ContainerFilter cf, ExpProtocol protocol) { - super(schema, DilutionManager.getTableInfoDilutionData(), protocol); + super(schema, DilutionManager.getTableInfoDilutionData(), cf, protocol); addRunColumn(); for (ColumnInfo col : getRealTable().getColumns()) @@ -41,7 +42,7 @@ public NabDilutionDataTable(final NabProtocolSchema schema, ExpProtocol protocol String name = col.getName(); if ("RunDataId".equalsIgnoreCase(name)) name = "RunData"; - ColumnInfo newCol = addWrapColumn(name, col); + var newCol = addWrapColumn(name, col); if (col.isHidden()) { newCol.setHidden(col.isHidden()); diff --git a/nab/src/org/labkey/nab/query/NabProtocolSchema.java b/nab/src/org/labkey/nab/query/NabProtocolSchema.java index 32bce1d342..2521b0f0a5 100644 --- a/nab/src/org/labkey/nab/query/NabProtocolSchema.java +++ b/nab/src/org/labkey/nab/query/NabProtocolSchema.java @@ -27,6 +27,7 @@ import org.labkey.api.cache.Wrapper; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.DatabaseCache; import org.labkey.api.data.DisplayColumn; import org.labkey.api.data.DisplayColumnFactory; @@ -72,9 +73,9 @@ public NabProtocolSchema(User user, Container container, @NotNull NabAssayProvid } @Override - public NabRunDataTable createDataTable(boolean includeCopiedToStudyColumns) + public @Nullable TableInfo createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - NabRunDataTable table = new NabRunDataTable(this, getProtocol()); + NabRunDataTable table = new NabRunDataTable(this, cf, getProtocol()); if (includeCopiedToStudyColumns) { @@ -84,10 +85,10 @@ public NabRunDataTable createDataTable(boolean includeCopiedToStudyColumns) } @Override - public ExpRunTable createRunsTable() + public ExpRunTable createRunsTable(ContainerFilter cf) { - final ExpRunTable runTable = super.createRunsTable(); - ColumnInfo nameColumn = runTable.getColumn(ExpRunTable.Column.Name); + final ExpRunTable runTable = super.createRunsTable(cf); + var nameColumn = runTable.getMutableColumn(ExpRunTable.Column.Name); // NAb has two detail type views of a run - the filtered results/data grid, and the run details page that // shows the graph. Set the run's name to be a link to the grid instead of the default details page. nameColumn.setDisplayColumnFactory(new DisplayColumnFactory() @@ -104,7 +105,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo) protected void addQCFlagColumn(ExpRunTable runTable) { runTable.addColumn(new AssayQCFlagColumn(runTable, getSchemaName(), false)); - ColumnInfo qcEnabled = runTable.addColumn(new ExprColumn(runTable, "QCFlagsEnabled", AssayQCFlagColumn.createSQLFragment(runTable.getSqlDialect(), "Enabled"), JdbcType.VARCHAR)); + var qcEnabled = runTable.addColumn(new ExprColumn(runTable, "QCFlagsEnabled", AssayQCFlagColumn.createSQLFragment(runTable.getSqlDialect(), "Enabled"), JdbcType.VARCHAR)); qcEnabled.setLabel("QC Flags Enabled State"); qcEnabled.setHidden(true); } @@ -175,49 +176,49 @@ protected RunListQueryView createRunsQueryView(ViewContext context, QuerySetting } @Override - protected TableInfo createProviderTable(String tableType) + protected TableInfo createProviderTable(String tableType, ContainerFilter cf) { if(tableType != null) { if (DilutionManager.CUTOFF_VALUE_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createCutoffValueTable(); + return createCutoffValueTable(cf); } if (DilutionManager.NAB_SPECIMEN_TABLE_NAME.equalsIgnoreCase(tableType)) { - return createNAbSpecimenTable(); + return createNAbSpecimenTable(cf); } if (DilutionManager.WELL_DATA_TABLE_NAME.equalsIgnoreCase(tableType)) { - NabWellDataTable table = new NabWellDataTable(this, getProtocol()); + NabWellDataTable table = new NabWellDataTable(this, cf, getProtocol()); return table; } if (DilutionManager.DILUTION_DATA_TABLE_NAME.equalsIgnoreCase(tableType)) { - return new NabDilutionDataTable(this, getProtocol()); + return new NabDilutionDataTable(this, cf, getProtocol()); } if (DilutionManager.VIRUS_TABLE_NAME.equalsIgnoreCase(tableType)) { Domain virusDomain = getVirusWellGroupDomain(); if (virusDomain != null) - return new NabVirusDataTable(this, virusDomain); + return new NabVirusDataTable(this, cf, virusDomain); } } - return super.createProviderTable(tableType); + return super.createProviderTable(tableType, cf); } - private NAbSpecimenTable createNAbSpecimenTable() + private NAbSpecimenTable createNAbSpecimenTable(ContainerFilter cf) { - return new NAbSpecimenTable(this); + return new NAbSpecimenTable(this, cf); } - private CutoffValueTable createCutoffValueTable() + private CutoffValueTable createCutoffValueTable(ContainerFilter cf) { - return new CutoffValueTable(this); + return new CutoffValueTable(this, cf); } public Set getTableNames() diff --git a/nab/src/org/labkey/nab/query/NabProviderSchema.java b/nab/src/org/labkey/nab/query/NabProviderSchema.java index 4c72e9f8c8..fcb4357686 100644 --- a/nab/src/org/labkey/nab/query/NabProviderSchema.java +++ b/nab/src/org/labkey/nab/query/NabProviderSchema.java @@ -21,6 +21,7 @@ import org.labkey.api.assay.dilution.SampleInfoMethod; import org.labkey.api.assay.dilution.query.DilutionProviderSchema; import org.labkey.api.data.Container; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.EnumTableInfo; import org.labkey.api.data.TableInfo; import org.labkey.api.data.statistics.StatsService; @@ -90,7 +91,7 @@ protected Set getTableNames(boolean visible) } @Override - public TableInfo createTable(String name) + public TableInfo createTable(String name, ContainerFilter cf) { if (SAMPLE_PREPARATION_METHOD_TABLE_NAME.equalsIgnoreCase(name)) { @@ -113,14 +114,14 @@ public TableInfo createTable(String name) String tableName = AssaySchema.getLegacyProtocolTableName(protocol, NabProtocolSchema.DATA_ROW_TABLE_NAME); if (tableName.equalsIgnoreCase(name)) { - return createDataRowTable(protocol); + return createDataRowTable(protocol, cf); } } - return super.createTable(name); + return super.createTable(name, cf); } - public NabRunDataTable createDataRowTable(ExpProtocol protocol) + public NabRunDataTable createDataRowTable(ExpProtocol protocol, ContainerFilter cf) { - return new NabRunDataTable(new NabProtocolSchema(getUser(), getContainer(), getProvider(), protocol, getTargetStudy()), protocol); + return new NabRunDataTable(new NabProtocolSchema(getUser(), getContainer(), getProvider(), protocol, getTargetStudy()), cf, protocol); } } diff --git a/nab/src/org/labkey/nab/query/NabRunCreator.java b/nab/src/org/labkey/nab/query/NabRunCreator.java index 6ce243f922..96ac02b6d9 100644 --- a/nab/src/org/labkey/nab/query/NabRunCreator.java +++ b/nab/src/org/labkey/nab/query/NabRunCreator.java @@ -1,18 +1,18 @@ -/* - * Copyright (c) 2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright (c) 2014 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.labkey.nab.query; import org.labkey.api.assay.dilution.DilutionManager; @@ -69,7 +69,7 @@ protected void resolveExtraRunData(ParticipantVisitResolver resolver, AssayRunUp { ExpData outputData = datas.iterator().next(); AssayProtocolSchema protocolSchema = context.getProvider().createProtocolSchema(context.getUser(), context.getContainer(), context.getProtocol(), null); - TableInfo virusTable = protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME); + TableInfo virusTable = protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME, null); if (virusTable instanceof FilteredTable) { diff --git a/nab/src/org/labkey/nab/query/NabRunDataTable.java b/nab/src/org/labkey/nab/query/NabRunDataTable.java index eb1a379db8..9b06c09bbb 100644 --- a/nab/src/org/labkey/nab/query/NabRunDataTable.java +++ b/nab/src/org/labkey/nab/query/NabRunDataTable.java @@ -21,7 +21,9 @@ import org.labkey.api.assay.dilution.query.DilutionProviderSchema; import org.labkey.api.assay.nab.query.CutoffValueTable; import org.labkey.api.assay.nab.query.NAbSpecimenTable; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; @@ -60,9 +62,9 @@ public class NabRunDataTable extends NabBaseTable { protected final NAbSpecimenTable _nabSpecimenTable; - public NabRunDataTable(final NabProtocolSchema schema, final ExpProtocol protocol) + public NabRunDataTable(final NabProtocolSchema schema, ContainerFilter cf, final ExpProtocol protocol) { - super(schema, new NAbSpecimenTable(schema), protocol); + super(schema, new NAbSpecimenTable(schema, cf), cf, protocol); _nabSpecimenTable = (NAbSpecimenTable) getRealTable(); final AssayProvider provider = AssayService.get().getProvider(protocol); @@ -78,7 +80,7 @@ public NabRunDataTable(final NabProtocolSchema schema, final ExpProtocol protoco addRunColumn(); ExprColumn runIdColumn = new ExprColumn(this, DilutionProviderSchema.RUN_ID_COLUMN_NAME, new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".RunID"), JdbcType.INTEGER); - ColumnInfo addedRunIdColumn = addColumn(runIdColumn); + var addedRunIdColumn = addColumn(runIdColumn); addedRunIdColumn.setHidden(true); Set hiddenProperties = new HashSet<>(); @@ -141,14 +143,14 @@ protected ColumnInfo resolveColumn(String name) { // Hook up a column that joins back to this table so that the columns formerly under the Properties // node when this was OntologyManager-backed can still be queried there - result = wrapColumn("Properties", getRealTable().getColumn("RowId")); - result.setIsUnselectable(true); - LookupForeignKey fk = new LookupForeignKey("RowId") + var wrapped = wrapColumn("Properties", getRealTable().getColumn("RowId")); + wrapped.setIsUnselectable(true); + LookupForeignKey fk = new LookupForeignKey(getContainerFilter(), "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return new NabRunDataTable(_schema, _protocol); + return new NabRunDataTable(_schema, getLookupContainerFilter(), _protocol); } @Override @@ -166,7 +168,8 @@ public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) } }; fk.setPrefixColumnCaption(false); - result.setFk(fk); + wrapped.setFk(fk); + result = wrapped; } else if ("Fit Error".equalsIgnoreCase(name)) { @@ -218,37 +221,37 @@ protected void addPropertyColumns(final NabProtocolSchema schema, final ExpProto // get all the properties from this plated-based protocol: Collection pds = getExistingDataProperties(protocol); - ColumnInfo objectUriColumn = addWrapColumn(_rootTable.getColumn("ObjectUri")); + var objectUriColumn = addWrapColumn(_rootTable.getColumn("ObjectUri")); objectUriColumn.setIsUnselectable(true); objectUriColumn.setHidden(true); - ColumnInfo rowIdColumn = addWrapColumn(_rootTable.getColumn("RowId")); + var rowIdColumn = addWrapColumn(_rootTable.getColumn("RowId")); rowIdColumn.setKeyField(true); rowIdColumn.setHidden(true); rowIdColumn.setIsUnselectable(true); // add object ID again, this time as a lookup to a virtual property table that contains our selected NAB properties: - QcAwarePropertyForeignKey fk = new QcAwarePropertyForeignKey(pds, this, schema) // Needed by NewNab only to get defaultHiddenProperties + // TODO ContainerFilter -- add ContainerFilter to QcAwarePropertyForeignKey + QcAwarePropertyForeignKey fk = new QcAwarePropertyForeignKey(schema, this, pds) // Needed by NewNab only to get defaultHiddenProperties { @Override - protected ColumnInfo constructColumnInfo(ColumnInfo parent, FieldKey name, PropertyDescriptor pd) + protected BaseColumnInfo constructColumnInfo(ColumnInfo parent, FieldKey name, PropertyDescriptor pd) { - ColumnInfo result = super.constructColumnInfo(parent, name, pd); + var result = super.constructColumnInfo(parent, name, pd); if (getInputMaterialPropertyName().equals(pd.getName())) { result.setLabel("Specimen"); - result.setFk(new LookupForeignKey("LSID") + result.setFk(new LookupForeignKey(NabRunDataTable.this.getContainerFilter(), "LSID", null) { public TableInfo getLookupTableInfo() { - ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema); + ExpMaterialTable materials = ExperimentService.get().createMaterialTable(ExpSchema.TableType.Materials.toString(), schema, getLookupContainerFilter()); // Make sure we are filtering to the same set of containers - materials.setContainerFilter(getContainerFilter()); if (sampleSet != null) { materials.setSampleSet(sampleSet, true); } - ColumnInfo propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); + var propertyCol = materials.addColumn(ExpMaterialTable.Column.Property); if (propertyCol.getFk() instanceof PropertyForeignKey) { ((PropertyForeignKey)propertyCol.getFk()).addDecorator(new SpecimenPropertyColumnDecorator(provider, protocol, schema)); @@ -275,18 +278,18 @@ public TableInfo getLookupTableInfo() for (Double value : cutoffValuess) { final Integer intCutoff = (int)Math.floor(value); - final CutoffValueTable cutoffValueTable = new CutoffValueTable(schema); + final CutoffValueTable cutoffValueTable = new CutoffValueTable(schema, getContainerFilter()); cutoffValueTable.removeContainerAndProtocolFilters(); cutoffValueTable.addCondition(new SimpleFilter(FieldKey.fromString("Cutoff"), intCutoff)); - ColumnInfo nabSpecimenColumn = cutoffValueTable.getColumn("NabSpecimenId"); + var nabSpecimenColumn = cutoffValueTable.getMutableColumn("NabSpecimenId"); nabSpecimenColumn.setIsUnselectable(true); nabSpecimenColumn.setHidden(true); // Update column labels like IC_4pl to Curve ICxx 4pl - for (ColumnInfo column : cutoffValueTable.getColumns()) + for (var column : cutoffValueTable.getMutableColumns()) updateLabelWithCutoff(column, intCutoff); - ColumnInfo cutoffColumn = wrapColumn("Cutoff" + intCutoff, _rootTable.getColumn("RowId")); + var cutoffColumn = wrapColumn("Cutoff" + intCutoff, _rootTable.getColumn("RowId")); cutoffColumn.setLabel("Cutoff " + intCutoff); cutoffColumn.setKeyField(false); cutoffColumn.setIsUnselectable(true); @@ -317,7 +320,7 @@ public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) } else if (columnName.equals("wellgroupname")) { - ColumnInfo wellgroupColumn = wrapColumn(columnInfo); + var wellgroupColumn = wrapColumn(columnInfo); wellgroupColumn.setLabel("Wellgroup Name"); addColumn(wellgroupColumn); } @@ -354,17 +357,17 @@ else if (columnName.equals("wellgroupname")) Domain domain = ((NabAssayProvider)provider).getVirusWellGroupDomain(protocol); if (null != domain) { - ColumnInfo virusColumn = wrapColumn(_rootTable.getColumn("VirusLsid")); + var virusColumn = wrapColumn(_rootTable.getColumn("VirusLsid")); virusColumn.setLabel("Virus"); virusColumn.setIsUnselectable(true); virusColumn.setKeyField(false); - LookupForeignKey fkVirus = new LookupForeignKey("VirusLsid") + LookupForeignKey fkVirus = new LookupForeignKey(getContainerFilter(), "VirusLsid", null) { @Override public TableInfo getLookupTableInfo() { AssayProtocolSchema protocolSchema = provider.createProtocolSchema(schema.getUser(), getContainer(), protocol, null); - return protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME); + return protocolSchema.createTable(DilutionManager.VIRUS_TABLE_NAME, getContainerFilter()); } }; virusColumn.setFk(fkVirus); @@ -375,7 +378,7 @@ public TableInfo getLookupTableInfo() } } - private static void updateLabelWithCutoff(ColumnInfo column, Integer intCutoff) + private static void updateLabelWithCutoff(BaseColumnInfo column, Integer intCutoff) { if (null != intCutoff) { diff --git a/nab/src/org/labkey/nab/query/NabVirusDataTable.java b/nab/src/org/labkey/nab/query/NabVirusDataTable.java index 64e2ca3847..1c9795a508 100644 --- a/nab/src/org/labkey/nab/query/NabVirusDataTable.java +++ b/nab/src/org/labkey/nab/query/NabVirusDataTable.java @@ -19,7 +19,9 @@ import org.labkey.api.assay.dilution.DilutionManager; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.collections.CaseInsensitiveHashSet; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerForeignKey; import org.labkey.api.data.Parameter; import org.labkey.api.data.StatementUtils; @@ -65,9 +67,9 @@ public class NabVirusDataTable extends FilteredTable implem protected final AssayProvider _provider; private Domain _virusDomain = null; - public NabVirusDataTable(AssayProtocolSchema schema, Domain virusDomain) + public NabVirusDataTable(AssayProtocolSchema schema, ContainerFilter cf, Domain virusDomain) { - super(StorageProvisioner.createTableInfo(virusDomain), schema); + super(StorageProvisioner.createTableInfo(virusDomain), schema, cf); _protocol = _userSchema.getProtocol(); _provider = _userSchema.getProvider(); @@ -80,9 +82,7 @@ public NabVirusDataTable(AssayProtocolSchema schema, Domain virusDomain) List visibleColumns = new ArrayList<>(); for (ColumnInfo baseColumn : getRealTable().getColumns()) { - ColumnInfo col; - - col = wrapColumn(baseColumn); + var col = wrapColumn(baseColumn); if (NabVirusDomainKind.VIRUS_LSID_COLUMN_NAME.equalsIgnoreCase(col.getName())) { @@ -110,7 +110,7 @@ else if ("Container".equalsIgnoreCase(col.getName())) if (col.getMvColumnName() != null) { - ColumnInfo rawValueCol = createRawValueColumn(baseColumn, col, RawValueColumn.RAW_VALUE_SUFFIX, "Raw Value", "This column contains the raw value itself, regardless of any missing value indicators that may have been set."); + var rawValueCol = createRawValueColumn(baseColumn, col, RawValueColumn.RAW_VALUE_SUFFIX, "Raw Value", "This column contains the raw value itself, regardless of any missing value indicators that may have been set."); addColumn(rawValueCol); } @@ -118,7 +118,7 @@ else if ("Container".equalsIgnoreCase(col.getName())) visibleColumns.add(col.getFieldKey()); } - getColumn(NabAssayProvider.VIRUS_LSID_COLUMN_NAME).setShownInUpdateView(false); + getMutableColumn(NabAssayProvider.VIRUS_LSID_COLUMN_NAME).setShownInUpdateView(false); setDefaultVisibleColumns(visibleColumns); } @@ -128,10 +128,10 @@ public Domain getDomain() return _virusDomain; } - private ColumnInfo createRawValueColumn(ColumnInfo baseColumn, ColumnInfo col, String nameSuffix, String labelSuffix, String descriptionSuffix) + private BaseColumnInfo createRawValueColumn(ColumnInfo baseColumn, ColumnInfo col, String nameSuffix, String labelSuffix, String descriptionSuffix) { - ColumnInfo rawValueCol = new AliasedColumn(baseColumn.getName() + nameSuffix, col); - rawValueCol.setDisplayColumnFactory(ColumnInfo.DEFAULT_FACTORY); + var rawValueCol = new AliasedColumn(baseColumn.getName() + nameSuffix, col); + rawValueCol.setDisplayColumnFactory(BaseColumnInfo.DEFAULT_FACTORY); rawValueCol.setLabel(baseColumn.getLabel() + " " + labelSuffix); String description = baseColumn.getDescription(); if (description == null) diff --git a/nab/src/org/labkey/nab/query/NabWellDataTable.java b/nab/src/org/labkey/nab/query/NabWellDataTable.java index c68c0e42e8..55470933e5 100644 --- a/nab/src/org/labkey/nab/query/NabWellDataTable.java +++ b/nab/src/org/labkey/nab/query/NabWellDataTable.java @@ -18,7 +18,9 @@ import org.labkey.api.assay.dilution.DilutionManager; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.data.AbstractForeignKey; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; +import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.JdbcType; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableInfo; @@ -47,9 +49,10 @@ public class NabWellDataTable extends NabBaseTable public static final String VIRUS_WELLGROUP_NAME = "VirusWellgroup"; public static final String SPECIMEN_WELLGROUP_NAME = "SpecimenWellgroup"; public static final String REPLICATE_WELLGROUP_NAME = "ReplicateWellgroup"; - public NabWellDataTable(final NabProtocolSchema schema, ExpProtocol protocol) + + public NabWellDataTable(final NabProtocolSchema schema, ContainerFilter cf, ExpProtocol protocol) { - super(schema, DilutionManager.getTableInfoWellData(), protocol); + super(schema, DilutionManager.getTableInfoWellData(), cf, protocol); addRunColumn(); addSpecimenColumn(); @@ -66,7 +69,7 @@ public NabWellDataTable(final NabProtocolSchema schema, ExpProtocol protocol) else if ("RunDataId".equalsIgnoreCase(name)) name = "RunData"; - ColumnInfo newCol; + BaseColumnInfo newCol; if ("Row".equalsIgnoreCase(name) || "Column".equalsIgnoreCase(name)) newCol = addOneBasedColumn(name, col); else @@ -91,7 +94,7 @@ else if ("RunDataId".equalsIgnoreCase(name)) addCondition(getRealTable().getColumn("ProtocolId"), protocol.getRowId()); } - private ColumnInfo addOneBasedColumn(String name, ColumnInfo column) + private BaseColumnInfo addOneBasedColumn(String name, ColumnInfo column) { if (!JdbcType.INTEGER.equals(column.getJdbcType())) throw new IllegalStateException("Can only add 1 to value of integer type."); @@ -155,10 +158,10 @@ private void addWellgroupPropertyColumns(Map wellgrou } } - final ColumnInfo wellgroupNameColumn = getColumn(wellgroupNameColumnName); + final var wellgroupNameColumn = getMutableColumn(wellgroupNameColumnName); final TableInfo parentTable = this; - wellgroupNameColumn.setFk(new AbstractForeignKey() + wellgroupNameColumn.setFk(new AbstractForeignKey(getUserSchema(), getContainerFilter()) { // This is a little interesting. The virtual table has an ExprColumn for each property, but since the properties // are all from the plate template, their values are fixed, from the point of view of this protocol @@ -183,7 +186,7 @@ public ColumnInfo createLookupColumn(ColumnInfo parent, String displayField) @Override public TableInfo getLookupTableInfo() { - VirtualTable ret = new VirtualTable(ExperimentService.get().getSchema(), null); + VirtualTable ret = new VirtualTable(ExperimentService.get().getSchema(), null, getUserSchema()); for (Map.Entry> propertyEntry : propertyMap.entrySet()) { SQLFragment sql = new SQLFragment("(CASE "); diff --git a/viability/src/org/labkey/viability/ViabilityAssaySchema.java b/viability/src/org/labkey/viability/ViabilityAssaySchema.java index 9287ff550f..6478253d86 100644 --- a/viability/src/org/labkey/viability/ViabilityAssaySchema.java +++ b/viability/src/org/labkey/viability/ViabilityAssaySchema.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.labkey.api.data.BaseColumnInfo; import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; @@ -105,37 +106,39 @@ public Set getTableNames() return result; } - public TableInfo createProviderTable(String name) + @Override + public TableInfo createProviderTable(String name, ContainerFilter cf) { if (name.equalsIgnoreCase(UserTables.ResultSpecimens.name())) - return createResultSpecimensTable(); + return createResultSpecimensTable(cf); - return super.createProviderTable(name); + return super.createProviderTable(name, cf); } @Override - public FilteredTable createDataTable(boolean includeCopiedToStudyColumns) + public FilteredTable createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { // UNDONE: add copy to study columns when copy to study is implemented //addCopiedToStudyColumns(table, protocol, schema.getUser(), "rowId", true); - return new ResultsTable(); + return new ResultsTable(cf); } - public ResultSpecimensTable createResultSpecimensTable() + public ResultSpecimensTable createResultSpecimensTable(ContainerFilter cf) { - return new ResultSpecimensTable(); + return new ResultSpecimensTable(cf); } public ExpDataTable createDataFileTable() { - ExpDataTable ret = ExperimentService.get().createDataTable(ExpSchema.TableType.Data.toString(), this); + // TODO ContainerFilter + ExpDataTable ret = ExperimentService.get().createDataTable(ExpSchema.TableType.Data.toString(), this, null); ret.addColumn(ExpDataTable.Column.RowId); ret.addColumn(ExpDataTable.Column.Name); ret.addColumn(ExpDataTable.Column.Flag); ret.addColumn(ExpDataTable.Column.Created); ret.addColumn(ExpDataTable.Column.SourceProtocolApplication).setHidden(true); ret.setTitleColumn("Name"); - ColumnInfo protocol = ret.addColumn(ExpDataTable.Column.Protocol); + var protocol = ret.addColumn(ExpDataTable.Column.Protocol); protocol.setHidden(true); ret.setPublicSchemaName(ExpSchema.SCHEMA_NAME); return ret; @@ -145,17 +148,17 @@ class ViabilityAssayTable extends FilteredTable { ViabilityAssayProvider _provider; - protected ViabilityAssayTable(TableInfo table) + protected ViabilityAssayTable(TableInfo table, ContainerFilter cf) { - super(table, ViabilityAssaySchema.this); + super(table, ViabilityAssaySchema.this, cf); _provider = ViabilityManager.get().getProvider(); _defaultVisibleColumns = new ArrayList<>(); setPublicSchemaName(ViabilityAssaySchema.this.getSchemaName()); } - protected ColumnInfo addVisible(ColumnInfo col) + protected BaseColumnInfo addVisible(BaseColumnInfo col) { - ColumnInfo ret = addColumn(col); + var ret = addColumn(col); addDefaultVisible(col.getName()); return ret; } @@ -182,7 +185,7 @@ public SQLFragment getFromSQL(String alias) } } - protected static ColumnInfo copyProperties(ColumnInfo column, DomainProperty dp) + protected static BaseColumnInfo copyProperties(BaseColumnInfo column, DomainProperty dp) { if (dp != null) { @@ -201,9 +204,9 @@ public class ResultsTable extends ViabilityAssayTable { protected Domain _resultsDomain; - public ResultsTable() + public ResultsTable(ContainerFilter cf) { - super(ViabilitySchema.getTableInfoResults()); + super(ViabilitySchema.getTableInfoResults(), cf); setName(AssayProtocolSchema.DATA_TABLE_NAME); _resultsDomain = _provider.getResultsDomain(getProtocol()); @@ -212,11 +215,11 @@ public ResultsTable() for (DomainProperty property : resultDomainProperties) propertyMap.put(property.getName(), property); - ColumnInfo rowId = addColumn(wrapColumn(getRealTable().getColumn("RowId"))); + var rowId = addColumn(wrapColumn(getRealTable().getColumn("RowId"))); rowId.setHidden(true); rowId.setKeyField(true); - ColumnInfo dataColumn = addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))); + var dataColumn = addColumn(wrapColumn("Data", getRealTable().getColumn("DataId"))); dataColumn.setHidden(true); dataColumn.setFk(new LookupForeignKey("RowId") { @@ -229,10 +232,10 @@ public TableInfo getLookupTableInfo() }); boolean addedTargetStudy = false; - ColumnInfo objectIdCol = wrapColumn(_rootTable.getColumn("ObjectId")); + var objectIdCol = wrapColumn(_rootTable.getColumn("ObjectId")); for (DomainProperty dp : resultDomainProperties) { - ColumnInfo col; + BaseColumnInfo col; // UNDONE: OOR columns? @@ -289,32 +292,33 @@ else if (ViabilityAssayProvider.ORIGINAL_CELLS_PROPERTY_NAME.equals(dp.getName() } } - ColumnInfo runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); + var runColumn = addColumn(wrapColumn("Run", getRealTable().getColumn("RunId"))); runColumn.setHidden(true); - runColumn.setFk(new LookupForeignKey("RowId") + runColumn.setFk(new LookupForeignKey(cf, "RowId", null) { public TableInfo getLookupTableInfo() { - ExpRunTable expRunTable = AssayService.get().createRunTable(getProtocol(), _provider, ViabilityAssaySchema.this.getUser(), ViabilityAssaySchema.this.getContainer()); + ExpRunTable expRunTable = AssayService.get().createRunTable(getProtocol(), _provider, + ViabilityAssaySchema.this.getUser(), ViabilityAssaySchema.this.getContainer(), getLookupContainerFilter()); expRunTable.setContainerFilter(getContainerFilter()); return expRunTable; } }); - ColumnInfo specimenCount = addVisible(wrapColumn("SpecimenCount", getRealTable().getColumn("SpecimenCount"))); + var specimenCount = addVisible(wrapColumn("SpecimenCount", getRealTable().getColumn("SpecimenCount"))); - ColumnInfo specimenMatchCount = wrapColumn("SpecimenMatchCount", getRealTable().getColumn("SpecimenMatchCount")); + var specimenMatchCount = wrapColumn("SpecimenMatchCount", getRealTable().getColumn("SpecimenMatchCount")); specimenMatchCount.setHidden(true); addColumn(specimenMatchCount); - ColumnInfo specimenMatches = wrapColumn("SpecimenMatches", getRealTable().getColumn("SpecimenMatches")); + var specimenMatches = wrapColumn("SpecimenMatches", getRealTable().getColumn("SpecimenMatches")); specimenMatches.setHidden(true); addColumn(specimenMatches); if (!addedTargetStudy) { - ColumnInfo targetStudy = createTargetStudyCol(); + var targetStudy = createTargetStudyCol(); addColumn(targetStudy); } @@ -332,32 +336,33 @@ public Domain getDomain() @Override protected ColumnInfo resolveColumn(String name) { - ColumnInfo result = super.resolveColumn(name); + var result = super.resolveColumn(name); if ("Properties".equalsIgnoreCase(name)) { // Hook up a column that joins back to this table so that the columns formerly under the Properties // node can still be queried there. - result = wrapColumn("Properties", getRealTable().getColumn("RowId")); - result.setIsUnselectable(true); - LookupForeignKey fk = new LookupForeignKey("RowId") + var wrapped = wrapColumn("Properties", getRealTable().getColumn("RowId")); + wrapped.setIsUnselectable(true); + LookupForeignKey fk = new LookupForeignKey(getContainerFilter(), "RowId", null) { @Override public TableInfo getLookupTableInfo() { - return new ResultsTable(); + return new ResultsTable(getLookupContainerFilter()); } }; fk.setPrefixColumnCaption(false); - result.setFk(fk); + wrapped.setFk(fk); + result = wrapped; } return result; } - private ColumnInfo createTargetStudyCol() + private BaseColumnInfo createTargetStudyCol() { - ColumnInfo col = wrapColumn(AbstractAssayProvider.TARGET_STUDY_PROPERTY_NAME, getRealTable().getColumn("TargetStudy")); + var col = wrapColumn(AbstractAssayProvider.TARGET_STUDY_PROPERTY_NAME, getRealTable().getColumn("TargetStudy")); fixupRenderers(col, col); col.setUserEditable(false); col.setReadOnly(true); @@ -383,8 +388,8 @@ public SpecimenAggregateColumn(TableInfo parent, String name, JdbcType type, Col @Override public void declareJoins(String parentAlias, Map map) { - ResultSpecimensTable rs = new ResultSpecimensTable(); - // 9024: propogate container filter + ResultSpecimensTable rs = new ResultSpecimensTable(getContainerFilter()); + // 9024: propagate container filter rs.setContainerFilter(getContainerFilter()); List fields = new ArrayList<>(); FieldKey resultId = FieldKey.fromParts("ResultID"); @@ -494,24 +499,23 @@ public void addQueryFieldKeys(Set keys) public class ResultSpecimensTable extends ViabilityAssayTable { - public ResultSpecimensTable() + public ResultSpecimensTable(ContainerFilter cf) { - super(ViabilitySchema.getTableInfoResultSpecimens()); + super(ViabilitySchema.getTableInfoResultSpecimens(), cf); - ColumnInfo resultIDCol = addVisible(wrapColumn(getRealTable().getColumn("ResultID"))); + var resultIDCol = addVisible(wrapColumn(getRealTable().getColumn("ResultID"))); resultIDCol.setLabel("Result"); resultIDCol.setKeyField(true); - resultIDCol.setFk(new LookupForeignKey("RowID") + resultIDCol.setFk(new LookupForeignKey(cf, "RowID", null) { public TableInfo getLookupTableInfo() { - ResultsTable results = new ResultsTable(); - results.setContainerFilter(new DelegatingContainerFilter(ResultSpecimensTable.this)); + ResultsTable results = new ResultsTable(getLookupContainerFilter()); return results; } }); - ColumnInfo specimenID = addVisible(wrapColumn(getRealTable().getColumn("SpecimenID"))); + var specimenID = addVisible(wrapColumn(getRealTable().getColumn("SpecimenID"))); specimenID.setLabel("Specimen"); specimenID.setKeyField(true); AssayTableMetadata metadata = new ViabilityAssayProvider.ResultsSpecimensAssayTableMetadata(_provider, getProtocol()); @@ -521,7 +525,7 @@ public TableInfo getLookupTableInfo() fk.addSpecimenFilter(filter); specimenID.setFk(fk); - ColumnInfo indexCol = addVisible(wrapColumn(getRealTable().getColumn("SpecimenIndex"))); + var indexCol = addVisible(wrapColumn(getRealTable().getColumn("SpecimenIndex"))); indexCol.setKeyField(true); } diff --git a/viability/src/org/labkey/viability/ViabilityAssayUploadWizardAction.java b/viability/src/org/labkey/viability/ViabilityAssayUploadWizardAction.java index 28fcc84bc6..c36362876c 100644 --- a/viability/src/org/labkey/viability/ViabilityAssayUploadWizardAction.java +++ b/viability/src/org/labkey/viability/ViabilityAssayUploadWizardAction.java @@ -20,7 +20,6 @@ import org.labkey.api.action.SpringActionController; import org.labkey.api.data.ActionButton; import org.labkey.api.data.ButtonBar; -import org.labkey.api.data.ColumnInfo; import org.labkey.api.data.DataRegion; import org.labkey.api.data.DbScope; import org.labkey.api.data.DisplayColumn; @@ -227,7 +226,7 @@ protected InsertView _getResultsView(ViabilityAssayRunUploadForm form, boolean e if (initialValue != null) view.setInitialValue(inputName, initialValue); - ColumnInfo col = resultDomainProperty.getPropertyDescriptor().createColumnInfo(view.getDataRegion().getTable(), lsidCol, form.getUser(), form.getContainer()); + var col = resultDomainProperty.getPropertyDescriptor().createColumnInfo(view.getDataRegion().getTable(), lsidCol, form.getUser(), form.getContainer()); col.setUserEditable(editable); col.setName(inputName); diff --git a/viability/src/org/labkey/viability/ViabilityManager.java b/viability/src/org/labkey/viability/ViabilityManager.java index 11617834c7..79c2ec124d 100644 --- a/viability/src/org/labkey/viability/ViabilityManager.java +++ b/viability/src/org/labkey/viability/ViabilityManager.java @@ -381,8 +381,7 @@ public Long handle(ResultSet rs, Connection conn) throws SQLException @Nullable private static SQLFragment specimenAggregates(ViabilityAssaySchema schema, ExpRun run) { - ViabilityAssaySchema.ResultSpecimensTable rs = schema.createResultSpecimensTable(); - rs.setContainerFilter(ContainerFilter.EVERYTHING); + ViabilityAssaySchema.ResultSpecimensTable rs = schema.createResultSpecimensTable(ContainerFilter.EVERYTHING); List fields = new ArrayList<>(); FieldKey resultId = FieldKey.fromParts("ResultID");