-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature/csr retrieve entity #1246
base: feature/new-csr
Are you sure you want to change the base?
Conversation
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.
A first quick review
search-service/src/main/kotlin/com/egm/stellio/search/entity/service/EntityQueryService.kt
Outdated
Show resolved
Hide resolved
fun buildWHEREStatement(): String { | ||
val idsMatcher = if (ids.isNotEmpty()) "(" + | ||
"entity_info.id is null" + | ||
" OR entity_info.id in ('${ids.joinToString("', '")}')" + | ||
") AND (" + | ||
"entity_info.\"idPattern\" is null OR " + | ||
ids.map { "'$it' ~ entity_info.\"idPattern\"" }.joinToString(" OR ") + | ||
")" | ||
else "true" | ||
return idsMatcher |
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.
a bit ugly TBH. at least use multiline strings.
why not put it in CSRService like is done for other services?
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.
at least use multiline strings.
Yes
why not put it in CSRService like is done for other services?
I think it make more sense to put it there especially since the CSRService already do lot of stuff.
Do you see a reason why not?
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.
consistency with other services. And CSRService is only 230 lines...
search-service/src/main/kotlin/com/egm/stellio/search/csr/model/CSRFilters.kt
Outdated
Show resolved
Hide resolved
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Outdated
Show resolved
Hide resolved
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
21561cc
to
9d2ee23
Compare
9d2ee23
to
e89f92f
Compare
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.
PS: I still have to look at the merge algorithm
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Outdated
Show resolved
Hide resolved
|
||
val filteredExpandedEntity = ExpandedEntity( | ||
expandedEntity.filterAttributes(queryParams.attrs, queryParams.datasetId) | ||
val matchingCSR = contextSourceRegistrationService.getContextSourceRegistrations( |
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.
here you also have to filter CSRs that match the current operation (so retrieveEntity
in the operations or federationOps
in the operation groups)
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.
filtering the results from the call to the service is not a clean way to do it. it should be part of the call to the service.
search-service/src/test/kotlin/com/egm/stellio/search/entity/web/EntityHandlerTests.kt
Outdated
Show resolved
Hide resolved
shared/src/main/kotlin/com/egm/stellio/shared/util/ApiResponses.kt
Outdated
Show resolved
Hide resolved
shared/src/main/kotlin/com/egm/stellio/shared/model/ErrorResponse.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
…some typos and naming
search-service/src/test/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtilsTests.kt
Outdated
Show resolved
Hide resolved
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Outdated
Show resolved
Hide resolved
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Outdated
Show resolved
Hide resolved
...rvice/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceRegistrationService.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/entity/web/EntityHandler.kt
Outdated
Show resolved
Hide resolved
|
||
val filteredExpandedEntity = ExpandedEntity( | ||
expandedEntity.filterAttributes(queryParams.attrs, queryParams.datasetId) | ||
val matchingCSR = contextSourceRegistrationService.getContextSourceRegistrations( |
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.
filtering the results from the call to the service is not a clean way to do it. it should be part of the call to the service.
shared/src/main/kotlin/com/egm/stellio/shared/model/ErrorResponse.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
shared/src/main/kotlin/com/egm/stellio/shared/model/ApiExceptions.kt
Outdated
Show resolved
Hide resolved
… merging return warnings
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceCaller.kt
Outdated
Show resolved
Hide resolved
@@ -23,16 +24,25 @@ import java.util.regex.Pattern | |||
data class ContextSourceRegistration( | |||
val id: URI = "urn:ngsi-ld:ContextSourceRegistration:${UUID.randomUUID()}".toUri(), | |||
val endpoint: URI, | |||
val registrationName: String? = null, |
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.
don't forget to "bind" in CSRService (create and get operations)
search-service/src/test/kotlin/com/egm/stellio/search/csr/service/ContextSourceCallerTests.kt
Show resolved
Hide resolved
search-service/src/test/kotlin/com/egm/stellio/search/csr/service/ContextSourceCallerTests.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Outdated
Show resolved
Hide resolved
search-service/src/main/kotlin/com/egm/stellio/search/csr/service/ContextSourceUtils.kt
Show resolved
Hide resolved
remoteEntitiesWithMode.sortedBy { (_, csr) -> csr.isAuxiliary() } | ||
.forEach { (entity, csr) -> | ||
mergedEntity.putAll( | ||
getMergeNewValues(mergedEntity, entity, csr).toIor().toIorNel().bind() |
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.
this deserves a test to be sure we get the expected result if one or two merges fail
localEntity: CompactedEntity, | ||
remoteEntity: CompactedEntity, |
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.
when fixing merge conflicts, the terminology is current
and incoming
Quality Gate passedIssues Measures |
|
||
params.remove(QUERY_PARAM_GEOMETRY_PROPERTY) | ||
params.remove(QUERY_PARAM_OPTIONS) // only request normalized | ||
params.remove(QUERY_PARAM_LANG) // todo not sure its needed |
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.
it is handled when doing the final representation, so yes, it should be removed.
typealias DataSetId = String? | ||
typealias AttributeByDataSetId = Map<DataSetId, CompactedAttributeInstance> | ||
|
||
typealias AttributeByDataSetId = Map<String?, CompactedAttributeInstance> |
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.
still DataSetId
-> DatasetId
@@ -110,7 +111,7 @@ object ContextSourceUtils { | |||
if (values.size == 1) values[0] else values | |||
} | |||
|
|||
// do not work with CORE MEMBER since they are nor list nor map |
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.
I would instead say: only meant to work with attributes under the normalized representation
) | ||
verify( | ||
getRequestedFor(urlPathEqualTo(path)) | ||
.withHeader(ACCEPT, notContaining("GEO_JSON_MEDIA_TYPE")) |
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.
the value of the header is application/geo+json
(and not GEO_JSON_MEDIA_TYPE
)
} | ||
|
||
@Test | ||
fun `getDistributedInformation should not ask context source for a GEO_JSON`() = runTest { |
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.
getDistributedInformation should not ask context source for a GeoJson representation
} | ||
|
||
private fun getMergeNewValues( | ||
fun getMergeNewValues( |
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.
if it is just to be able to call it in the test, you can instead make it internal
@@ -804,6 +808,43 @@ class EntityHandlerTests { | |||
) | |||
} | |||
|
|||
@Test | |||
fun `get entity by id should return the warnings send by the csr and update the csr status`() { |
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.
... the warning sent by ...
Context Source registration working for retrieve entity.
some minimal testing ok with postman and the test suite
missing :