|
1 | 1 | package org.labkey.studies.query; |
2 | 2 |
|
| 3 | +import com.google.gwt.user.client.ui.TabBar; |
3 | 4 | import org.apache.logging.log4j.Logger; |
4 | 5 | import org.labkey.api.collections.CaseInsensitiveHashMap; |
5 | 6 | import org.labkey.api.collections.CaseInsensitiveTreeSet; |
6 | 7 | import org.labkey.api.data.AbstractTableInfo; |
7 | 8 | import org.labkey.api.data.Container; |
8 | 9 | import org.labkey.api.data.ContainerFilter; |
9 | 10 | import org.labkey.api.data.DbSchema; |
| 11 | +import org.labkey.api.data.JdbcType; |
| 12 | +import org.labkey.api.data.SQLFragment; |
10 | 13 | import org.labkey.api.data.SchemaTableInfo; |
11 | 14 | import org.labkey.api.data.SimpleFilter; |
12 | 15 | import org.labkey.api.data.TableInfo; |
13 | 16 | import org.labkey.api.data.TableSelector; |
14 | 17 | import org.labkey.api.ldk.table.ContainerScopedTable; |
15 | 18 | import org.labkey.api.ldk.table.CustomPermissionsTable; |
| 19 | +import org.labkey.api.query.ExprColumn; |
16 | 20 | import org.labkey.api.query.FieldKey; |
17 | 21 | import org.labkey.api.query.QueryDefinition; |
18 | 22 | import org.labkey.api.query.QueryException; |
@@ -134,7 +138,7 @@ else if (TABLE_LOOKUPS.equalsIgnoreCase(name)) |
134 | 138 | } |
135 | 139 | else if (TABLE_STUDIES.equalsIgnoreCase(name)) |
136 | 140 | { |
137 | | - return createStudyDesignTable(name, cf, false); |
| 141 | + return createStudiesTable(name, cf, false); |
138 | 142 | } |
139 | 143 | else if (TABLE_COHORTS.equalsIgnoreCase(name)) |
140 | 144 | { |
@@ -165,7 +169,22 @@ else if (TABLE_EVENT_TYPES.equalsIgnoreCase(name)) |
165 | 169 | return super.createTable(name, cf); |
166 | 170 | } |
167 | 171 |
|
168 | | - private TableInfo createStudyDesignTable(String name, ContainerFilter cf, boolean addTriggers) |
| 172 | + private TableInfo createStudiesTable(String name, ContainerFilter cf, boolean addTriggers) |
| 173 | + { |
| 174 | + CustomPermissionsTable<?> ret = createStudyDesignTable(name, cf, addTriggers); |
| 175 | + |
| 176 | + final String chr = ret.getSqlDialect().isPostgreSQL() ? "chr" : "char"; |
| 177 | + SQLFragment sql1 = new SQLFragment("(SELECT ").append(ret.getSqlDialect().getGroupConcat(new SQLFragment("c.label"), true, true, new SQLFragment(chr + "(10)"))).append(" as expr FROM " + StudiesSchema.NAME + "." + TABLE_COHORTS + " c WHERE c.studyId = " + ExprColumn.STR_TABLE_ALIAS + ".rowId)"); |
| 178 | + ExprColumn col1 = new ExprColumn(ret, "cohorts", sql1, JdbcType.VARCHAR, ret.getColumn("rowid")); |
| 179 | + col1.setLabel("Cohort(s)"); |
| 180 | + col1.setDescription("This column lists the cohort labels for this study"); |
| 181 | + |
| 182 | + ret.addColumn(col1); |
| 183 | + |
| 184 | + return ret; |
| 185 | + } |
| 186 | + |
| 187 | + private CustomPermissionsTable<?> createStudyDesignTable(String name, ContainerFilter cf, boolean addTriggers) |
169 | 188 | { |
170 | 189 | CustomPermissionsTable<SimpleUserSchema> ret = new CustomPermissionsTable<>(this, createSourceTable(name), cf); |
171 | 190 | ret.addPermissionMapping(InsertPermission.class, StudiesDataAdminPermission.class); |
|
0 commit comments