-
Notifications
You must be signed in to change notification settings - Fork 7
mvtc empty #7348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
labkey-matthewb
wants to merge
34
commits into
develop
Choose a base branch
from
fb_mvtc_empty
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+985
−276
Open
mvtc empty #7348
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
685f9ed
Multi choices
XingY 322bd91
Multi value text choices
XingY 672a750
fix empty array
XingY 11f042c
crlf
XingY 65538dc
support filters
XingY 5a017c6
Merge remote-tracking branch 'origin/develop' into fb_mvtc
XingY 9801a9c
clean
XingY afbfda0
fix
XingY c628cc8
order inputs
XingY 3283986
Merge remote-tracking branch 'origin/develop' into fb_mvtc
XingY 16150fc
order elements of a MultiChoice.Array
labkey-matthewb 3013578
explicit null/isBlank() tests
labkey-matthewb 74f54e4
bug fixes
XingY 9e711cc
fix assay import
XingY 21cc32b
fix assay import
XingY 4aabc6b
code review changes
XingY defb3c1
show advanced settings
XingY 0edb7ec
Fix study dataset multi value crud
XingY c34b984
code review changes
XingY 6630ad0
Merge remote-tracking branch 'origin/develop' into fb_mvtc
XingY a96ac32
code review changes
XingY 61693b3
Merge remote-tracking branch 'origin/develop' into fb_mvtc_empty
labkey-matthewb 3059b18
SimpleConvert
labkey-matthewb 421a026
SimpleConvert
labkey-matthewb b446305
JdbcType.isEmpty()
labkey-matthewb e3e491b
Merge remote-tracking branch 'origin/develop' into fb_mvtc_empty
labkey-matthewb e7b3df9
add to the right branch
labkey-matthewb b1a9acd
Merge remote-tracking branch 'origin/develop' into fb_mvtc_empty
labkey-matthewb 6740d1a
merge from develop
XingY 03c2f64
fix selectRows api
XingY b2c1fca
add compare type for array is null
XingY e4b9f51
fix check
labkey-matthewb 910d2a0
fix comparator
XingY 5212b4e
Merge remote-tracking branch 'origin/develop' into fb_mvtc_empty
labkey-matthewb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,259 @@ | ||
| <%@ page import="org.labkey.api.data.JdbcType" %> | ||
| <%@ page import="org.junit.Test" %> | ||
| <%@ page import="static org.junit.Assert.*" %> | ||
| <%@ page import="org.labkey.api.data.BaseColumnInfo" %> | ||
| <%@ page import="org.jetbrains.annotations.NotNull" %> | ||
| <%@ page import="java.math.BigDecimal" %> | ||
| <%@ page import="org.labkey.api.exp.PropertyType" %> | ||
| <%@ page import="org.labkey.api.ontology.Quantity" %> | ||
| <%@ page import="org.labkey.api.ontology.Unit" %> | ||
| <%@ page import="org.labkey.api.ontology.KindOfQuantity" %> | ||
| <%@ page import="org.labkey.api.data.MutableColumnInfo" %> | ||
| <%@ page import="org.labkey.api.data.WrappedColumnInfo" %> | ||
| <%@ page import="org.apache.commons.beanutils.ConversionException" %> | ||
| <%@ page import="org.labkey.api.data.ColumnInfo" %> | ||
| <%@ page import="org.labkey.api.data.dialect.SqlDialect" %> | ||
| <%@ page import="org.labkey.api.data.CoreSchema" %> | ||
| <%@ page import="java.nio.ByteBuffer" %> | ||
| <%@ page extends="org.labkey.api.jsp.JspTest.BVT" %> | ||
| <%-- | ||
| This tests uses MockRequest to test some expected Headers and Meta tags for various types of requests. | ||
| --%> | ||
| <%! | ||
| void testConvert(ColumnInfo col, Object expected, Object val) | ||
| { | ||
| var result = col.convert(val); | ||
| assertNotNull(result); | ||
| assertEquals(col.getJdbcType().getJavaClass(), result.getClass()); | ||
| assertEquals(expected, result); | ||
| } | ||
|
|
||
| void testConvertsToNull(ColumnInfo col, Object val) | ||
| { | ||
| var result = col.convert(val); | ||
| assertNull(result); | ||
| } | ||
|
|
||
| void testConversionException(ColumnInfo col, Object val) | ||
| { | ||
| try | ||
| { | ||
| col.convert(val); | ||
| fail(); | ||
| } | ||
| catch (ConversionException x) | ||
| { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| void testConvert(JdbcType type, Object expected, Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, type); | ||
| testConvert(col.lock(), expected, val); | ||
| } | ||
|
|
||
| void testConvertsToNull(JdbcType type, Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, type); | ||
| testConvertsToNull(col.lock(), val); | ||
| } | ||
|
|
||
| void testConversionException(JdbcType type, Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, type); | ||
| testConversionException(col.lock(), val); | ||
| } | ||
|
|
||
| void testConvert(PropertyType pt, Object expected, @NotNull Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, pt.getJdbcType()); | ||
| col.setPropertyType(pt); | ||
| testConvert(col.lock(), expected, val); | ||
| } | ||
|
|
||
| void testConvertsToNull(PropertyType pt, Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, pt.getJdbcType()); | ||
| col.setPropertyType(pt); | ||
| testConvertsToNull(col.lock(), val); | ||
| } | ||
|
|
||
| void testConversionException(PropertyType pt, Object val) | ||
| { | ||
| var col = new BaseColumnInfo("~", null, pt.getJdbcType()); | ||
| col.setPropertyType(pt); | ||
| testConversionException(col.lock(), val); | ||
| } | ||
|
|
||
| void testQuantity(Unit displayUnit, Quantity expected, Object value) | ||
| { | ||
| // UNDONE: setDisplayUnit is NYI??? | ||
| var col = new BaseColumnInfo("~", null, JdbcType.DOUBLE) | ||
| { | ||
| @Override | ||
| public Unit getDisplayUnit() | ||
| { | ||
| return displayUnit; | ||
| } | ||
|
|
||
| @Override | ||
| public KindOfQuantity getKindOfQuantity() | ||
| { | ||
| return null==displayUnit ? null : displayUnit.getKindOfQuantity(); | ||
| } | ||
| }; | ||
| testConvert(col.lock(), expected, value); | ||
| } | ||
|
|
||
|
|
||
| /** This test is for the integrated ColumnInfo.convert() logic. | ||
| * <p></p> | ||
| * A lot of this testing is redunant with lower-level unit testing, | ||
| * however, his till servers as a basic conversion smoke test. | ||
| * <p></p> | ||
| * In particualr, the PropertyType conversions are pretty | ||
| * redundant with ConvertHelper.convert() and JdbcType.convert() | ||
| * (PropertyType predates JdbcType), but there are some differenes | ||
| * in implementation. We should try to reconcile these differences. | ||
| */ | ||
| // @Test | ||
| public void testColumnConvert() throws Exception | ||
| { | ||
| // see also ConvertHelper.testEmpty() | ||
|
|
||
| // w/o propertyType | ||
| for (JdbcType type : JdbcType.values()) | ||
| { | ||
| switch (type) | ||
| { | ||
| case BIGINT -> | ||
| { | ||
| testConvert(type, Long.valueOf(5), Integer.valueOf(5)); | ||
| testConvert(type, Long.valueOf(5), "5"); | ||
| testConvert(type, Long.valueOf(5), Double.valueOf(5.00000)); | ||
| testConversionException(type, Double.valueOf(5.00001)); | ||
| testConvert(type, Long.valueOf(5), new BigDecimal("5.000")); | ||
| testConversionException(type, new BigDecimal("5.001")); | ||
| testConversionException(type, "5g"); | ||
| testConvertsToNull(type, ""); | ||
| testConvertsToNull(type, null); | ||
| } | ||
| case BINARY, LONGVARBINARY, VARBINARY -> | ||
| { | ||
| testConvert(type, ByteBuffer.wrap(new byte[] {0x00,0x00,0x00,0x05}), Long.valueOf(5)); | ||
| } | ||
| case BOOLEAN -> {} | ||
| case CHAR,LONGVARCHAR,VARCHAR -> | ||
| { | ||
| testConvertsToNull(type, null); | ||
| // NOTE StandardDataIterator optionally trims, but convert() does not. | ||
| // see SimpleTranslator.createConvertColumn() | ||
| testConvert(type, " no trim ", " no trim "); | ||
| // JdbcType does not convert empty string to null, ColumnInfo.convert() and PropertyType.conver() do | ||
| assertEquals("", type.convert("")); | ||
| testConvertsToNull(type, ""); | ||
| testConvertsToNull(type, null); | ||
| } | ||
| case DECIMAL -> {} | ||
| case DOUBLE -> {} | ||
| case INTEGER -> {} | ||
| case REAL -> {} | ||
| case SMALLINT, TINYINT -> {} | ||
| case DATE -> {} | ||
| case TIME -> {} | ||
| case TIMESTAMP -> {} | ||
| case GUID -> {} | ||
| case ARRAY, NULL, OTHER -> { /* ignore */ } | ||
| default -> fail("We missed a JdbcType: " + type.name()); | ||
| } | ||
| } | ||
|
|
||
| // testArray() | ||
|
|
||
| // w/ propertyType | ||
| for (var type : PropertyType.values()) | ||
| { | ||
| switch (type) | ||
| { | ||
| case BOOLEAN -> {} | ||
| case STRING -> | ||
| { | ||
| testConvertsToNull(type, null); | ||
| testConvertsToNull(type, ""); | ||
| testConvert(type, " no trim ", " no trim "); | ||
| } | ||
| case MULTI_LINE -> | ||
| { | ||
| testConvertsToNull(type, null); | ||
| testConvertsToNull(type, ""); | ||
| testConvert(type, " no trim ", " no trim "); | ||
| } | ||
| case MULTI_CHOICE -> {} | ||
| case RESOURCE -> {} | ||
| case INTEGER -> {} | ||
| case BIGINT -> | ||
| { | ||
| testConvert(type, Long.valueOf(5), Integer.valueOf(5)); | ||
| testConvert(type, Long.valueOf(5), "5"); | ||
| testConvert(type, Long.valueOf(5), new BigDecimal("5.001")); | ||
| testConvertsToNull(type, null); | ||
| testConvertsToNull(type, ""); | ||
| testConversionException(type, "5g"); | ||
| } | ||
| case BINARY -> {} | ||
| case FILE_LINK -> {} | ||
| case ATTACHMENT -> {} | ||
| case DATE_TIME -> {} | ||
| case DATE -> {} | ||
| case TIME -> {} | ||
| case DOUBLE -> {} | ||
| case FLOAT -> {} | ||
| case DECIMAL -> {} | ||
| case XML_TEXT -> {} | ||
| default -> fail("We missed a PropertyType: " + type.name()); | ||
| } | ||
| } | ||
|
|
||
| // Quantity | ||
| Unit unit = Unit.kg; | ||
| testQuantity(unit, Quantity.of(5000,unit.getBase()), "5"); | ||
| } | ||
|
|
||
|
|
||
| public void testLocked(MutableColumnInfo col) | ||
| { | ||
| col.setAlias("!"); | ||
| col.lock(); | ||
| try | ||
| { | ||
| col.setAlias("!"); | ||
| fail("not locked?"); | ||
| } | ||
| catch (IllegalStateException x) | ||
| { | ||
| // success | ||
| } | ||
| } | ||
|
|
||
| static class _ColumnInfo extends BaseColumnInfo | ||
| { | ||
| _ColumnInfo() | ||
| { | ||
| super("~", JdbcType.INTEGER); | ||
| } | ||
|
|
||
| @Override | ||
| public SqlDialect getSqlDialect() | ||
| { | ||
| return CoreSchema.getInstance().getSqlDialect(); | ||
| } | ||
| } | ||
|
|
||
| // @Test | ||
| public void testLocked() | ||
| { | ||
| testLocked(new _ColumnInfo()); | ||
| testLocked(WrappedColumnInfo.wrap(new _ColumnInfo())); | ||
| } | ||
| %> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple spelling errors in the comment: "redunant" should be "redundant", "his till servers" should be "this still serves", "particualr" should be "particular", and "differenes" should be "differences".