Skip to content

Commit 91a4c60

Browse files
committed
hsearch-feature-examples: Fix line length for presentations
1 parent 1381825 commit 91a4c60

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

hibernate-search/hsearch-feature-examples/base/src/main/java/org/hibernate/demos/hsearchfeatureexamples/FashionCollectionService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public FashionCollectionOutputDto create(FashionCollectionInputDto input) {
3636

3737
@PUT
3838
@Path("{id}")
39-
public FashionCollectionOutputDto update(@PathParam long id, FashionCollectionInputDto input) {
39+
public FashionCollectionOutputDto update(@PathParam long id,
40+
FashionCollectionInputDto input) {
4041
FashionCollection entity = find( id );
4142
mapper.input( entity, input );
4243
return mapper.output( entity );
@@ -51,7 +52,8 @@ public FashionCollectionOutputDto retrieve(@PathParam long id) {
5152

5253
@GET
5354
public List<FashionCollectionOutputDto> list(@QueryParam int page) {
54-
List<FashionCollection> entities = FashionCollection.findAll().page( page, PAGE_SIZE ).list();
55+
List<FashionCollection> entities = FashionCollection.findAll()
56+
.page( page, PAGE_SIZE ).list();
5557
return mapper.output( entities );
5658
}
5759

hibernate-search/hsearch-feature-examples/base/src/main/java/org/hibernate/demos/hsearchfeatureexamples/TShirtService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public List<TShirtOutputDto> list(@QueryParam int page, @QueryParam boolean brie
6464
@Path("search")
6565
public SearchResultDto<TShirtOutputDto> search(@QueryParam String q,
6666
@QueryParam int page, @QueryParam boolean brief) {
67-
PanacheQuery<PanacheEntityBase> query = TShirt.find( "lower(name) like concat('%', lower(?1), '%')",
68-
Sort.ascending( "name" ), q );
67+
PanacheQuery<PanacheEntityBase> query =
68+
TShirt.find( "lower(name) like concat('%', lower(?1), '%')",
69+
Sort.ascending( "name" ), q );
6970
query.page( page, PAGE_SIZE );
7071
return new SearchResultDto<>( query.count(), mapper.output( query.list(), brief ) );
7172
}

hibernate-search/hsearch-feature-examples/search-advanced/src/main/java/org/hibernate/demos/hsearchfeatureexamples/FashionCollectionService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public FashionCollectionOutputDto create(FashionCollectionInputDto input) {
3636

3737
@PUT
3838
@Path("{id}")
39-
public FashionCollectionOutputDto update(@PathParam long id, FashionCollectionInputDto input) {
39+
public FashionCollectionOutputDto update(@PathParam long id,
40+
FashionCollectionInputDto input) {
4041
FashionCollection entity = find( id );
4142
mapper.input( entity, input );
4243
return mapper.output( entity );
@@ -51,7 +52,8 @@ public FashionCollectionOutputDto retrieve(@PathParam long id) {
5152

5253
@GET
5354
public List<FashionCollectionOutputDto> list(@QueryParam int page) {
54-
List<FashionCollection> entities = FashionCollection.findAll().page( page, PAGE_SIZE ).list();
55+
List<FashionCollection> entities = FashionCollection.findAll()
56+
.page( page, PAGE_SIZE ).list();
5557
return mapper.output( entities );
5658
}
5759

hibernate-search/hsearch-feature-examples/search-advanced/src/main/java/org/hibernate/demos/hsearchfeatureexamples/TShirtService.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public TShirtOutputDto retrieve(@PathParam long id) {
8080

8181
@GET
8282
public List<TShirtOutputDto> list(@QueryParam int page, @QueryParam boolean brief) {
83-
List<TShirt> entities = TShirt.findAll().page( page, PAGE_SIZE ).list();
83+
List<TShirt> entities = TShirt.findAll()
84+
.page( page, PAGE_SIZE ).list();
8485
return mapper.output( entities, brief );
8586
}
8687

@@ -96,14 +97,14 @@ public SearchResultDto<TShirtOutputDto> search(@QueryParam String q,
9697
else {
9798
return f.simpleQueryString()
9899
.fields( "name", "collection.keywords",
99-
"variants.color", "variants.size"
100-
)
100+
"variants.color", "variants.size" )
101101
.matching( q );
102102
}
103103
} )
104104
.fetch( page * PAGE_SIZE, PAGE_SIZE );
105105

106-
return new SearchResultDto<>( result.total().hitCount(), mapper.output( result.hits(), brief ) );
106+
return new SearchResultDto<>( result.total().hitCount(),
107+
mapper.output( result.hits(), brief ) );
107108
}
108109

109110
@GET
@@ -140,9 +141,12 @@ public SearchResultDto<TShirtOutputDto> searchWithFacets(@QueryParam String q,
140141
@QueryParam String color, @QueryParam TShirtSize size,
141142
@QueryParam PriceRangeDto priceRange,
142143
@QueryParam int page, @QueryParam boolean brief) {
143-
AggregationKey<Map<String, Long>> countByColor = AggregationKey.of( "count-by-color" );
144-
AggregationKey<Map<TShirtSize, Long>> countBySize = AggregationKey.of( "count-by-size" );
145-
AggregationKey<Map<Range<BigDecimal>, Long>> countByPriceRange = AggregationKey.of( "count-by-price-range" );
144+
AggregationKey<Map<String, Long>> countByColor =
145+
AggregationKey.of( "count-by-color" );
146+
AggregationKey<Map<TShirtSize, Long>> countBySize =
147+
AggregationKey.of( "count-by-size" );
148+
AggregationKey<Map<Range<BigDecimal>, Long>> countByPriceRange =
149+
AggregationKey.of( "count-by-price-range" );
146150

147151
SearchResult<TShirt> result = searchSession.search( TShirt.class )
148152
.where( f -> f.bool( b -> {
@@ -151,8 +155,7 @@ public SearchResultDto<TShirtOutputDto> searchWithFacets(@QueryParam String q,
151155
if ( q != null && !q.isBlank() ) {
152156
b.must( f.simpleQueryString()
153157
.fields( "name", "collection.keywords",
154-
"variants_nested.color", "variants_nested.size"
155-
)
158+
"variants_nested.color", "variants_nested.size" )
156159
.matching( q ) );
157160
}
158161

@@ -173,17 +176,17 @@ public SearchResultDto<TShirtOutputDto> searchWithFacets(@QueryParam String q,
173176
.minDocumentCount( 0 ) )
174177
.aggregation( countByPriceRange, f -> f.range()
175178
.field( "variants_nested.price", BigDecimal.class )
176-
.ranges( EnumSet.allOf( PriceRangeDto.class ).stream().map( r -> r.value )
179+
.ranges( EnumSet.allOf( PriceRangeDto.class )
180+
.stream().map( r -> r.value )
177181
.collect( Collectors.toList() ) )
178182
.filter( f2 -> variantFilter( f2, size, color, priceRange ) ) )
179183
.fetch( page * PAGE_SIZE, PAGE_SIZE );
180184

181-
return new SearchResultDto<>( result.total().hitCount(), mapper.output( result.hits(), brief ),
182-
Map.of(
183-
countByColor.name(), result.aggregation( countByColor ),
185+
return new SearchResultDto<>( result.total().hitCount(),
186+
mapper.output( result.hits(), brief ),
187+
Map.of( countByColor.name(), result.aggregation( countByColor ),
184188
countBySize.name(), result.aggregation( countBySize ),
185-
countByPriceRange.name(), result.aggregation( countByPriceRange )
186-
)
189+
countByPriceRange.name(), result.aggregation( countByPriceRange ) )
187190
);
188191
}
189192

@@ -194,13 +197,19 @@ private PredicateFinalStep variantFilter(SearchPredicateFactory f, TShirtSize si
194197
}
195198
return f.bool( variantsBool -> {
196199
if ( color != null ) {
197-
variantsBool.must( f.match().field( "variants_nested.color" ).matching( color ) );
200+
variantsBool.must( f.match()
201+
.field( "variants_nested.color" )
202+
.matching( color ) );
198203
}
199204
if ( size != null ) {
200-
variantsBool.must( f.match().field( "variants_nested.size" ).matching( size ) );
205+
variantsBool.must( f.match()
206+
.field( "variants_nested.size" )
207+
.matching( size ) );
201208
}
202209
if ( priceRange != null ) {
203-
variantsBool.must( f.range().field( "variants_nested.price" ).range( priceRange.value ) );
210+
variantsBool.must( f.range()
211+
.field( "variants_nested.price" )
212+
.range( priceRange.value ) );
204213
}
205214
} );
206215
}

hibernate-search/hsearch-feature-examples/search/src/main/java/org/hibernate/demos/hsearchfeatureexamples/FashionCollectionService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public FashionCollectionOutputDto create(FashionCollectionInputDto input) {
3636

3737
@PUT
3838
@Path("{id}")
39-
public FashionCollectionOutputDto update(@PathParam long id, FashionCollectionInputDto input) {
39+
public FashionCollectionOutputDto update(@PathParam long id,
40+
FashionCollectionInputDto input) {
4041
FashionCollection entity = find( id );
4142
mapper.input( entity, input );
4243
return mapper.output( entity );
@@ -51,7 +52,8 @@ public FashionCollectionOutputDto retrieve(@PathParam long id) {
5152

5253
@GET
5354
public List<FashionCollectionOutputDto> list(@QueryParam int page) {
54-
List<FashionCollection> entities = FashionCollection.findAll().page( page, PAGE_SIZE ).list();
55+
List<FashionCollection> entities = FashionCollection.findAll()
56+
.page( page, PAGE_SIZE ).list();
5557
return mapper.output( entities );
5658
}
5759

hibernate-search/hsearch-feature-examples/search/src/main/java/org/hibernate/demos/hsearchfeatureexamples/TShirtService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ public SearchResultDto<TShirtOutputDto> search(@QueryParam String q,
7373
else {
7474
return f.simpleQueryString()
7575
.fields( "name", "collection.keywords",
76-
"variants.color", "variants.size"
77-
)
76+
"variants.color", "variants.size" )
7877
.matching( q );
7978
}
8079
} )
8180
.fetch( page * PAGE_SIZE, PAGE_SIZE );
8281

83-
return new SearchResultDto<>( result.total().hitCount(), mapper.output( result.hits(), brief ) );
82+
return new SearchResultDto<>( result.total().hitCount(),
83+
mapper.output( result.hits(), brief ) );
8484
}
8585

8686
private TShirt find(long id) {

0 commit comments

Comments
 (0)