Skip to content

Commit 1cfcf68

Browse files
johardiclaude
andcommitted
refactor(wire-dto): pin @JsonProperty on FRAGILE record components
Add explicit @JsonProperty("<name>") on every record component flagged FRAGILE by the wire-DTO conformance audit, so the JSON contract no longer depends on incidental agreement between Java component names and gwt-ui client field names. A future rename on either side will now surface as an explicit contract change instead of silently deserializing as null. Covers all 58 backend files listed in #52 (two already had the annotation, so 56 files actually change here). Closes #52 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 36a7417 commit 1cfcf68

56 files changed

Lines changed: 196 additions & 114 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/edu/stanford/protege/webprotege/app/GetApplicationSettingsResult.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.app;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import edu.stanford.protege.webprotege.dispatch.Result;
56

@@ -11,6 +12,6 @@
1112

1213

1314
@JsonTypeName("webprotege.application.GetApplicationSettings")
14-
public record GetApplicationSettingsResult(ApplicationSettings settings) implements Result {
15+
public record GetApplicationSettingsResult(@JsonProperty("settings") ApplicationSettings settings) implements Result {
1516

1617
}

src/main/java/edu/stanford/protege/webprotege/change/GetProjectChangesAction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.change;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import edu.stanford.protege.webprotege.common.PageRequest;
56
import edu.stanford.protege.webprotege.common.ProjectId;
@@ -16,9 +17,9 @@
1617
* 24/02/15
1718
*/
1819
@JsonTypeName("webprotege.history.GetProjectChanges")
19-
public record GetProjectChangesAction(@Nonnull ProjectId projectId,
20-
@Nonnull Optional<OWLEntity> subject,
21-
@Nonnull PageRequest pageRequest) implements ProjectAction<GetProjectChangesResult> {
20+
public record GetProjectChangesAction(@JsonProperty("projectId") @Nonnull ProjectId projectId,
21+
@JsonProperty("subject") @Nonnull Optional<OWLEntity> subject,
22+
@JsonProperty("pageRequest") @Nonnull PageRequest pageRequest) implements ProjectAction<GetProjectChangesResult> {
2223

2324
public static final String CHANNEL = "webprotege.history.GetProjectChanges";
2425

src/main/java/edu/stanford/protege/webprotege/entity/CreateClassesAction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package edu.stanford.protege.webprotege.entity;
22

33
import com.fasterxml.jackson.annotation.JsonClassDescription;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
45
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
56
import com.fasterxml.jackson.annotation.JsonTypeName;
67
import com.google.common.collect.ImmutableSet;
@@ -19,16 +20,20 @@
1920
*/
2021
@JsonTypeName("webprotege.entities.CreateClasses")
2122
@JsonClassDescription("Represents a request to create OWL classes in a specified project")
22-
public record CreateClassesAction(ChangeRequestId changeRequestId,
23+
public record CreateClassesAction(@JsonProperty("changeRequestId") ChangeRequestId changeRequestId,
24+
@JsonProperty("projectId")
2325
@JsonPropertyDescription("The id of the project where the classes will be created")
2426
ProjectId projectId,
27+
@JsonProperty("sourceText")
2528
@JsonPropertyDescription("""
2629
The source text that contains the user supplied names for the classes.
2730
2831
Multiple user-supplied class names should be separated with a new line.""")
2932
String sourceText,
33+
@JsonProperty("langTag")
3034
@JsonPropertyDescription("The language tag that should be used for the labels of the created classes")
3135
String langTag,
36+
@JsonProperty("parents")
3237
@JsonPropertyDescription("""
3338
A set of classes that the created classes will be subclasses of.
3439

src/main/java/edu/stanford/protege/webprotege/entity/CreateClassesResult.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -14,7 +15,7 @@
1415
* Date: 22/02/2013
1516
*/
1617
@JsonTypeName("webprotege.entities.CreateClasses")
17-
public record CreateClassesResult(ChangeRequestId changeRequestId,
18-
ProjectId projectId,
19-
ImmutableSet<EntityNode> entities) implements Result, Response {
18+
public record CreateClassesResult(@JsonProperty("changeRequestId") ChangeRequestId changeRequestId,
19+
@JsonProperty("projectId") ProjectId projectId,
20+
@JsonProperty("entities") ImmutableSet<EntityNode> entities) implements Result, Response {
2021
}

src/main/java/edu/stanford/protege/webprotege/entity/CreateDataPropertiesAction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -17,11 +18,11 @@
1718
* Date: 25/03/2013
1819
*/
1920
@JsonTypeName("webprotege.entities.CreateDataProperties")
20-
public record CreateDataPropertiesAction(@Nonnull ChangeRequestId changeRequestId,
21-
@Nonnull ProjectId projectId,
22-
@Nonnull String sourceText,
23-
@Nonnull String langTag,
24-
ImmutableSet<OWLDataProperty> parents) implements ProjectAction<CreateDataPropertiesResult>, ContentChangeRequest {
21+
public record CreateDataPropertiesAction(@JsonProperty("changeRequestId") @Nonnull ChangeRequestId changeRequestId,
22+
@JsonProperty("projectId") @Nonnull ProjectId projectId,
23+
@JsonProperty("sourceText") @Nonnull String sourceText,
24+
@JsonProperty("langTag") @Nonnull String langTag,
25+
@JsonProperty("parents") ImmutableSet<OWLDataProperty> parents) implements ProjectAction<CreateDataPropertiesResult>, ContentChangeRequest {
2526

2627
public static final String CHANNEL = "webprotege.entities.CreateDataProperties";
2728

src/main/java/edu/stanford/protege/webprotege/entity/CreateDataPropertiesResult.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -13,7 +14,7 @@
1314
* Date: 25/03/2013
1415
*/
1516
@JsonTypeName("webprotege.entities.CreateDataProperties")
16-
public record CreateDataPropertiesResult(ProjectId projectId,
17-
ImmutableSet<EntityNode> entities,
18-
ChangeRequestId changeRequestId) implements Result {
17+
public record CreateDataPropertiesResult(@JsonProperty("projectId") ProjectId projectId,
18+
@JsonProperty("entities") ImmutableSet<EntityNode> entities,
19+
@JsonProperty("changeRequestId") ChangeRequestId changeRequestId) implements Result {
1920
}

src/main/java/edu/stanford/protege/webprotege/entity/CreateNamedIndividualsAction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -17,11 +18,11 @@
1718
* Date: 12/09/2013
1819
*/
1920
@JsonTypeName("webprotege.entities.CreateNamedIndividuals")
20-
public record CreateNamedIndividualsAction(@Nonnull ChangeRequestId changeRequestId,
21-
@Nonnull ProjectId projectId,
22-
@Nonnull String sourceText,
23-
@Nonnull String langTag,
24-
@Nonnull ImmutableSet<OWLClass> types) implements ProjectAction<CreateNamedIndividualsResult>, ContentChangeRequest {
21+
public record CreateNamedIndividualsAction(@JsonProperty("changeRequestId") @Nonnull ChangeRequestId changeRequestId,
22+
@JsonProperty("projectId") @Nonnull ProjectId projectId,
23+
@JsonProperty("sourceText") @Nonnull String sourceText,
24+
@JsonProperty("langTag") @Nonnull String langTag,
25+
@JsonProperty("types") @Nonnull ImmutableSet<OWLClass> types) implements ProjectAction<CreateNamedIndividualsResult>, ContentChangeRequest {
2526

2627
public static final String CHANNEL = "webprotege.entities.CreateNamedIndividuals";
2728

src/main/java/edu/stanford/protege/webprotege/entity/CreateNamedIndividualsResult.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -15,7 +16,7 @@
1516
* Date: 12/09/2013
1617
*/
1718
@JsonTypeName("webprotege.entities.CreateNamedIndividuals")
18-
public record CreateNamedIndividualsResult(@Nonnull ProjectId projectId,
19-
ImmutableSet<EntityNode> entities,
20-
ChangeRequestId changeRequestId) implements Result {
19+
public record CreateNamedIndividualsResult(@JsonProperty("projectId") @Nonnull ProjectId projectId,
20+
@JsonProperty("entities") ImmutableSet<EntityNode> entities,
21+
@JsonProperty("changeRequestId") ChangeRequestId changeRequestId) implements Result {
2122
}

src/main/java/edu/stanford/protege/webprotege/entity/CreateObjectPropertiesAction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -17,11 +18,11 @@
1718
* Date: 25/03/2013
1819
*/
1920
@JsonTypeName("webprotege.entities.CreateObjectProperties")
20-
public record CreateObjectPropertiesAction(@Nonnull ChangeRequestId changeRequestId,
21-
@Nonnull ProjectId projectId,
22-
@Nonnull String sourceText,
23-
@Nonnull String langTag,
24-
@Nonnull ImmutableSet<OWLObjectProperty> parents) implements ProjectAction<CreateObjectPropertiesResult>, ContentChangeRequest {
21+
public record CreateObjectPropertiesAction(@JsonProperty("changeRequestId") @Nonnull ChangeRequestId changeRequestId,
22+
@JsonProperty("projectId") @Nonnull ProjectId projectId,
23+
@JsonProperty("sourceText") @Nonnull String sourceText,
24+
@JsonProperty("langTag") @Nonnull String langTag,
25+
@JsonProperty("parents") @Nonnull ImmutableSet<OWLObjectProperty> parents) implements ProjectAction<CreateObjectPropertiesResult>, ContentChangeRequest {
2526

2627
public static final String CHANNEL = "webprotege.entities.CreateObjectProperties";
2728

src/main/java/edu/stanford/protege/webprotege/entity/DeleteEntitiesAction.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.stanford.protege.webprotege.entity;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.fasterxml.jackson.annotation.JsonTypeName;
45
import com.google.common.collect.ImmutableSet;
56
import edu.stanford.protege.webprotege.common.ChangeRequestId;
@@ -16,9 +17,9 @@
1617
* 9 May 2017
1718
*/
1819
@JsonTypeName("webprotege.entities.DeleteEntities")
19-
public record DeleteEntitiesAction(ChangeRequestId changeRequestId,
20-
ProjectId projectId,
21-
ImmutableSet<OWLEntity> entities) implements ProjectAction<DeleteEntitiesResult>, ContentChangeRequest {
20+
public record DeleteEntitiesAction(@JsonProperty("changeRequestId") ChangeRequestId changeRequestId,
21+
@JsonProperty("projectId") ProjectId projectId,
22+
@JsonProperty("entities") ImmutableSet<OWLEntity> entities) implements ProjectAction<DeleteEntitiesResult>, ContentChangeRequest {
2223

2324
public static final String CHANNEL = "webprotege.entities.DeleteEntities";
2425

@@ -27,7 +28,9 @@ public String getChannel() {
2728
return CHANNEL;
2829
}
2930

30-
public DeleteEntitiesAction(ChangeRequestId changeRequestId, ProjectId projectId, ImmutableSet<OWLEntity> entities) {
31+
public DeleteEntitiesAction(@JsonProperty("changeRequestId") ChangeRequestId changeRequestId,
32+
@JsonProperty("projectId") ProjectId projectId,
33+
@JsonProperty("entities") ImmutableSet<OWLEntity> entities) {
3134
this.changeRequestId = checkNotNull(changeRequestId);
3235
this.projectId = checkNotNull(projectId);
3336
this.entities = checkNotNull(entities);

0 commit comments

Comments
 (0)