diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 461b2a0e..5816605b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,6 @@ name: Build DISCVR on: + workflow_dispatch: push: pull_request: jobs: diff --git a/LDK/api-src/org/labkey/api/ldk/table/AbstractDataDefinedTable.java b/LDK/api-src/org/labkey/api/ldk/table/AbstractDataDefinedTable.java index fe0cb3a8..a974a4d7 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/AbstractDataDefinedTable.java +++ b/LDK/api-src/org/labkey/api/ldk/table/AbstractDataDefinedTable.java @@ -57,7 +57,7 @@ * Date: 4/2/13 * Time: 2:54 PM */ -abstract public class AbstractDataDefinedTable extends CustomPermissionsTable +abstract public class AbstractDataDefinedTable extends CustomPermissionsTable { protected String _pk; @@ -65,7 +65,7 @@ abstract public class AbstractDataDefinedTable extends CustomPermissionsTable 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; @@ -77,7 +77,7 @@ public AbstractDataDefinedTable(UserSchema schema, SchemaTableInfo table, Contai } @Override - public CustomPermissionsTable init() + public CustomPermissionsTable init() { super.init(); @@ -85,7 +85,7 @@ public CustomPermissionsTable init() addCondition(col, _filterValue); //enforce only showing rows from this category List pks = getRealTable().getPkColumnNames(); - assert pks.size() > 0; + assert !pks.isEmpty(); _pk = pks.get(0); var valueCol = getMutableColumn(_valueColumn); @@ -93,7 +93,7 @@ public CustomPermissionsTable init() valueCol.setKeyField(true); valueCol.setNullable(false); - getMutableColumn(_pk).setKeyField(false); + getMutableColumnOrThrow(_pk).setKeyField(false); ColumnInfo filterCol = getColumn(_filterColumn); assert filterCol != null; @@ -135,7 +135,7 @@ protected class UpdateService extends SimpleQueryUpdateService { private final ValuesManager _vm; - public UpdateService(SimpleUserSchema.SimpleTable ti) + public UpdateService(SimpleUserSchema.SimpleTable ti) { super(ti, ti.getRealTable()); @@ -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; } diff --git a/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java b/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java index 3575eeca..40c6152b 100644 --- a/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java +++ b/LDK/api-src/org/labkey/api/ldk/table/ContainerScopedTable.java @@ -287,7 +287,8 @@ public Object call() Object pesudoPkVal = it.getInputColumnValue(inputColMap.get(_pseudoPk)); if (pesudoPkVal != null) { - if (_context.getInsertOption() != QueryUpdateService.InsertOption.MERGE && keyManager.rowExists(c, pesudoPkVal)) + // NOTE: this code is called for both inserts and updates: + if (_context.getInsertOption() == QueryUpdateService.InsertOption.INSERT && keyManager.rowExists(c, pesudoPkVal)) { _context.getErrors().addRowError(new ValidationException("A record is already present with value: " + pesudoPkVal)); } diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index 23cdbdf6..7503a70a 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -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; @@ -1415,6 +1418,7 @@ private void samplesTableTest() throws Exception columnLabels.add(getColumnLabel(srr, name)); } + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); List> rows = new ArrayList<>(); for (Map row : srr.getRows()) { @@ -1425,7 +1429,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) ? "" : ExcelHelper.getDateTimeFormat().format(Date.parse(val)); } target.add(val); diff --git a/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java b/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java index 72fe0ef3..a1611849 100644 --- a/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java +++ b/laboratory/src/org/labkey/laboratory/query/LaboratoryTableCustomizer.java @@ -19,7 +19,6 @@ import org.labkey.api.data.SQLFragment; import org.labkey.api.data.TableCustomizer; import org.labkey.api.data.TableInfo; -import org.labkey.api.data.WrappedColumnInfo; import org.labkey.api.gwt.client.FacetingBehaviorType; import org.labkey.api.laboratory.LaboratoryService; import org.labkey.api.ldk.LDKService; @@ -184,7 +183,8 @@ public void customizeColumns(AbstractTableInfo ti) { container.setHidden(true); - BaseColumnInfo wrappedContainer = WrappedColumnInfo.wrapAsCopy(ti, FieldKey.fromString("workbook"), container, "Workbook", null); + ExprColumn wrappedContainer = new ExprColumn(ti, FieldKey.fromString("workbook"), container.getValueSql(ExprColumn.STR_TABLE_ALIAS), container.getJdbcType(), container); + wrappedContainer.setLabel("Workbook"); wrappedContainer.setName("workbook"); wrappedContainer.setCalculated(true); wrappedContainer.setShownInInsertView(false); @@ -373,7 +373,8 @@ private void appendMajorEventsCol(final UserSchema us, AbstractTableInfo ds, fin final String pkColSelectName = pk.getFieldKey().toSQLString(); final String pkColRawName = pk.getName(); - BaseColumnInfo col = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(name), pk, "Major Events", null); + BaseColumnInfo col = new ExprColumn(ds, FieldKey.fromString(name), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col.setLabel("Major Events"); col.setDescription("This column shows all major events recorded in this subject's history and will calculate the time elapsed between the current sample and these dates."); col.setName(name); col.setCalculated(true); @@ -454,7 +455,8 @@ private void appendOverlapingProjectsCol(final UserSchema us, AbstractTableInfo final String subjectSelectName = ds.getSqlDialect().makeLegalIdentifier(subjectColName); final String dateSelectName = dateColName == null ? null : ds.getSqlDialect().makeLegalIdentifier(dateColName); - BaseColumnInfo col = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(name), pk, "Overlapping Groups", null); + BaseColumnInfo col = new ExprColumn(ds, FieldKey.fromString(name), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col.setLabel("Overlapping Groups"); col.setDescription("This column shows all groups to which this subject belonged at the time of this sample."); col.setName(name); col.setCalculated(true); @@ -503,7 +505,8 @@ public TableInfo getLookupTableInfo() //add pivot column String pivotColName = "overlappingProjectsPivot"; - BaseColumnInfo col2 = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(pivotColName), pk, "Overlapping Group List", null); + BaseColumnInfo col2 = new ExprColumn(ds, FieldKey.fromString(pivotColName), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col2.setLabel("Overlapping Group List"); col2.setName(pivotColName); col2.setCalculated(true); col2.setShownInInsertView(false); @@ -572,7 +575,8 @@ public void appendProjectsCol(final UserSchema us, AbstractTableInfo ds, final S final String publicTableName = ds.getPublicName(); final String colName = ds.getName() + "_allProjects"; - BaseColumnInfo col = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(name), pk, "Groups", null); + BaseColumnInfo col = new ExprColumn(ds, FieldKey.fromString(name), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col.setLabel("Groups"); col.setName(name); col.setCalculated(true); col.setShownInInsertView(false); @@ -622,7 +626,8 @@ public TableInfo getLookupTableInfo() //add pivot column String pivotColName = "allProjectsPivot"; final String lookupName = ds.getName() + "_allProjectsPivot"; - BaseColumnInfo col2 = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(pivotColName), pk, "Group Summary List", null); + BaseColumnInfo col2 = new ExprColumn(ds, FieldKey.fromString(pivotColName), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col2.setLabel("Group Summary List"); col2.setName(pivotColName); col2.setCalculated(true); col2.setShownInInsertView(false); @@ -772,7 +777,8 @@ private void appendRelativeDatesCol(final UserSchema us, AbstractTableInfo ds, f final String pkColSelectName = pk.getFieldKey().toSQLString(); final String pkColRawName = pk.getName(); - BaseColumnInfo col = WrappedColumnInfo.wrapAsCopy(ds, FieldKey.fromString(name), pk, "Relative Dates", null); + BaseColumnInfo col = new ExprColumn(ds, FieldKey.fromString(name), pk.getValueSql(ExprColumn.STR_TABLE_ALIAS), pk.getJdbcType(), pk); + col.setLabel("Relative Dates"); col.setName(name); col.setCalculated(true); col.setShownInInsertView(false);