Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/org/labkey/snd/SNDManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class SNDManager
{
private static final SNDManager _instance = new SNDManager();

private final StringKeyCache<Object> _cache;
private final StringKeyCache<Map<String, Map<String, Object>>> _cache;

private List<TableInfo> _attributeLookups = new ArrayList<>();

Expand All @@ -121,7 +121,7 @@ public static SNDManager get()
return _instance;
}

public StringKeyCache getCache()
public StringKeyCache<Map<String, Map<String, Object>>> getCache()
{
return _cache;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ private QueryUpdateService getNewQueryUpdateService(@NotNull UserSchema schema,
if (dbTableInfo == null)
throw new IllegalStateException(table + " db table info not found.");

SimpleUserSchema.SimpleTable simpleTable = new SimpleUserSchema.SimpleTable(schema, dbTableInfo);
SimpleUserSchema.SimpleTable simpleTable = new SimpleUserSchema.SimpleTable(schema, dbTableInfo, null);
QueryUpdateService qus = new SimpleQueryUpdateService(simpleTable, dbTableInfo);

if (qus == null)
Expand Down
63 changes: 32 additions & 31 deletions src/org/labkey/snd/SNDUserSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.collections.CaseInsensitiveTreeSet;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.TableInfo;
Expand Down Expand Up @@ -69,76 +70,76 @@ public enum TableType
SuperPkgs
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new SuperPackagesTable(schema, SNDSchema.getInstance().getTableInfoSuperPkgs()).init();
return new SuperPackagesTable(schema, SNDSchema.getInstance().getTableInfoSuperPkgs(), cf).init();
}
},
Pkgs
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new PackagesTable(schema, SNDSchema.getInstance().getTableInfoPkgs()).init();
return new PackagesTable(schema, SNDSchema.getInstance().getTableInfoPkgs(), cf).init();
}
},
PkgCategories
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new CategoriesTable(schema, SNDSchema.getInstance().getTableInfoPkgCategories()).init();
return new CategoriesTable(schema, SNDSchema.getInstance().getTableInfoPkgCategories(), cf).init();

}
},
PkgCategoryJunction
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
SimpleUserSchema.SimpleTable<SNDUserSchema> table =
new SimpleUserSchema.SimpleTable<>(
schema, SNDSchema.getInstance().getTableInfoPkgCategoryJunction()).init();
schema, SNDSchema.getInstance().getTableInfoPkgCategoryJunction(), cf).init();

return table;
}
},
ProjectItems
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
SimpleUserSchema.SimpleTable<SNDUserSchema> table =
new SimpleUserSchema.SimpleTable<>(
schema, SNDSchema.getInstance().getTableInfoProjectItems()).init();
schema, SNDSchema.getInstance().getTableInfoProjectItems(), cf).init();

return table;
}
},
Projects
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new ProjectsTable(schema, SNDSchema.getInstance().getTableInfoProjects()).init();
return new ProjectsTable(schema, SNDSchema.getInstance().getTableInfoProjects(), cf).init();
}
},
Events
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new EventsTable(schema, SNDSchema.getInstance().getTableInfoEvents()).init();
return new EventsTable(schema, SNDSchema.getInstance().getTableInfoEvents(), cf).init();
}
},
EventNotes
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
if (!schema.getPermissionCheck() || schema.getContainer().hasPermission(schema.getUser(), AdminPermission.class))
{
return new EventNotesTable(schema, SNDSchema.getInstance().getTableInfoEventNotes()).init();
return new EventNotesTable(schema, SNDSchema.getInstance().getTableInfoEventNotes(), cf).init();
}

return null;
Expand All @@ -147,11 +148,11 @@ public TableInfo createTable(SNDUserSchema schema)
EventData
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
if (!schema.getPermissionCheck() || schema.getContainer().hasPermission(schema.getUser(), AdminPermission.class))
{
return new EventDataTable(schema, SNDSchema.getInstance().getTableInfoEventData()).init();
return new EventDataTable(schema, SNDSchema.getInstance().getTableInfoEventData(), cf).init();
}

return null;
Expand All @@ -160,11 +161,11 @@ public TableInfo createTable(SNDUserSchema schema)
AttributeData
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
if (!schema.getPermissionCheck() || schema.getContainer().hasPermission(schema.getUser(), AdminPermission.class))
{
return new AttributeDataTable(schema);
return new AttributeDataTable(schema, cf);
}

