Skip to content

Commit e8b4f8d

Browse files
authored
Ensure data region name uniqueness (#7846)
1 parent 243448a commit e8b4f8d

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

api/src/org/labkey/api/exp/ExperimentRunListView.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ public ExperimentRunListView(UserSchema schema, QuerySettings settings, @NotNull
8585

8686
public static QuerySettings getRunListQuerySettings(UserSchema schema, ViewContext model, String tableName, boolean allowCustomizations)
8787
{
88-
QuerySettings settings = schema.getSettings(model, tableName, tableName);
88+
return getRunListQuerySettings(schema, model, tableName, null, allowCustomizations);
89+
}
90+
91+
public static QuerySettings getRunListQuerySettings(UserSchema schema, ViewContext model, String tableName, @Nullable String dataRegionName, boolean allowCustomizations)
92+
{
93+
QuerySettings settings = schema.getSettings(model, dataRegionName != null ? dataRegionName : tableName, tableName);
8994
settings.getQueryDef(schema);
9095
settings.setBaseSort(new Sort("-RowId"));
9196
settings.setAllowChooseView(allowCustomizations);
@@ -107,6 +112,11 @@ protected void renderHeaderView(HttpServletRequest request, HttpServletResponse
107112
}
108113

109114
public static ExperimentRunListView createView(ViewContext model, ExperimentRunType selectedType, boolean allowCustomizations)
115+
{
116+
return createView(model, selectedType, null, allowCustomizations);
117+
}
118+
119+
public static ExperimentRunListView createView(ViewContext model, ExperimentRunType selectedType, @Nullable String dataRegionName, boolean allowCustomizations)
110120
{
111121
UserSchema schema = QueryService.get().getUserSchema(model.getUser(), model.getContainer(), selectedType.getSchemaName());
112122
if (schema == null)
@@ -115,7 +125,8 @@ public static ExperimentRunListView createView(ViewContext model, ExperimentRunT
115125
selectedType = ExperimentRunType.ALL_RUNS_TYPE;
116126
schema = QueryService.get().getUserSchema(model.getUser(), model.getContainer(), selectedType.getSchemaName());
117127
}
118-
return new ExperimentRunListView(schema, getRunListQuerySettings(schema, model, selectedType.getTableName(), allowCustomizations), selectedType);
128+
String tableName = selectedType.getTableName();
129+
return new ExperimentRunListView(schema, getRunListQuerySettings(schema, model, tableName, dataRegionName, allowCustomizations), selectedType);
119130
}
120131

121132
public void setShowUploadAssayRunsButton(boolean showUploadAssayRunsButton)

api/src/org/labkey/api/exp/api/ExperimentService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static void validateParentAlias(Map<String, String> aliasMap, Set<String> reserv
738738

739739
ExperimentRunListView createExperimentRunWebPart(ViewContext context, ExperimentRunType type);
740740

741+
ExperimentRunListView createExperimentRunWebPart(ViewContext context, ExperimentRunType type, @Nullable String dataRegionName);
742+
741743
DbSchema getSchema();
742744

743745
ExpProtocolApplication getExpProtocolApplication(String lsid);

experiment/src/org/labkey/experiment/ExperimentRunWebPartFactory.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ private String getConfiguredRunFilterName(Portal.WebPart webPart)
5353
return webPart.getPropertyMap().get(EXPERIMENT_RUN_FILTER);
5454
}
5555

56+
/**
57+
* Create a unique data region name for the webpart.
58+
*/
59+
private String getDataRegionName(Portal.WebPart webPart, int index)
60+
{
61+
return String.format("expRunWebPart_%d_%d", webPart.getIndex(), index);
62+
}
63+
5664
public static class Bean
5765
{
5866
private final Set<ExperimentRunType> _types;
@@ -106,9 +114,11 @@ public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Po
106114
VBox result = new VBox();
107115
result.setTitle("Experiment Runs");
108116
result.setFrame(WebPartView.FrameType.PORTAL);
117+
int gridIndex = 0;
109118
for (ExperimentRunType runType : runTypes)
110119
{
111-
ExperimentRunListView runView = ExperimentService.get().createExperimentRunWebPart(new ViewContext(portalCtx), runType);
120+
// GitHub Issue 1295: give each grid a unique data region name
121+
ExperimentRunListView runView = ExperimentService.get().createExperimentRunWebPart(new ViewContext(portalCtx), runType, getDataRegionName(webPart, gridIndex++));
112122
if (runType != ExperimentRunType.ALL_RUNS_TYPE)
113123
{
114124
runView.setTitle(runType.getDescription() + " Runs");
@@ -125,7 +135,8 @@ public WebPartView<?> getWebPartView(@NotNull ViewContext portalCtx, @NotNull Po
125135
selectedType = ChooseExperimentTypeBean.getBestTypeSelection(types, selectedType, protocols);
126136
}
127137

128-
ExperimentRunListView result = ExperimentService.get().createExperimentRunWebPart(new ViewContext(portalCtx), selectedType);
138+
// GitHub Issue 1295: give the grid a unique data region name
139+
ExperimentRunListView result = ExperimentService.get().createExperimentRunWebPart(new ViewContext(portalCtx), selectedType, getDataRegionName(webPart, 0));
129140
if (selectedType != ExperimentRunType.ALL_RUNS_TYPE)
130141
{
131142
result.setTitle(result.getTitle() + " (" + selectedType.getDescription() + ")");

experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,13 @@ public DbScope.Transaction ensureTransaction(Lock... locks)
21462146
@Override
21472147
public ExperimentRunListView createExperimentRunWebPart(ViewContext context, ExperimentRunType type)
21482148
{
2149-
ExperimentRunListView view = ExperimentRunListView.createView(context, type, true);
2149+
return createExperimentRunWebPart(context, type, null);
2150+
}
2151+
2152+
@Override
2153+
public ExperimentRunListView createExperimentRunWebPart(ViewContext context, ExperimentRunType type, @Nullable String dataRegionName)
2154+
{
2155+
ExperimentRunListView view = ExperimentRunListView.createView(context, type, dataRegionName, true);
21502156
view.setShowDeleteButton(true);
21512157
view.setShowAddToRunGroupButton(true);
21522158
view.setShowMoveRunsButton(true);

0 commit comments

Comments
 (0)