Skip to content

Commit ae258a6

Browse files
Merge 25.9 to develop
2 parents 7d44d44 + e784b91 commit ae258a6

7 files changed

Lines changed: 58 additions & 44 deletions

File tree

api/src/org/labkey/api/assay/AbstractTsvAssayProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public abstract class AbstractTsvAssayProvider extends AbstractAssayProvider
4141
public static final String ASSAY_SCHEMA_NAME = "assayresult";
4242
public static final String ROW_ID_COLUMN_NAME = "RowId";
4343
public static final String DATA_ID_COLUMN_NAME = "DataId";
44+
public static final String GPAT_PROTOCOL_LSID_PREFIX = "GeneralAssayProtocol";
4445

4546
public AbstractTsvAssayProvider(String protocolLSIDPrefix, String runLSIDPrefix, AssayDataType dataType, Module declaringModule)
4647
{

api/src/org/labkey/api/data/DataRegion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ protected String getRecordSelectorValue(RenderContext ctx)
19111911
// of values (even if they're empty) between commas for deterministic parsing (bug 6755)
19121912
checkboxValue.append(and);
19131913
if (null != v)
1914-
checkboxValue.append(PageFlowUtil.filter(v.toString()));
1914+
checkboxValue.append(v);
19151915
and = ",";
19161916
}
19171917
}
@@ -1924,7 +1924,7 @@ protected String getRecordSelectorValue(RenderContext ctx)
19241924
// of values (even if they're empty) between commas for deterministic parsing (bug 6755)
19251925
checkboxValue.append(and);
19261926
if (null != v)
1927-
checkboxValue.append(PageFlowUtil.filter(v.toString()));
1927+
checkboxValue.append(v);
19281928
and = ",";
19291929
}
19301930
}

api/src/org/labkey/api/query/QueryKey.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ else if (contains(ILLEGAL, String.valueOf(c)))
200200

201201
static protected boolean contains(String[] strs, String s)
202202
{
203-
for (int i = 0; i < strs.length; i++)
204-
if (strs[i].equals(s))
203+
for (String str : strs)
204+
if (str.equals(s))
205205
return true;
206206

207207
return false;
@@ -221,7 +221,7 @@ protected QueryKey(QueryKey<T> parent, @NotNull String name)
221221
_hash = _name.toLowerCase().hashCode() ^ Objects.hashCode(_parent);
222222
}
223223

224-
protected QueryKey(QueryKey<T> parent, Enum name)
224+
protected QueryKey(QueryKey<T> parent, Enum<?> name)
225225
{
226226
this(parent, name.toString());
227227
}
@@ -251,7 +251,7 @@ public boolean equals(Object other)
251251
{
252252
if (other == null || !(getClass().equals(other.getClass())))
253253
return false;
254-
QueryKey that = (QueryKey) other;
254+
QueryKey<?> that = (QueryKey<?>) other;
255255
return strEqualsIgnoreCase(_name, that._name) &&
256256
Objects.equals(_parent, that._parent);
257257
}
@@ -349,7 +349,7 @@ protected boolean needsQuotes(String part)
349349
return true;
350350
}
351351

