Skip to content

Commit

Permalink
chore: bump up jnosql version to 1.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: Maximillian Arruda <[email protected]>
  • Loading branch information
dearrudam committed Feb 26, 2024
1 parent 00bc226 commit a4313cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 58 deletions.
2 changes: 1 addition & 1 deletion jnopo-talk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<compiler-plugin.version>3.10.1</compiler-plugin.version>
<war-plugin.version>3.3.2</war-plugin.version>
<wildfly-plugin.version>4.2.1.Final</wildfly-plugin.version>
<jnosql.version>1.0.4</jnosql.version>
<jnosql.version>1.1.0</jnosql.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package br.org.soujava.coffewithjava.jnopo;

import jakarta.data.repository.PageableRepository;
import jakarta.data.repository.DataRepository;
import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;
import jakarta.data.repository.Save;

import java.util.List;

@Repository
public interface Playoffs extends PageableRepository<GameMatch,String> {
List<GameMatch> findByWinnerNameLike(String name);
public interface Playoffs extends DataRepository<GameMatch,String> {

@Query("select * from GameMatch where tied=true")
List<GameMatch> listTiedPlayoffs();
@Save
GameMatch save(GameMatch gameMatch);

@Query("select * from GameMatch where tied=false")
List<GameMatch> listPlayoffsWithWinnerAndLoser();
List<GameMatch> listNonTiedGameMatches();

List<GameMatch> findByLoserNameLike(String name);
default Ranking winnerRanking(){
return Ranking.winnerRanking(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

import io.opentelemetry.instrumentation.annotations.WithSpan;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.eclipse.jnosql.mapping.Database;
import org.eclipse.jnosql.mapping.DatabaseType;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Path("/playoffs")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
Expand All @@ -20,51 +18,10 @@ public class PlayoffsResource {
@Database(DatabaseType.DOCUMENT)
Playoffs playoffs;

@GET
@Path("/tied")
@WithSpan
public List<GameMatch> tiedPlayoffs() {
return playoffs.listTiedPlayoffs();
}

@GET
@Path("/winners")
@WithSpan
public Set<String> getWinners(
@QueryParam("name") String name
) {
if (name != null)
return playoffs.findByWinnerNameLike(name)
.stream()
.map(g -> g.winner().name())
.collect(Collectors.toSet());
return playoffs.listPlayoffsWithWinnerAndLoser()
.stream()
.map(g -> g.winner().name())
.collect(Collectors.toSet());
}

@GET
@Path("/losers")
@WithSpan
public Set<String> getLosers(
@QueryParam("name") String name
) {
if (name != null)
return playoffs.findByLoserNameLike(name)
.stream()
.map(g -> g.loser().name())
.collect(Collectors.toSet());
return playoffs.listPlayoffsWithWinnerAndLoser()
.stream()
.map(g -> g.loser().name())
.collect(Collectors.toSet());
}

@GET
@Path("/ranking")
@WithSpan
public Ranking getRanking(){
return Ranking.winnerRanking(playoffs);
public Ranking getWinnerRanking(){
return playoffs.winnerRanking();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static Ranking winnerRanking(Playoffs playoffs) {

private static Ranking of(Playoffs playoffs, Function<GameMatch, String> groupingFunction) {
var data =
playoffs.listPlayoffsWithWinnerAndLoser()
playoffs.listNonTiedGameMatches()
.stream()
.collect(
Collectors.groupingBy(
Expand Down

0 comments on commit a4313cb

Please sign in to comment.