Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
* Date: 4/2/13
* Time: 2:54 PM
*/
abstract public class AbstractDataDefinedTable extends CustomPermissionsTable
abstract public class AbstractDataDefinedTable<SchemaType extends UserSchema> extends CustomPermissionsTable<SchemaType>
{
protected String _pk;

protected String _filterColumn;
protected String _filterValue;
protected String _valueColumn;

public AbstractDataDefinedTable(UserSchema schema, SchemaTableInfo table, ContainerFilter cf, String filterColumn, String valueColumn, String tableName, String filterValue)
public AbstractDataDefinedTable(SchemaType schema, SchemaTableInfo table, ContainerFilter cf, String filterColumn, String valueColumn, String tableName, String filterValue)
{
super(schema, table, cf);
_filterColumn = filterColumn;
Expand All @@ -77,23 +77,23 @@ public AbstractDataDefinedTable(UserSchema schema, SchemaTableInfo table, Contai
}

@Override
public CustomPermissionsTable init()
public CustomPermissionsTable<SchemaType> init()
{
super.init();

ColumnInfo col = getRealTable().getColumn(_filterColumn);
addCondition(col, _filterValue); //enforce only showing rows from this category

List<String> pks = getRealTable().getPkColumnNames();
assert pks.size() > 0;
assert !pks.isEmpty();
_pk = pks.get(0);

var valueCol = getMutableColumn(_valueColumn);
assert valueCol != null;

valueCol.setKeyField(true);
valueCol.setNullable(false);
getMutableColumn(_pk).setKeyField(false);
getMutableColumnOrThrow(_pk).setKeyField(false);

ColumnInfo filterCol = getColumn(_filterColumn);
assert filterCol != null;
Expand Down Expand Up @@ -135,7 +135,7 @@ protected class UpdateService extends SimpleQueryUpdateService
{
private final ValuesManager _vm;

public UpdateService(SimpleUserSchema.SimpleTable ti)
public UpdateService(SimpleUserSchema.SimpleTable<SchemaType> ti)
{
super(ti, ti.getRealTable());

Expand Down Expand Up @@ -217,8 +217,7 @@ public boolean testIfRowExists(String value)
{
boolean ret = _distinctValues.contains(value);

if (!_distinctValues.contains(value))
_distinctValues.add(value);
_distinctValues.add(value);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
package org.labkey.test.tests.external.labModules;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.api.util.DateUtil;
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.collections.CaseInsensitiveHashMap;
Expand Down Expand Up @@ -301,6 +304,9 @@ private void dateParseTest() throws ParseException
String dateFormat3 = "MM/dd/yy";
checkDate("02/20/11", dateFormat3);
checkDate("3/5/99", dateFormat3);

String clientFormattedString = (String)executeScript("return Ext4.Date.format(LDK.ConvertUtils.parseDate('2024-01-01', 'c'), 'Y-m-d');");
assertEquals("Incorrect date parsing", clientFormattedString, "2024-01-01");
}

private void checkDate(String dateStr, String javaFormatStr) throws ParseException
Expand Down Expand Up @@ -1415,6 +1421,7 @@ private void samplesTableTest() throws Exception
columnLabels.add(getColumnLabel(srr, name));
}

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<List<String>> rows = new ArrayList<>();
for (Map<String, Object> row : srr.getRows())
{
Expand All @@ -1425,7 +1432,7 @@ private void samplesTableTest() throws Exception
String val = row.get(name) == null ? "" : String.valueOf(row.get(name));
if (name.toLowerCase().contains("date"))
{
val = StringUtils.isEmpty(val) ? "" : ExcelHelper.getDateTimeFormat().format(new Date(val));
val = StringUtils.isEmpty(val) ? "" : dateFormat.format(Date.parse(val));
}

target.add(val);
Expand All @@ -1440,10 +1447,10 @@ private void samplesTableTest() throws Exception
List<List<String>> lines = ExcelHelper.getFirstNRows(sheet, 5);

Assert.assertEquals(columnLabels, lines.get(0));
Assert.assertEquals(rows.get(0), lines.get(1));
Assert.assertEquals(rows.get(0), lines.get(2));
Assert.assertEquals(rows.get(1), lines.get(3));
Assert.assertEquals(rows.get(1), lines.get(4));
Assert.assertEquals("Row did not match. ExcelHelper pattern: " + ExcelHelper.getDateTimeFormat().toPattern(), rows.get(0), lines.get(1));
Assert.assertEquals("Row did not match. ExcelHelper pattern: " + ExcelHelper.getDateTimeFormat().toPattern(), rows.get(0), lines.get(2));
Assert.assertEquals("Row did not match. ExcelHelper pattern: " + ExcelHelper.getDateTimeFormat().toPattern(), rows.get(1), lines.get(3));
Assert.assertEquals("Row did not match. ExcelHelper pattern: " + ExcelHelper.getDateTimeFormat().toPattern(), rows.get(1), lines.get(4));
}

refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ALTER TABLE laboratory.species ADD createdby int;
ALTER TABLE laboratory.species ADD modified timestamp;
ALTER TABLE laboratory.species ADD modifiedby int;

UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers WHERE name = 'Shared');
UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers c1 WHERE name = 'Shared' and (select parent from core.Containers c2 where c2.EntityId = c1.Parent) is null);

ALTER TABLE laboratory.species DROP CONSTRAINT PK_species;
ALTER TABLE laboratory.species ADD CONSTRAINT PK_species PRIMARY KEY (rowid);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ALTER TABLE laboratory.species ADD createdby int;
ALTER TABLE laboratory.species ADD modified datetime;
ALTER TABLE laboratory.species ADD modifiedby int;
GO
UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers WHERE name = 'Shared');
UPDATE laboratory.species SET container = (SELECT entityid FROM core.containers c1 WHERE name = 'Shared' and (select parent from core.Containers c2 where c2.EntityId = c1.Parent) is null);

ALTER TABLE laboratory.species DROP CONSTRAINT PK_species;
ALTER TABLE laboratory.species ADD CONSTRAINT PK_species PRIMARY KEY (rowid);