<parent>
<groupId>org.hedgecode.maven</groupId>
<artifactId>lib-parent</artifactId>
- <version>2</version>
+ <version>3</version>
<relativePath>../lib-parent/pom.xml</relativePath>
</parent>
<groupId>org.hedgecode.chess</groupId>
<artifactId>chesshog-scanner</artifactId>
<version>0.1-SNAPSHOT</version>
- <packaging>pom</packaging>
+ <packaging>jar</packaging>
<name>Hedgecode ChessHog Scanner</name>
<description>
PGNGame getGame(String gameId) throws ChessHogScannerException;
+ PGNGame getGame(String gameId, String tournamentId) throws ChessHogScannerException;
+
}
protected String assignUrl(String tournamentId, String pageId) {
String tournamentUrl = assignUrlWithParams(
- settings.getTournamentUrl(), settings.getGameQueryParams()
+ settings.getTournamentUrl(), settings.getTournamentQueryParams()
);
return RegexBuilder.build(
Type.TOURNAMENT,
);
}
+ protected String assignUrl(String gameId, String tournamentId, boolean withTournament) {
+ String gameUrl = settings.getGamePgnUrl() != null
+ ? settings.getGamePgnUrl()
+ : settings.getGameUrl();
+ return RegexBuilder.build(
+ Type.GAME,
+ assignUrlWithParams(gameUrl, settings.getGameQueryParams()),
+ new RegexParams(
+ gameId,
+ tournamentId,
+ withTournament
+ )
+ );
+ }
+
protected String assignUrl(String query, boolean isUrlEncode) {
return RegexBuilder.build(
Type.QUERY,
settings.getTournamentQuery(),
- new RegexParams(query, isUrlEncode)
+ new RegexParams(
+ query,
+ isUrlEncode
+ )
);
}
);
}
+ @Override
+ public PGNGame getGame(String gameId, String tournamentId) throws ChessHogScannerException {
+ return getGame(gameId);
+ }
+
private void assignTournamentGames(PGNTournament tournament) throws ChessHogScannerException {
tournament.clearGames();
List<String> gamesId = new ArrayList<>();
);
}
+ @Override
+ public PGNGame getGame(String gameId, String tournamentId) throws ChessHogScannerException {
+ return getGame(gameId);
+ }
+
private void assignTournamentGames(PGNTournament tournament) throws ChessHogScannerException {
tournament.clearGames();
List<String> pgnGames = split(
GAME {
@Override
public String format(String target, RegexParams params) {
+ if (params.getTournamentId() != null) {
+ target = target.replace(
+ RegexParams.TOURNAMENT_ID,
+ params.getTournamentId()
+ );
+ }
return target.replace(
RegexParams.GAME_ID,
params.getGameId()
this.gameId = gameId;
}
+ public RegexParams(String gameId, String tournamentId, boolean withTournament) {
+ this.gameId = gameId;
+ if (withTournament) {
+ this.tournamentId = tournamentId;
+ }
+ }
+
public RegexParams(String query, boolean isUrlEncode) {
this.query = query;
this.isUrlEncode = isUrlEncode;