@@ -138,11 +138,11 @@ else if (TABLE_LOOKUPS.equalsIgnoreCase(name))
138138 }
139139 else if (TABLE_STUDIES .equalsIgnoreCase (name ))
140140 {
141- return createStudiesTable (name , cf , false );
141+ return createStudiesTable (name , cf );
142142 }
143143 else if (TABLE_COHORTS .equalsIgnoreCase (name ))
144144 {
145- return createStudyDesignTable (name , cf , true );
145+ return createCohortsTable (name , cf );
146146 }
147147 else if (TABLE_ANCHOR_EVENTS .equalsIgnoreCase (name ))
148148 {
@@ -169,18 +169,41 @@ else if (TABLE_EVENT_TYPES.equalsIgnoreCase(name))
169169 return super .createTable (name , cf );
170170 }
171171
172- private TableInfo createStudiesTable (String name , ContainerFilter cf , boolean addTriggers )
172+ private TableInfo createCohortsTable (String name , ContainerFilter cf )
173+ {
174+ CustomPermissionsTable <?> ret = createStudyDesignTable (name , cf , true );
175+
176+ SQLFragment sql2 = new SQLFragment ("coalesce(" + ExprColumn .STR_TABLE_ALIAS + ".label, " + ExprColumn .STR_TABLE_ALIAS + ".cohortName)" );
177+ ExprColumn col2 = new ExprColumn (ret , "labelOrName" , sql2 , JdbcType .VARCHAR , ret .getColumn ("cohortName" ), ret .getColumn ("label" ));
178+ col2 .setLabel ("Cohort Name" );
179+ col2 .setHidden (true );
180+ col2 .setDescription ("This column lists the cohort label, and the name if label is blank" );
181+
182+ ret .addColumn (col2 );
183+
184+ return ret ;
185+ }
186+
187+ private TableInfo createStudiesTable (String name , ContainerFilter cf )
173188 {
174- CustomPermissionsTable <?> ret = createStudyDesignTable (name , cf , addTriggers );
189+ CustomPermissionsTable <?> ret = createStudyDesignTable (name , cf , false );
175190
176191 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)" );
192+ SQLFragment sql1 = new SQLFragment ("(SELECT " ).append (ret .getSqlDialect ().getGroupConcat (new SQLFragment ("coalesce( c.label, c.cohortName) " ), true , true , new SQLFragment (chr + "(10)" ))).append (" as expr FROM " + StudiesSchema .NAME + "." + TABLE_COHORTS + " c WHERE c.studyId = " + ExprColumn .STR_TABLE_ALIAS + ".rowId)" );
178193 ExprColumn col1 = new ExprColumn (ret , "cohorts" , sql1 , JdbcType .VARCHAR , ret .getColumn ("rowid" ));
179194 col1 .setLabel ("Cohort(s)" );
180195 col1 .setDescription ("This column lists the cohort labels for this study" );
181196
182197 ret .addColumn (col1 );
183198
199+ SQLFragment sql2 = new SQLFragment ("coalesce(" + ExprColumn .STR_TABLE_ALIAS + ".label, " + ExprColumn .STR_TABLE_ALIAS + ".studyName)" );
200+ ExprColumn col2 = new ExprColumn (ret , "labelOrName" , sql2 , JdbcType .VARCHAR , ret .getColumn ("studyName" ), ret .getColumn ("label" ));
201+ col2 .setLabel ("Study Name" );
202+ col2 .setHidden (true );
203+ col2 .setDescription ("This column lists the study label, and the name if label is blank" );
204+
205+ ret .addColumn (col2 );
206+
184207 return ret ;
185208 }
186209
0 commit comments