-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify crud example, add more complex list service example
- Loading branch information
1 parent
0d65e38
commit 8237007
Showing
7 changed files
with
222 additions
and
102 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/vaadin/demo/fusion/crud/ProductAdvancedDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.vaadin.demo.fusion.crud; | ||
|
||
//tag::snippet[] | ||
public record ProductAdvancedDto(Long productId, | ||
String productName, | ||
String productCategory, | ||
double productPrice, | ||
Long supplierId, | ||
String supplierInfo) { | ||
public static ProductAdvancedDto fromEntity(Product product) { | ||
// Compute a custom property that includes the supplier name and city | ||
String supplierInfo = product.getSupplier() != null | ||
? String.format("%s (%s)", product.getSupplier().getSupplierName(), product.getSupplier().getHeadquarterCity()) | ||
: ""; | ||
|
||
return new ProductAdvancedDto( | ||
product.getId(), | ||
product.getName(), | ||
product.getCategory(), | ||
product.getPrice(), | ||
product.getSupplier().getId(), | ||
supplierInfo | ||
); | ||
} | ||
} | ||
//end::snippet[] |
Oops, something went wrong.