3636import org .labkey .api .query .FieldKey ;
3737import org .labkey .api .query .FilteredTable ;
3838import org .labkey .api .query .QueryForeignKey ;
39- import org .labkey .api .query .QueryService ;
4039import org .labkey .api .query .SimpleUserSchema ;
41- import org .labkey .api .query .UserSchema ;
4240import org .labkey .api .security .Group ;
4341import org .labkey .api .security .MemberType ;
4442import org .labkey .api .security .RoleAssignment ;
6866public class EHRLookupsUserSchema extends SimpleUserSchema
6967{
7068 public static final String TABLE_AREAS = "areas" ;
71- public static final String TABLE_BUILDINGS = "buildings" ;
7269 public static final String TABLE_CAGE = "cage" ;
7370 public static final String TABLE_CAGE_POSITIONS = "cage_positions" ;
7471 public static final String TABLE_CAGE_TYPE = "cage_type" ;
75- public static final String TABLE_GEOGRAPHIC_ORIGINS = "geographic_origins" ;
7672 public static final String TABLE_ROOMS = "rooms" ;
7773 public static final String TABLE_SNOMED = "snomed" ;
7874 public static final String TABLE_SNOMED_SUBSET_CODES = "snomed_subset_codes" ;
79- public static final String TABLE_TREATMENT_CODES = "treatment_codes" ;
8075 public static final String TABLE_VETERINARIANS = "veterinarians" ;
8176
8277 public EHRLookupsUserSchema (User user , Container container , DbSchema dbschema )
@@ -218,7 +213,7 @@ else if (EHRSchema.TABLE_LOOKUP_SETS.equalsIgnoreCase(name))
218213 // By default, any hard tables in the ehr_lookups schema not accounted for above will fall into one of the
219214 // two categories below. Both of these will add a check that makes sure the user has EHRDataAdminPermission
220215 // in order to insert/update/delete on the table. The ContainerScopedTable case is for those tables that
221- // have a true DB PK or rowid but a User psedoPK that should be accounted for at the container level.
216+ // have a true DB PK or rowid but a User pseudoPK that should be accounted for at the container level.
222217 String pkColName = getPkColName (ti );
223218 if (pkColName != null && !"rowid" .equalsIgnoreCase (pkColName ) && ti .getColumn ("container" ) != null )
224219 return getContainerScopedTable (name , cf , pkColName , EHRDataAdminPermission .class );
@@ -252,7 +247,7 @@ private String getPkColName(TableInfo ti)
252247
253248 private TableInfo createVeterinariansTable (String name , ContainerFilter cf )
254249 {
255- FilteredTable ti = new FilteredTable <>(CoreSchema .getInstance ().getTableInfoUsersData (), this , cf );
250+ FilteredTable < EHRLookupsUserSchema > ti = new FilteredTable <>(CoreSchema .getInstance ().getTableInfoUsersData (), this , cf );
256251 ti .setPublicSchemaName (EHRSchema .EHR_LOOKUPS );
257252
258253 Set <Integer > userIds = new HashSet <>();
@@ -271,9 +266,9 @@ private TableInfo createVeterinariansTable(String name, ContainerFilter cf)
271266 else
272267 {
273268 Group assignedGroup = SecurityManager .getGroup (r .getUserId ());
274- if (assignedGroup != null && ! assignedGroup . isProjectGroup () )
269+ if (assignedGroup != null )
275270 {
276- // Add all site groups
271+ // Add all groups, both site and project-scoped
277272 groupsToExpand .add (assignedGroup );
278273 }
279274 }
@@ -293,7 +288,7 @@ private TableInfo createVeterinariansTable(String name, ContainerFilter cf)
293288
294289 ti .addWrapColumn (ti .getRealTable ().getColumn ("UserId" ));
295290 ti .addWrapColumn (ti .getRealTable ().getColumn ("DisplayName" ));
296- ti .getMutableColumn ("UserId" ).setFk (new QueryForeignKey ( QueryService . get (). getUserSchema ( getUser (), getContainer (), "core" ), null , "Users" , "UserId" , "DisplayName " ));
291+ ti .getMutableColumnOrThrow ("UserId" ).setFk (new QueryForeignKey . Builder ( this , getDefaultContainerFilter ()). schema ( CoreSchema . getInstance (). getSchemaName ()). table ( "Users" ));
297292 ti .setName (name );
298293 ti .setTitle ("Veterinarians" );
299294
@@ -302,7 +297,7 @@ private TableInfo createVeterinariansTable(String name, ContainerFilter cf)
302297
303298 private TableInfo getContainerScopedTable (String name , ContainerFilter cf , String psuedoPk , @ Nullable Class <? extends Permission > perm )
304299 {
305- EHR_LookupsContainerScopedTable ret = new EHR_LookupsContainerScopedTable <>(this , this .createSourceTable (name ), cf , psuedoPk );
300+ EHR_LookupsContainerScopedTable <?> ret = new EHR_LookupsContainerScopedTable <>(this , this .createSourceTable (name ), cf , psuedoPk );
306301 if (perm != null )
307302 {
308303 ret .addPermissionMapping (InsertPermission .class , perm );
@@ -314,14 +309,14 @@ private TableInfo getContainerScopedTable(String name, ContainerFilter cf, Strin
314309
315310 private TableInfo getCustomPermissionTable (TableInfo schemaTable , ContainerFilter cf , Class <? extends Permission > perm )
316311 {
317- EHR_LookupsCustomPermissionsTable ret = new EHR_LookupsCustomPermissionsTable <>(this , schemaTable , cf );
312+ EHR_LookupsCustomPermissionsTable <?> ret = new EHR_LookupsCustomPermissionsTable <>(this , schemaTable , cf );
318313 ret .addPermissionMapping (InsertPermission .class , perm );
319314 ret .addPermissionMapping (UpdatePermission .class , perm );
320315 ret .addPermissionMapping (DeletePermission .class , perm );
321316 return ret .init ();
322317 }
323318
324- private LookupSetTable createForPropertySet (UserSchema us , ContainerFilter cf , String setName , Map <String , Object > map )
319+ private LookupSetTable createForPropertySet (EHRLookupsUserSchema us , ContainerFilter cf , String setName , Map <String , Object > map )
325320 {
326321 SchemaTableInfo table = _dbSchema .getTable (EHRSchema .TABLE_LOOKUPS );
327322 LookupSetTable ret = new LookupSetTable (us , table , cf , setName , map );
@@ -331,7 +326,7 @@ private LookupSetTable createForPropertySet(UserSchema us, ContainerFilter cf, S
331326 return ret .init ();
332327 }
333328
334- private LabworkTypeTable createForLabwork (UserSchema us , ContainerFilter cf , String tableName , String typeName )
329+ private LabworkTypeTable createForLabwork (EHRLookupsUserSchema us , ContainerFilter cf , String tableName , String typeName )
335330 {
336331 SchemaTableInfo table = _dbSchema .getTable (EHRSchema .TABLE_LAB_TESTS );
337332 return new LabworkTypeTable (us , table , cf , tableName , typeName ).init ();
0 commit comments