Skip to content

Commit

Permalink
adds support for java.util.Map and embedded fields sharing annotation…
Browse files Browse the repository at this point in the history
…s with embedded entity.
  • Loading branch information
ivangsa committed Mar 27, 2024
1 parent b008d2b commit 62d66b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/antlr4/io.github.zenwave360.zdl.antlr/Zdl.g4
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ entity_table_name: keyword;
entity_body: LBRACE fields RBRACE;
fields: (field COMMA?)*;
field: javadoc? annotations field_name field_type field_initialization? (LPAREN entity_table_name RPAREN)? (field_validations)* suffix_javadoc? (nested_field)?;
field: javadoc? annotations field_name field_type (LPAREN entity_table_name RPAREN)? field_initialization? (field_validations)* suffix_javadoc? (nested_field)?;
nested_field: LBRACE (field)* RBRACE nested_field_validations*;
field_name: keyword;
field_type: ID | ID ARRAY;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/zenwave360/zdl/ZdlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class ZdlParser {

public static final List<String> STANDARD_FIELD_TYPES = List.of("String", "Integer", "Long", "int", "long", "BigDecimal", "Float", "float", "Double", "double", "Enum", "Boolean", "boolean", "LocalDate", "LocalDateTime", "ZonedDateTime", "Instant", "Duration", "UUID", "byte", "byte[]", "Blob", "AnyBlob", "ImageBlob", "TextBlob");
public static final List<String> STANDARD_FIELD_TYPES = List.of("String", "Integer", "Long", "int", "long", "BigDecimal", "Float", "float", "Double", "double", "Enum", "Boolean", "boolean", "Map", "LocalDate", "LocalDateTime", "ZonedDate", "ZonedDateTime", "Instant", "Duration", "UUID", "byte", "byte[]", "Blob", "AnyBlob", "ImageBlob", "TextBlob");

public static final List<String> STANDARD_VALIDATIONS = List.of("required", "unique", "min", "max", "minlength", "maxlength", "pattern");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public void enterNested_field(io.github.zenwave360.zdl.antlr.ZdlParser.Nested_fi
((Map)parentField).put("validations", validations);
currentStack.push(processEntity(entityName, entityJavadoc, tableName).with("type", currentCollection.split("\\.")[0]));
currentStack.peek().appendTo("options", "embedded", true);
var parenFieldOptions = JSONPath.get(parentField, "options", Map.of());
for (var entry : parenFieldOptions.entrySet()) {
currentStack.peek().appendTo("options", (String) entry.getKey(), entry.getValue());
}
model.appendTo(currentCollection, entityName, currentStack.peek());
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/complete.zdl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ entity CustomerOrder {
orderTime Instant = "Instant.now()" required /** orderTime javadoc */
status OrderStatus = OrderStatus.RECEIVED required
@auditing @ref
customerDetails Customer {
customerDetails Customer(customer_table) {
customerId String required
firstName String required
lastName String required
Expand Down

0 comments on commit 62d66b6

Please sign in to comment.