|
7 | 7 | import org.labkey.api.data.Container; |
8 | 8 | import org.labkey.api.data.ContainerFilter; |
9 | 9 | import org.labkey.api.data.DbSchema; |
| 10 | +import org.labkey.api.data.JdbcType; |
| 11 | +import org.labkey.api.data.SQLFragment; |
10 | 12 | import org.labkey.api.data.SchemaTableInfo; |
11 | 13 | import org.labkey.api.data.SimpleFilter; |
12 | 14 | import org.labkey.api.data.TableInfo; |
13 | 15 | import org.labkey.api.data.TableSelector; |
14 | 16 | import org.labkey.api.ldk.table.ContainerScopedTable; |
15 | 17 | import org.labkey.api.ldk.table.CustomPermissionsTable; |
| 18 | +import org.labkey.api.query.ExprColumn; |
16 | 19 | import org.labkey.api.query.FieldKey; |
17 | 20 | import org.labkey.api.query.QueryDefinition; |
18 | 21 | import org.labkey.api.query.QueryException; |
@@ -177,7 +180,16 @@ private TableInfo createStudyDesignTable(String name, ContainerFilter cf, boolea |
177 | 180 | ret.addTriggerFactory(new StudiesTriggerFactory()); |
178 | 181 | } |
179 | 182 |
|
180 | | - return ret.init(); |
| 183 | + ret = ret.init(); |
| 184 | + |
| 185 | + final String chr = ret.getSqlDialect().isPostgreSQL() ? "chr" : "char"; |
| 186 | + 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)"); |
| 187 | + ExprColumn col1 = new ExprColumn(ret, "cohorts", sql1, JdbcType.VARCHAR, ret.getColumn("rowid")); |
| 188 | + col1.setLabel("Cohort(s)"); |
| 189 | + col1.setDescription("This column lists the cohort labels for this study"); |
| 190 | + ret.addColumn(col1); |
| 191 | + |
| 192 | + return ret; |
181 | 193 | } |
182 | 194 |
|
183 | 195 | private LookupSetTable createForPropertySet(StudiesUserSchema us, ContainerFilter cf, String setName, Map<String, Object> map) |
|
0 commit comments