return null;
Expand All @@ -173,44 +174,44 @@ public TableInfo createTable(SNDUserSchema schema)
Lookups
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
return new LookupsTable(schema, SNDSchema.getInstance().getTableInfoLookups()).init();
return new LookupsTable(schema, SNDSchema.getInstance().getTableInfoLookups(), cf).init();
}
},
LookupSets
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
SimpleUserSchema.SimpleTable<SNDUserSchema> table =
new SimpleUserSchema.SimpleTable<>(
schema, SNDSchema.getInstance().getTableInfoLookupSets()).init();
schema, SNDSchema.getInstance().getTableInfoLookupSets(), cf).init();

return table;
}
},
EventsCache
{
@Override
public TableInfo createTable(SNDUserSchema schema)
public TableInfo createTable(SNDUserSchema schema, ContainerFilter cf)
{
if (!schema.getPermissionCheck() || schema.getContainer().hasPermission(schema.getUser(), AdminPermission.class))
{
return new EventsCacheTable(schema, SNDSchema.getInstance().getTableInfoEventsCache()).init();
return new EventsCacheTable(schema, SNDSchema.getInstance().getTableInfoEventsCache(), cf).init();
}

return null;
}
};


public abstract TableInfo createTable(SNDUserSchema schema);
public abstract TableInfo createTable(SNDUserSchema schema, ContainerFilter cf);
}

@Override
@Nullable
public TableInfo createTable(String name)
public TableInfo createTable(String name, ContainerFilter cf)
{
if (name != null)
{
Expand All @@ -226,15 +227,15 @@ public TableInfo createTable(String name)
}
if (tableType != null)
{
return tableType.createTable(this);
return tableType.createTable(this, cf);
}
else
{
Map<String, Map<String, Object>> nameMap = getLookupSets();
if (nameMap.containsKey(name))
{
TableInfo table = SNDSchema.getInstance().getTableInfoLookups();
return new LookupSetsTable(this, table, name, nameMap.get(name)).init();
return new LookupSetsTable(this, table, name, nameMap.get(name), cf).init();
}
}
}
Expand All @@ -243,7 +244,7 @@ public TableInfo createTable(String name)

public Map<String, Map<String, Object>> getLookupSets()
{
Map<String, Map<String, Object>> nameMap = (Map<String, Map<String, Object>>) SNDManager.get().getCache().get(LookupSetsTable.getCacheKey(getContainer()));
Map<String, Map<String, Object>> nameMap = SNDManager.get().getCache().get(LookupSetsTable.getCacheKey(getContainer()));
if (nameMap != null)
return nameMap;

Expand Down
24 changes: 13 additions & 11 deletions src/org/labkey/snd/query/AttributeDataTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.labkey.api.data.ContainerForeignKey;
import org.labkey.api.data.DbSchema;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.ForeignKey;
import org.labkey.api.data.JdbcType;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SqlExecutor;
Expand All @@ -36,11 +37,8 @@
import org.labkey.api.query.BatchValidationException;
import org.labkey.api.query.ExprColumn;
import org.labkey.api.query.FilteredTable;
import org.labkey.api.query.InvalidKeyException;
import org.labkey.api.query.QueryForeignKey;
import org.labkey.api.query.QueryService;
import org.labkey.api.query.QueryUpdateService;
import org.labkey.api.query.QueryUpdateServiceException;
import org.labkey.api.query.SimpleQueryUpdateService;
import org.labkey.api.query.SimpleUserSchema;
import org.labkey.api.query.UserSchema;
Expand All @@ -57,7 +55,6 @@
import org.labkey.snd.SNDUserSchema;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Expand All @@ -72,9 +69,9 @@
*/
public class AttributeDataTable extends FilteredTable<SNDUserSchema>
{
public AttributeDataTable(@NotNull SNDUserSchema userSchema)
public AttributeDataTable(@NotNull SNDUserSchema userSchema, ContainerFilter cf)
{
super(OntologyManager.getTinfoObjectProperty(), userSchema);
super(OntologyManager.getTinfoObjectProperty(), userSchema, cf);
setName(SNDUserSchema.TableType.AttributeData.name());
setDescription("Event/package attribute data, one row per attribute/value combination.");

Expand All @@ -89,15 +86,19 @@ public AttributeDataTable(@NotNull SNDUserSchema userSchema)
// Inject a lookup to the EventData table
ExprColumn eventDataCol = new ExprColumn(this, "EventData", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".EventDataId"), JdbcType.VARCHAR);
addColumn(eventDataCol);
eventDataCol.setFk(new QueryForeignKey(getUserSchema(), null, SNDUserSchema.TableType.EventData.name(), "EventDataId", "EventDataId", true));
eventDataCol.setFk(QueryForeignKey.from(getUserSchema(), this.getContainerFilter())
.table(SNDUserSchema.TableType.EventData.name())
.key("EventDataId")
.display("EventDataId")
.raw(true));

// Inject a Container column directly into the table, making it easier to follow container filtering rules
ExprColumn containerCol = new ExprColumn(this, "Container", new SQLFragment(ExprColumn.STR_TABLE_ALIAS + ".Container"), JdbcType.VARCHAR);
addColumn(containerCol);
containerCol.setFk(new ContainerForeignKey(getUserSchema()));

getColumn("ObjectId").setFk(null);
getColumn("PropertyId").setLabel("Property");
getMutableColumn("ObjectId").setFk((ForeignKey)null);
getMutableColumn("PropertyId").setLabel("Property");
}

@Override
Expand All @@ -106,6 +107,7 @@ protected void applyContainerFilter(ContainerFilter filter)
// Handle this in the FROM SQL generation
}

