Skip to content

Commit

Permalink
Adjust updateRow and importData interfaces to account for auditUs…
Browse files Browse the repository at this point in the history
…erComments (#190)
  • Loading branch information
labkey-susanh authored Mar 11, 2024
1 parent 382431d commit 035cd6c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.AbstractTableInfo;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.CompareType;
Expand Down Expand Up @@ -174,7 +175,7 @@ protected Map<String, Object> insertRow(User user, Container container, Map<Stri
}

@Override
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow, @Nullable Map<Enum, Object> configParameters) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
{
String oldValue = (String)oldRow.get(_valueColumn);
String newValue = (String)row.get(_valueColumn);
Expand All @@ -186,7 +187,7 @@ protected Map<String, Object> updateRow(User user, Container container, Map<Stri
_vm.uncacheValue(oldValue);

row.put(_filterColumn, _filterValue);
return super.updateRow(user, container, row, oldRow);
return super.updateRow(user, container, row, oldRow, configParameters);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ public List<Map<String,Object>> insertRows(User user, Container container, List<
}

@Override
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow, @Nullable Map<Enum, Object> configParameters) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
{
Object oldValue = oldRow.get(_pseudoPk);
Object newValue = row.get(_pseudoPk);

if (oldRow != null && newValue != null && !oldValue.equals(newValue) && _keyManager.rowExists(container, newValue))
throw new ValidationException("There is already a record where " + _pseudoPk + " equals " + newValue);

return super.updateRow(user, container, row, oldRow);
return super.updateRow(user, container, row, oldRow, configParameters);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Aggregate;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.CompareType;
Expand Down Expand Up @@ -133,15 +134,15 @@ else if (rowId != null)
}

@Override
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow, @Nullable Map<Enum, Object> configParameters) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
{
Integer oldValue = getInteger(oldRow.get(_incrementingCol));
Integer newValue = getInteger(row.get(_incrementingCol));

if (oldValue != null && newValue != null && !oldValue.equals(newValue))
throw new ValidationException("Cannot change the value of the column: " + _incrementingCol);

return super.updateRow(user, container, row, oldRow);
return super.updateRow(user, container, row, oldRow, configParameters);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerFilter;
Expand Down Expand Up @@ -137,15 +138,15 @@ protected Map<String, Object> insertRow(User user, Container container, Map<Stri
}

@Override
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
protected Map<String, Object> updateRow(User user, Container container, Map<String, Object> row, @NotNull Map<String, Object> oldRow, @Nullable Map<Enum, Object> configParameters) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
{
Object oldValue = oldRow.get(WORKBOOK_ID_COl);
Object newValue = row.get(WORKBOOK_ID_COl);

if (oldValue != null && newValue != null && !oldValue.equals(newValue))
throw new ValidationException("Cannot change the workbook Id");

return super.updateRow(user, container, row, oldRow);
return super.updateRow(user, container, row, oldRow, configParameters);
}

/**
Expand Down

0 comments on commit 035cd6c

Please sign in to comment.