Skip to content

Commit b15d471

Browse files
committed
ACC-2104 fix merge errors
1 parent 0ac7c77 commit b15d471

File tree

8 files changed

+75
-12
lines changed

8 files changed

+75
-12
lines changed

contentgrid-appserver-domain/src/test/java/com/contentgrid/appserver/domain/ThunkExpressionGeneratorTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.contentgrid.appserver.application.model.values.AttributeName;
1313
import com.contentgrid.appserver.application.model.values.ColumnName;
1414
import com.contentgrid.appserver.application.model.values.EntityName;
15+
import com.contentgrid.appserver.application.model.values.LinkName;
1516
import com.contentgrid.appserver.application.model.values.PathSegmentName;
1617
import com.contentgrid.appserver.application.model.values.TableName;
1718
import com.contentgrid.appserver.exception.InvalidParameterException;
@@ -92,17 +93,18 @@ class ThunkExpressionGeneratorTest {
9293
.build();
9394

9495
private static final Entity testEntity = Entity.builder()
95-
.name(EntityName.of("testEntity"))
96-
.table(TableName.of("test_entity"))
97-
.pathSegment(PathSegmentName.of("test-entities"))
98-
.primaryKey(UUID_ATTR)
99-
.attribute(LONG_ATTR)
100-
.attribute(DOUBLE_ATTR)
101-
.attribute(BOOLEAN_ATTR)
102-
.attribute(TEXT_ATTR)
103-
.attribute(DATETIME_ATTR)
104-
.attribute(COMP_ATTR)
105-
.build();
96+
.name(EntityName.of("testEntity"))
97+
.table(TableName.of("test_entity"))
98+
.pathSegment(PathSegmentName.of("test-entities"))
99+
.linkName(LinkName.of("test-entities"))
100+
.primaryKey(UUID_ATTR)
101+
.attribute(LONG_ATTR)
102+
.attribute(DOUBLE_ATTR)
103+
.attribute(BOOLEAN_ATTR)
104+
.attribute(TEXT_ATTR)
105+
.attribute(DATETIME_ATTR)
106+
.attribute(COMP_ATTR)
107+
.build();
106108

107109
@Test
108110
void emptyParamsShouldReturnTrueExpression() {

contentgrid-appserver-json-schema/src/main/java/com/contentgrid/appserver/json/DefaultApplicationSchemaConverter.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.contentgrid.appserver.application.model.values.ColumnName;
2222
import com.contentgrid.appserver.application.model.values.EntityName;
2323
import com.contentgrid.appserver.application.model.values.FilterName;
24+
import com.contentgrid.appserver.application.model.values.LinkName;
2425
import com.contentgrid.appserver.application.model.values.PathSegmentName;
2526
import com.contentgrid.appserver.application.model.values.RelationName;
2627
import com.contentgrid.appserver.application.model.values.TableName;
@@ -119,6 +120,7 @@ private com.contentgrid.appserver.application.model.Entity fromJsonEntity(
119120
return com.contentgrid.appserver.application.model.Entity.builder()
120121
.name(EntityName.of(jsonEntity.getName()))
121122
.pathSegment(PathSegmentName.of(jsonEntity.getPathSegment()))
123+
.linkName(LinkName.of(jsonEntity.getLinkName()))
122124
.description(jsonEntity.getDescription())
123125
.table(TableName.of(jsonEntity.getTable()))
124126
.primaryKey(primaryKey)
@@ -181,6 +183,7 @@ private com.contentgrid.appserver.application.model.attributes.ContentAttribute
181183
.description(ca.getDescription())
182184
.flags(fromJsonFlags(ca.getFlags()))
183185
.pathSegment(PathSegmentName.of(ca.getPathSegment()))
186+
.linkName(LinkName.of(ca.getLinkName()))
184187
.idColumn(ColumnName.of(ca.getIdColumn()))
185188
.filenameColumn(ColumnName.of(ca.getFileNameColumn()))
186189
.mimetypeColumn(ColumnName.of(ca.getMimeTypeColumn()))
@@ -286,19 +289,23 @@ private com.contentgrid.appserver.application.model.relations.Relation fromJsonR
286289
var targetPath = targetEp.getPathSegment() != null
287290
? PathSegmentName.of(targetEp.getPathSegment())
288291
: null;
292+
var sourceLink = sourceEp.getLinkName() != null ? LinkName.of(sourceEp.getLinkName()) : null;
293+
var targetLink = targetEp.getLinkName() != null ? LinkName.of(targetEp.getLinkName()) : null;
289294
var sourceRequired = sourceEp.isRequired();
290295
var targetRequired = targetEp.isRequired();
291296
var sourceEndPoint = com.contentgrid.appserver.application.model.relations.Relation.RelationEndPoint.builder()
292297
.entity(sourceEntity)
293298
.name(sourceName)
294299
.pathSegment(sourcePath)
300+
.linkName(sourceLink)
295301
.required(sourceRequired)
296302
.description(sourceEp.getDescription())
297303
.build();
298304
var targetEndPoint = com.contentgrid.appserver.application.model.relations.Relation.RelationEndPoint.builder()
299305
.entity(targetEntity)
300306
.name(targetName)
301307
.pathSegment(targetPath)
308+
.linkName(targetLink)
302309
.required(targetRequired)
303310
.description(targetEp.getDescription())
304311
.build();
@@ -362,6 +369,7 @@ private Entity toJsonEntity(com.contentgrid.appserver.application.model.Entity e
362369
var jsonEntity = new Entity();
363370
jsonEntity.setName(entity.getName().getValue());
364371
jsonEntity.setPathSegment(entity.getPathSegment().getValue());
372+
jsonEntity.setLinkName(entity.getLinkName().getValue());
365373
jsonEntity.setDescription(entity.getDescription());
366374
jsonEntity.setTable(entity.getTable().getValue());
367375
jsonEntity.setPrimaryKey(toJsonSimpleAttribute(entity.getPrimaryKey()));
@@ -420,6 +428,7 @@ private ContentAttribute toJsonContentAttribute(
420428
jsonAttr.setDescription(ca.getDescription());
421429
jsonAttr.setFlags(ca.getFlags().stream().map(this::toJsonAttribute).toList());
422430
jsonAttr.setPathSegment(ca.getPathSegment().getValue());
431+
jsonAttr.setLinkName(ca.getLinkName().getValue());
423432
jsonAttr.setIdColumn(ca.getId().getColumn().getValue());
424433
jsonAttr.setFileNameColumn(ca.getFilename().getColumn().getValue());
425434
jsonAttr.setMimeTypeColumn(ca.getMimetype().getColumn().getValue());
@@ -513,6 +522,7 @@ private RelationEndPoint toJsonRelationEndpoint(
513522
rep.setName(relationEndPoint.getName() != null ? relationEndPoint.getName().getValue() : null);
514523
rep.setPathSegment(
515524
relationEndPoint.getPathSegment() != null ? relationEndPoint.getPathSegment().getValue() : null);
525+
rep.setLinkName(relationEndPoint.getLinkName() != null ? relationEndPoint.getLinkName().getValue() : null);
516526
rep.setRequired(relationEndPoint.isRequired());
517527
rep.setDescription(relationEndPoint.getDescription());
518528
return rep;

contentgrid-appserver-json-schema/src/main/java/com/contentgrid/appserver/json/model/ContentAttribute.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
@Getter
1010
@Setter
1111
@JsonInclude(JsonInclude.Include.NON_NULL)
12-
@JsonPropertyOrder({"type", "name", "description", "pathSegment", "idColumn", "fileNameColumn", "mimeTypeColumn", "lengthColumn", "flags"})
12+
@JsonPropertyOrder({"type", "name", "description", "pathSegment", "linkName", "idColumn", "fileNameColumn", "mimeTypeColumn", "lengthColumn", "flags"})
1313
public final class ContentAttribute extends Attribute {
1414

1515
@NonNull
1616
private String pathSegment;
1717

18+
@NonNull
19+
private String linkName;
20+
1821
@NonNull
1922
private String idColumn;
2023

contentgrid-appserver-json-schema/src/main/java/com/contentgrid/appserver/json/model/Entity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class Entity {
2121
@NonNull
2222
private String pathSegment;
2323

24+
@NonNull
25+
private String linkName;
26+
2427
@NonNull
2528
private SimpleAttribute primaryKey;
2629

contentgrid-appserver-json-schema/src/main/java/com/contentgrid/appserver/json/model/RelationEndPoint.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public class RelationEndPoint {
1616
private String entityName;
1717
private String description;
1818
private boolean required;
19+
private String linkName;
1920
}

contentgrid-appserver-json-schema/src/main/resources/schemas/application-schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"type": "string",
3535
"description": "The path segment for the entity."
3636
},
37+
"linkName": {
38+
"type": "string",
39+
"description": "The link name of the 'cg:entity' link relation."
40+
},
3741
"primaryKey": {
3842
"$ref": "#/$defs/simpleAttribute"
3943
},
@@ -80,6 +84,7 @@
8084
"name",
8185
"table",
8286
"pathSegment",
87+
"linkName",
8388
"primaryKey"
8489
],
8590
"additionalProperties": false
@@ -205,6 +210,10 @@
205210
"type": "string",
206211
"description": "The URL path segment used to navigate from this endpoint's entity (entityName) to the related entity or entities. For example, if an 'Invoice' entity links to its 'Supplier', this pathSegment could be 'supplier'. This pathSegment and the name property must either both be defined or both be absent."
207212
},
213+
"linkName": {
214+
"type": "string",
215+
"description": "The link name of the 'cg:relation' link relation for the entity of this endpoint. Must be present when pathSegment is present, must be absent when pathSegment is absent."
216+
},
208217
"entityName": {
209218
"type": "string",
210219
"description": "The name of the entity."
@@ -425,6 +434,10 @@
425434
"type": "string",
426435
"description": "The path segment for the content attribute."
427436
},
437+
"linkName": {
438+
"type": "string",
439+
"description": "The link name of the 'cg:content' link relation."
440+
},
428441
"idColumn": {
429442
"type": "string",
430443
"description": "The name of the column in the database that stores the content ID."
@@ -445,6 +458,7 @@
445458
"required": [
446459
"name",
447460
"pathSegment",
461+
"linkName",
448462
"idColumn",
449463
"fileNameColumn",
450464
"mimeTypeColumn",

contentgrid-appserver-json-schema/src/test/java/com/contentgrid/appserver/json/DefaultApplicationSchemaConverterTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.contentgrid.appserver.application.model.values.AttributeName;
2121
import com.contentgrid.appserver.application.model.values.ColumnName;
2222
import com.contentgrid.appserver.application.model.values.EntityName;
23+
import com.contentgrid.appserver.application.model.values.LinkName;
2324
import com.contentgrid.appserver.application.model.values.PathSegmentName;
2425
import com.contentgrid.appserver.application.model.values.RelationName;
2526
import com.contentgrid.appserver.application.model.values.TableName;
@@ -88,6 +89,7 @@ void testUnknownFlag() {
8889
"description": "An employee of the company",
8990
"table": "employees",
9091
"pathSegment": "employee",
92+
"linkName": "employee",
9193
"primaryKey":
9294
{
9395
"name": "id",
@@ -121,6 +123,7 @@ void testTargetOneToOneSerialization() {
121123
.entity(targetEntity)
122124
.name(RelationName.of("source"))
123125
.pathSegment(PathSegmentName.of("source"))
126+
.linkName(LinkName.of("source"))
124127
.build())
125128
.sourceReference(ColumnName.of("source_ref"))
126129
.build();
@@ -148,6 +151,7 @@ void testTargetOneToOneSerialization() {
148151
"description": "source entity",
149152
"table": "source_table",
150153
"pathSegment": "source",
154+
"linkName": "source",
151155
"primaryKey":
152156
{
153157
"name": "id",
@@ -170,6 +174,7 @@ void testTargetOneToOneSerialization() {
170174
"description": "target entity",
171175
"table": "target_table",
172176
"pathSegment": "target",
177+
"linkName": "target",
173178
"primaryKey":
174179
{
175180
"name": "id",
@@ -196,6 +201,7 @@ void testTargetOneToOneSerialization() {
196201
"entityName": "target",
197202
"name": "source",
198203
"pathSegment": "source",
204+
"linkName": "source",
199205
"required": false
200206
},
201207
"targetEndpoint":
@@ -224,6 +230,7 @@ void testManyToOneSerialization() {
224230
.entity(targetEntity)
225231
.name(RelationName.of("source"))
226232
.pathSegment(PathSegmentName.of("source"))
233+
.linkName(LinkName.of("source"))
227234
.build())
228235
.targetReference(ColumnName.of("target_ref"))
229236
.build();
@@ -251,6 +258,7 @@ void testManyToOneSerialization() {
251258
"description": "source entity",
252259
"table": "source_table",
253260
"pathSegment": "source",
261+
"linkName": "source",
254262
"primaryKey":
255263
{
256264
"name": "id",
@@ -273,6 +281,7 @@ void testManyToOneSerialization() {
273281
"description": "target entity",
274282
"table": "target_table",
275283
"pathSegment": "target",
284+
"linkName": "target",
276285
"primaryKey":
277286
{
278287
"name": "id",
@@ -299,6 +308,7 @@ void testManyToOneSerialization() {
299308
"entityName": "target",
300309
"name": "source",
301310
"pathSegment": "source",
311+
"linkName": "source",
302312
"required": false
303313
},
304314
"targetEndpoint":
@@ -319,6 +329,7 @@ private static Entity getEntity(String name, String description, String table) {
319329
.description(description)
320330
.table(TableName.of(table))
321331
.pathSegment(PathSegmentName.of(name))
332+
.linkName(LinkName.of(name))
322333
.primaryKey(
323334
getPrimaryKey()
324335
)

0 commit comments

Comments
 (0)