From 93dfea996980648f4665f91508f4db8b03d9acc3 Mon Sep 17 00:00:00 2001 From: soimugeo Date: Mon, 6 Jan 2025 16:03:46 +0200 Subject: [PATCH] Revert "fix for https://github.com/who-icatx/icatx-project/issues/142" This reverts commit 57738c083203bfdd49973d48fdc06e8c63be4bfc. --- .../dto/LinearizationDefinition.java | 34 +++++++++---------- ...tcoordinationFromParentCommandHandler.java | 2 +- ...PostCoordinationSpecificationRevision.java | 22 +++++++----- .../changes/ProjectChangesManager.java | 6 ++-- .../diff/Revision2DiffElementsTranslator.java | 4 +-- .../Revision2DiffElementsTranslatorTest.java | 4 +-- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/dto/LinearizationDefinition.java b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/dto/LinearizationDefinition.java index b9a18b7..a7021f4 100644 --- a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/dto/LinearizationDefinition.java +++ b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/dto/LinearizationDefinition.java @@ -6,13 +6,13 @@ public class LinearizationDefinition { - @JsonProperty("linearizationId") - private final String linearizationId; + @JsonProperty("Id") + private final String id; - @JsonProperty("linearizationUri") - private final String linearizationUri; + @JsonProperty("whoficEntityIri") + private final String whoficEntityIri; - @JsonProperty("description") + @JsonProperty("Description") private final String description; @JsonProperty("linearizationMode") @@ -27,7 +27,7 @@ public class LinearizationDefinition { @JsonProperty("sortingCode") private final String sortingCode; - @JsonProperty("displayLabel") + @JsonProperty("DisplayLabel") private final String displayLabel; @JsonProperty("oldId") @@ -35,17 +35,17 @@ public class LinearizationDefinition { @JsonCreator - public LinearizationDefinition(@JsonProperty("linearizationId") String linearizationId, - @JsonProperty("linearizationUri") String linearizationUri, + public LinearizationDefinition(@JsonProperty("Id") String id, + @JsonProperty("whoficEntityIri") String whoficEntityIri, @JsonProperty("oldId") String oldId, - @JsonProperty("description")String description, - @JsonProperty("linearizationMode") String linearizationMode, - @JsonProperty("displayLabel") String displayLabel, + @JsonProperty("Description")String description, + @JsonProperty("LinearizationMode") String linearizationMode, + @JsonProperty("DisplayLabel") String displayLabel, @JsonProperty("rootId") String rootId, @JsonProperty("CoreLinId") String coreLinId, @JsonProperty("sortingCode") String sortingCode) { - this.linearizationId = linearizationId; - this.linearizationUri = linearizationUri; + this.id = id; + this.whoficEntityIri = whoficEntityIri; this.description = description; this.linearizationMode = linearizationMode; this.rootId = rootId; @@ -55,12 +55,12 @@ public LinearizationDefinition(@JsonProperty("linearizationId") String lineariza this.displayLabel = displayLabel; } - public String getLinearizationId() { - return linearizationId; + public String getId() { + return id; } - public String getLinearizationUri() { - return linearizationUri; + public String getWhoficEntityIri() { + return whoficEntityIri; } public String getLinearizationMode() { diff --git a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/handlers/CreatePostcoordinationFromParentCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/handlers/CreatePostcoordinationFromParentCommandHandler.java index e89bfd9..d2f3d53 100644 --- a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/handlers/CreatePostcoordinationFromParentCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/handlers/CreatePostcoordinationFromParentCommandHandler.java @@ -51,7 +51,7 @@ public Mono handleRequest(CreatePostco var parentWhoficSpec = eventProcessor.processHistory(parentWhoficHistory); parentWhoficSpec.postcoordinationSpecifications().forEach(spec -> { - var currDef = definitionList.stream().filter(lin -> lin.getLinearizationUri().equalsIgnoreCase(spec.getLinearizationView())).findFirst(); + var currDef = definitionList.stream().filter(lin -> lin.getWhoficEntityIri().equalsIgnoreCase(spec.getLinearizationView())).findFirst(); if (currDef.isEmpty()) { return; } diff --git a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/model/PostCoordinationSpecificationRevision.java b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/model/PostCoordinationSpecificationRevision.java index 5fb5900..002dd66 100644 --- a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/model/PostCoordinationSpecificationRevision.java +++ b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/model/PostCoordinationSpecificationRevision.java @@ -2,25 +2,31 @@ import com.google.common.base.Objects; -import edu.stanford.protege.webprotege.common.*; +import edu.stanford.protege.webprotege.common.ChangeRequestId; +import edu.stanford.protege.webprotege.common.UserId; import edu.stanford.protege.webprotege.postcoordinationservice.dto.LinearizationDefinition; -import edu.stanford.protege.webprotege.postcoordinationservice.events.*; +import edu.stanford.protege.webprotege.postcoordinationservice.events.AddToDefaultAxisEvent; +import edu.stanford.protege.webprotege.postcoordinationservice.events.AddToNotAllowedAxisEvent; +import edu.stanford.protege.webprotege.postcoordinationservice.events.PostCoordinationSpecificationEvent; import org.jetbrains.annotations.NotNull; import org.springframework.data.mongodb.core.index.*; -import java.util.*; +import java.time.Instant; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public record PostCoordinationSpecificationRevision(UserId userId, @Indexed(name = "spec_timestamp", direction = IndexDirection.DESCENDING) Long timestamp, Set postCoordinationEvents, CommitStatus commitStatus, - String changeRequestId) implements Comparable { + String changeRequestId) implements Comparable{ public static PostCoordinationSpecificationRevision create(UserId userId, Set postCoordinationEventList) { return create(userId, postCoordinationEventList, null); } - public static PostCoordinationSpecificationRevision create(UserId userId, Set postCoordinationEventList, ChangeRequestId changeRequestId) { CommitStatus status = changeRequestId != null && changeRequestId.id() != null ? CommitStatus.UNCOMMITTED : CommitStatus.COMMITTED; return new PostCoordinationSpecificationRevision(userId, System.currentTimeMillis(), postCoordinationEventList, status, changeRequestId != null ? changeRequestId.id() : null); @@ -42,12 +48,12 @@ public static PostCoordinationSpecificationRevision createDefaultInitialRevision List specificationEvents = tableConfiguration.getPostCoordinationAxes().stream() .map(availableAxis -> { if (definition.getCoreLinId() != null && !definition.getCoreLinId().isEmpty()) { - return new AddToDefaultAxisEvent(availableAxis, definition.getLinearizationUri()); + return new AddToDefaultAxisEvent(availableAxis, definition.getWhoficEntityIri()); } else { - return new AddToNotAllowedAxisEvent(availableAxis, definition.getLinearizationUri()); + return new AddToNotAllowedAxisEvent(availableAxis, definition.getWhoficEntityIri()); } }).toList(); - postCoordinationEvents.add(new PostCoordinationViewEvent(definition.getLinearizationUri(), specificationEvents)); + postCoordinationEvents.add(new PostCoordinationViewEvent(definition.getWhoficEntityIri(), specificationEvents)); } diff --git a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/changes/ProjectChangesManager.java b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/changes/ProjectChangesManager.java index ad58d6c..cffe501 100644 --- a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/changes/ProjectChangesManager.java +++ b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/changes/ProjectChangesManager.java @@ -197,7 +197,7 @@ private Map createOrderAxisMapWithSubAxis() { public Set getProjectChangesForSpecHistories(ProjectId projectId, List entitySpecHistories) { Map entityIrisAndNames = new HashMap<>(); List linearizationDefinitions = linearizationService.getLinearizationDefinitions(); - linearizationDefinitions.forEach(linDef -> entityIrisAndNames.put(linDef.getLinearizationUri(), linDef.getDisplayLabel())); + linearizationDefinitions.forEach(linDef -> entityIrisAndNames.put(linDef.getWhoficEntityIri(), linDef.getDisplayLabel())); Set specRevisions = entitySpecHistories.stream() .flatMap(history -> @@ -302,8 +302,8 @@ public ProjectChangeForEntity getProjectChangesForSpecRevision(ProjectId project }); List linDefs = linearizationService.getLinearizationDefinitions(); linDefs.forEach(linDef -> { - if (entityIrisAndNames.get(linDef.getLinearizationUri()) != null) { - entityIrisAndNames.put(linDef.getLinearizationUri(), linDef.getDisplayLabel()); + if (entityIrisAndNames.get(linDef.getWhoficEntityIri()) != null) { + entityIrisAndNames.put(linDef.getWhoficEntityIri(), linDef.getDisplayLabel()); } }); diff --git a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslator.java b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslator.java index 225d27d..cee7c3b 100644 --- a/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslator.java +++ b/src/main/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslator.java @@ -95,11 +95,11 @@ private DiffElement SpecDocumentChange sourceDocument; Optional linearizationDefinitionOptional = linearizationDefinitions.stream() - .filter(linearizationDefinition -> linearizationDefinition.getLinearizationUri().equals(linearizationView)) + .filter(linearizationDefinition -> linearizationDefinition.getWhoficEntityIri().equals(linearizationView)) .findFirst(); if (linearizationDefinitionOptional.isPresent()) { LinearizationDefinition linDef = linearizationDefinitionOptional.get(); - sourceDocument = SpecDocumentChange.create(linearizationView, linDef.getDisplayLabel(), linDef.getLinearizationId(), linDef.getSortingCode()); + sourceDocument = SpecDocumentChange.create(linearizationView, linDef.getDisplayLabel(), linDef.getId(), linDef.getSortingCode()); } else { sourceDocument = SpecDocumentChange.create(linearizationView, linearizationView, linearizationView, "0"); } diff --git a/src/test/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslatorTest.java b/src/test/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslatorTest.java index 3777dd7..582fcd7 100644 --- a/src/test/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslatorTest.java +++ b/src/test/java/edu/stanford/protege/webprotege/postcoordinationservice/uiHistoryConcern/diff/Revision2DiffElementsTranslatorTest.java @@ -99,9 +99,9 @@ void GIVEN_nonEmptyChangesByView_WHEN_getDiffElementsFromSpecRevision_THEN_retur orderedAxisMap.put("Axis2", 2); LinearizationDefinition linDef = mock(LinearizationDefinition.class); - when(linDef.getLinearizationUri()).thenReturn("LinearizationView"); + when(linDef.getWhoficEntityIri()).thenReturn("LinearizationView"); when(linDef.getDisplayLabel()).thenReturn("Linearization View Label"); - when(linDef.getLinearizationId()).thenReturn("LinearizationViewID"); + when(linDef.getId()).thenReturn("LinearizationViewID"); when(linearizationService.getLinearizationDefinitions()).thenReturn(List.of(linDef));