-
Notifications
You must be signed in to change notification settings - Fork 1
LPD-55983 Add Entity Field Type for filter and serialize the URL with… #4955
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
Changes from all commits
cd4e9e8
673d311
3117fcb
aea719b
92de8d1
3fa4659
4948d60
f02267f
d2a1576
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,8 @@ function getValidFields({ | |
| }); | ||
| } | ||
|
|
||
| field.entityFieldType = type; | ||
|
|
||
| fields.push(field); | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -895,7 +895,14 @@ private JSONObject _serializeFilterClientExtension( | |
| return JSONUtil.put( | ||
| "clientExtensionFilterURL", fdsFilterCET.getURL() | ||
| ).put( | ||
| "entityFieldType", FDSEntityFieldTypes.STRING | ||
| "entityFieldType", | ||
| () -> { | ||
| if (Validator.isNotNull(properties.get("entityFieldType"))) { | ||
| return properties.get("entityFieldType"); | ||
| } | ||
|
|
||
| return FDSEntityFieldTypes.STRING; | ||
| } | ||
| ).put( | ||
| "id", fieldName | ||
| ).put( | ||
|
|
@@ -964,6 +971,10 @@ private JSONObject _serializeFilterSelection( | |
| Map<String, Object> properties, String sourceType) | ||
| throws Exception { | ||
|
|
||
| String entityFieldType = properties.get( | ||
| "entityFieldType" | ||
| ).toString(); | ||
|
|
||
| if (Objects.equals( | ||
| sourceType, FDSEntryItemImportPolicy.ITEM_PROXY.toString())) { | ||
|
|
||
|
|
@@ -987,6 +998,10 @@ private JSONObject _serializeFilterSelection( | |
| ).put( | ||
| "entityFieldType", | ||
| () -> { | ||
| if (Validator.isNotNull(entityFieldType)) { | ||
| return entityFieldType; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change represents a breaking change, as follows:
Another example:
Note FDS can't handle these values for entity field type, so odata query would be generated in a different way. This is the breaking change we'd like to avoid. We can fix it bu translating both |
||
| } | ||
|
|
||
| if (_isCollection( | ||
| String.valueOf(properties.get("fieldName")), | ||
| sourceType)) { | ||
|
|
@@ -997,20 +1012,7 @@ private JSONObject _serializeFilterSelection( | |
| return FDSEntityFieldTypes.STRING; | ||
| } | ||
| ).put( | ||
| "id", | ||
| () -> { | ||
| if (!Objects.equals(sourceType, "OBJECT_PICKLIST")) { | ||
| return fieldName; | ||
| } | ||
|
|
||
| int index = fieldName.lastIndexOf(StringPool.FORWARD_SLASH); | ||
|
|
||
| if (index <= 0) { | ||
| return fieldName; | ||
| } | ||
|
|
||
| return fieldName.substring(0, index); | ||
| } | ||
| "id", fieldName | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this code was removed? Is now object REST api able to filter by a picklist field using We had to add this special case for picklist because object REST api expects the parent field name (as exposed by the REST) even if the value used for comparison is a child field indeed. |
||
| ).put( | ||
| "label", | ||
| MapUtil.getWithFallbackKey(properties, "label", "fieldName") | ||
|
|
@@ -1075,7 +1077,17 @@ private JSONObject _serializeFilterSelection( | |
| listTypeEntry.getName( | ||
| PortalUtil.getLocale(httpServletRequest)) | ||
| ).put( | ||
| "value", listTypeEntry.getKey() | ||
| "value", | ||
| () -> { | ||
| if (Validator.isNotNull(entityFieldType) && | ||
| StringUtil.equalsIgnoreCase( | ||
| entityFieldType, FDSEntityFieldTypes.INTEGER)) { | ||
|
|
||
| return Integer.valueOf(listTypeEntry.getKey()); | ||
| } | ||
|
|
||
| return listTypeEntry.getKey(); | ||
| } | ||
| )) | ||
| ).put( | ||
| "preloadedData", | ||
|
|
@@ -1106,7 +1118,19 @@ private JSONObject _serializeFilterSelection( | |
| listTypeEntry.getName( | ||
| PortalUtil.getLocale(httpServletRequest)) | ||
| ).put( | ||
| "value", listTypeEntry.getKey() | ||
| "value", | ||
| () -> { | ||
| if (Validator.isNotNull(entityFieldType) && | ||
| StringUtil.equalsIgnoreCase( | ||
| entityFieldType, | ||
| FDSEntityFieldTypes.INTEGER)) { | ||
|
|
||
| return Integer.valueOf( | ||
| listTypeEntry.getKey()); | ||
| } | ||
|
|
||
| return listTypeEntry.getKey(); | ||
| } | ||
| )); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,13 +114,15 @@ function getOdataString({ | |
| } | ||
|
|
||
| const quotedSelectedItems = selectedItems.map((item) => | ||
| typeof item.value === 'string' || | ||
| entityFieldType === EEntityFieldType.STRING | ||
| ? `'${item.value}'` | ||
| : item.value | ||
| entityFieldType === EEntityFieldType.INTEGER | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 this is great, now we don't need to guess. This logic should be fine for old data sets which have |
||
| ? Number(item.value) | ||
| : `'${item.value}'` | ||
| ); | ||
|
|
||
| if (entityFieldType === EEntityFieldType.COLLECTION) { | ||
| if ( | ||
| entityFieldType === EEntityFieldType.COLLECTION || | ||
| entityFieldType === EEntityFieldType.ARRAY | ||
| ) { | ||
| return `${id}/any(x:${quotedSelectedItems | ||
| .map((value) => `(x ${exclude ? 'ne' : 'eq'} ${value})`) | ||
| .join(exclude ? ' and ' : ' or ')})`; | ||
|
|
||
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.
Note, this piece of code will make data set manager to store types like 'object' or 'array' as valid values for the entityFieldType field, in addition to the well known
string,dateorintegerThis is fine 👍 . At this level, we don't want to "translate" anything to the FDS domain but just persist information provided by REST openapi metadata.