@Override
@NotNull
public SQLFragment getFromSQL(String alias)
{
Expand Down Expand Up @@ -143,7 +145,7 @@ public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class<? exten
public QueryUpdateService getUpdateService()
{
UserSchema schema = SNDManager.getSndUserSchema(getContainer(), getUserSchema().getUser());
SimpleUserSchema.SimpleTable simpleTable = new SimpleUserSchema.SimpleTable(schema, this);
SimpleUserSchema.SimpleTable simpleTable = new SimpleUserSchema.SimpleTable(schema, this, null);
return new AttributeDataTable.UpdateService(simpleTable);
}

Expand Down Expand Up @@ -280,7 +282,7 @@ private List<Map<String, Object>> updateObjectProperty(User user, Container cont

Double floatValue = (Double) row.get("FloatValue");
String stringValue = (String) row.get("StringValue");
Character typeTag = ((String) row.get("TypeTag")).toCharArray()[0];
char typeTag = ((String) row.get("TypeTag")).toCharArray()[0];
String key = (String) row.get("_Key");

//add to list of cached narrative rows to delete
Expand Down
13 changes: 7 additions & 6 deletions src/org/labkey/snd/query/CategoriesTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
import org.labkey.api.data.JdbcType;
import org.labkey.api.data.SQLFragment;
import org.labkey.api.data.SimpleFilter;
Expand All @@ -30,7 +31,7 @@
import org.labkey.api.query.QueryUpdateService;
import org.labkey.api.query.QueryUpdateServiceException;
import org.labkey.api.query.SimpleQueryUpdateService;
import org.labkey.api.query.SimpleUserSchema;
import org.labkey.api.query.SimpleUserSchema.SimpleTable;
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.User;
import org.labkey.api.snd.SNDSequencer;
Expand All @@ -45,7 +46,7 @@
/**
* Created by marty on 8/27/2017.
*/
public class CategoriesTable extends SimpleUserSchema.SimpleTable<SNDUserSchema>
public class CategoriesTable extends SimpleTable<SNDUserSchema>
{

/**
Expand All @@ -55,13 +56,13 @@ public class CategoriesTable extends SimpleUserSchema.SimpleTable<SNDUserSchema>
* @param schema
* @param table
*/
public CategoriesTable(SNDUserSchema schema, TableInfo table)
public CategoriesTable(SNDUserSchema schema, TableInfo table, ContainerFilter cf)
{
super(schema, table);
super(schema, table, cf);
}

@Override
public SimpleUserSchema.SimpleTable init()
public SimpleTable<SNDUserSchema> init()
{
super.init();

Expand Down Expand Up @@ -92,7 +93,7 @@ public QueryUpdateService getUpdateService()

protected class UpdateService extends SimpleQueryUpdateService
{
public UpdateService(SimpleUserSchema.SimpleTable ti)
public UpdateService(SimpleTable ti)
{
super(ti, ti.getRealTable());
}
Expand Down
5 changes: 3 additions & 2 deletions src/org/labkey/snd/query/EventDataTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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.DbSchema;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.SQLFragment;
Expand Down Expand Up @@ -62,9 +63,9 @@ public class EventDataTable extends SimpleUserSchema.SimpleTable<SNDUserSchema>
* @param schema
* @param table
*/
public EventDataTable(SNDUserSchema schema, TableInfo table)
public EventDataTable(SNDUserSchema schema, TableInfo table, ContainerFilter cf)
{
super(schema, table);
super(schema, table, cf);
}

@Override
Expand Down
Loading