Skip to content

Commit

Permalink
Revert "fix for who-icatx/icatx-project#142"
Browse files Browse the repository at this point in the history
This reverts commit 57738c0.
  • Loading branch information
soimugeo committed Jan 6, 2025
1 parent d1bd046 commit 93dfea9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -27,25 +27,25 @@ public class LinearizationDefinition {
@JsonProperty("sortingCode")
private final String sortingCode;

@JsonProperty("displayLabel")
@JsonProperty("DisplayLabel")
private final String displayLabel;

@JsonProperty("oldId")
private final String oldId;


@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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Mono<CreatePostcoordinationFromParentResponse> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PostCoordinationViewEvent> postCoordinationEvents,
CommitStatus commitStatus,
String changeRequestId) implements Comparable<PostCoordinationSpecificationRevision> {
String changeRequestId) implements Comparable<PostCoordinationSpecificationRevision>{


public static PostCoordinationSpecificationRevision create(UserId userId, Set<PostCoordinationViewEvent> postCoordinationEventList) {
return create(userId, postCoordinationEventList, null);
}

public static PostCoordinationSpecificationRevision create(UserId userId, Set<PostCoordinationViewEvent> 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);
Expand All @@ -42,12 +48,12 @@ public static PostCoordinationSpecificationRevision createDefaultInitialRevision
List<PostCoordinationSpecificationEvent> 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));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private Map<String, Integer> createOrderAxisMapWithSubAxis() {
public Set<ProjectChangeForEntity> getProjectChangesForSpecHistories(ProjectId projectId, List<EntityPostCoordinationHistory> entitySpecHistories) {
Map<String, String> entityIrisAndNames = new HashMap<>();
List<LinearizationDefinition> linearizationDefinitions = linearizationService.getLinearizationDefinitions();
linearizationDefinitions.forEach(linDef -> entityIrisAndNames.put(linDef.getLinearizationUri(), linDef.getDisplayLabel()));
linearizationDefinitions.forEach(linDef -> entityIrisAndNames.put(linDef.getWhoficEntityIri(), linDef.getDisplayLabel()));

Set<SpecRevisionWithEntity> specRevisions = entitySpecHistories.stream()
.flatMap(history ->
Expand Down Expand Up @@ -302,8 +302,8 @@ public ProjectChangeForEntity getProjectChangesForSpecRevision(ProjectId project
});
List<LinearizationDefinition> 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());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ private DiffElement<SpecDocumentChange, List<PostCoordinationSpecificationEvent>

SpecDocumentChange sourceDocument;
Optional<LinearizationDefinition> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 93dfea9

Please sign in to comment.