352-
public boolean startsWith(@NotNull QueryKey<? extends QueryKey> prefix)
352+
public boolean startsWith(@NotNull QueryKey<? extends QueryKey<?>> prefix)
353353
{
354354
if (size() < prefix.size())
355355
return false;

assay/src/org/labkey/assay/TsvAssayProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class TsvAssayProvider extends AbstractTsvAssayProvider
153153

154154
public TsvAssayProvider()
155155
{
156-
this("GeneralAssayProtocol", "GeneralAssayRun", "General" + RESULT_LSID_PREFIX_PART, ModuleLoader.getInstance().getModule(assayModuleClass));
156+
this(GPAT_PROTOCOL_LSID_PREFIX, "GeneralAssayRun", "General" + RESULT_LSID_PREFIX_PART, ModuleLoader.getInstance().getModule(assayModuleClass));
157157
}
158158

159159
protected TsvAssayProvider(String protocolLSIDPrefix, String runLSIDPrefix, String resultRowLSIDPrefix, Module declaringModule)

core/src/org/labkey/core/webdav/DavController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,8 +3607,7 @@ private static FileTime getLastModified(InputStream in) throws IOException
36073607
{
36083608
try
36093609
{
3610-
SAXParserFactory factory = SAXParserFactory.newInstance();
3611-
SAXParser saxParser = factory.newSAXParser();
3610+
SAXParser saxParser = XmlBeansUtil.SAX_PARSER_FACTORY.newSAXParser();
36123611
final List<StringBuilder> lastModifieds = new ArrayList<>();
36133612

36143613
saxParser.parse(new InputSource(in), new DefaultHandler()

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

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
import static java.util.Collections.singleton;
297297
import static java.util.stream.Collectors.toList;
298298
import static java.util.stream.Collectors.toSet;
299+
import static org.labkey.api.assay.AbstractTsvAssayProvider.GPAT_PROTOCOL_LSID_PREFIX;
299300
import static org.labkey.api.data.CompareType.IN;
300301
import static org.labkey.api.data.DbScope.CommitTaskOption.POSTCOMMIT;
301302
import static org.labkey.api.data.DbScope.CommitTaskOption.POSTROLLBACK;
@@ -4229,6 +4230,7 @@ public void deleteExperimentRuns(Container container, final User user, @Nullable
42294230

42304231
try (DbScope.Transaction transaction = ensureTransaction())
42314232
{
4233+
AssayService assayService = AssayService.get();
42324234
// This can be slightly expensive to fetch, so don't do it multiple times if runs share protocols
42334235
Map<ExpProtocol, ProtocolImplementation> protocolImpls = new HashMap<>();
42344236

@@ -4264,18 +4266,21 @@ public void deleteExperimentRuns(Container container, final User user, @Nullable
42644266
throw new UnauthorizedException("Cannot delete rows from dataset " + dataset);
42654267
}
42664268

4267-
AssayProvider provider = AssayService.get().getProvider(protocol);
4268-
if (provider != null)
4269+
if (assayService != null)
42694270
{
4270-
AssayTableMetadata tableMetadata = provider.getTableMetadata(protocol);
4271-
SimpleFilter filter = new SimpleFilter(tableMetadata.getRunRowIdFieldKeyFromResults(), run.getRowId());
4272-
Collection<String> lsids = new TableSelector(tableInfo, singleton("LSID"), filter, null).getCollection(String.class);
4271+
AssayProvider provider = assayService.getProvider(protocol);
4272+
if (provider != null)
4273+
{
4274+
AssayTableMetadata tableMetadata = provider.getTableMetadata(protocol);
4275+
SimpleFilter filter = new SimpleFilter(tableMetadata.getRunRowIdFieldKeyFromResults(), run.getRowId());
4276+
Collection<String> lsids = new TableSelector(tableInfo, singleton("LSID"), filter, null).getCollection(String.class);
42734277

4274-
// Add an audit event to the link to study history
4275-
publishService.addRecallAuditEvent(run.getContainer(), user, dataset, lsids.size(), null);
4278+
// Add an audit event to the link to study history
4279+
publishService.addRecallAuditEvent(run.getContainer(), user, dataset, lsids.size(), null);
42764280

4277-
// Do the actual delete on the dataset for the rows in question
4278-
dataset.deleteDatasetRows(user, lsids);
4281+
// Do the actual delete on the dataset for the rows in question
4282+
dataset.deleteDatasetRows(user, lsids);
4283+
}
42794284
}
42804285
}
42814286
}
@@ -4339,12 +4344,12 @@ public void deleteExperimentRuns(Container container, final User user, @Nullable
43394344
// ideally this would be transacted as a commit task but we decided against it due to complications
43404345
run.archiveDataFiles(user);
43414346
// Re-index replaced run if replacing run is deleted
4342-
if (run.getReplacesRuns() != null)
4347+
if (assayService != null && run.getReplacesRuns() != null)
43434348
{
43444349
List<ExpRunImpl> replacedRuns = run.getReplacesRuns();
43454350
transaction.addCommitTask(() ->
43464351
replacedRuns.forEach(replacedRun ->
4347-
AssayService.get().indexAssayRun(SearchService.get().defaultTask().getQueue(container, SearchService.PRIORITY.modified), replacedRun.getRowId())
4352+
assayService.indexAssayRun(SearchService.get().defaultTask().getQueue(container, SearchService.PRIORITY.modified), replacedRun.getRowId())
43484353
),
43494354
DbScope.CommitTaskOption.POSTCOMMIT
43504355
);
@@ -6469,8 +6474,12 @@ public Protocol saveProtocol(
64696474
if (newProtocol)
64706475
{
64716476
// if protocol exists, throw error
6472-
if (AssayService.get().getAssayProtocolByName(protocol.getContainer(), protocol.getName()) != null)
6473-
throw new RuntimeSQLException(new SQLException("Assay design with name '" + protocol.getName() + "' already exists."));
6477+
if (GPAT_PROTOCOL_LSID_PREFIX.equals(protocol.getLSIDNamespacePrefix()) && AssayService.get() != null)
6478+
{
6479+
ExpProtocol existingProtocol = AssayService.get().getAssayProtocolByName(protocol.getContainer(), protocol.getName());
6480+
if (existingProtocol != null && GPAT_PROTOCOL_LSID_PREFIX.equals(existingProtocol.getLSIDNamespacePrefix()))
6481+
throw new RuntimeSQLException(new SQLException("Assay design with name '" + protocol.getName() + "' already exists."));
6482+
}
64746483

64756484
result = Table.insert(user, getTinfoProtocol(), protocol);
64766485
}
@@ -9793,26 +9802,30 @@ public Map<String, Integer> moveAssayRuns(@NotNull List<? extends ExpRun> assayR
97939802
AbstractQueryUpdateService.addTransactionAuditEvent(transaction, user, auditEvent);
97949803
}
97959804

9796-
for (Map.Entry<ExpProtocol, List<ExpRun>> entry: protocolMap.entrySet())
9805+
AssayService assayService = AssayService.get();
9806+
if (assayService != null)
97979807
{
9798-
ExpProtocol protocol = entry.getKey();
9799-
AssayProvider provider = AssayService.get().getProvider(protocol);
9800-
List<ExpRun> runs = entry.getValue();
9801-
if (provider != null)
9808+
for (Map.Entry<ExpProtocol, List<ExpRun>> entry: protocolMap.entrySet())
98029809
{
9803-
provider.moveRuns(runs, targetContainer, user, assayMoveData);
9804-
Map<String, Integer> counts = assayMoveData.counts();
9805-
int auditEventCount = expService.moveAuditEvents(targetContainer, runLsids);
9806-
counts.put("auditEvents", counts.getOrDefault("auditEvents", 0) + auditEventCount);
9807-
if (auditBehavior != null && AuditBehaviorType.NONE != auditBehavior)
9810+
ExpProtocol protocol = entry.getKey();
9811+
AssayProvider provider = assayService.getProvider(protocol);
9812+
List<ExpRun> runs = entry.getValue();
9813+
if (provider != null)
98089814
{
9809-
for (ExpRun run : runs)
9815+
provider.moveRuns(runs, targetContainer, user, assayMoveData);
9816+
Map<String, Integer> counts = assayMoveData.counts();
9817+
int auditEventCount = expService.moveAuditEvents(targetContainer, runLsids);
9818+
counts.put("auditEvents", counts.getOrDefault("auditEvents", 0) + auditEventCount);
9819+
if (auditBehavior != null && AuditBehaviorType.NONE != auditBehavior)
98109820
{
9811-
run.setContainer(targetContainer);
9821+
for (ExpRun run : runs)
9822+
{
9823+
run.setContainer(targetContainer);
98129824

9813-
// Issue 52570: include source and target containers in the audit event message
9814-
String message = String.format("Moved from %s to %s", container.getPath(), targetContainer.getPath());
9815-
auditRunEvent(user, protocol, run, null, "Assay run was moved.", userComment, message);
9825+
// Issue 52570: include source and target containers in the audit event message
9826+
String message = String.format("Moved from %s to %s", container.getPath(), targetContainer.getPath());
9827+
auditRunEvent(user, protocol, run, null, "Assay run was moved.", userComment, message);
9828+
}
98169829
}
98179830
}
98189831
}

query/src/org/labkey/query/LinkedSchema.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.labkey.query;
1717

1818
import org.apache.commons.lang3.StringUtils;
19+
import org.apache.commons.lang3.Strings;
1920
import org.apache.logging.log4j.Logger;
2021
import org.jetbrains.annotations.NotNull;
2122
import org.jetbrains.annotations.Nullable;
@@ -106,7 +107,7 @@ public static LinkedSchema get(User user, Container container, LinkedSchemaDef d
106107
Container sourceContainer = def.lookupSourceContainer();
107108
if (sourceContainer == null)
108109
{
109-
LOG.warn("Source container '" + def.getSourceContainerId() + "' not found for linked schema " + def.getUserSchemaName());
110+
LOG.warn("Source container '{}' not found for linked schema {}", def.getSourceContainerId(), def.getUserSchemaName());
110111
return null;
111112
}
112113

@@ -117,7 +118,7 @@ public static LinkedSchema get(User user, Container container, LinkedSchemaDef d
117118
UserSchema sourceSchema = getSourceSchema(def, sourceSchemaName, sourceContainer, user);
118119
if (sourceSchema == null)
119120
{
120-
LOG.warn("Source schema '" + sourceSchemaName + "' not found in container '" + sourceContainer.getPath() + "' for linked schema " + def.getUserSchemaName());
121+
LOG.warn("Source schema '{}' not found in container '{}' for linked schema {}", sourceSchemaName, sourceContainer.getPath(), def.getUserSchemaName());
121122
return null;
122123
}
123124

@@ -166,7 +167,7 @@ private static UserSchema getSourceSchema(LinkedSchemaDef def, String sourceSche
166167
// Disallow recursive linked schema
167168
if (def.lookupContainer() == sourceContainer && def.getUserSchemaName().equals(sourceSchemaName))
168169
{
169-
LOG.warn("Disallowed recursive linked schema definition '" + sourceSchemaName + "' in container '" + sourceContainer.getPath() + "'");
170+
LOG.warn("Disallowed recursive linked schema definition '{}' in container '{}'", sourceSchemaName, sourceContainer.getPath());
170171
return null;
171172
}
172173

@@ -343,7 +344,7 @@ protected LinkedTableInfo createWrappedTable(String name, @NotNull TableInfo sou
343344
if (null != metaData && null != metaData.getIncludeColumnsList())
344345
{
345346
String cols = StringUtils.trim(metaData.getIncludeColumnsList());
346-
if (!StringUtils.equals("*",cols))
347+
if (!Strings.CS.equals("*",cols))
347348
{
348349
includedFields = Arrays.stream(StringUtils.split(cols,";"))
349350
.map((col)->new FieldKey(null,col))
@@ -483,7 +484,7 @@ public static String generateLabKeySQL(TableInfo sourceTable, SQLWhereClauseSour
483484
for (QueryService.ParameterDecl decl : parameterDecls)
484485
{
485486
sql.append(paramSep);
486-
sql.append(" \"").append(decl.getName()).append("\" ").append(decl.getJdbcType().name());
487+
sql.append(" ").append(FieldKey.fromParts(decl.getName()).toSQLString()).append(" ").append(decl.getJdbcType().name());
487488
if (decl.getDefault() != null)
488489
sql.append(" DEFAULT ").append(decl.getDefault());
489490
paramSep = ",\n";
@@ -499,7 +500,7 @@ public static String generateLabKeySQL(TableInfo sourceTable, SQLWhereClauseSour
499500
if (col.isAdditionalQueryColumn())
500501
continue;
501502
sql.append(columnSep);
502-
sql.append("\"").append(col.getName()).append("\"");
503+
sql.append(col.getFieldKey().toSQLString());
503504
if (col.isHidden())
504505
sql.append(" @hidden");
505506

0 commit comments

Comments
 (0)