Skip to content
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

feat: add language filter to sub attributes #1274

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

ranim-n
Copy link
Contributor

@ranim-n ranim-n commented Nov 28, 2024

No description provided.

@ranim-n ranim-n added feature New feature or request core Relates to core API labels Nov 28, 2024
@ranim-n ranim-n self-assigned this Nov 28, 2024
@ranim-n ranim-n linked an issue Nov 28, 2024 that may be closed by this pull request
entry.key to (entry.value as CompactedEntity).toFilteredLanguageProperties(languageFilter)
!JSONLD_COMPACTED_ATTRIBUTE_CORE_MEMBERS.contains(entry.key) ->
entry.key to filterLanguageProperty(entry.value as Map<String, Any>, transformationParameters)
else -> entry.key to entry.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to keep entry as the argument (as you want) you can use entry.toPair()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current is easier to read as it is similar to other branches in the when

Copy link
Contributor

github-actions bot commented Nov 28, 2024

Test Results

   69 files  +  8     69 suites  +8   1m 27s ⏱️ +33s
1 096 tests +160  1 096 ✅ +160  0 💤 ±0  0 ❌ ±0 
1 135 runs  +160  1 135 ✅ +160  0 💤 ±0  0 ❌ ±0 

Results for commit 0403c57. ± Comparison against base commit f3d668b.

This pull request removes 189 and adds 193 tests. Note that renamed tests count towards both.
                                    { "id":…, withTemporalValues=true, withAudit=false, expectation={
                      "@id": "https://uri…
                      "@type": "@json",
                      …
                    "@value": "/A/B"
                    "@value": "/C/D"
                    "@value": 20
                    "…
                    {
                  "@type": "https://uri.etsi.org/ngsi-ld/DateTime",
…
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z"
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM"
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z"
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [1] source={
    "attribute": {
        "type": "Property",
        "value": 12.0,
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": 12.2,
        "unitCode": "GRM",
        "observedAt": "2024-04-14T12:34:56Z",
        "subAttribute": {
            "type": "Property",
            "value": "newSubAttributeValue"
        }
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [2] source={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "voiture" }
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": { "fr": "vélo", "es": "bicicleta" }
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": { "en": "car", "fr": "vélo", "es": "bicicleta" }
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [2] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 1, "b": null, "c": 12.4 },
        "observedAt": "2022-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z"
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "id": 2, "b": "something" },
        "observedAt": "2023-12-24T14:01:22.066Z",
        "subAttribute": {
            "type": "Property",
            "value": "subAttribute"
        }
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [3] source={
    "attribute": {
        "type": "Property",
        "value": [ "car", "voiture" ]
    }
}, target={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}, expected={
    "attribute": {
        "type": "Property",
        "value": [ "vélo", "bicicleta" ]
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [3] source={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "stellio"
    }
}, target={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}, expected={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [4] source={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:01"
    }
}, target={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}, expected={
    "attribute": {
        "type": "Relationship",
        "object": "urn:ngsi-ld:Entity:02"
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [5] source={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "train" }
    }
}, target={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "fr": "TGV", "es": "tren" }
    }
}, expected={
    "attribute": {
        "type": "LanguageProperty",
        "languageMap": { "en": "train", "fr": "TGV", "es": "tren" }
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [6] source={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 1, "b": "thing" }
    }
}, target={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "c": "other thing" }
    }
}, expected={
    "incoming": {
        "type": "JsonProperty",
        "json": { "a": 2, "b": "thing", "c": "other thing" }
    }
}
com.egm.stellio.search.entity.util.PatchAttributeTests ‑ [7] source={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "stellio"
    }
}, target={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}, expected={
    "attribute": {
        "type": "VocabProperty",
        "vocab": "egm"
    }
}
…

♻️ This comment has been updated with latest results.

@@ -42,6 +46,20 @@ typealias CompactedEntity = Map<String, Any>
typealias CompactedAttributeInstance = Map<String, Any>
typealias CompactedAttributeInstances = List<CompactedAttributeInstance>

val JSONLD_COMPACTED_ATTRIBUTE_CORE_MEMBERS =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSONLD_LANGUAGEMAP_TERM should be in the list (if it is not in the list, it is a trap for future users of your list)

entry.key to (entry.value as CompactedEntity).toFilteredLanguageProperties(languageFilter)
!JSONLD_COMPACTED_ATTRIBUTE_CORE_MEMBERS.contains(entry.key) ->
entry.key to filterLanguageProperty(entry.value as Map<String, Any>, transformationParameters)
else -> entry.key to entry.value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current is easier to read as it is similar to other branches in the when

@bobeal
Copy link
Member

bobeal commented Nov 29, 2024

I added a test that fails (but should not )

@bobeal bobeal force-pushed the feature/add-language-filter-to-sub-attributes branch from dc3fa78 to 10ed185 Compare November 30, 2024 09:05
Copy link
Member

@bobeal bobeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did some changes to remove detekt warning and more fluent processing

@ranim-n ranim-n force-pushed the feature/add-language-filter-to-sub-attributes branch from 10ed185 to 0403c57 Compare December 3, 2024 08:15
@ranim-n ranim-n merged commit 9417306 into develop Dec 3, 2024
11 checks passed
@ranim-n ranim-n deleted the feature/add-language-filter-to-sub-attributes branch December 3, 2024 08:26
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Relates to core API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LanguageProperty not being filtered on the subproperty level
3 participants