Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
743b48f
WIP
gunplar Dec 10, 2024
5ad3974
WIP
gunplar Dec 11, 2024
b26b58f
WIP
gunplar Jan 3, 2025
4e2ee4f
WIP
gunplar Jan 9, 2025
b7f0855
WIP
gunplar Jan 10, 2025
38b7a45
WIP
gunplar Jan 11, 2025
9af1851
WIP
gunplar Jan 13, 2025
45eaa06
WIP
gunplar Jan 13, 2025
f3ac3e1
WIP
gunplar Jan 14, 2025
db597e8
WIP
gunplar Jan 15, 2025
da4f94f
Merge remote-tracking branch 'origin/v3' into v3-CASL-658-activitylog…
gunplar Jan 16, 2025
8e5e34e
fix compiler errors after merging
gunplar Jan 16, 2025
a657213
WIP
gunplar Jan 17, 2025
e98e748
refactor Action enum values
gunplar Jan 17, 2025
2c12204
Revert "refactor Action enum values"
gunplar Jan 17, 2025
2b381c6
fix test data temporarily until CASL-791
gunplar Jan 17, 2025
c36b019
Merge remote-tracking branch 'origin/v3' into v3-CASL-658-activitylog…
gunplar Jan 17, 2025
96c8649
gradle
gunplar Jan 17, 2025
7416abf
WIP new kotlin classes for activity log
gunplar Jan 20, 2025
53bd5c2
WIP new kotlin classes for activity log
gunplar Jan 20, 2025
6cd53ba
WIP
gunplar Jan 20, 2025
b8b6afa
disable old patcher in lib-core
gunplar Jan 20, 2025
eff731c
fix bug
gunplar Jan 20, 2025
9334854
remove old diff package
gunplar Jan 20, 2025
fead327
fix test
gunplar Jan 21, 2025
970e12d
add module to github cicd
gunplar Jan 21, 2025
99b2b53
Merge remote-tracking branch 'origin/v3' into v3-CASL-658-activitylog…
gunplar Jan 21, 2025
d0e97dd
remove old patcher
gunplar Jan 21, 2025
3f0d8ed
move gradle settings
gunplar Jan 21, 2025
c44a92b
fix assertion
gunplar Jan 21, 2025
ce17a52
Merge branch 'v3' into v3-CASL-658-activitylog-migration
Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reusable-build-and-publish-v3s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# run: gradle shadowJar jacocoTestReport jacocoTestCoverageVerification
shell: bash
run: |
array=( here-naksha-lib-model here-naksha-lib-base here-naksha-lib-core here-naksha-lib-psql here-naksha-lib-view here-naksha-storage-http here-naksha-lib-diff here-naksha-lib-handlers here-naksha-lib-hub )
array=( here-naksha-lib-model here-naksha-lib-base here-naksha-lib-core here-naksha-lib-psql here-naksha-lib-view here-naksha-storage-http here-naksha-lib-diff here-naksha-lib-handlers here-naksha-lib-hub here-naksha-handler-activitylog)
for item in ${array[@]}; do
gradle -x jsNodeTest :$item:build :$item:jacocoTestReport :$item:jacocoTestCoverageVerification
done
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
implementation("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:2.0.20")
implementation("org.jetbrains.kotlin.plugin.js-plain-objects:org.jetbrains.kotlin.plugin.js-plain-objects.gradle.plugin:2.0.20")
implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:2.1.0")
}
7 changes: 6 additions & 1 deletion here-naksha-handler-activitylog/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
plugins {
id("naksha.java")
id("naksha.publish")
kotlin("jvm")
}
description = "Naksha Activity Log Handler"
dependencies {
implementation(project(":here-naksha-lib-core"))
implementation(project(":here-naksha-lib-psql"))
implementation(project(":here-naksha-lib-handlers"))
implementation(project(":here-naksha-lib-diff"))

implementation(Lib.flipkart_zjsonpatch)
testImplementation(Lib.jayway_jsonpath)
testImplementation(Lib.mockito)
testImplementation(Lib.json_assert)
testImplementation(testFixtures(project(":here-naksha-lib-core")))
}
setOverallCoverage(0.4) // only increasing allowed!
setOverallCoverage(0.4) // only increasing allowed!
kotlin {
jvmToolchain(17)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@
*/
package com.here.naksha.handler.activitylog;

import naksha.model.XyzFeature;
import com.here.naksha.lib.core.models.geojson.implementation.namespaces.XyzNamespace;
import java.util.Comparator;
import naksha.model.XyzNs;
import naksha.model.objects.NakshaFeature;

public class ActivityLogComparator implements Comparator<XyzFeature> {
public class ActivityLogComparator implements Comparator<NakshaFeature> {

@Override
public int compare(XyzFeature featureA, XyzFeature featureB) {
public int compare(NakshaFeature featureA, NakshaFeature featureB) {
int updatedAtComparison = Long.compare(updatedAt(featureA), updatedAt(featureB));
if (updatedAtComparison == 0) {
return uuid(featureA).compareTo(uuid(featureB)) * -1;
}
return updatedAtComparison * -1;
}

private static String uuid(XyzFeature feature) {
private static String uuid(NakshaFeature feature) {
return xyzNamespace(feature).getUuid();
}

private static long updatedAt(XyzFeature feature) {
return xyzNamespace(feature).getUpdatedAt();
private static long updatedAt(NakshaFeature feature) {
return xyzNamespace(feature).getUpdatedAt().toLong();
}

private static XyzNamespace xyzNamespace(XyzFeature feature) {
return feature.getProperties().getXyzNamespace();
private static XyzNs xyzNamespace(NakshaFeature feature) {
return feature.getProperties().getXyz();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import static com.here.naksha.handler.activitylog.ReversePatchUtil.toJsonNode;

import com.fasterxml.jackson.databind.JsonNode;
import naksha.model.EXyzAction;
import naksha.model.XyzFeature;
import com.here.naksha.lib.core.models.geojson.implementation.namespaces.Original;
import com.here.naksha.lib.core.models.geojson.implementation.namespaces.XyzActivityLog;
import com.here.naksha.lib.core.models.geojson.implementation.namespaces.XyzNamespace;
import naksha.model.Action;
import naksha.model.XyzNs;
import naksha.model.objects.NakshaFeature;
import naksha.model.objects.NakshaProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand All @@ -38,34 +37,32 @@ public class ActivityLogEnhancer {

private ActivityLogEnhancer() {}

static XyzFeature enhanceWithActivityLog(
@NotNull XyzFeature newFeature, @Nullable XyzFeature oldFeature, @NotNull String spaceId) {
XyzActivityLog activityLog = activityLog(newFeature, oldFeature, spaceId);
newFeature.getProperties().setXyzActivityLog(activityLog);
static NakshaFeature enhanceWithActivityLog(
@NotNull NakshaFeature newFeature, @Nullable NakshaFeature oldFeature, @NotNull String spaceId) {
NakshaActivityLog activityLog = activityLog(newFeature, oldFeature, spaceId);
newFeature.getProperties().put(NakshaProperties.XYZ_ACTIVITY_LOG_NS, activityLog);
newFeature.setId(uuid(newFeature));
return newFeature;
}

private static XyzActivityLog activityLog(
@NotNull XyzFeature newFeature, @Nullable XyzFeature oldFeature, @NotNull String spaceId) {
final XyzNamespace xyzNamespace = xyzNamespace(newFeature);
final XyzActivityLog xyzActivityLog = new XyzActivityLog();
xyzActivityLog.setId(newFeature.getId());
xyzActivityLog.setOriginal(original(xyzNamespace, spaceId));
EXyzAction action = xyzNamespace.getAction();
if (action != null) {
xyzActivityLog.setAction(action);
}
xyzActivityLog.setDiff(calculateDiff(action, newFeature, oldFeature));
return xyzActivityLog;
private static NakshaActivityLog activityLog(
@NotNull NakshaFeature newFeature, @Nullable NakshaFeature oldFeature, @NotNull String spaceId) {
final XyzNs xyzNamespace = xyzNamespace(newFeature);
final NakshaActivityLog activityLog = new NakshaActivityLog();
activityLog.setId(newFeature.getId());
activityLog.setOriginal(original(xyzNamespace, spaceId));
Action action = xyzNamespace.getAction();
activityLog.setAction(action.toString());
activityLog.setDiff(calculateDiff(action, newFeature, oldFeature));
return activityLog;
}

private static Original original(@Nullable XyzNamespace xyzNamespace, @Nullable String spaceId) {
private static Original original(@Nullable XyzNs xyzNamespace, @Nullable String spaceId) {
Original original = new Original();
if (xyzNamespace != null) {
original.setPuuid(xyzNamespace.getPuuid());
original.setUpdatedAt(xyzNamespace.getUpdatedAt());
original.setCreatedAt(xyzNamespace.getCreatedAt());
original.setUpdatedAt(xyzNamespace.getUpdatedAt().toLong());
original.setCreatedAt(xyzNamespace.getCreatedAt().toLong());
}
if (spaceId != null) {
original.setSpace(spaceId);
Expand All @@ -74,10 +71,10 @@ private static Original original(@Nullable XyzNamespace xyzNamespace, @Nullable
}

private static @Nullable JsonNode calculateDiff(
@Nullable EXyzAction action, @NotNull XyzFeature newFeature, @Nullable XyzFeature oldFeature) {
if (action == null || EXyzAction.CREATE.equals(action) || EXyzAction.DELETE.equals(action)) {
@Nullable Action action, @NotNull NakshaFeature newFeature, @Nullable NakshaFeature oldFeature) {
if (action == null || Action.CREATED.equals(action) || Action.DELETED.equals(action)) {
return null;
} else if (EXyzAction.UPDATE.equals(action)) {
} else if (Action.UPDATED.equals(action)) {
if (oldFeature == null) {
logger.warn(
"Unable to calculate reversePatch for, missing predecessor for feature with uuid: {}, returning null",
Expand All @@ -91,11 +88,11 @@ private static Original original(@Nullable XyzNamespace xyzNamespace, @Nullable
}
}

private static String uuid(XyzFeature feature) {
private static String uuid(NakshaFeature feature) {
return xyzNamespace(feature).getUuid();
}

private static XyzNamespace xyzNamespace(XyzFeature feature) {
return feature.getProperties().getXyzNamespace();
private static XyzNs xyzNamespace(NakshaFeature feature) {
return feature.getProperties().getXyz();
}
}
Loading
Loading