Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal committed Mar 23, 2024
2 parents aec1d53 + f3518c0 commit 6283c02
Show file tree
Hide file tree
Showing 94 changed files with 2,725 additions and 1,550 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/anchore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Assemble project
uses: gradle/gradle-build-action@v2
with:
arguments: assemble
run: ./gradlew assemble
- name: Upload jars artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ jobs:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/[email protected].1
uses: cla-assistant/[email protected].2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v4.1.1
- uses: TimonVS/pr-labeler-action@v5.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion api-gateway/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.4")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.5")
}

springBoot {
Expand Down
18 changes: 9 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ plugins {
`kotlin-dsl`
// only apply the plugin in the subprojects requiring it because it expects a Spring Boot app
// and the shared lib is obviously not one
id("org.springframework.boot") version "3.2.1" apply false
id("org.springframework.boot") version "3.2.4" apply false
id("io.spring.dependency-management") version "1.1.4" apply false
id("org.graalvm.buildtools.native") version "0.9.28"
kotlin("jvm") version "1.9.22" apply false
kotlin("plugin.spring") version "1.9.22" apply false
id("com.google.cloud.tools.jib") version "3.4.0" apply false
id("io.gitlab.arturbosch.detekt") version "1.23.4" apply false
id("org.graalvm.buildtools.native") version "0.10.1"
kotlin("jvm") version "1.9.23" apply false
kotlin("plugin.spring") version "1.9.23" apply false
id("com.google.cloud.tools.jib") version "3.4.1" apply false
id("io.gitlab.arturbosch.detekt") version "1.23.5" apply false
id("org.sonarqube") version "4.4.1.3373"
jacoco
}
Expand Down Expand Up @@ -64,10 +64,10 @@ subprojects {

implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

implementation("com.apicatalog:titanium-json-ld:1.3.3")
implementation("com.apicatalog:titanium-json-ld:1.4.0")
implementation("org.glassfish:jakarta.json:2.0.1")

implementation("io.arrow-kt:arrow-fx-coroutines:1.2.1")
implementation("io.arrow-kt:arrow-fx-coroutines:1.2.3")

implementation("org.locationtech.jts.io:jts-io-common:1.19.0")

Expand Down Expand Up @@ -104,7 +104,7 @@ subprojects {
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion("1.9.21")
useVersion("1.9.22")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions search-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ dependencies {
// implementation (and not runtime) because we are using the native jsonb encoding provided by PG
implementation("org.postgresql:r2dbc-postgresql")
implementation("com.github.stellio-hub:json-merge:0.1.0")
implementation("org.json:json:20231013")
implementation("org.json:json:20240303")
implementation(project(":shared"))

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.4")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.5")

developmentOnly("org.springframework.boot:spring-boot-devtools")

Expand Down
4 changes: 1 addition & 3 deletions search-service/config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<ID>LongMethod:V0_29__JsonLd_migration.kt$V0_29__JsonLd_migration$override fun migrate(context: Context)</ID>
<ID>LongParameterList:AttributeInstance.kt$AttributeInstance.Companion$( temporalEntityAttribute: UUID, instanceId: URI = generateRandomInstanceId(), timeAndProperty: Pair&lt;ZonedDateTime, TemporalProperty&gt;, value: Triple&lt;String?, Double?, WKTCoordinates?&gt;, payload: ExpandedAttributeInstance, sub: String? )</ID>
<ID>LongParameterList:AttributeInstance.kt$AttributeInstance.Companion$( temporalEntityAttribute: UUID, instanceId: URI = generateRandomInstanceId(), timeProperty: TemporalProperty? = TemporalProperty.OBSERVED_AT, modifiedAt: ZonedDateTime? = null, attributeMetadata: AttributeMetadata, payload: ExpandedAttributeInstance, time: ZonedDateTime, sub: String? = null )</ID>
<ID>LongParameterList:EntityEventService.kt$EntityEventService$( sub: String?, entityId: URI, attributeName: ExpandedTerm, datasetId: URI? = null, deleteAll: Boolean, contexts: List&lt;String&gt; )</ID>
<ID>LongParameterList:EntityEventService.kt$EntityEventService$( sub: String?, entityId: URI, jsonLdAttributes: Map&lt;String, Any&gt;, updateResult: UpdateResult, overwrite: Boolean, contexts: List&lt;String&gt; )</ID>
<ID>LongParameterList:EntityEventService.kt$EntityEventService$( updatedDetails: UpdatedDetails, sub: String?, tenantName: String, entityId: URI, entityTypesAndPayload: Pair&lt;List&lt;ExpandedTerm&gt;, String&gt;, serializedAttribute: Pair&lt;ExpandedTerm, String&gt;, overwrite: Boolean, contexts: List&lt;String&gt; )</ID>
<ID>LongParameterList:EntityEventService.kt$EntityEventService$( updatedDetails: UpdatedDetails, sub: String?, tenantName: String, entityId: URI, entityTypesAndPayload: Pair&lt;List&lt;ExpandedTerm&gt;, String&gt;, serializedAttribute: Pair&lt;ExpandedTerm, String&gt;, overwrite: Boolean )</ID>
<ID>LongParameterList:TemporalEntityAttributeService.kt$TemporalEntityAttributeService$( entityId: URI, attributeName: ExpandedTerm, attributeMetadata: AttributeMetadata, createdAt: ZonedDateTime, attributePayload: ExpandedAttributeInstance, sub: Sub? )</ID>
<ID>LongParameterList:TemporalEntityAttributeService.kt$TemporalEntityAttributeService$( entityUri: URI, ngsiLdAttributes: List&lt;NgsiLdAttribute&gt;, expandedAttributes: ExpandedAttributes, createdAt: ZonedDateTime, observedAt: ZonedDateTime?, sub: Sub? )</ID>
<ID>LongParameterList:TemporalEntityAttributeService.kt$TemporalEntityAttributeService$( entityUri: URI, ngsiLdAttributes: List&lt;NgsiLdAttribute&gt;, expandedAttributes: ExpandedAttributes, disallowOverwrite: Boolean, createdAt: ZonedDateTime, sub: Sub? )</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class ObservationEventListener(
entityEventService.publishEntityCreateEvent(
observationEvent.sub,
observationEvent.entityId,
expandJsonLdTerms(observationEvent.entityTypes, observationEvent.contexts),
observationEvent.contexts
expandJsonLdTerms(observationEvent.entityTypes, observationEvent.contexts)
)
}
}.writeContextAndSubscribe(tenantName, observationEvent)
Expand Down Expand Up @@ -115,8 +114,7 @@ class ObservationEventListener(
observationEvent.entityId,
expandedAttribute.toExpandedAttributes(),
it,
false,
observationEvent.contexts
false
)
}
}
Expand Down Expand Up @@ -153,8 +151,7 @@ class ObservationEventListener(
observationEvent.entityId,
expandedAttribute.toExpandedAttributes(),
it,
observationEvent.overwrite,
observationEvent.contexts
observationEvent.overwrite
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.egm.stellio.search.model

import com.egm.stellio.search.util.toJson
import com.egm.stellio.shared.model.ExpandedAttributeInstance
import com.egm.stellio.shared.model.WKTCoordinates
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_INSTANCE_ID_PROPERTY
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_MODIFIED_AT_PROPERTY
import com.egm.stellio.shared.util.JsonLdUtils.buildNonReifiedPropertyValue
import com.egm.stellio.shared.util.JsonLdUtils.buildNonReifiedTemporalValue
import com.egm.stellio.shared.util.JsonUtils.serializeObject
import com.egm.stellio.shared.util.toUri
import io.r2dbc.postgresql.codec.Json
import java.net.URI
Expand Down Expand Up @@ -66,8 +66,6 @@ data class AttributeInstance private constructor(
sub = sub
)

private fun ExpandedAttributeInstance.toJson(): Json = Json.of(serializeObject(this))

private fun ExpandedAttributeInstance.composePayload(
instanceId: URI,
modifiedAt: ZonedDateTime? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ data class EntityPayload(
val scopes: List<String>? = null,
val createdAt: ZonedDateTime,
val modifiedAt: ZonedDateTime? = null,
// creation time contexts
// FIXME only stored because needed to compact types at deletion time...
val contexts: List<String>,
val payload: Json,
val specificAccessPolicy: SpecificAccessPolicy? = null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ data class AttributeInfo(
enum class AttributeType(val key: String) {
Property("Property"),
Relationship("Relationship"),
GeoProperty("GeoProperty");
GeoProperty("GeoProperty"),
JsonProperty("JsonProperty");

companion object {
fun forKey(key: String): AttributeType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package com.egm.stellio.search.model

import com.egm.stellio.shared.model.ExpandedTerm
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_GEOPROPERTY_TYPE
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_GEOPROPERTY_VALUES
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_JSONPROPERTY_TYPE
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_JSONPROPERTY_VALUES
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_PROPERTY_TYPE
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_PROPERTY_VALUES
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_RELATIONSHIP_OBJECTS
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_RELATIONSHIP_TYPE
import io.r2dbc.postgresql.codec.Json
import org.springframework.data.annotation.Id
Expand Down Expand Up @@ -32,19 +37,33 @@ data class TemporalEntityAttribute(
DATETIME,
DATE,
TIME,
URI
URI,
JSON
}

enum class AttributeType {
Property,
Relationship,
GeoProperty;
GeoProperty,
JsonProperty;

fun toExpandedName(): String =
when (this) {
Property -> NGSILD_PROPERTY_TYPE.uri
Relationship -> NGSILD_RELATIONSHIP_TYPE.uri
GeoProperty -> NGSILD_GEOPROPERTY_TYPE.uri
JsonProperty -> NGSILD_JSONPROPERTY_TYPE.uri
}

/**
* Returns the key of the member for the simplified representation of the attribute, as defined in 4.5.9
*/
fun toSimpliedRepresentationKey(): String =
when (this) {
Property -> NGSILD_PROPERTY_VALUES
Relationship -> NGSILD_RELATIONSHIP_OBJECTS
GeoProperty -> NGSILD_GEOPROPERTY_VALUES
JsonProperty -> NGSILD_JSONPROPERTY_VALUES
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ class EntityEventService(
suspend fun publishEntityCreateEvent(
sub: String?,
entityId: URI,
entityTypes: List<ExpandedTerm>,
contexts: List<String>
entityTypes: List<ExpandedTerm>
): Job {
val tenantName = getTenantFromContext()
val entity = getSerializedEntity(entityId)
return coroutineScope.launch {
logger.debug("Sending create event for entity {} in tenant {}", entityId, tenantName)
entity.onRight {
publishEntityEvent(
EntityCreateEvent(sub, tenantName, entityId, entityTypes, it.second, contexts)
EntityCreateEvent(sub, tenantName, entityId, entityTypes, it.second, emptyList())
)
}.logEntityEvent(EventsType.ENTITY_CREATE, entityId, tenantName)
}
Expand All @@ -56,25 +55,23 @@ class EntityEventService(
suspend fun publishEntityReplaceEvent(
sub: String?,
entityId: URI,
entityTypes: List<ExpandedTerm>,
contexts: List<String>
entityTypes: List<ExpandedTerm>
): Job {
val tenantName = getTenantFromContext()
val entity = getSerializedEntity(entityId)
return coroutineScope.launch {
logger.debug("Sending replace event for entity {} in tenant {}", entityId, tenantName)
entity.onRight {
publishEntityEvent(
EntityReplaceEvent(sub, tenantName, entityId, entityTypes, it.second, contexts)
EntityReplaceEvent(sub, tenantName, entityId, entityTypes, it.second, emptyList())
)
}.logEntityEvent(EventsType.ENTITY_REPLACE, entityId, tenantName)
}
}

suspend fun publishEntityDeleteEvent(
sub: String?,
entityPayload: EntityPayload,
contexts: List<String>
entityPayload: EntityPayload
): Job {
val tenantName = getTenantFromContext()
return coroutineScope.launch {
Expand All @@ -86,7 +83,7 @@ class EntityEventService(
entityPayload.entityId,
entityPayload.types,
entityPayload.payload.asString(),
contexts
emptyList()
)
)
}
Expand All @@ -97,8 +94,7 @@ class EntityEventService(
entityId: URI,
jsonLdAttributes: Map<String, Any>,
updateResult: UpdateResult,
overwrite: Boolean,
contexts: List<String>
overwrite: Boolean
): Job {
val tenantName = getTenantFromContext()
val entity = getSerializedEntity(entityId)
Expand All @@ -116,8 +112,7 @@ class EntityEventService(
entityId,
it,
serializedAttribute,
overwrite,
contexts
overwrite
)
}
}.logAttributeEvent("Attribute Change", entityId, tenantName)
Expand All @@ -131,8 +126,7 @@ class EntityEventService(
entityId: URI,
entityTypesAndPayload: Pair<List<ExpandedTerm>, String>,
serializedAttribute: Pair<ExpandedTerm, String>,
overwrite: Boolean,
contexts: List<String>
overwrite: Boolean
) {
when (updatedDetails.updateOperationResult) {
UpdateOperationResult.APPENDED ->
Expand All @@ -147,7 +141,7 @@ class EntityEventService(
overwrite,
serializedAttribute.second,
entityTypesAndPayload.second,
contexts
emptyList()
)
)

Expand All @@ -162,7 +156,7 @@ class EntityEventService(
updatedDetails.datasetId,
serializedAttribute.second,
entityTypesAndPayload.second,
contexts
emptyList()
)
)

Expand All @@ -177,7 +171,7 @@ class EntityEventService(
updatedDetails.datasetId,
serializedAttribute.second,
entityTypesAndPayload.second,
contexts
emptyList()
)
)

Expand All @@ -194,8 +188,7 @@ class EntityEventService(
entityId: URI,
attributeName: ExpandedTerm,
datasetId: URI? = null,
deleteAll: Boolean,
contexts: List<String>
deleteAll: Boolean
): Job {
val tenantName = getTenantFromContext()
val entity = getSerializedEntity(entityId)
Expand All @@ -216,7 +209,7 @@ class EntityEventService(
it.first,
attributeName,
it.second,
contexts
emptyList()
)
)
else
Expand All @@ -229,7 +222,7 @@ class EntityEventService(
attributeName,
datasetId,
it.second,
contexts
emptyList()
)
)
}.logAttributeEvent("Attribute Delete", entityId, tenantName)
Expand Down
Loading

0 comments on commit 6283c02

Please sign in to comment.