Skip to content
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
48 changes: 42 additions & 6 deletions src/org/labkey/remoteapi/plate/PlateParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

import org.json.JSONObject;

import java.util.List;
import java.util.Map;

public class PlateParams
{
private boolean _archived;
private String _assayType;
private String _barcode;
private int _columns;
private String _description;
private String _name;
private String _plateId;
private int _rowId;
private int _plateSetId;
private String _description;
private int _rows;
private int _columns;
private int _plateType;
private String _assayType;
private int _rowId;
private int _rows;
private boolean _template;
private boolean _archived;

private PlateParams()
{
}

public PlateParams(JSONObject json)
{
Expand Down Expand Up @@ -45,6 +52,35 @@ public PlateParams(JSONObject json)

if (json.has("archived"))
_archived = json.getBoolean("archived");

if (json.has("barcode"))
_barcode = json.getString("barcode");
}

public static final List<String> QUERY_COLUMNS = List.of("Archived", "AssayType", "Barcode", "Description", "Name", "PlateId", "PlateSet", "PlateType", "PlateType/Columns", "PlateType/Rows", "RowId", "Template");

public static PlateParams fromQueryRow(Map<String, Object> row)
{
var params = new PlateParams();
params._archived = (Boolean) row.get("Archived");
params._assayType = (String) row.get("AssayType");
params._barcode = (String) row.get("Barcode");
params._columns = (Integer) row.get("PlateType/Columns");
params._description = (String) row.get("Description");
params._name = (String) row.get("Name");
params._plateId = (String) row.get("PlateId");
params._plateSetId = (Integer) row.get("PlateSet");
params._plateType = (Integer) row.get("PlateType");
params._rowId = (Integer) row.get("RowId");
params._rows = (Integer) row.get("PlateType/Rows");
params._template = (Boolean) row.get("Template");

return params;
}

public String getBarcode()
{
return _barcode;
}

public String getName()
Expand Down
32 changes: 32 additions & 0 deletions src/org/labkey/remoteapi/plate/PlateSetParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.json.JSONObject;

import java.util.List;
import java.util.Map;

public class PlateSetParams
{
private boolean _archived;
Expand All @@ -22,6 +25,10 @@ public class PlateSetParams
private boolean _template;
private CreatePlateSetParams.PlateSetType _plateSetType;

private PlateSetParams()
{
}

public PlateSetParams(JSONObject json)
{
if (json.has("archived"))
Expand Down Expand Up @@ -58,6 +65,31 @@ public PlateSetParams(JSONObject json)
_plateSetType = CreatePlateSetParams.PlateSetType.fromName(json.getString("type"));
}

public static final List<String> QUERY_COLUMNS = List.of("Archived", "Created", "CreatedBy", "Description", "Folder/EntityId", "Folder/Name", "Folder/Path", "Modified", "ModifiedBy", "Name", "PlateCount", "PlateSetId", "PrimaryPlateSetId", "RootPlateSetId", "RowId", "Template", "Type");

public static PlateSetParams fromQueryRow(Map<String, Object> row)
{
var params = new PlateSetParams();
params._containerId = (String) row.get("Folder/EntityId");
params._containerName = (String) row.get("Folder/Name");
params._containerPath = (String) row.get("Folder/Path");
params._created = row.get("Created").toString();
params._createdBy = (Integer) row.get("CreatedBy");
params._description = (String) row.get("Description");
params._modified = row.get("Modified").toString();
params._modifiedBy = (Integer) row.get("ModifiedBy");
params._name = (String) row.get("Name");
params._plateCount = (Integer) row.get("PlateCount");
params._plateSetId = (String) row.get("PlateSetId");
params._plateSetType = CreatePlateSetParams.PlateSetType.fromName((String) row.get("Type"));
params._primaryPlateSetId = (Integer) row.get("PrimaryPlateSetId");
params._rootPlateSetId = (Integer) row.get("RootPlateSetId");
params._rowId = (Integer) row.get("RowId");
params._template = (Boolean) row.get("Template");

return params;
}

public boolean getArchived()
{
return _archived;
Expand Down
10 changes: 5 additions & 5 deletions src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1530,26 +1530,26 @@ protected SelectRowsResponse executeSelectRowCommand(String schemaName, String q
protected SelectRowsResponse executeSelectRowCommand(String schemaName, String queryName, ContainerFilter containerFilter,
String path, @Nullable List<Filter> filters, @Nullable List<String> requestedColumns)
{
Connection cn = createDefaultConnection();
SelectRowsCommand selectCmd = new SelectRowsCommand(schemaName, queryName);
selectCmd.setMaxRows(-1);
selectCmd.setContainerFilter(containerFilter);
selectCmd.setColumns(requestedColumns);
if (filters != null)
selectCmd.setFilters(filters);

SelectRowsResponse selectResp;
return executeSelectRowCommand(path, selectCmd);
}

protected SelectRowsResponse executeSelectRowCommand(String containerPath, SelectRowsCommand command)
{
try
{
selectResp = selectCmd.execute(cn, path);
return command.execute(createDefaultConnection(), containerPath);
}
catch (CommandException | IOException e)
{
throw new RuntimeException(e);
}

return selectResp;
}

// Returns the text contents of every "Status" cell in the pipeline StatusFiles grid
Expand Down
48 changes: 35 additions & 13 deletions src/org/labkey/test/util/AuditLogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONException;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.query.ContainerFilter;
Expand All @@ -29,10 +30,10 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

import static java.lang.Integer.parseInt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
Expand Down Expand Up @@ -85,16 +86,19 @@ public enum AuditBehaviorType

public enum AuditEvent
{
SAMPLE_TIMELINE_EVENT("SampleTimelineEvent"),
SOURCES_AUDIT_EVENT("SourcesAuditEvent"), // avaialble with SampleManagement module
ASSAY_AUDIT_EVENT("AssayAuditEvent"), // available with SampleManagement module
ASSAY_RESULT_AUDIT_EVENT("AssayResultAuditEvent"), // available with SampleManagement module
EXPERIMENT_AUDIT_EVENT("ExperimentAuditEvent"),
FILE_SYSTEM_EVENT("FileSystem"),
INVENTORY_AUDIT_EVENT("InventoryAuditEvent"),
LIST_AUDIT_EVENT("ListAuditEvent"),
ASSAY_AUDIT_EVENT("AssayAuditEvent"), // avaialble with SampleManagement module
ASSAY_RESULT_AUDIT_EVENT("AssayResultAuditEvent"), // avaialble with SampleManagement module
EXPERIMENT_AUDIT_EVENT("ExperimentAuditEvent"),
SAMPLE_WORKFLOW_AUDIT_EVENT("SamplesWorkflowAuditEvent"),
PLATE_AUDIT_EVENT("PlateEvent"), // available in Biologics module
PLATE_DATA_AUDIT_EVENT("PlateDataAuditEvent"), // available in Biologics module
PLATE_SET_AUDIT_EVENT("PlateSetEvent"), // available in Biologics module
QUERY_UPDATE_AUDIT_EVENT("QueryUpdateAuditEvent"),
FILE_SYSTEM_EVENT("FileSystem");
SAMPLE_TIMELINE_EVENT("SampleTimelineEvent"),
SAMPLE_WORKFLOW_AUDIT_EVENT("SamplesWorkflowAuditEvent"),
SOURCES_AUDIT_EVENT("SourcesAuditEvent"); // available with SampleManagement module

private final String _name;

Expand Down Expand Up @@ -257,16 +261,16 @@ public void checkAuditEventDiffCount(String containerPath, AuditEvent auditEvent
boolean isInventoryUpdateType = event.get("InventoryUpdateType") != null;
int expectedDiffCount = isInventoryUpdateType ? 0 : expectedDiffCounts.get(i);
String dataChangesStr = (String) event.get(eventDiffFieldName);
String[] dataChanges = dataChangesStr != null ? dataChangesStr.split("&") : new String[0];
Map<String, String> dataChanges = decodeValues(dataChangesStr);

// filter out SampleStateLabel as that is not a change, it is added for display purposes
dataChanges = Stream.of(dataChanges).filter(s -> !s.toLowerCase().startsWith("samplestatelabel=")).toArray(String[]::new);
dataChanges.remove("SampleStateLabel");
// filter out RowId as that is not a change, it is added for display purposes
dataChanges = Stream.of(dataChanges).filter(s -> !s.toLowerCase().startsWith("rowid=")).toArray(String[]::new);
dataChanges.remove("RowId");

log("Audit record data changes diff count check (" + eventDiffFieldName + "): " + dataChangesStr);
assertEquals("Audit record data changes did not include the expected number of diffs in " + eventDiffFieldName + ", expected " + expectedDiffCount + " but was " + dataChanges.length + ": " + dataChangesStr,
expectedDiffCount, dataChanges.length);
assertEquals("Audit record data changes did not include the expected number of diffs in " + eventDiffFieldName + ", expected " + expectedDiffCount + " but was " + dataChanges.size() + ": " + dataChangesStr,
expectedDiffCount, dataChanges.size());
}
}

Expand Down Expand Up @@ -527,6 +531,24 @@ public String getLogString()
}
}

public static Map<String, String> decodeValues(String recordMapString)
{
if (recordMapString == null || recordMapString.isEmpty())
return Collections.emptyMap();

Map<String, String> recordMap = new CaseInsensitiveHashMap<>();
for (String part : recordMapString.split("&"))
{
String[] keyValue = part.split("=");
String key = EscapeUtil.decode(keyValue[0]);
assertFalse(String.format("Audit record map already contains key for %s", key), recordMap.containsKey(key));

recordMap.put(key, keyValue.length > 1 ? EscapeUtil.decode(keyValue[1]) : null);
}

return recordMap;
}

/**
* URL-encode fields and values for {@link DetailedAuditEventRow#newValues} or {@link DetailedAuditEventRow#oldValues}
* @param pairs alternating field names and their associated values
Expand Down