repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
gcewing/SGCraft | src/base/gcewing/sg/BaseRenderTarget.java | // Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITexture {
// ResourceLocation location();
// int tintIndex();
// double red();
// double green();
// double blue();
// double interpolateU(double u);
// double interpolateV(double v);
// boolean isEmissive();
// boolean isProjected();
// boolean isSolid();
// ITexture tinted(int index);
// ITexture colored(double red, double green, double blue);
// ITexture projected();
// ITexture emissive();
// ITiledTexture tiled(int numRows, int numCols);
// }
| import java.util.*;
import java.nio.*;
import static java.lang.Math.*;
import net.minecraft.block.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.item.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraftforge.client.model.*;
import gcewing.sg.BaseModClient.ITexture; | //------------------------------------------------------------------------------------------------
//
// Greg's Mod Base for 1.7 Version B - Rendering target base class
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
// import net.minecraft.block.state.*;
// import net.minecraft.client.renderer.block.model.*;
//import net.minecraft.client.renderer.vertex.*;
// import net.minecraft.client.resources.model.*;
public abstract class BaseRenderTarget implements BaseModClient.IRenderTarget {
// Position of block in rendering coordinates (may be different from world coordinates)
protected double blockX, blockY, blockZ;
protected int verticesPerFace;
protected int vertexCount; | // Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITexture {
// ResourceLocation location();
// int tintIndex();
// double red();
// double green();
// double blue();
// double interpolateU(double u);
// double interpolateV(double v);
// boolean isEmissive();
// boolean isProjected();
// boolean isSolid();
// ITexture tinted(int index);
// ITexture colored(double red, double green, double blue);
// ITexture projected();
// ITexture emissive();
// ITiledTexture tiled(int numRows, int numCols);
// }
// Path: src/base/gcewing/sg/BaseRenderTarget.java
import java.util.*;
import java.nio.*;
import static java.lang.Math.*;
import net.minecraft.block.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.item.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraftforge.client.model.*;
import gcewing.sg.BaseModClient.ITexture;
//------------------------------------------------------------------------------------------------
//
// Greg's Mod Base for 1.7 Version B - Rendering target base class
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
// import net.minecraft.block.state.*;
// import net.minecraft.client.renderer.block.model.*;
//import net.minecraft.client.renderer.vertex.*;
// import net.minecraft.client.resources.model.*;
public abstract class BaseRenderTarget implements BaseModClient.IRenderTarget {
// Position of block in rendering coordinates (may be different from world coordinates)
protected double blockX, blockY, blockZ;
protected int verticesPerFace;
protected int vertexCount; | protected ITexture texture; |
gcewing/SGCraft | src/mod/gcewing/sg/DHDBlock.java | // Path: src/base/gcewing/sg/BaseMod.java
// public static class ModelSpec {
// public String modelName;
// public String[] textureNames;
// public Vector3 origin;
// public ModelSpec(String model, String... textures) {
// this(model, Vector3.zero, textures);
// }
// public ModelSpec(String model, Vector3 origin, String... textures) {
// modelName = model;
// textureNames = textures;
// this.origin = origin;
// }
// }
| import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.creativetab.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import gcewing.sg.BaseMod.ModelSpec; | //------------------------------------------------------------------------------------------------
//
// SG Craft - Stargate Controller Block
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
// import net.minecraft.block.state.IBlockState;
public class DHDBlock extends BaseBlock<DHDTE> {
protected static String[] textures = {
"dhd_top",
"dhd_side",
"stargateBlock",
"dhd_button_dim",
}; | // Path: src/base/gcewing/sg/BaseMod.java
// public static class ModelSpec {
// public String modelName;
// public String[] textureNames;
// public Vector3 origin;
// public ModelSpec(String model, String... textures) {
// this(model, Vector3.zero, textures);
// }
// public ModelSpec(String model, Vector3 origin, String... textures) {
// modelName = model;
// textureNames = textures;
// this.origin = origin;
// }
// }
// Path: src/mod/gcewing/sg/DHDBlock.java
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.creativetab.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import gcewing.sg.BaseMod.ModelSpec;
//------------------------------------------------------------------------------------------------
//
// SG Craft - Stargate Controller Block
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
// import net.minecraft.block.state.IBlockState;
public class DHDBlock extends BaseBlock<DHDTE> {
protected static String[] textures = {
"dhd_top",
"dhd_side",
"stargateBlock",
"dhd_button_dim",
}; | protected static ModelSpec model = new ModelSpec("dhd.smeg", new Vector3(0, -0.5, 0), textures); |
gcewing/SGCraft | src/base/gcewing/sg/BaseTexture.java | // Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITexture {
// ResourceLocation location();
// int tintIndex();
// double red();
// double green();
// double blue();
// double interpolateU(double u);
// double interpolateV(double v);
// boolean isEmissive();
// boolean isProjected();
// boolean isSolid();
// ITexture tinted(int index);
// ITexture colored(double red, double green, double blue);
// ITexture projected();
// ITexture emissive();
// ITiledTexture tiled(int numRows, int numCols);
// }
//
// Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITiledTexture extends ITexture {
// ITexture tile(int row, int col);
// }
| import net.minecraft.client.renderer.texture.*;
import net.minecraft.util.*;
import gcewing.sg.BaseModClient.ITexture;
import gcewing.sg.BaseModClient.ITiledTexture; | public ResourceLocation location() {
return location;
}
public ITexture tinted(int index) {
BaseTexture result = new Proxy(this);
result.tintIndex = index;
return result;
}
public ITexture colored(double red, double green, double blue) {
BaseTexture result = new Proxy(this);
result.red = red;
result.green = green;
result.blue = blue;
return result;
}
public ITexture emissive() {
BaseTexture result = new Proxy(this);
result.isEmissive = true;
return result;
}
public ITexture projected() {
BaseTexture result = new Proxy(this);
result.isProjected = true;
return result;
}
| // Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITexture {
// ResourceLocation location();
// int tintIndex();
// double red();
// double green();
// double blue();
// double interpolateU(double u);
// double interpolateV(double v);
// boolean isEmissive();
// boolean isProjected();
// boolean isSolid();
// ITexture tinted(int index);
// ITexture colored(double red, double green, double blue);
// ITexture projected();
// ITexture emissive();
// ITiledTexture tiled(int numRows, int numCols);
// }
//
// Path: src/base/gcewing/sg/BaseModClient.java
// public interface ITiledTexture extends ITexture {
// ITexture tile(int row, int col);
// }
// Path: src/base/gcewing/sg/BaseTexture.java
import net.minecraft.client.renderer.texture.*;
import net.minecraft.util.*;
import gcewing.sg.BaseModClient.ITexture;
import gcewing.sg.BaseModClient.ITiledTexture;
public ResourceLocation location() {
return location;
}
public ITexture tinted(int index) {
BaseTexture result = new Proxy(this);
result.tintIndex = index;
return result;
}
public ITexture colored(double red, double green, double blue) {
BaseTexture result = new Proxy(this);
result.red = red;
result.green = green;
result.blue = blue;
return result;
}
public ITexture emissive() {
BaseTexture result = new Proxy(this);
result.isEmissive = true;
return result;
}
public ITexture projected() {
BaseTexture result = new Proxy(this);
result.isProjected = true;
return result;
}
| public ITiledTexture tiled(int numRows, int numCols) { |
gcewing/SGCraft | src/base/gcewing/sg/BaseMod.java | // Path: src/base/gcewing/sg/BaseModClient.java
// public interface IModel {
// AxisAlignedBB getBounds();
// void addBoxesToList(Trans3 t, List list);
// void render(Trans3 t, IRenderTarget renderer, ITexture... textures);
// }
| import java.io.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import java.util.jar.*;
import net.minecraft.block.*;
import net.minecraft.creativetab.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.network.Packet;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraftforge.common.*;
import net.minecraftforge.common.config.*;
import net.minecraftforge.client.*;
import net.minecraftforge.oredict.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.registry.VillagerRegistry.*;
import cpw.mods.fml.relauncher.*;
import gcewing.sg.BaseModClient.IModel; | //------------------------------------------------------------------------------------------------
//
// Greg's Mod Base for 1.7 Version B - Generic Mod
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
//import net.minecraft.block.state.IBlockState;
public class BaseMod<CLIENT extends BaseModClient<? extends BaseMod>>
extends BaseSubsystem implements IGuiHandler
{
| // Path: src/base/gcewing/sg/BaseModClient.java
// public interface IModel {
// AxisAlignedBB getBounds();
// void addBoxesToList(Trans3 t, List list);
// void render(Trans3 t, IRenderTarget renderer, ITexture... textures);
// }
// Path: src/base/gcewing/sg/BaseMod.java
import java.io.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import java.util.jar.*;
import net.minecraft.block.*;
import net.minecraft.creativetab.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.network.Packet;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.world.*;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraftforge.common.*;
import net.minecraftforge.common.config.*;
import net.minecraftforge.client.*;
import net.minecraftforge.oredict.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.registry.VillagerRegistry.*;
import cpw.mods.fml.relauncher.*;
import gcewing.sg.BaseModClient.IModel;
//------------------------------------------------------------------------------------------------
//
// Greg's Mod Base for 1.7 Version B - Generic Mod
//
//------------------------------------------------------------------------------------------------
package gcewing.sg;
//import net.minecraft.block.state.IBlockState;
public class BaseMod<CLIENT extends BaseModClient<? extends BaseMod>>
extends BaseSubsystem implements IGuiHandler
{
| protected Map<ResourceLocation, IModel> modelCache = new HashMap<ResourceLocation, IModel>(); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.nio.file.Path; | package pl.setblack.pongi.scores.repo;
public class ScoreRepositoryES implements ScoresRepository {
private final Persistent<ScoresRepositoryInMem> perstenceController;
public ScoreRepositoryES(Path where) {
this.perstenceController = Persistent.loadOptional(
where, () -> new ScoresRepositoryInMem());
}
@Override | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.nio.file.Path;
package pl.setblack.pongi.scores.repo;
public class ScoreRepositoryES implements ScoresRepository {
private final Persistent<ScoresRepositoryInMem> perstenceController;
public ScoreRepositoryES(Path where) {
this.perstenceController = Persistent.loadOptional(
where, () -> new ScoresRepositoryInMem());
}
@Override | public List<UserScore> getTopScores(int limit) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.nio.file.Path; | package pl.setblack.pongi.scores.repo;
public class ScoreRepositoryES implements ScoresRepository {
private final Persistent<ScoresRepositoryInMem> perstenceController;
public ScoreRepositoryES(Path where) {
this.perstenceController = Persistent.loadOptional(
where, () -> new ScoresRepositoryInMem());
}
@Override
public List<UserScore> getTopScores(int limit) {
return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
}
@Override | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.nio.file.Path;
package pl.setblack.pongi.scores.repo;
public class ScoreRepositoryES implements ScoresRepository {
private final Persistent<ScoresRepositoryInMem> perstenceController;
public ScoreRepositoryES(Path where) {
this.perstenceController = Persistent.loadOptional(
where, () -> new ScoresRepositoryInMem());
}
@Override
public List<UserScore> getTopScores(int limit) {
return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
}
@Override | public void registerScore(List<ScoreRecord> rec) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java | // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
| import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.nio.file.Path; | package pl.setblack.pongi.users.repo;
public class UsersRepoES implements UsersRepository {
private final Persistent<UsersRepositoryInMemory> controller;
public UsersRepoES(Path where) {
controller = Persistent.loadOptional(
where,
() -> new UsersRepositoryInMemory());
}
public void close() {
this.controller.close();
}
@Override | // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.nio.file.Path;
package pl.setblack.pongi.users.repo;
public class UsersRepoES implements UsersRepository {
private final Persistent<UsersRepositoryInMemory> controller;
public UsersRepoES(Path where) {
controller = Persistent.loadOptional(
where,
() -> new UsersRepositoryInMemory());
}
public void close() {
this.controller.close();
}
@Override | public RegUserStatus addUser(String login, String pass) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersService.java | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
| import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson; | package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
| // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersService.java
import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson;
package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
| private final SessionsRepo sessionsRepo; |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersService.java | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
| import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson; | package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
| // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersService.java
import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson;
package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
| public UsersService(UsersRepository usersRepo, SessionsRepo sessionsRepo) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersService.java | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
| import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson; | package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
public UsersService(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = new UsersRepositoryProcessor(usersRepo);
this.sessionsRepo = sessionsRepo;
}
public Action<Chain> usersApi() {
return apiChain -> apiChain
.prefix("users", users())
.prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id"); | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersService.java
import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson;
package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
public UsersService(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = new UsersRepositoryProcessor(usersRepo);
this.sessionsRepo = sessionsRepo;
}
public Action<Chain> usersApi() {
return apiChain -> apiChain
.prefix("users", users())
.prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id"); | ctx.parse(NewUser.class).then( |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersService.java | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
| import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson; | package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
public UsersService(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = new UsersRepositoryProcessor(usersRepo);
this.sessionsRepo = sessionsRepo;
}
public Action<Chain> usersApi() {
return apiChain -> apiChain
.prefix("users", users())
.prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id");
ctx.parse(NewUser.class).then(
newUser -> { | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersService.java
import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson;
package pl.setblack.pongi.users;
/**
* Created by jarek on 1/29/17.
*/
public class UsersService {
private final UsersRepositoryProcessor usersRepo;
private final SessionsRepo sessionsRepo;
public UsersService(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = new UsersRepositoryProcessor(usersRepo);
this.sessionsRepo = sessionsRepo;
}
public Action<Chain> usersApi() {
return apiChain -> apiChain
.prefix("users", users())
.prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id");
ctx.parse(NewUser.class).then(
newUser -> { | ctx.render(JsonMapping.toJsonPromise(usersRepo.addUser(userId, newUser.password))); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersService.java | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
| import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson; | .prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id");
ctx.parse(NewUser.class).then(
newUser -> {
ctx.render(JsonMapping.toJsonPromise(usersRepo.addUser(userId, newUser.password)));
}
);
};
}
private Handler loginUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id"); | // Path: src/main/java/pl/setblack/pongi/JsonMapping.java
// public class JsonMapping {
//
// private static final ObjectMapper MAPPER = configureMapping();
//
// private static ObjectMapper configureMapping() {
// return new ObjectMapper()
// .registerModule(new ParameterNamesModule())
// .registerModule(new Jdk8Module())
// .registerModule(new JavaTimeModule())
// .registerModule(new JavaslangModule());
// }
//
//
// public static final ObjectMapper getJsonMapping() {
// return JsonMapping.MAPPER;
// }
//
// public static Promise<JsonRender> toJsonPromise(CompletionStage<?> future) {
// return Promise.async(
// d -> d.accept(future.thenApply(Jackson::json))
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/LoginData.java
// @Immutable
// @JsonDeserialize
// public class LoginData {
// public final String password;
//
// @JsonCreator
// public LoginData(String password) {
// this.password = password;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/NewUser.java
// @Immutable
// @JsonDeserialize
// public class NewUser {
// public final String password;
//
// @JsonCreator
// public NewUser(String password) {
// this.password = password;
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
// public class UsersRepositoryProcessor {
// private final UsersRepository usersRepository;
//
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
//
// public UsersRepositoryProcessor(UsersRepository usersRepository) {
// this.usersRepository = usersRepository;
// }
//
// public CompletionStage<RegUserStatus> addUser(final String login, final String pass) {
// final CompletableFuture<RegUserStatus> result = new CompletableFuture<>();
// writesExecutor.execute(() -> {
// result.complete(this.usersRepository.addUser(login, pass));
// });
// return result;
// }
//
// public boolean login(final String login, final String pass) {
// return this.usersRepository.login(login, pass);
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersService.java
import javaslang.control.Option;
import pl.setblack.pongi.JsonMapping;
import pl.setblack.pongi.users.api.LoginData;
import pl.setblack.pongi.users.api.NewUser;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepository;
import pl.setblack.pongi.users.repo.UsersRepositoryProcessor;
import ratpack.func.Action;
import ratpack.handling.Chain;
import ratpack.handling.Handler;
import ratpack.jackson.Jackson;
.prefix("sessions", sessions());
}
private Action<Chain> users() {
return chain -> chain
.post(":id", addUser());
}
private Action<Chain> sessions() {
return chain -> chain
.post(":id", loginUser());
}
private Handler addUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id");
ctx.parse(NewUser.class).then(
newUser -> {
ctx.render(JsonMapping.toJsonPromise(usersRepo.addUser(userId, newUser.password)));
}
);
};
}
private Handler loginUser() {
return ctx -> {
final String userId = ctx.getPathTokens().get("id"); | ctx.parse(LoginData.class).then( |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore; | package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public interface ScoresRepository {
void registerScore(List<ScoreRecord> rec);
| // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java
import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public interface ScoresRepository {
void registerScore(List<ScoreRecord> rec);
| Option<UserScore> getUserScore(String userId); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/ScoresModule.java | // Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
// public class ScoreRepositoryES implements ScoresRepository {
//
// private final Persistent<ScoresRepositoryInMem> perstenceController;
//
// public ScoreRepositoryES(Path where) {
// this.perstenceController = Persistent.loadOptional(
// where, () -> new ScoresRepositoryInMem());
// }
//
// @Override
// public List<UserScore> getTopScores(int limit) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
// }
//
// @Override
// public void registerScore(List<ScoreRecord> rec) {
//
// this.perstenceController.execute(scoreRepo -> scoreRepo.registerScore(rec));
// }
//
// @Override
// public Option<UserScore> getUserScore(String userId) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getUserScore(userId));
// }
//
// public void close() {
// this.perstenceController.close();
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java
// public interface ScoresRepository {
//
// void registerScore(List<ScoreRecord> rec);
//
// Option<UserScore> getUserScore(String userId);
//
// List<UserScore> getTopScores(final int limit);
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
| import pl.setblack.pongi.scores.repo.ScoreRepositoryES;
import pl.setblack.pongi.scores.repo.ScoresRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import java.nio.file.Paths; | package pl.setblack.pongi.scores;
/**
* Created by jarek on 2/13/17.
*/
public class ScoresModule {
private final ScoresRepositoryProcessor scoresRepository;
| // Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
// public class ScoreRepositoryES implements ScoresRepository {
//
// private final Persistent<ScoresRepositoryInMem> perstenceController;
//
// public ScoreRepositoryES(Path where) {
// this.perstenceController = Persistent.loadOptional(
// where, () -> new ScoresRepositoryInMem());
// }
//
// @Override
// public List<UserScore> getTopScores(int limit) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
// }
//
// @Override
// public void registerScore(List<ScoreRecord> rec) {
//
// this.perstenceController.execute(scoreRepo -> scoreRepo.registerScore(rec));
// }
//
// @Override
// public Option<UserScore> getUserScore(String userId) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getUserScore(userId));
// }
//
// public void close() {
// this.perstenceController.close();
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java
// public interface ScoresRepository {
//
// void registerScore(List<ScoreRecord> rec);
//
// Option<UserScore> getUserScore(String userId);
//
// List<UserScore> getTopScores(final int limit);
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
import pl.setblack.pongi.scores.repo.ScoreRepositoryES;
import pl.setblack.pongi.scores.repo.ScoresRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import java.nio.file.Paths;
package pl.setblack.pongi.scores;
/**
* Created by jarek on 2/13/17.
*/
public class ScoresModule {
private final ScoresRepositoryProcessor scoresRepository;
| public ScoresModule(ScoresRepository scoresRepository) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/ScoresModule.java | // Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
// public class ScoreRepositoryES implements ScoresRepository {
//
// private final Persistent<ScoresRepositoryInMem> perstenceController;
//
// public ScoreRepositoryES(Path where) {
// this.perstenceController = Persistent.loadOptional(
// where, () -> new ScoresRepositoryInMem());
// }
//
// @Override
// public List<UserScore> getTopScores(int limit) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
// }
//
// @Override
// public void registerScore(List<ScoreRecord> rec) {
//
// this.perstenceController.execute(scoreRepo -> scoreRepo.registerScore(rec));
// }
//
// @Override
// public Option<UserScore> getUserScore(String userId) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getUserScore(userId));
// }
//
// public void close() {
// this.perstenceController.close();
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java
// public interface ScoresRepository {
//
// void registerScore(List<ScoreRecord> rec);
//
// Option<UserScore> getUserScore(String userId);
//
// List<UserScore> getTopScores(final int limit);
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
| import pl.setblack.pongi.scores.repo.ScoreRepositoryES;
import pl.setblack.pongi.scores.repo.ScoresRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import java.nio.file.Paths; | package pl.setblack.pongi.scores;
/**
* Created by jarek on 2/13/17.
*/
public class ScoresModule {
private final ScoresRepositoryProcessor scoresRepository;
public ScoresModule(ScoresRepository scoresRepository) {
this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
}
public ScoresModule() { | // Path: src/main/java/pl/setblack/pongi/scores/repo/ScoreRepositoryES.java
// public class ScoreRepositoryES implements ScoresRepository {
//
// private final Persistent<ScoresRepositoryInMem> perstenceController;
//
// public ScoreRepositoryES(Path where) {
// this.perstenceController = Persistent.loadOptional(
// where, () -> new ScoresRepositoryInMem());
// }
//
// @Override
// public List<UserScore> getTopScores(int limit) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getTopScores(limit));
// }
//
// @Override
// public void registerScore(List<ScoreRecord> rec) {
//
// this.perstenceController.execute(scoreRepo -> scoreRepo.registerScore(rec));
// }
//
// @Override
// public Option<UserScore> getUserScore(String userId) {
// return this.perstenceController.query(scoreRepo -> scoreRepo.getUserScore(userId));
// }
//
// public void close() {
// this.perstenceController.close();
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepository.java
// public interface ScoresRepository {
//
// void registerScore(List<ScoreRecord> rec);
//
// Option<UserScore> getUserScore(String userId);
//
// List<UserScore> getTopScores(final int limit);
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
import pl.setblack.pongi.scores.repo.ScoreRepositoryES;
import pl.setblack.pongi.scores.repo.ScoresRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import java.nio.file.Paths;
package pl.setblack.pongi.scores;
/**
* Created by jarek on 2/13/17.
*/
public class ScoresModule {
private final ScoresRepositoryProcessor scoresRepository;
public ScoresModule(ScoresRepository scoresRepository) {
this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
}
public ScoresModule() { | this(new ScoreRepositoryES(Paths.get("airomem/score"))); |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java | // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
| import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | package pl.setblack.pongi.scores.repo;
abstract class ScoresRepositoryBase {
protected ScoresRepository testee;
@Test
public void shouldCollectSingleWinUserScore() { | // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
// Path: src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java
import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
package pl.setblack.pongi.scores.repo;
abstract class ScoresRepositoryBase {
protected ScoresRepository testee;
@Test
public void shouldCollectSingleWinUserScore() { | final ScoreRecord singleGameResult = singleWin("aa"); |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java | // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
| import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | package pl.setblack.pongi.scores.repo;
abstract class ScoresRepositoryBase {
protected ScoresRepository testee;
@Test
public void shouldCollectSingleWinUserScore() {
final ScoreRecord singleGameResult = singleWin("aa");
testee.registerScore(List.of(singleGameResult));
assertThat( testee.getUserScore("aa").get().gamesWon, is (equalTo(1)) );
}
@Test
public void shouldCalculateScoreForWin() {
final ScoreRecord singleGameResult = singleWin("aa");
testee.registerScore(List.of(singleGameResult));
| // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
// Path: src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java
import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
package pl.setblack.pongi.scores.repo;
abstract class ScoresRepositoryBase {
protected ScoresRepository testee;
@Test
public void shouldCollectSingleWinUserScore() {
final ScoreRecord singleGameResult = singleWin("aa");
testee.registerScore(List.of(singleGameResult));
assertThat( testee.getUserScore("aa").get().gamesWon, is (equalTo(1)) );
}
@Test
public void shouldCalculateScoreForWin() {
final ScoreRecord singleGameResult = singleWin("aa");
testee.registerScore(List.of(singleGameResult));
| assertThat( testee.getUserScore("aa").get().totalScore, is (equalTo(ScoreRules.SCORE_FOR_WIN)) ); |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java | // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
| import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; |
@Test
public void shouldSelectTop5() {
recordTestGames();
assertThat( testee.getTopScores(5).map( score -> score.userId),
is (equalTo(List.of("jacek0", "jacek1", "jacek2", "jacek3", "jacek4")) ));
}
@Test
public void shouldReturnOnly5Elements() {
recordTestGames();
assertThat( testee.getTopScores(5).size(),
is (equalTo(5) ));
}
private void recordTestGames() {
for ( int j =0 ; j < 12 ; j++) {
for (int i = 0; i < j; i++) {
final List<ScoreRecord> game = makeGameScore("jacek" + i, "placek" + i);
testee.registerScore(game);
}
}
}
private List<ScoreRecord> makeGameScore(final String winner, final String loser) {
return List.of( singleWin(winner), singleLoss(loser));
}
private ScoreRecord singleWin(final String userId) {
return new ScoreRecord(userId, | // Path: src/main/java/pl/setblack/pongi/scores/GameResult.java
// public enum GameResult {
// WON(ScoreRules.SCORE_FOR_WIN),
// LOST(ScoreRules.SCORE_FOR_LOSS);
//
// public final int score;
//
// GameResult(int score) {
// this.score = score;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoreRules.java
// public final class ScoreRules {
// public static final int SCORE_FOR_WIN = 5;
// public static final int SCORE_FOR_LOSS = 0;
//
// }
// Path: src/test/java/pl/setblack/pongi/scores/repo/ScoresRepositoryBase.java
import javaslang.collection.List;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.scores.GameResult;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.ScoreRules;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
@Test
public void shouldSelectTop5() {
recordTestGames();
assertThat( testee.getTopScores(5).map( score -> score.userId),
is (equalTo(List.of("jacek0", "jacek1", "jacek2", "jacek3", "jacek4")) ));
}
@Test
public void shouldReturnOnly5Elements() {
recordTestGames();
assertThat( testee.getTopScores(5).size(),
is (equalTo(5) ));
}
private void recordTestGames() {
for ( int j =0 ; j < 12 ; j++) {
for (int i = 0; i < j; i++) {
final List<ScoreRecord> game = makeGameScore("jacek" + i, "placek" + i);
testee.registerScore(game);
}
}
}
private List<ScoreRecord> makeGameScore(final String winner, final String loser) {
return List.of( singleWin(winner), singleLoss(loser));
}
private ScoreRecord singleWin(final String userId) {
return new ScoreRecord(userId, | GameResult.WON, |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/Main.java | // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
| import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock; | package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
| // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/Main.java
import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock;
package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
| final UsersModule usersModule = new UsersModule(clock); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/Main.java | // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
| import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock; | package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
final UsersModule usersModule = new UsersModule(clock); | // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/Main.java
import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock;
package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
final UsersModule usersModule = new UsersModule(clock); | final ScoresModule scoresModule = new ScoresModule(); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/Main.java | // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
| import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock; | package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
final UsersModule usersModule = new UsersModule(clock);
final ScoresModule scoresModule = new ScoresModule(); | // Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
// public class GamesModule {
// private final GamesRepository gamesRepo;
//
// private final SessionsRepo sessionsRepo;
//
// private final ScoresRepositoryProcessor scoresRepo;
//
//
// public GamesModule(GamesRepository gamesRepo,
// SessionsRepo sessionsRepo,
// ScoresRepositoryProcessor scoresRepo) {
// this.gamesRepo = gamesRepo;
// this.sessionsRepo = sessionsRepo;
// this.scoresRepo = scoresRepo;
// }
//
// public GamesModule(
// final Clock clock,
// final SessionsRepo sessionsRepo,
// final ScoresRepositoryProcessor scoresRepo) {
// this(
// new GamesRepoES(clock),
// sessionsRepo,
// scoresRepo);
// }
//
//
// public GamesService createService() {
// return new GamesService(gamesRepo, sessionsRepo, scoresRepo);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/ScoresModule.java
// public class ScoresModule {
//
// private final ScoresRepositoryProcessor scoresRepository;
//
// public ScoresModule(ScoresRepository scoresRepository) {
// this.scoresRepository = new ScoresRepositoryProcessor(scoresRepository);
// }
//
// public ScoresModule() {
// this(new ScoreRepositoryES(Paths.get("airomem/score")));
// }
//
// public ScoresService createService() {
// return new ScoresService(scoresRepository);
// }
//
// public ScoresRepositoryProcessor getScoresRepository() {
// return this.scoresRepository;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
// public class UsersModule {
//
// private final UsersRepository usersRepo;
// private final SessionsRepo sessionsRepo;
//
//
// public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
// this.usersRepo = usersRepo;
// this.sessionsRepo = sessionsRepo;
// }
//
// public UsersModule(Clock clock) {
// this(
// new UsersRepoES(Paths.get("airomem/users")),
// new SessionsRepo(clock));
// }
//
// public UsersService createService() {
// return new UsersService(this.usersRepo, this.sessionsRepo);
// }
//
// public SessionsRepo getSessionsRepo() {
// return this.sessionsRepo;
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/Main.java
import pl.setblack.pongi.games.GamesModule;
import pl.setblack.pongi.scores.ScoresModule;
import pl.setblack.pongi.users.UsersModule;
import java.time.Clock;
package pl.setblack.pongi;
public class Main {
public static void main(final String... args) throws Exception {
final Clock clock = Clock.systemUTC();
final UsersModule usersModule = new UsersModule(clock);
final ScoresModule scoresModule = new ScoresModule(); | final GamesModule gamesModule = new GamesModule( |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/users/repo/UsersRepositoryTest.java | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
| import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.AiromemHelper;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | package pl.setblack.pongi.users.repo;
class UsersRepositoryTest extends UserRepositoryBase{
@BeforeEach
public void initRepo() {
this.usersRepository = new UsersRepositoryInMemory();
}
}
class UserPersistentRepoTest extends UserRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private UsersRepoES persistentRepo;
@BeforeEach
public void initRepo() {
this.persistentRepo = new UsersRepoES(testRepoPath);
this.usersRepository = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException{
this.persistentRepo.close(); | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
// Path: src/test/java/pl/setblack/pongi/users/repo/UsersRepositoryTest.java
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.AiromemHelper;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
package pl.setblack.pongi.users.repo;
class UsersRepositoryTest extends UserRepositoryBase{
@BeforeEach
public void initRepo() {
this.usersRepository = new UsersRepositoryInMemory();
}
}
class UserPersistentRepoTest extends UserRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private UsersRepoES persistentRepo;
@BeforeEach
public void initRepo() {
this.persistentRepo = new UsersRepoES(testRepoPath);
this.usersRepository = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException{
this.persistentRepo.close(); | AiromemHelper.clearFolder(testRepoPath); |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/users/repo/UsersRepositoryTest.java | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
| import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.AiromemHelper;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; | package pl.setblack.pongi.users.repo;
class UsersRepositoryTest extends UserRepositoryBase{
@BeforeEach
public void initRepo() {
this.usersRepository = new UsersRepositoryInMemory();
}
}
class UserPersistentRepoTest extends UserRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private UsersRepoES persistentRepo;
@BeforeEach
public void initRepo() {
this.persistentRepo = new UsersRepoES(testRepoPath);
this.usersRepository = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException{
this.persistentRepo.close();
AiromemHelper.clearFolder(testRepoPath);
}
}
abstract class UserRepositoryBase {
protected UsersRepository usersRepository;
@Test
public void shouldRegisterUserOnce() { | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
// Path: src/test/java/pl/setblack/pongi/users/repo/UsersRepositoryTest.java
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import pl.setblack.pongi.AiromemHelper;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
package pl.setblack.pongi.users.repo;
class UsersRepositoryTest extends UserRepositoryBase{
@BeforeEach
public void initRepo() {
this.usersRepository = new UsersRepositoryInMemory();
}
}
class UserPersistentRepoTest extends UserRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private UsersRepoES persistentRepo;
@BeforeEach
public void initRepo() {
this.persistentRepo = new UsersRepoES(testRepoPath);
this.usersRepository = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException{
this.persistentRepo.close();
AiromemHelper.clearFolder(testRepoPath);
}
}
abstract class UserRepositoryBase {
protected UsersRepository usersRepository;
@Test
public void shouldRegisterUserOnce() { | final RegUserStatus result = this.usersRepository.addUser( "irreg" , "baaaa"); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java | // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
| import pl.setblack.pongi.users.api.RegUserStatus;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; | package pl.setblack.pongi.users.repo;
/**
* Created by jarek on 1/30/17.
*/
public class UsersRepositoryProcessor {
private final UsersRepository usersRepository;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public UsersRepositoryProcessor(UsersRepository usersRepository) {
this.usersRepository = usersRepository;
}
| // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryProcessor.java
import pl.setblack.pongi.users.api.RegUserStatus;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
package pl.setblack.pongi.users.repo;
/**
* Created by jarek on 1/30/17.
*/
public class UsersRepositoryProcessor {
private final UsersRepository usersRepository;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public UsersRepositoryProcessor(UsersRepository usersRepository) {
this.usersRepository = usersRepository;
}
| public CompletionStage<RegUserStatus> addUser(final String login, final String pass) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryProcessor.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.function.Supplier; | package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public class GamesRepositoryProcessor {
private final GamesRepository gamesRepo;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public GamesRepositoryProcessor(GamesRepository gamesRepo) {
this.gamesRepo = gamesRepo;
}
| // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryProcessor.java
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public class GamesRepositoryProcessor {
private final GamesRepository gamesRepo;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public GamesRepositoryProcessor(GamesRepository gamesRepo) {
this.gamesRepo = gamesRepo;
}
| public CompletionStage<Seq<GameInfo>> listGames() { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryProcessor.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.function.Supplier; | package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public class GamesRepositoryProcessor {
private final GamesRepository gamesRepo;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public GamesRepositoryProcessor(GamesRepository gamesRepo) {
this.gamesRepo = gamesRepo;
}
public CompletionStage<Seq<GameInfo>> listGames() {
return CompletableFuture.completedFuture(gamesRepo.listGames());
}
public CompletionStage<Option<GameInfo>> createGame(String uuid, String name, String userId) {
return callLongOneOperation(() -> gamesRepo.createGame(uuid, name, userId));
}
| // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryProcessor.java
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public class GamesRepositoryProcessor {
private final GamesRepository gamesRepo;
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
public GamesRepositoryProcessor(GamesRepository gamesRepo) {
this.gamesRepo = gamesRepo;
}
public CompletionStage<Seq<GameInfo>> listGames() {
return CompletableFuture.completedFuture(gamesRepo.listGames());
}
public CompletionStage<Option<GameInfo>> createGame(String uuid, String name, String userId) {
return callLongOneOperation(() -> gamesRepo.createGame(uuid, name, userId));
}
| public CompletionStage<Option<GameState>> joinGame(final String uuid, final String userId) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryInMem.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.HashMap;
import javaslang.collection.List;
import javaslang.collection.PriorityQueue;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.io.Serializable;
import java.util.Comparator; | package pl.setblack.pongi.scores.repo;
public class ScoresRepositoryInMem implements ScoresRepository, Serializable {
private static final long serialVersionUID = 1L; | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryInMem.java
import javaslang.collection.HashMap;
import javaslang.collection.List;
import javaslang.collection.PriorityQueue;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.io.Serializable;
import java.util.Comparator;
package pl.setblack.pongi.scores.repo;
public class ScoresRepositoryInMem implements ScoresRepository, Serializable {
private static final long serialVersionUID = 1L; | private volatile PriorityQueue<UserScore> bestScores; |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryInMem.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.HashMap;
import javaslang.collection.List;
import javaslang.collection.PriorityQueue;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.io.Serializable;
import java.util.Comparator; | package pl.setblack.pongi.scores.repo;
public class ScoresRepositoryInMem implements ScoresRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile PriorityQueue<UserScore> bestScores;
private volatile HashMap<String, UserScore> userScores;
public ScoresRepositoryInMem() {
this.bestScores = PriorityQueue.empty(new ScoreComparator());
this.userScores = HashMap.empty();
}
@Override | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryInMem.java
import javaslang.collection.HashMap;
import javaslang.collection.List;
import javaslang.collection.PriorityQueue;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.io.Serializable;
import java.util.Comparator;
package pl.setblack.pongi.scores.repo;
public class ScoresRepositoryInMem implements ScoresRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile PriorityQueue<UserScore> bestScores;
private volatile HashMap<String, UserScore> userScores;
public ScoresRepositoryInMem() {
this.bestScores = PriorityQueue.empty(new ScoreComparator());
this.userScores = HashMap.empty();
}
@Override | public void registerScore(List<ScoreRecord> rec) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryInMemory.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.HashMap;
import javaslang.collection.Map;
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.io.Serializable;
import java.time.Clock;
import java.util.Random; | package pl.setblack.pongi.games.repo;
public class GamesRepositoryInMemory implements GamesRepository, Serializable {
private static final long serialVersionUID = 1L; | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryInMemory.java
import javaslang.collection.HashMap;
import javaslang.collection.Map;
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.io.Serializable;
import java.time.Clock;
import java.util.Random;
package pl.setblack.pongi.games.repo;
public class GamesRepositoryInMemory implements GamesRepository, Serializable {
private static final long serialVersionUID = 1L; | private volatile Map<String, GameInfo> allGamesInfo = HashMap.empty(); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryInMemory.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.HashMap;
import javaslang.collection.Map;
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.io.Serializable;
import java.time.Clock;
import java.util.Random; | package pl.setblack.pongi.games.repo;
public class GamesRepositoryInMemory implements GamesRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile Map<String, GameInfo> allGamesInfo = HashMap.empty();
| // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepositoryInMemory.java
import javaslang.collection.HashMap;
import javaslang.collection.Map;
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.io.Serializable;
import java.time.Clock;
import java.util.Random;
package pl.setblack.pongi.games.repo;
public class GamesRepositoryInMemory implements GamesRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile Map<String, GameInfo> allGamesInfo = HashMap.empty();
| private volatile Map<String, GameState> allGamesState = HashMap.empty(); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.nio.file.Paths;
import java.time.Clock; | package pl.setblack.pongi.games.repo;
public class GamesRepoES implements GamesRepository {
final Persistent<GamesRepositoryInMemory> persistent;
public GamesRepoES(final Clock clock) {
persistent = Persistent.loadOptional(
Paths.get("airomem/games"),
() -> new GamesRepositoryInMemory(clock)
);
}
@Override | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.nio.file.Paths;
import java.time.Clock;
package pl.setblack.pongi.games.repo;
public class GamesRepoES implements GamesRepository {
final Persistent<GamesRepositoryInMemory> persistent;
public GamesRepoES(final Clock clock) {
persistent = Persistent.loadOptional(
Paths.get("airomem/games"),
() -> new GamesRepositoryInMemory(clock)
);
}
@Override | public Option<GameInfo> createGame(String uuid, String name, String userId) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.nio.file.Paths;
import java.time.Clock; | package pl.setblack.pongi.games.repo;
public class GamesRepoES implements GamesRepository {
final Persistent<GamesRepositoryInMemory> persistent;
public GamesRepoES(final Clock clock) {
persistent = Persistent.loadOptional(
Paths.get("airomem/games"),
() -> new GamesRepositoryInMemory(clock)
);
}
@Override
public Option<GameInfo> createGame(String uuid, String name, String userId) {
return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
}
@Override
public Seq<GameInfo> listGames() {
return persistent.query(rep -> rep.listGames());
}
@Override | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.airomem.core.Persistent;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
import java.nio.file.Paths;
import java.time.Clock;
package pl.setblack.pongi.games.repo;
public class GamesRepoES implements GamesRepository {
final Persistent<GamesRepositoryInMemory> persistent;
public GamesRepoES(final Clock clock) {
persistent = Persistent.loadOptional(
Paths.get("airomem/games"),
() -> new GamesRepositoryInMemory(clock)
);
}
@Override
public Option<GameInfo> createGame(String uuid, String name, String userId) {
return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
}
@Override
public Seq<GameInfo> listGames() {
return persistent.query(rep -> rep.listGames());
}
@Override | public Option<GameState> joinGame(String uuid, String userId) { |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/users/UsersServiceTest.java | // Path: src/main/java/pl/setblack/pongi/Server.java
// public class Server {
//
// private final UsersService usersService;
// private final GamesService gamesService;
// private final ScoresService scoresService;
//
// private final RatpackServer ratpackServer;
//
// public Server(UsersService usersService, GamesService gamesService, ScoresService scoresService) {
// this.usersService = usersService;
// this.gamesService = gamesService;
// this.scoresService = scoresService;
// ratpackServer =
// Try.of(() -> createDefaultServer(
// defineApi()))
// .onFailure(this::handleError).get();
// }
//
// public void start() {
// Try.run(() -> this.ratpackServer.start()).onFailure(System.out::println);
//
// }
//
// public void stop() {
// Try.run(() -> this.ratpackServer.stop());
// }
//
//
// public static RatpackServer createUnconfiguredServer(Action<Chain> handlers) {
// return createDefaultServer(makeApi(handlers), x -> x);
// }
//
// private static RatpackServer createDefaultServer(Action<Chain> handlers) {
// return createDefaultServer(makeApi(handlers).append(serveFiles()), Server::configuration);
// }
//
//
// private static Action<Chain> makeApi(Action<Chain> handlers) {
// return chain -> chain.prefix("api", handlers);
// }
//
// private static Action<Chain> serveFiles() {
// return chain -> chain
// .files(fileHandlerSpec -> fileHandlerSpec
// .dir("src/main/webapp")
// .indexFiles("index.html")
// );
// }
//
// private static RatpackServer createDefaultServer(Action<Chain> handlers,
// Function1<RatpackServerSpec, RatpackServerSpec> configuration) {
// try {
// return RatpackServer.of(server -> configuration.apply(createEmptyServer(server))
// .handlers(chain ->
// handlers.execute(chain.all(RequestLogger.ncsa()))
// )
// );
// } catch (Exception e) {
// throw new IllegalStateException(e);
// }
// }
//
//
// private Action<Chain> defineApi() {
// return apiChain -> apiChain
// .insert(usersService.usersApi())
// .insert(gamesService.gamesApi())
// .prefix("score", scoresService.scores());
// }
//
// private static RatpackServerSpec createEmptyServer(RatpackServerSpec initial)
// throws Exception {
// return initial
// .registryOf(r -> r.add(JsonMapping.getJsonMapping()));
// }
//
// private static RatpackServerSpec configuration(RatpackServerSpec server) {
// final Path currentRelativePath = Paths.get("").toAbsolutePath();
// try {
// return server.serverConfig(
// scb ->
// scb
// .baseDir(currentRelativePath)
// .publicAddress(new URI("http://0.0.0.0"))
// .port(9000)
// .threads(4)
// );
// } catch (Exception e) {
// throw new IllegalStateException(e);
// }
// }
//
//
// private void handleError(final Throwable t) {
// System.err.println(t);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryInMemory.java
// public class UsersRepositoryInMemory implements UsersRepository, Serializable {
// private static final long serialVersionUID = 1L;
//
// private volatile HashMap<String, UserData> allUsers = HashMap.empty();
//
//
// public RegUserStatus addUser(final String login, final String pass) {
// if (!allUsers.containsKey(login)) {
// allUsers = allUsers.put(login, new UserData(login, pass));
// return new RegUserStatus(Option.none());
// } else {
// return new RegUserStatus(Option.some("user existed"));
// }
// }
//
// public boolean login(final String login, final String password) {
// return allUsers.get(login).map(userData -> userData
// .hashedPassword
// .equals(password))
// .getOrElse(false);
//
// }
//
// }
| import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import pl.setblack.pongi.Server;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepositoryInMemory;
import ratpack.test.embed.EmbeddedApp;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId; | package pl.setblack.pongi.users;
class UsersServiceTest {
private final Clock clock = Clock.fixed(Instant.parse("2007-12-03T10:15:30.00Z"), ZoneId.of("GMT"));
@Test
public void shouldRegisterUser() throws Exception {
prepareServer().test(
testHttpClient -> {
final String response = testHttpClient.requestSpec(rs ->
rs.headers( mh -> mh.add("Content-type", "application/json"))
.body( body -> body.text("{\"password\": \"upa\"}")))
.post("/api/users/aa")
.getBody().getText();
assertEquals("{\"problem\":null,\"ok\":true}", response);
}
);
}
/*
* Prepare ratpack server - (but only starting one service UsersService).
*
*/
private EmbeddedApp prepareServer() {
final UsersService usersService = initService();
return EmbeddedApp.fromServer( | // Path: src/main/java/pl/setblack/pongi/Server.java
// public class Server {
//
// private final UsersService usersService;
// private final GamesService gamesService;
// private final ScoresService scoresService;
//
// private final RatpackServer ratpackServer;
//
// public Server(UsersService usersService, GamesService gamesService, ScoresService scoresService) {
// this.usersService = usersService;
// this.gamesService = gamesService;
// this.scoresService = scoresService;
// ratpackServer =
// Try.of(() -> createDefaultServer(
// defineApi()))
// .onFailure(this::handleError).get();
// }
//
// public void start() {
// Try.run(() -> this.ratpackServer.start()).onFailure(System.out::println);
//
// }
//
// public void stop() {
// Try.run(() -> this.ratpackServer.stop());
// }
//
//
// public static RatpackServer createUnconfiguredServer(Action<Chain> handlers) {
// return createDefaultServer(makeApi(handlers), x -> x);
// }
//
// private static RatpackServer createDefaultServer(Action<Chain> handlers) {
// return createDefaultServer(makeApi(handlers).append(serveFiles()), Server::configuration);
// }
//
//
// private static Action<Chain> makeApi(Action<Chain> handlers) {
// return chain -> chain.prefix("api", handlers);
// }
//
// private static Action<Chain> serveFiles() {
// return chain -> chain
// .files(fileHandlerSpec -> fileHandlerSpec
// .dir("src/main/webapp")
// .indexFiles("index.html")
// );
// }
//
// private static RatpackServer createDefaultServer(Action<Chain> handlers,
// Function1<RatpackServerSpec, RatpackServerSpec> configuration) {
// try {
// return RatpackServer.of(server -> configuration.apply(createEmptyServer(server))
// .handlers(chain ->
// handlers.execute(chain.all(RequestLogger.ncsa()))
// )
// );
// } catch (Exception e) {
// throw new IllegalStateException(e);
// }
// }
//
//
// private Action<Chain> defineApi() {
// return apiChain -> apiChain
// .insert(usersService.usersApi())
// .insert(gamesService.gamesApi())
// .prefix("score", scoresService.scores());
// }
//
// private static RatpackServerSpec createEmptyServer(RatpackServerSpec initial)
// throws Exception {
// return initial
// .registryOf(r -> r.add(JsonMapping.getJsonMapping()));
// }
//
// private static RatpackServerSpec configuration(RatpackServerSpec server) {
// final Path currentRelativePath = Paths.get("").toAbsolutePath();
// try {
// return server.serverConfig(
// scb ->
// scb
// .baseDir(currentRelativePath)
// .publicAddress(new URI("http://0.0.0.0"))
// .port(9000)
// .threads(4)
// );
// } catch (Exception e) {
// throw new IllegalStateException(e);
// }
// }
//
//
// private void handleError(final Throwable t) {
// System.err.println(t);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryInMemory.java
// public class UsersRepositoryInMemory implements UsersRepository, Serializable {
// private static final long serialVersionUID = 1L;
//
// private volatile HashMap<String, UserData> allUsers = HashMap.empty();
//
//
// public RegUserStatus addUser(final String login, final String pass) {
// if (!allUsers.containsKey(login)) {
// allUsers = allUsers.put(login, new UserData(login, pass));
// return new RegUserStatus(Option.none());
// } else {
// return new RegUserStatus(Option.some("user existed"));
// }
// }
//
// public boolean login(final String login, final String password) {
// return allUsers.get(login).map(userData -> userData
// .hashedPassword
// .equals(password))
// .getOrElse(false);
//
// }
//
// }
// Path: src/test/java/pl/setblack/pongi/users/UsersServiceTest.java
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import pl.setblack.pongi.Server;
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepositoryInMemory;
import ratpack.test.embed.EmbeddedApp;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
package pl.setblack.pongi.users;
class UsersServiceTest {
private final Clock clock = Clock.fixed(Instant.parse("2007-12-03T10:15:30.00Z"), ZoneId.of("GMT"));
@Test
public void shouldRegisterUser() throws Exception {
prepareServer().test(
testHttpClient -> {
final String response = testHttpClient.requestSpec(rs ->
rs.headers( mh -> mh.add("Content-type", "application/json"))
.body( body -> body.text("{\"password\": \"upa\"}")))
.post("/api/users/aa")
.getBody().getText();
assertEquals("{\"problem\":null,\"ok\":true}", response);
}
);
}
/*
* Prepare ratpack server - (but only starting one service UsersService).
*
*/
private EmbeddedApp prepareServer() {
final UsersService usersService = initService();
return EmbeddedApp.fromServer( | Server.createUnconfiguredServer(usersService.usersApi()) |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersModule.java | // Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java
// public class UsersRepoES implements UsersRepository {
//
//
// private final Persistent<UsersRepositoryInMemory> controller;
//
//
// public UsersRepoES(Path where) {
// controller = Persistent.loadOptional(
// where,
// () -> new UsersRepositoryInMemory());
// }
//
// public void close() {
// this.controller.close();
// }
//
// @Override
// public RegUserStatus addUser(String login, String pass) {
// return controller.executeAndQuery(usersRepo -> usersRepo.addUser(login, pass));
// }
//
// @Override
// public boolean login(String login, String password) {
// return controller.query(usersRepo -> usersRepo.login(login, password));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
| import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepoES;
import pl.setblack.pongi.users.repo.UsersRepository;
import java.nio.file.Paths;
import java.time.Clock; | package pl.setblack.pongi.users;
public class UsersModule {
private final UsersRepository usersRepo; | // Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java
// public class UsersRepoES implements UsersRepository {
//
//
// private final Persistent<UsersRepositoryInMemory> controller;
//
//
// public UsersRepoES(Path where) {
// controller = Persistent.loadOptional(
// where,
// () -> new UsersRepositoryInMemory());
// }
//
// public void close() {
// this.controller.close();
// }
//
// @Override
// public RegUserStatus addUser(String login, String pass) {
// return controller.executeAndQuery(usersRepo -> usersRepo.addUser(login, pass));
// }
//
// @Override
// public boolean login(String login, String password) {
// return controller.query(usersRepo -> usersRepo.login(login, password));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepoES;
import pl.setblack.pongi.users.repo.UsersRepository;
import java.nio.file.Paths;
import java.time.Clock;
package pl.setblack.pongi.users;
public class UsersModule {
private final UsersRepository usersRepo; | private final SessionsRepo sessionsRepo; |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/UsersModule.java | // Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java
// public class UsersRepoES implements UsersRepository {
//
//
// private final Persistent<UsersRepositoryInMemory> controller;
//
//
// public UsersRepoES(Path where) {
// controller = Persistent.loadOptional(
// where,
// () -> new UsersRepositoryInMemory());
// }
//
// public void close() {
// this.controller.close();
// }
//
// @Override
// public RegUserStatus addUser(String login, String pass) {
// return controller.executeAndQuery(usersRepo -> usersRepo.addUser(login, pass));
// }
//
// @Override
// public boolean login(String login, String password) {
// return controller.query(usersRepo -> usersRepo.login(login, password));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
| import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepoES;
import pl.setblack.pongi.users.repo.UsersRepository;
import java.nio.file.Paths;
import java.time.Clock; | package pl.setblack.pongi.users;
public class UsersModule {
private final UsersRepository usersRepo;
private final SessionsRepo sessionsRepo;
public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = usersRepo;
this.sessionsRepo = sessionsRepo;
}
public UsersModule(Clock clock) {
this( | // Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepoES.java
// public class UsersRepoES implements UsersRepository {
//
//
// private final Persistent<UsersRepositoryInMemory> controller;
//
//
// public UsersRepoES(Path where) {
// controller = Persistent.loadOptional(
// where,
// () -> new UsersRepositoryInMemory());
// }
//
// public void close() {
// this.controller.close();
// }
//
// @Override
// public RegUserStatus addUser(String login, String pass) {
// return controller.executeAndQuery(usersRepo -> usersRepo.addUser(login, pass));
// }
//
// @Override
// public boolean login(String login, String password) {
// return controller.query(usersRepo -> usersRepo.login(login, password));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepository.java
// public interface UsersRepository {
//
// RegUserStatus addUser(final String login, final String pass);
//
// boolean login(final String login, final String password);
// }
// Path: src/main/java/pl/setblack/pongi/users/UsersModule.java
import pl.setblack.pongi.users.repo.SessionsRepo;
import pl.setblack.pongi.users.repo.UsersRepoES;
import pl.setblack.pongi.users.repo.UsersRepository;
import java.nio.file.Paths;
import java.time.Clock;
package pl.setblack.pongi.users;
public class UsersModule {
private final UsersRepository usersRepo;
private final SessionsRepo sessionsRepo;
public UsersModule(UsersRepository usersRepo, SessionsRepo sessionsRepo) {
this.usersRepo = usersRepo;
this.sessionsRepo = sessionsRepo;
}
public UsersModule(Clock clock) {
this( | new UsersRepoES(Paths.get("airomem/users")), |
javaFunAgain/ratpong | src/test/java/pl/setblack/pongi/scores/repo/ScoreRepoEsTest.java | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
| import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import pl.setblack.pongi.AiromemHelper;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths; | package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 4/12/17.
*/
public class ScoreRepoEsTest extends ScoresRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private ScoreRepositoryES persistentRepo;
@BeforeEach
protected void createRepo () {
this.persistentRepo = new ScoreRepositoryES(testRepoPath);
this.testee = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException {
this.persistentRepo.close(); | // Path: src/test/java/pl/setblack/pongi/AiromemHelper.java
// public class AiromemHelper {
//
// public static void clearFolder(Path testRepoPath) {
// Politician.beatAroundTheBush(() -> {
// Files.walkFileTree(testRepoPath, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// Files.delete(file);
// return FileVisitResult.CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// Files.delete(dir);
// return FileVisitResult.CONTINUE;
// }
//
// });
// }
// );
// }
// }
// Path: src/test/java/pl/setblack/pongi/scores/repo/ScoreRepoEsTest.java
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import pl.setblack.pongi.AiromemHelper;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 4/12/17.
*/
public class ScoreRepoEsTest extends ScoresRepositoryBase {
private final Path testRepoPath = Paths.get("target/airomem/test");
private ScoreRepositoryES persistentRepo;
@BeforeEach
protected void createRepo () {
this.persistentRepo = new ScoreRepositoryES(testRepoPath);
this.testee = this.persistentRepo;
}
@AfterEach
public void deleteRepo() throws IOException {
this.persistentRepo.close(); | AiromemHelper.clearFolder(testRepoPath); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; | package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public class ScoresRepositoryProcessor {
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
private final ScoresRepository repository;
public ScoresRepositoryProcessor(ScoresRepository repository) {
this.repository = repository;
}
| // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public class ScoresRepositoryProcessor {
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
private final ScoresRepository repository;
public ScoresRepositoryProcessor(ScoresRepository repository) {
this.repository = repository;
}
| public void registerScore(List<ScoreRecord> rec) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java | // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
| import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors; | package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public class ScoresRepositoryProcessor {
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
private final ScoresRepository repository;
public ScoresRepositoryProcessor(ScoresRepository repository) {
this.repository = repository;
}
public void registerScore(List<ScoreRecord> rec) {
this.writesExecutor.execute(() -> repository.registerScore(rec));
}
| // Path: src/main/java/pl/setblack/pongi/scores/ScoreRecord.java
// @Immutable
// public class ScoreRecord {
// public final String userId;
// public final GameResult result;
// public final int playerScored;
// public final int opponentScore;
// public final String gameId;
//
// public ScoreRecord(
// String userId,
// GameResult result,
// int playerScore,
// int opponentScore,
// String gameId) {
// this.userId = userId;
// this.result = result;
// this.playerScored = playerScore;
// this.opponentScore = opponentScore;
// this.gameId = gameId;
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/UserScore.java
// @JsonDeserialize
// @Immutable
// public class UserScore implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String userId;
// public final int totalScore;
// public final int gamesWon;
// public final int gamesLost;
// public final int gamesPlayed;
// public final int pointsScored;
// public final int pointsLost;
//
// @JsonCreator
// public UserScore(String userId, int totalScore, int gamesWon, int gamesLost, int gamesPlayed, int pointsScored, int pointsLost) {
// this.userId = userId;
// this.totalScore = totalScore;
// this.gamesWon = gamesWon;
// this.gamesLost = gamesLost;
// this.gamesPlayed = gamesPlayed;
// this.pointsScored = pointsScored;
// this.pointsLost = pointsLost;
// }
//
// public static UserScore emptyFor(String userId) {
// return new UserScore(
// userId,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0);
// }
//
// public UserScore add(ScoreRecord rec) {
// final int newScore = this.totalScore + rec.result.score;
// final int newWon = this.gamesWon +
// (rec.result == GameResult.WON ? 1 : 0);
// final int newLost = this.gamesLost +
// (rec.result == GameResult.LOST ? 1 : 0);
// final int newPlayed = this.gamesPlayed + 1;
// final int newPointsScored = this.pointsScored + rec.playerScored;
// final int newPointsLost = this.pointsLost + rec.opponentScore;
// return new UserScore(
// this.userId,
// newScore,
// newWon,
// newLost,
// newPlayed,
// newPointsScored,
// newPointsLost);
// }
// }
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
import javaslang.collection.List;
import javaslang.control.Option;
import pl.setblack.pongi.scores.ScoreRecord;
import pl.setblack.pongi.scores.UserScore;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
package pl.setblack.pongi.scores.repo;
/**
* Created by jarek on 2/5/17.
*/
public class ScoresRepositoryProcessor {
private final Executor writesExecutor = Executors.newSingleThreadExecutor();
private final ScoresRepository repository;
public ScoresRepositoryProcessor(ScoresRepository repository) {
this.repository = repository;
}
public void registerScore(List<ScoreRecord> rec) {
this.writesExecutor.execute(() -> repository.registerScore(rec));
}
| public CompletionStage<Option<UserScore>> getUserScore(String userId) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryInMemory.java | // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
| import javaslang.collection.HashMap;
import javaslang.control.Option;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.Serializable; | package pl.setblack.pongi.users.repo;
public class UsersRepositoryInMemory implements UsersRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile HashMap<String, UserData> allUsers = HashMap.empty();
| // Path: src/main/java/pl/setblack/pongi/users/api/RegUserStatus.java
// @Immutable
// @JsonDeserialize
// public class RegUserStatus {
//
// public final boolean ok;
//
// public final Option<String> problem;
//
// @JsonCreator
// public RegUserStatus(Option<String> problem) {
// this.problem = problem;
// this.ok = problem.isEmpty();
// }
// }
// Path: src/main/java/pl/setblack/pongi/users/repo/UsersRepositoryInMemory.java
import javaslang.collection.HashMap;
import javaslang.control.Option;
import pl.setblack.pongi.users.api.RegUserStatus;
import java.io.Serializable;
package pl.setblack.pongi.users.repo;
public class UsersRepositoryInMemory implements UsersRepository, Serializable {
private static final long serialVersionUID = 1L;
private volatile HashMap<String, UserData> allUsers = HashMap.empty();
| public RegUserStatus addUser(final String login, final String pass) { |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java | // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
| import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState; | package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public interface GamesRepository {
Option<GameInfo> createGame(String uuid, String name, String userId);
Seq<GameInfo> listGames();
| // Path: src/main/java/pl/setblack/pongi/games/api/GameInfo.java
// @Immutable
// @JsonDeserialize
// public class GameInfo implements Serializable {
// private static final long serialVersionUID = 1L;
// public final String name;
//
// public final String uuid;
//
// public final List<String> players;
//
// @JsonCreator
// public GameInfo(String name, String uuid, List<String> players) {
// this.name = name;
// this.uuid = uuid;
// this.players = players;
// }
//
// public GameInfo(String name, String uuid, String player1) {
// this(name, uuid, List.of(player1));
// }
//
// public Option<GameInfo> withPlayer(String userId) {
// if (this.players.contains(userId)) {
// return Option.some(this);
// } else if (this.players.size() <= 1) {
// return Option.some(new GameInfo(this.name, this.uuid, this.players.append(userId)));
// } else {
// return Option.none();
// }
//
// }
//
// @Override
// public String toString() {
// return "GameInfo{" +
// "name='" + name + '\'' +
// ", uuid='" + uuid + '\'' +
// ", players=" + players +
// '}';
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/api/GameState.java
// @Immutable
// @JsonDeserialize
// public class GameState implements Serializable {
// private static final long serialVersionUID = 1L;
// public final GamePhase phase;
// public final Ball ball;
// public final Players players;
// public final long updateTime;
//
//
// @JsonCreator
// public GameState(
// final Ball ball,
// final Players players,
// final long updateTime) {
// this.ball = ball;
// this.players = players;
// this.updateTime = updateTime;
// this.phase = players.phaseFromScore();
// }
//
//
// public static Option<GameState> startFrom(
// GameInfo info,
// long startTime,
// final Random rnd) {
//
// if (info.players.size() == 2) {
// final Ball ball = new Ball(0.5f, 0.5f);
// final Player player1 = new Player(0, info.players.get(0), Paddle.createPaddleForPlayer(1));
// final Player player2 = new Player(0, info.players.get(1), Paddle.createPaddleForPlayer(2));
// return Option.some(new GameState(ball, Players.of(player1, player2), startTime).start(startTime, rnd));
// } else {
// return Option.none();
// }
// }
//
//
// private GameState start(long startTime, final Random rnd) {
//
// return new GameState(
// Ball.randomDirection(rnd),
// this.players,
// startTime);
//
// }
//
// public GameState push(long newTime, final Random rnd) {
// if (this.phase == GamePhase.STARTED) {
// long diff = newTime - this.updateTime;
// float scale = diff / GameParams.RELATIVE_SPEED;
// final Tuple2<Ball, Players> newPositions = this.ball
// .move(scale)
// .bounce(this.players, rnd);
// final Function<Player, Player> movePaddle = player -> player.movePaddle(diff);
// final Players newPlayers = newPositions._2.map(movePaddle);
//
// return new GameState(newPositions._1, newPlayers, newTime);
// } else {
// return this;
// }
//
// }
//
//
// public GameState playerMovingTo(String userId, float targetY) {
// final Function<Player, Player> movePaddle = player -> player.makeMoving(userId, targetY);
// final Players newPlayers = this.players.map(movePaddle);
// return new GameState(this.ball, newPlayers, this.updateTime);
// }
//
// @Override
// public String toString() {
// return "GameState{" +
// "ball=" + ball +
// ", players=" + players +
// ", updateTime=" + updateTime +
// '}';
// }
// }
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
import javaslang.collection.Seq;
import javaslang.control.Option;
import pl.setblack.pongi.games.api.GameInfo;
import pl.setblack.pongi.games.api.GameState;
package pl.setblack.pongi.games.repo;
/**
* Created by jarek on 2/2/17.
*/
public interface GamesRepository {
Option<GameInfo> createGame(String uuid, String name, String userId);
Seq<GameInfo> listGames();
| Option<GameState> joinGame(String uuid, String userId); |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/GamesModule.java | // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
| import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock; | package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
| // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock;
package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
| private final SessionsRepo sessionsRepo; |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/GamesModule.java | // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
| import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock; | package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
private final SessionsRepo sessionsRepo;
| // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock;
package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
private final SessionsRepo sessionsRepo;
| private final ScoresRepositoryProcessor scoresRepo; |
javaFunAgain/ratpong | src/main/java/pl/setblack/pongi/games/GamesModule.java | // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
| import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock; | package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
private final SessionsRepo sessionsRepo;
private final ScoresRepositoryProcessor scoresRepo;
public GamesModule(GamesRepository gamesRepo,
SessionsRepo sessionsRepo,
ScoresRepositoryProcessor scoresRepo) {
this.gamesRepo = gamesRepo;
this.sessionsRepo = sessionsRepo;
this.scoresRepo = scoresRepo;
}
public GamesModule(
final Clock clock,
final SessionsRepo sessionsRepo,
final ScoresRepositoryProcessor scoresRepo) {
this( | // Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepoES.java
// public class GamesRepoES implements GamesRepository {
//
// final Persistent<GamesRepositoryInMemory> persistent;
//
// public GamesRepoES(final Clock clock) {
// persistent = Persistent.loadOptional(
// Paths.get("airomem/games"),
// () -> new GamesRepositoryInMemory(clock)
// );
// }
//
// @Override
// public Option<GameInfo> createGame(String uuid, String name, String userId) {
// return persistent.executeAndQuery(rep -> rep.createGame(uuid, name, userId));
// }
//
// @Override
// public Seq<GameInfo> listGames() {
// return persistent.query(rep -> rep.listGames());
// }
//
//
// @Override
// public Option<GameState> joinGame(String uuid, String userId) {
// return persistent.executeAndQuery(rep -> rep.joinGame(uuid, userId));
// }
//
// @Override
// public Option<GameState> getGame(String uuid) {
// return persistent.query(rep -> rep.getGame(uuid));
// }
//
// @Override
// public boolean movePaddle(String gameId, String userId, float targetY) {
// return persistent.executeAndQuery(rep -> rep.movePaddle(gameId, userId, targetY));
// }
//
// @Override
// public Option<GameState> push(String gameUUID) {
// return persistent.executeAndQuery(rep -> rep.push(gameUUID));
// }
//
// @Override
// public void removeGame(final String gameUUID) {
// persistent.execute(rep -> rep.removeGame(gameUUID));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/games/repo/GamesRepository.java
// public interface GamesRepository {
// Option<GameInfo> createGame(String uuid, String name, String userId);
//
// Seq<GameInfo> listGames();
//
//
// Option<GameState> joinGame(String uuid, String userId);
//
// Option<GameState> getGame(String uuid);
//
// boolean movePaddle(String gameId, String userId, float targetY);
//
// Option<GameState> push(String gameUUID);
//
// void removeGame(String gameUUID);
//
// }
//
// Path: src/main/java/pl/setblack/pongi/scores/repo/ScoresRepositoryProcessor.java
// public class ScoresRepositoryProcessor {
// private final Executor writesExecutor = Executors.newSingleThreadExecutor();
//
// private final ScoresRepository repository;
//
// public ScoresRepositoryProcessor(ScoresRepository repository) {
// this.repository = repository;
// }
//
// public void registerScore(List<ScoreRecord> rec) {
// this.writesExecutor.execute(() -> repository.registerScore(rec));
// }
//
// public CompletionStage<Option<UserScore>> getUserScore(String userId) {
// return CompletableFuture.completedFuture(repository.getUserScore(userId));
// }
//
// public CompletionStage<List<UserScore>> getTopScores(final int limit) {
// return CompletableFuture.completedFuture(repository.getTopScores(limit));
// }
// }
//
// Path: src/main/java/pl/setblack/pongi/users/repo/SessionsRepo.java
// public class SessionsRepo {
// private AtomicReference<HashMap<String, Session>> activeSesssions =
// new AtomicReference<>(HashMap.empty());
//
// private final Clock clock;
//
// public SessionsRepo(Clock clock) {
// this.clock = clock;
// }
//
//
// public Session startSession(String userId) {
// final UUID uuid = UUID.randomUUID();
// final LocalDateTime now = LocalDateTime.now(this.clock);
// final LocalDateTime expirationTime = now.plusDays(1);
// final Session sess = new Session(userId, uuid, expirationTime);
// this.activeSesssions.updateAndGet(map -> map.put(uuid.toString(), sess));
// return sess;
// }
//
// public Option<Session> getSession(final String uuid) {
// return this.activeSesssions.get().get(uuid);
// }
//
// }
// Path: src/main/java/pl/setblack/pongi/games/GamesModule.java
import pl.setblack.pongi.games.repo.GamesRepoES;
import pl.setblack.pongi.games.repo.GamesRepository;
import pl.setblack.pongi.scores.repo.ScoresRepositoryProcessor;
import pl.setblack.pongi.users.repo.SessionsRepo;
import java.time.Clock;
package pl.setblack.pongi.games;
public class GamesModule {
private final GamesRepository gamesRepo;
private final SessionsRepo sessionsRepo;
private final ScoresRepositoryProcessor scoresRepo;
public GamesModule(GamesRepository gamesRepo,
SessionsRepo sessionsRepo,
ScoresRepositoryProcessor scoresRepo) {
this.gamesRepo = gamesRepo;
this.sessionsRepo = sessionsRepo;
this.scoresRepo = scoresRepo;
}
public GamesModule(
final Clock clock,
final SessionsRepo sessionsRepo,
final ScoresRepositoryProcessor scoresRepo) {
this( | new GamesRepoES(clock), |
ixa-ehu/ixa-pipe-pos | src/main/java/eus/ixa/ixa/pipe/lemma/StatisticalLemmatizer.java | // Path: src/main/java/eus/ixa/ixa/pipe/pos/Morpheme.java
// public class Morpheme {
//
// /**
// * The surface form of the morpheme, e.g., the word.
// */
// private String word;
// /**
// * The morphological tag of the morpheme.
// */
// private String tag;
// /**
// * The lemma of the morpheme.
// */
// private String lemma;
//
// /**
// * Create a new <code>Morpheme</code> with a null content (i.e., word).
// */
// public Morpheme() {
// }
//
// /**
// * Construct a morpheme object.
// *
// * @param aWord
// * the word
// * @param aTag
// * the tag
// */
// public Morpheme(final String aWord, final String aTag) {
// this.word = aWord;
// this.tag = aTag.toUpperCase();
// }
//
// /**
// * Construct a morpheme object with lemma.
// *
// * @param aWord
// * the word
// * @param aTag
// * the tag
// * @param aLemma
// * the lemma
// */
// public Morpheme(final String aWord, final String aTag, final String aLemma) {
// this.word = aWord;
// this.tag = aTag.toUpperCase();
// this.lemma = aLemma;
// }
//
// /**
// * Get the word.
// *
// * @return the word
// */
// public final String getWord() {
// return this.word;
// }
//
// /**
// * Get the morphological tag.
// *
// * @return the morphological tag
// */
// public final String getTag() {
// return this.tag;
// }
//
// /**
// * Get the lemma.
// *
// * @return the lemma
// */
// public final String getLemma() {
// return this.lemma;
// }
//
// /**
// * Set the value of the word.
// *
// * @param aWord
// * the word
// */
// public final void setValue(final String aWord) {
// this.word = aWord;
// }
//
// /**
// * Set the morphological tag.
// *
// * @param aTag
// * the morphological tag
// */
// public final void setTag(final String aTag) {
// this.tag = aTag.toUpperCase();
// }
//
// /**
// * Set the lemma.
// *
// * @param aLemma
// * the lemma
// */
// public final void setLemma(final String aLemma) {
// this.lemma = aLemma;
// }
//
// }
//
// Path: src/main/java/eus/ixa/ixa/pipe/pos/MorphoFactory.java
// public class MorphoFactory {
//
// /**
// * Construct morpheme object with word and morphological tag.
// *
// * @param word
// * the word
// * @param tag
// * the morphological tag
// * @return the morpheme object
// */
// public final Morpheme createMorpheme(final String word, final String tag) {
// final Morpheme morpheme = new Morpheme();
// morpheme.setValue(word);
// morpheme.setTag(tag);
// return morpheme;
// }
//
// /**
// * Construct morpheme object with word, tag and lemma.
// *
// * @param word
// * the word
// * @param tag
// * the tag
// * @param lemma
// * the lemma
// * @return the morphological object
// */
// public final Morpheme createMorpheme(final String word, final String tag,
// final String lemma) {
// final Morpheme morpheme = new Morpheme();
// morpheme.setValue(word);
// morpheme.setTag(tag);
// morpheme.setLemma(lemma);
// return morpheme;
// }
//
// }
| import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import eus.ixa.ixa.pipe.pos.Morpheme;
import eus.ixa.ixa.pipe.pos.MorphoFactory; | /*
* Copyright 2016 Rodrigo Agerri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package eus.ixa.ixa.pipe.lemma;
/**
* Probabilistic lemmatizer.
*
* @author ragerri
* @version 2016-01-28
*/
public class StatisticalLemmatizer {
/**
* The lemmatizer.
*/
private final LemmatizerME lemmatizer;
/**
* The models to use for every language. The keys of the hashmap are the language
* codes, the values the models.
*/
private final static ConcurrentHashMap<String, LemmatizerModel> lemmaModels = new ConcurrentHashMap<String, LemmatizerModel>();
/**
* The morpho factory.
*/ | // Path: src/main/java/eus/ixa/ixa/pipe/pos/Morpheme.java
// public class Morpheme {
//
// /**
// * The surface form of the morpheme, e.g., the word.
// */
// private String word;
// /**
// * The morphological tag of the morpheme.
// */
// private String tag;
// /**
// * The lemma of the morpheme.
// */
// private String lemma;
//
// /**
// * Create a new <code>Morpheme</code> with a null content (i.e., word).
// */
// public Morpheme() {
// }
//
// /**
// * Construct a morpheme object.
// *
// * @param aWord
// * the word
// * @param aTag
// * the tag
// */
// public Morpheme(final String aWord, final String aTag) {
// this.word = aWord;
// this.tag = aTag.toUpperCase();
// }
//
// /**
// * Construct a morpheme object with lemma.
// *
// * @param aWord
// * the word
// * @param aTag
// * the tag
// * @param aLemma
// * the lemma
// */
// public Morpheme(final String aWord, final String aTag, final String aLemma) {
// this.word = aWord;
// this.tag = aTag.toUpperCase();
// this.lemma = aLemma;
// }
//
// /**
// * Get the word.
// *
// * @return the word
// */
// public final String getWord() {
// return this.word;
// }
//
// /**
// * Get the morphological tag.
// *
// * @return the morphological tag
// */
// public final String getTag() {
// return this.tag;
// }
//
// /**
// * Get the lemma.
// *
// * @return the lemma
// */
// public final String getLemma() {
// return this.lemma;
// }
//
// /**
// * Set the value of the word.
// *
// * @param aWord
// * the word
// */
// public final void setValue(final String aWord) {
// this.word = aWord;
// }
//
// /**
// * Set the morphological tag.
// *
// * @param aTag
// * the morphological tag
// */
// public final void setTag(final String aTag) {
// this.tag = aTag.toUpperCase();
// }
//
// /**
// * Set the lemma.
// *
// * @param aLemma
// * the lemma
// */
// public final void setLemma(final String aLemma) {
// this.lemma = aLemma;
// }
//
// }
//
// Path: src/main/java/eus/ixa/ixa/pipe/pos/MorphoFactory.java
// public class MorphoFactory {
//
// /**
// * Construct morpheme object with word and morphological tag.
// *
// * @param word
// * the word
// * @param tag
// * the morphological tag
// * @return the morpheme object
// */
// public final Morpheme createMorpheme(final String word, final String tag) {
// final Morpheme morpheme = new Morpheme();
// morpheme.setValue(word);
// morpheme.setTag(tag);
// return morpheme;
// }
//
// /**
// * Construct morpheme object with word, tag and lemma.
// *
// * @param word
// * the word
// * @param tag
// * the tag
// * @param lemma
// * the lemma
// * @return the morphological object
// */
// public final Morpheme createMorpheme(final String word, final String tag,
// final String lemma) {
// final Morpheme morpheme = new Morpheme();
// morpheme.setValue(word);
// morpheme.setTag(tag);
// morpheme.setLemma(lemma);
// return morpheme;
// }
//
// }
// Path: src/main/java/eus/ixa/ixa/pipe/lemma/StatisticalLemmatizer.java
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import eus.ixa.ixa.pipe.pos.Morpheme;
import eus.ixa.ixa.pipe.pos.MorphoFactory;
/*
* Copyright 2016 Rodrigo Agerri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package eus.ixa.ixa.pipe.lemma;
/**
* Probabilistic lemmatizer.
*
* @author ragerri
* @version 2016-01-28
*/
public class StatisticalLemmatizer {
/**
* The lemmatizer.
*/
private final LemmatizerME lemmatizer;
/**
* The models to use for every language. The keys of the hashmap are the language
* codes, the values the models.
*/
private final static ConcurrentHashMap<String, LemmatizerModel> lemmaModels = new ConcurrentHashMap<String, LemmatizerModel>();
/**
* The morpho factory.
*/ | private MorphoFactory morphoFactory; |
ixa-ehu/ixa-pipe-pos | src/main/java/eus/ixa/ixa/pipe/pos/train/AbstractTaggerTrainer.java | // Path: src/main/java/eus/ixa/ixa/pipe/pos/MorphoSampleStream.java
// public class MorphoSampleStream extends FilterObjectStream<String, POSSample> {
//
// public MorphoSampleStream(ObjectStream<String> samples) {
// super(samples);
// }
//
// /**
// * Parses the next sentence and return the next
// * {@link POSSample} object.
// *
// * If an error occurs an empty {@link POSSample} object is returned
// * and an warning message is logged. Usually it does not matter if one
// * of many sentences is ignored.
// *
// * TODO: An exception in error case should be thrown.
// */
// public POSSample read() throws IOException {
//
// List<String> toks = new ArrayList<String>();
// List<String> tags = new ArrayList<String>();
//
// for (String line = samples.read(); line != null && !line.equals(""); line = samples.read()) {
// String[] parts = line.split("\t");
// if (parts.length != 3) {
// System.err.println("Skipping corrupt line: " + line);
// }
// else {
// toks.add(parts[0]);
// tags.add(parts[1]);
// }
// }
// if (toks.size() > 0) {
// POSSample posSample = new POSSample(toks.toArray(new String[toks.size()]), tags.toArray(new String[tags.size()]));
// //System.err.println(posSample.toString());
// return posSample;
// }
// else {
// return null;
// }
// }
// }
| import opennlp.tools.util.TrainingParameters;
import java.io.File;
import java.io.IOException;
import eus.ixa.ixa.pipe.pos.MorphoSampleStream;
import opennlp.tools.cmdline.TerminateToolException;
import opennlp.tools.dictionary.Dictionary;
import opennlp.tools.postag.MutableTagDictionary;
import opennlp.tools.postag.POSEvaluator;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSSample;
import opennlp.tools.postag.POSTaggerFactory;
import opennlp.tools.postag.POSTaggerME;
import opennlp.tools.postag.TagDictionary;
import opennlp.tools.util.ObjectStream; | /*
* Copyright 2014 Rodrigo Agerri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package eus.ixa.ixa.pipe.pos.train;
/**
* Training POS tagger with Apache OpenNLP Machine Learning API.
*
* @author ragerri
* @version 2014-07-07
*/
public abstract class AbstractTaggerTrainer implements TaggerTrainer {
/**
* The language.
*/
private final String lang;
/**
* ObjectStream of the training data.
*/
private final ObjectStream<POSSample> trainSamples;
/**
* ObjectStream of the test data.
*/
private final ObjectStream<POSSample> testSamples;
/**
* ObjectStream of the automatically created dictionary data, taken from the
* training data.
*/ | // Path: src/main/java/eus/ixa/ixa/pipe/pos/MorphoSampleStream.java
// public class MorphoSampleStream extends FilterObjectStream<String, POSSample> {
//
// public MorphoSampleStream(ObjectStream<String> samples) {
// super(samples);
// }
//
// /**
// * Parses the next sentence and return the next
// * {@link POSSample} object.
// *
// * If an error occurs an empty {@link POSSample} object is returned
// * and an warning message is logged. Usually it does not matter if one
// * of many sentences is ignored.
// *
// * TODO: An exception in error case should be thrown.
// */
// public POSSample read() throws IOException {
//
// List<String> toks = new ArrayList<String>();
// List<String> tags = new ArrayList<String>();
//
// for (String line = samples.read(); line != null && !line.equals(""); line = samples.read()) {
// String[] parts = line.split("\t");
// if (parts.length != 3) {
// System.err.println("Skipping corrupt line: " + line);
// }
// else {
// toks.add(parts[0]);
// tags.add(parts[1]);
// }
// }
// if (toks.size() > 0) {
// POSSample posSample = new POSSample(toks.toArray(new String[toks.size()]), tags.toArray(new String[tags.size()]));
// //System.err.println(posSample.toString());
// return posSample;
// }
// else {
// return null;
// }
// }
// }
// Path: src/main/java/eus/ixa/ixa/pipe/pos/train/AbstractTaggerTrainer.java
import opennlp.tools.util.TrainingParameters;
import java.io.File;
import java.io.IOException;
import eus.ixa.ixa.pipe.pos.MorphoSampleStream;
import opennlp.tools.cmdline.TerminateToolException;
import opennlp.tools.dictionary.Dictionary;
import opennlp.tools.postag.MutableTagDictionary;
import opennlp.tools.postag.POSEvaluator;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSSample;
import opennlp.tools.postag.POSTaggerFactory;
import opennlp.tools.postag.POSTaggerME;
import opennlp.tools.postag.TagDictionary;
import opennlp.tools.util.ObjectStream;
/*
* Copyright 2014 Rodrigo Agerri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package eus.ixa.ixa.pipe.pos.train;
/**
* Training POS tagger with Apache OpenNLP Machine Learning API.
*
* @author ragerri
* @version 2014-07-07
*/
public abstract class AbstractTaggerTrainer implements TaggerTrainer {
/**
* The language.
*/
private final String lang;
/**
* ObjectStream of the training data.
*/
private final ObjectStream<POSSample> trainSamples;
/**
* ObjectStream of the test data.
*/
private final ObjectStream<POSSample> testSamples;
/**
* ObjectStream of the automatically created dictionary data, taken from the
* training data.
*/ | private MorphoSampleStream dictSamples; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/sighup/controller/SighupController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/sighup/utils/MailUtils.java
// public class MailUtils {
//
// public static String HOST = "smtp.sina.com";
//
// public static String PROTOCOL = "smtp";
//
// public static int PORT = 25;
//
// public static String FROM = "upcmvc@sina.com";//发件人的email
//
// public static String PWD = "qilu2016";//发件人密码
//
// /**
// * 获取Session
// *
// * @return
// */
// private static Session getSession() {
// Properties props = new Properties();
// props.put("mail.smtp.host", HOST);//设置服务器地址
// props.put("mail.store.protocol", PROTOCOL);//设置协议
// props.put("mail.smtp.port", PORT);//设置端口
// props.put("mail.smtp.auth", "true");
//
// Authenticator authenticator = new Authenticator() {
// @Override
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(FROM, PWD);
// }
//
// };
// Session session = Session.getDefaultInstance(props, authenticator);
// // session.setDebug(true);
//
// return session;
// }
//
// public static void send(String toEmail, String content) {
// Session session = getSession();
// try {
// System.out.println("--send--" + content);
// // Instantiate a message
// Message msg = new MimeMessage(session);
//
// //Set message attributes
// msg.setFrom(new InternetAddress(FROM));
// InternetAddress[] address = {new InternetAddress(toEmail)};
// msg.setRecipients(Message.RecipientType.TO, address);
// msg.setSubject("邮件");
// msg.setSentDate(new Date());
// msg.setContent(content, "text/html;charset=utf-8");
// msg.saveChanges();
//
// //Send the message
// Transport.send(msg);
// System.out.println("发送完成");
// } catch (MessagingException mex) {
// mex.printStackTrace();
// }
// }
// }
| import cn.edu.upc.yb.integrate.sighup.model.SighUp;
import cn.edu.upc.yb.integrate.sighup.repository.SighUpRepository;
import cn.edu.upc.yb.integrate.sighup.utils.MailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; | package cn.edu.upc.yb.integrate.sighup.controller;
/**
* Created by Jaxlying on 2016/9/27.
*/
@Controller
@RequestMapping("/sighup")
public class SighupController {
@Autowired
private SighUpRepository sighUpRepository;
@RequestMapping(value = "",method = RequestMethod.POST)
public String send(Model model,String name,String major,String sex,String detail,String method){
SighUp sighUp = new SighUp(name, sex, method, detail, major);
sighUpRepository.save(sighUp); | // Path: src/main/java/cn/edu/upc/yb/integrate/sighup/utils/MailUtils.java
// public class MailUtils {
//
// public static String HOST = "smtp.sina.com";
//
// public static String PROTOCOL = "smtp";
//
// public static int PORT = 25;
//
// public static String FROM = "upcmvc@sina.com";//发件人的email
//
// public static String PWD = "qilu2016";//发件人密码
//
// /**
// * 获取Session
// *
// * @return
// */
// private static Session getSession() {
// Properties props = new Properties();
// props.put("mail.smtp.host", HOST);//设置服务器地址
// props.put("mail.store.protocol", PROTOCOL);//设置协议
// props.put("mail.smtp.port", PORT);//设置端口
// props.put("mail.smtp.auth", "true");
//
// Authenticator authenticator = new Authenticator() {
// @Override
// protected PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(FROM, PWD);
// }
//
// };
// Session session = Session.getDefaultInstance(props, authenticator);
// // session.setDebug(true);
//
// return session;
// }
//
// public static void send(String toEmail, String content) {
// Session session = getSession();
// try {
// System.out.println("--send--" + content);
// // Instantiate a message
// Message msg = new MimeMessage(session);
//
// //Set message attributes
// msg.setFrom(new InternetAddress(FROM));
// InternetAddress[] address = {new InternetAddress(toEmail)};
// msg.setRecipients(Message.RecipientType.TO, address);
// msg.setSubject("邮件");
// msg.setSentDate(new Date());
// msg.setContent(content, "text/html;charset=utf-8");
// msg.saveChanges();
//
// //Send the message
// Transport.send(msg);
// System.out.println("发送完成");
// } catch (MessagingException mex) {
// mex.printStackTrace();
// }
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/sighup/controller/SighupController.java
import cn.edu.upc.yb.integrate.sighup.model.SighUp;
import cn.edu.upc.yb.integrate.sighup.repository.SighUpRepository;
import cn.edu.upc.yb.integrate.sighup.utils.MailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
package cn.edu.upc.yb.integrate.sighup.controller;
/**
* Created by Jaxlying on 2016/9/27.
*/
@Controller
@RequestMapping("/sighup")
public class SighupController {
@Autowired
private SighUpRepository sighUpRepository;
@RequestMapping(value = "",method = RequestMethod.POST)
public String send(Model model,String name,String major,String sex,String detail,String method){
SighUp sighUp = new SighUp(name, sex, method, detail, major);
sighUpRepository.save(sighUp); | MailUtils mailUtils = new MailUtils(); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/common/util/LinkPage.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/template/PageItem.java
// public class PageItem {
// private int number;
// private boolean current;
//
// public PageItem(int number, boolean current) {
// this.number = number;
// this.current = current;
// }
//
// public int getNumber() {
// return number;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public boolean isCurrent() {
// return current;
// }
//
// public void setCurrent(boolean current) {
// this.current = current;
// }
// }
| import cn.edu.upc.yb.integrate.common.template.PageItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import java.util.ArrayList;
import java.util.List; | package cn.edu.upc.yb.integrate.common.util;
/**
* Created by wanghaojun on 2016/7/12.
*/
public class LinkPage<T> {
public static final int MAX_PAGE_ITEM_DISPLAY = 3;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/template/PageItem.java
// public class PageItem {
// private int number;
// private boolean current;
//
// public PageItem(int number, boolean current) {
// this.number = number;
// this.current = current;
// }
//
// public int getNumber() {
// return number;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public boolean isCurrent() {
// return current;
// }
//
// public void setCurrent(boolean current) {
// this.current = current;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/common/util/LinkPage.java
import cn.edu.upc.yb.integrate.common.template.PageItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import java.util.ArrayList;
import java.util.List;
package cn.edu.upc.yb.integrate.common.util;
/**
* Created by wanghaojun on 2016/7/12.
*/
public class LinkPage<T> {
public static final int MAX_PAGE_ITEM_DISPLAY = 3;
@Autowired | private PageItem pageItem; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired | private VarietyOfDishesDao varietyOfDishesDao; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired | AppAdminService appAdminService; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
AppAdminService appAdminService;
@Autowired
HttpSession httpSession;
@Autowired
UploadService uploadService;
@RequestMapping(method = RequestMethod.POST,value = "/create")
public Object create(String name, String region, String kind, String restaurant, String price,String introduce,MultipartFile file){
if(httpSession.getAttribute("user")==null) | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
AppAdminService appAdminService;
@Autowired
HttpSession httpSession;
@Autowired
UploadService uploadService;
@RequestMapping(method = RequestMethod.POST,value = "/create")
public Object create(String name, String region, String kind, String restaurant, String price,String introduce,MultipartFile file){
if(httpSession.getAttribute("user")==null) | return new cn.edu.upc.yb.integrate.deliciousfood.dto.JsonMes(0,"请先登录"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
AppAdminService appAdminService;
@Autowired
HttpSession httpSession;
@Autowired
UploadService uploadService;
@RequestMapping(method = RequestMethod.POST,value = "/create")
public Object create(String name, String region, String kind, String restaurant, String price,String introduce,MultipartFile file){
if(httpSession.getAttribute("user")==null)
return new cn.edu.upc.yb.integrate.deliciousfood.dto.JsonMes(0,"请先登录"); | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/EvaluateController.java
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliciousfood.service.UploadService;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
* 用于写菜品评价的接口
*/
@RestController
@RequestMapping(value = "/evaluate")
public class EvaluateController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
AppAdminService appAdminService;
@Autowired
HttpSession httpSession;
@Autowired
UploadService uploadService;
@RequestMapping(method = RequestMethod.POST,value = "/create")
public Object create(String name, String region, String kind, String restaurant, String price,String introduce,MultipartFile file){
if(httpSession.getAttribute("user")==null)
return new cn.edu.upc.yb.integrate.deliciousfood.dto.JsonMes(0,"请先登录"); | YibanBasicUserInfo yibanBasicUserInfo =(YibanBasicUserInfo) httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/common/TestAuth.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.config.BulletinBoardOauthConfig;
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; | package cn.edu.upc.yb.integrate.common;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class TestAuth {
@Autowired
private BulletinBoardOauthConfig bulletinBoardOauthConfig;
@Test
public void testAuth() throws Exception {
YibanOAuth yibanOAuth = new YibanOAuth();
String requset = "12d42600c43a4404ae38fa7499e85b59cfcf99a14cacaaaa38f70aa08d0c36638984d3756a2943823218e9eee9c1ad0e95dcf2e41a7863e0aaf927546d61cfdc3b57883fe47af30907702ad1c514824af8bde7b8cac3ebc470d760f13d27912c87b94870469944aa5786d147551d9ef331ca1759df87b9541d4d111cb6ddcba10a97bf02e96e64cd1cb0828a90ef7faf743c6a9c46f400b64fbc183b0285edcaa1b751defb335115879aa43e01ea9800ee2edb10c4336590e9f529257ab1ba908954660abdcb6be0a1a597696c91979df51c3ee07b20eb55873ea9919a3b3a25767c70321cd8e8d9a9ebe39d0b55016d9ad9f56d15b7d6fda23635a9eb75b7c51ccf9b708f40bd44db0c62b34fa316925e9af9c48f7ad4e0870e1de16f08dbcb"; | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/common/TestAuth.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.config.BulletinBoardOauthConfig;
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
package cn.edu.upc.yb.integrate.common;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class TestAuth {
@Autowired
private BulletinBoardOauthConfig bulletinBoardOauthConfig;
@Test
public void testAuth() throws Exception {
YibanOAuth yibanOAuth = new YibanOAuth();
String requset = "12d42600c43a4404ae38fa7499e85b59cfcf99a14cacaaaa38f70aa08d0c36638984d3756a2943823218e9eee9c1ad0e95dcf2e41a7863e0aaf927546d61cfdc3b57883fe47af30907702ad1c514824af8bde7b8cac3ebc470d760f13d27912c87b94870469944aa5786d147551d9ef331ca1759df87b9541d4d111cb6ddcba10a97bf02e96e64cd1cb0828a90ef7faf743c6a9c46f400b64fbc183b0285edcaa1b751defb335115879aa43e01ea9800ee2edb10c4336590e9f529257ab1ba908954660abdcb6be0a1a597696c91979df51c3ee07b20eb55873ea9919a3b3a25767c70321cd8e8d9a9ebe39d0b55016d9ad9f56d15b7d6fda23635a9eb75b7c51ccf9b708f40bd44db0c62b34fa316925e9af9c48f7ad4e0870e1de16f08dbcb"; | YibanBasicUserInfo yiban = (YibanBasicUserInfo) yibanOAuth.dealYibanOauth(requset, bulletinBoardOauthConfig.appid, bulletinBoardOauthConfig.appkey); |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional; | package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired | private BallotRepository ballotRepository; |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional; | package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired
private BallotRepository ballotRepository;
@Autowired
private TicketRepository ticketRepository;
@Autowired
private BallotService ballotService;
@Test
@Transactional
public void testBallot() { | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired
private BallotRepository ballotRepository;
@Autowired
private TicketRepository ticketRepository;
@Autowired
private BallotService ballotService;
@Test
@Transactional
public void testBallot() { | Ballot ballot = ballotRepository.save(new Ballot()); |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional; | package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired
private BallotRepository ballotRepository;
@Autowired
private TicketRepository ticketRepository;
@Autowired
private BallotService ballotService;
@Test
@Transactional
public void testBallot() {
Ballot ballot = ballotRepository.save(new Ballot()); | // Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ballot.java
// @Entity
// @Table(name = "ballot")
// public class Ballot {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String detail;
//
// private long deadline;
//
// private int num;//总数量
//
// private String picsrc;
//
// private int yibanid;
//
// private String yibanName;
//
// public Ballot(){}
//
//
// public Ballot(String detail, long deadline, int num) {
// this.detail = detail;
// this.deadline = deadline;
// this.num = num;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public String getYibanName() {
// return yibanName;
// }
//
// public void setYibanName(String yibanName) {
// this.yibanName = yibanName;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getDetail() {
// return detail;
// }
//
// public void setDetail(String detail) {
// this.detail = detail;
// }
//
// public long getDeadline() {
// return deadline;
// }
//
// public void setDeadline(long deadline) {
// this.deadline = deadline;
// }
//
// public int getNum() {
// return num;
// }
//
// public void setNum(int num) {
// this.num = num;
// }
//
// public String getPicsrc() {
// return picsrc;
// }
//
// public void setPicsrc(String picsrc) {
// this.picsrc = picsrc;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/model/Ticket.java
// @Entity
// @Table(name = "ballot_ticket")
// public class Ticket {
//
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @ManyToOne
// @JoinColumn(name = "ballot_id")
// private Ballot ballot;
//
// private int ybid;
//
// private String ybname;
//
// private int number;
//
// private int isGet = 0;
//
// public Ticket(){}
//
// public Ticket(Ballot ballot, int ybid, String ybname) {
// this.ballot = ballot;
// this.ybid = ybid;
// this.ybname = ybname;
// }
//
// public Ticket(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getNumber() {
// return number;
// }
//
// public int getIsGet() {
// return isGet;
// }
//
// public void setIsGet(int isGet) {
// this.isGet = isGet;
// }
//
// public void setNumber(int number) {
// this.number = number;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Ballot getBallot() {
// return ballot;
// }
//
// public void setBallot(Ballot ballot) {
// this.ballot = ballot;
// }
//
// public int getYbid() {
// return ybid;
// }
//
// public void setYbid(int ybid) {
// this.ybid = ybid;
// }
//
// public String getYbname() {
// return ybname;
// }
//
// public void setYbname(String ybname) {
// this.ybname = ybname;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/ballot/repository/BallotRepository.java
// public interface BallotRepository extends CrudRepository<Ballot,Integer>{
// Iterable<Ballot> findByYibanid(int id);
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/ballot/BallotTest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.ballot.model.Ballot;
import cn.edu.upc.yb.integrate.ballot.model.Ticket;
import cn.edu.upc.yb.integrate.ballot.repository.BallotRepository;
import cn.edu.upc.yb.integrate.ballot.repository.TicketRepository;
import cn.edu.upc.yb.integrate.ballot.service.BallotService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
package cn.edu.upc.yb.integrate.ballot;
/**
* Created by lylllcc on 2016/12/12.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class BallotTest {
@Autowired
private BallotRepository ballotRepository;
@Autowired
private TicketRepository ticketRepository;
@Autowired
private BallotService ballotService;
@Test
@Transactional
public void testBallot() {
Ballot ballot = ballotRepository.save(new Ballot()); | Ticket ticket = new Ticket(); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
| import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired | private BorrowMaterialRepository borrowMaterialRepository; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
| import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private BorrowMaterialRepository borrowMaterialRepository;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private BorrowMaterialRepository borrowMaterialRepository;
@Autowired | private AppAdminService appAdminService; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
| import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private BorrowMaterialRepository borrowMaterialRepository;
@Autowired
private AppAdminService appAdminService;
public Boolean isAdmin(){ | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialOfficialController.java
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/10.
*/
@RestController
@RequestMapping(value = "/material/official")
public class MaterialOfficialController {
@Autowired
private MaterialRepository materialRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private BorrowMaterialRepository borrowMaterialRepository;
@Autowired
private AppAdminService appAdminService;
public Boolean isAdmin(){ | YibanBasicUserInfo user = (YibanBasicUserInfo)httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/calendar/controller/CalendarController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/dao/SchoolCalendarDao.java
// public interface SchoolCalendarDao extends CrudRepository<SchoolCalendar, Integer> {
// public Iterable<SchoolCalendar> findBySchoolscheduleAndIsdelete(String schoolschedule,boolean isdelete);
// public Iterable<SchoolCalendar> findByIsdeleteOrderByIdDesc(boolean isdelete);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/model/SchoolCalendar.java
// @Entity
// @Table(name = "calendar")
// public class SchoolCalendar {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @Column(unique = true)
// private String schoolschedule;
//
// private String begindate;
// private String enddate;
//
// private boolean isdelete = false;
// private String creattime;
// private String updatetime;
//
// public boolean isdelete() {
// return isdelete;
// }
//
// public void setIsdelete(boolean isdelete) {
// this.isdelete = isdelete;
// }
//
// public String getCreattime() {
// return creattime;
// }
//
// public void setCreattime(String creattime) {
// this.creattime = creattime;
// }
//
// public String getUpdatetime() {
// return updatetime;
// }
//
// public void setUpdatetime(String updatetime) {
// this.updatetime = updatetime;
// }
//
// public SchoolCalendar(String schoolschedule, String begindate, String enddate) {
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.creattime = new Date().toString();
// this.updatetime = new Date().toString();
//
// }
// public SchoolCalendar(){}
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSchoolschedule() {
// return schoolschedule;
// }
//
// public void setSchoolschedule(String schoolschedule) {
// this.schoolschedule = schoolschedule;
// }
//
// public String getBegindate() {
// return begindate;
// }
//
// public void setBegindate(String begindate) {
// this.begindate = begindate;
// }
//
// public String getEnddate() {
// return enddate;
// }
//
// public void setEnddate(String enddate) {
// this.enddate = enddate;
// }
//
// public void updata(String schoolschedule, String begindate, String enddate){
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.updatetime = new Date().toString();
// }
// public void delete(){
// this.isdelete = true;
// this.updatetime = new Date().toString();
// }
// }
| import cn.edu.upc.yb.integrate.calendar.dao.SchoolCalendarDao;
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.calendar.model.SchoolCalendar;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.calendar.controller;
@RestController
@RequestMapping("/calendar")
public class CalendarController {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/dao/SchoolCalendarDao.java
// public interface SchoolCalendarDao extends CrudRepository<SchoolCalendar, Integer> {
// public Iterable<SchoolCalendar> findBySchoolscheduleAndIsdelete(String schoolschedule,boolean isdelete);
// public Iterable<SchoolCalendar> findByIsdeleteOrderByIdDesc(boolean isdelete);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/model/SchoolCalendar.java
// @Entity
// @Table(name = "calendar")
// public class SchoolCalendar {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @Column(unique = true)
// private String schoolschedule;
//
// private String begindate;
// private String enddate;
//
// private boolean isdelete = false;
// private String creattime;
// private String updatetime;
//
// public boolean isdelete() {
// return isdelete;
// }
//
// public void setIsdelete(boolean isdelete) {
// this.isdelete = isdelete;
// }
//
// public String getCreattime() {
// return creattime;
// }
//
// public void setCreattime(String creattime) {
// this.creattime = creattime;
// }
//
// public String getUpdatetime() {
// return updatetime;
// }
//
// public void setUpdatetime(String updatetime) {
// this.updatetime = updatetime;
// }
//
// public SchoolCalendar(String schoolschedule, String begindate, String enddate) {
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.creattime = new Date().toString();
// this.updatetime = new Date().toString();
//
// }
// public SchoolCalendar(){}
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSchoolschedule() {
// return schoolschedule;
// }
//
// public void setSchoolschedule(String schoolschedule) {
// this.schoolschedule = schoolschedule;
// }
//
// public String getBegindate() {
// return begindate;
// }
//
// public void setBegindate(String begindate) {
// this.begindate = begindate;
// }
//
// public String getEnddate() {
// return enddate;
// }
//
// public void setEnddate(String enddate) {
// this.enddate = enddate;
// }
//
// public void updata(String schoolschedule, String begindate, String enddate){
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.updatetime = new Date().toString();
// }
// public void delete(){
// this.isdelete = true;
// this.updatetime = new Date().toString();
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/controller/CalendarController.java
import cn.edu.upc.yb.integrate.calendar.dao.SchoolCalendarDao;
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.calendar.model.SchoolCalendar;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.calendar.controller;
@RestController
@RequestMapping("/calendar")
public class CalendarController {
@Autowired | private SchoolCalendarDao schoolCalendarDao; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/calendar/controller/CalendarController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/dao/SchoolCalendarDao.java
// public interface SchoolCalendarDao extends CrudRepository<SchoolCalendar, Integer> {
// public Iterable<SchoolCalendar> findBySchoolscheduleAndIsdelete(String schoolschedule,boolean isdelete);
// public Iterable<SchoolCalendar> findByIsdeleteOrderByIdDesc(boolean isdelete);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/model/SchoolCalendar.java
// @Entity
// @Table(name = "calendar")
// public class SchoolCalendar {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @Column(unique = true)
// private String schoolschedule;
//
// private String begindate;
// private String enddate;
//
// private boolean isdelete = false;
// private String creattime;
// private String updatetime;
//
// public boolean isdelete() {
// return isdelete;
// }
//
// public void setIsdelete(boolean isdelete) {
// this.isdelete = isdelete;
// }
//
// public String getCreattime() {
// return creattime;
// }
//
// public void setCreattime(String creattime) {
// this.creattime = creattime;
// }
//
// public String getUpdatetime() {
// return updatetime;
// }
//
// public void setUpdatetime(String updatetime) {
// this.updatetime = updatetime;
// }
//
// public SchoolCalendar(String schoolschedule, String begindate, String enddate) {
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.creattime = new Date().toString();
// this.updatetime = new Date().toString();
//
// }
// public SchoolCalendar(){}
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSchoolschedule() {
// return schoolschedule;
// }
//
// public void setSchoolschedule(String schoolschedule) {
// this.schoolschedule = schoolschedule;
// }
//
// public String getBegindate() {
// return begindate;
// }
//
// public void setBegindate(String begindate) {
// this.begindate = begindate;
// }
//
// public String getEnddate() {
// return enddate;
// }
//
// public void setEnddate(String enddate) {
// this.enddate = enddate;
// }
//
// public void updata(String schoolschedule, String begindate, String enddate){
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.updatetime = new Date().toString();
// }
// public void delete(){
// this.isdelete = true;
// this.updatetime = new Date().toString();
// }
// }
| import cn.edu.upc.yb.integrate.calendar.dao.SchoolCalendarDao;
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.calendar.model.SchoolCalendar;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.calendar.controller;
@RestController
@RequestMapping("/calendar")
public class CalendarController {
@Autowired
private SchoolCalendarDao schoolCalendarDao;
@Autowired
private CommonAdminService commonAdminService;
@RequestMapping("/create")
public Object creatCalendar(String schoolschedule, String begindate, String enddate) {
if (commonAdminService.isCommonAdmin() == false) return new ErrorReporter(-1, "您没有权限操作"); | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/dao/SchoolCalendarDao.java
// public interface SchoolCalendarDao extends CrudRepository<SchoolCalendar, Integer> {
// public Iterable<SchoolCalendar> findBySchoolscheduleAndIsdelete(String schoolschedule,boolean isdelete);
// public Iterable<SchoolCalendar> findByIsdeleteOrderByIdDesc(boolean isdelete);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/model/SchoolCalendar.java
// @Entity
// @Table(name = "calendar")
// public class SchoolCalendar {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// @Column(unique = true)
// private String schoolschedule;
//
// private String begindate;
// private String enddate;
//
// private boolean isdelete = false;
// private String creattime;
// private String updatetime;
//
// public boolean isdelete() {
// return isdelete;
// }
//
// public void setIsdelete(boolean isdelete) {
// this.isdelete = isdelete;
// }
//
// public String getCreattime() {
// return creattime;
// }
//
// public void setCreattime(String creattime) {
// this.creattime = creattime;
// }
//
// public String getUpdatetime() {
// return updatetime;
// }
//
// public void setUpdatetime(String updatetime) {
// this.updatetime = updatetime;
// }
//
// public SchoolCalendar(String schoolschedule, String begindate, String enddate) {
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.creattime = new Date().toString();
// this.updatetime = new Date().toString();
//
// }
// public SchoolCalendar(){}
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSchoolschedule() {
// return schoolschedule;
// }
//
// public void setSchoolschedule(String schoolschedule) {
// this.schoolschedule = schoolschedule;
// }
//
// public String getBegindate() {
// return begindate;
// }
//
// public void setBegindate(String begindate) {
// this.begindate = begindate;
// }
//
// public String getEnddate() {
// return enddate;
// }
//
// public void setEnddate(String enddate) {
// this.enddate = enddate;
// }
//
// public void updata(String schoolschedule, String begindate, String enddate){
// this.schoolschedule = schoolschedule;
// this.begindate = begindate;
// this.enddate = enddate;
// this.updatetime = new Date().toString();
// }
// public void delete(){
// this.isdelete = true;
// this.updatetime = new Date().toString();
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/calendar/controller/CalendarController.java
import cn.edu.upc.yb.integrate.calendar.dao.SchoolCalendarDao;
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.calendar.model.SchoolCalendar;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.calendar.controller;
@RestController
@RequestMapping("/calendar")
public class CalendarController {
@Autowired
private SchoolCalendarDao schoolCalendarDao;
@Autowired
private CommonAdminService commonAdminService;
@RequestMapping("/create")
public Object creatCalendar(String schoolschedule, String begindate, String enddate) {
if (commonAdminService.isCommonAdmin() == false) return new ErrorReporter(-1, "您没有权限操作"); | SchoolCalendar schoolCalendar = new SchoolCalendar(schoolschedule, begindate, enddate); |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/common/TestAdmin.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.common.dao.AppAdminRepository;
import cn.edu.upc.yb.integrate.common.model.AppAdmin;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional; | package cn.edu.upc.yb.integrate.common;
/**
* Created by lylllcc on 2017/4/2.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class TestAdmin {
@Autowired
private AppAdminRepository appAdminRepository;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/service/AppAdminService.java
// @Service
// public class AppAdminService {
//
// @Autowired
// private AppAdminRepository appAdminRepository;
//
// public boolean isAppAdmin(String appName,int ybid){
// Collection<AppAdmin> admins = appAdminRepository.findByAppNameAndYbid(appName,ybid);
// if(admins.isEmpty() == true)
// return false;
// return true;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/common/TestAdmin.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.common.dao.AppAdminRepository;
import cn.edu.upc.yb.integrate.common.model.AppAdmin;
import cn.edu.upc.yb.integrate.common.service.AppAdminService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
package cn.edu.upc.yb.integrate.common;
/**
* Created by lylllcc on 2017/4/2.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class TestAdmin {
@Autowired
private AppAdminRepository appAdminRepository;
@Autowired | private AppAdminService appAdminService; |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/calendar/CalendarTest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/config/CalendarConfig.java
// @Component
// public class CalendarConfig {
//
// @Value("${yibanoauth.calendar.APPID}")
// public String appid;
//
// @Value("${yibanoauth.calendar.APPkey}")
// public String appkey;
//
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.calendar.config.CalendarConfig;
import cn.edu.upc.yb.integrate.calendar.dao.SchoolEventDao;
import cn.edu.upc.yb.integrate.calendar.model.SchoolEvent;
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date; | System.out.println(date.toString());
System.out.println(localTime.toString());
}
@Test
public void creatEven() {
SchoolEvent schoolEvent = new SchoolEvent("2016-07-09", "2016-07-09", "11:03:20", "22:12:20", "易班放电影", "放电影");
System.out.println(schoolEventDao.save(schoolEvent));
}
@Test
public void updateEvent() {
SchoolEvent schoolEvent = new SchoolEvent("2016-07-09", "2016-07-09", "11:03:20", "22:12:20", "易班放电影", "放电影");
schoolEvent.setId(3);
schoolEventDao.save(schoolEvent);
}
@Test
public void eventSeeder() {
for (int i = 0; i < 9; i++){
SchoolEvent schoolEvent = new SchoolEvent( "11:03:20", "22:12:20","2016-07-0" + i, "2016-07-0" + i, "易班放电影" + i, "放电影" + i);
System.out.println(schoolEventDao.save(schoolEvent));
}
}
@Autowired
YibanOAuth yibanOAuth;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/calendar/config/CalendarConfig.java
// @Component
// public class CalendarConfig {
//
// @Value("${yibanoauth.calendar.APPID}")
// public String appid;
//
// @Value("${yibanoauth.calendar.APPkey}")
// public String appkey;
//
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/calendar/CalendarTest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.calendar.config.CalendarConfig;
import cn.edu.upc.yb.integrate.calendar.dao.SchoolEventDao;
import cn.edu.upc.yb.integrate.calendar.model.SchoolEvent;
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;
System.out.println(date.toString());
System.out.println(localTime.toString());
}
@Test
public void creatEven() {
SchoolEvent schoolEvent = new SchoolEvent("2016-07-09", "2016-07-09", "11:03:20", "22:12:20", "易班放电影", "放电影");
System.out.println(schoolEventDao.save(schoolEvent));
}
@Test
public void updateEvent() {
SchoolEvent schoolEvent = new SchoolEvent("2016-07-09", "2016-07-09", "11:03:20", "22:12:20", "易班放电影", "放电影");
schoolEvent.setId(3);
schoolEventDao.save(schoolEvent);
}
@Test
public void eventSeeder() {
for (int i = 0; i < 9; i++){
SchoolEvent schoolEvent = new SchoolEvent( "11:03:20", "22:12:20","2016-07-0" + i, "2016-07-0" + i, "易班放电影" + i, "放电影" + i);
System.out.println(schoolEventDao.save(schoolEvent));
}
}
@Autowired
YibanOAuth yibanOAuth;
@Autowired | CalendarConfig calendarConfig; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
| import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java
import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired | ContactsJobRepository contactJobRepository; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
| import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired
ContactsJobRepository contactJobRepository;
@Autowired
ContactsUnitRepository contactsUnitRepository;
@Autowired
private HttpSession httpSession;
@RequestMapping(value = "/showunit",method = RequestMethod.GET)
public Object showUnit(){ | // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java
import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired
ContactsJobRepository contactJobRepository;
@Autowired
ContactsUnitRepository contactsUnitRepository;
@Autowired
private HttpSession httpSession;
@RequestMapping(value = "/showunit",method = RequestMethod.GET)
public Object showUnit(){ | YibanBasicUserInfo yibanBasicUserInfo = (YibanBasicUserInfo) httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
| import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired
ContactsJobRepository contactJobRepository;
@Autowired
ContactsUnitRepository contactsUnitRepository;
@Autowired
private HttpSession httpSession;
@RequestMapping(value = "/showunit",method = RequestMethod.GET)
public Object showUnit(){
YibanBasicUserInfo yibanBasicUserInfo = (YibanBasicUserInfo) httpSession.getAttribute("user");
System.out.println(yibanBasicUserInfo.visit_user.userid + "123");
return contactsUnitRepository.findAll();
}
@RequestMapping(value = "/showjob",method = RequestMethod.GET)
public Object showJob(int unitid){
return contactJobRepository.findByContactsUnitId(unitid);
}
@RequestMapping(value = "/findjob",method = RequestMethod.GET)
public Object findJob(String name){
return contactJobRepository.findByNameLike(name);
}
@GetMapping("/all")
public Object findAll(){
List<Map<String,Object>> maplist = new ArrayList<>();
| // Path: src/main/java/cn/edu/upc/yb/integrate/contact/model/ContactsUnit.java
// @Entity
// @Table(name = "ContactsUnit")
// public class ContactsUnit {
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private String name;
//
// public ContactsUnit(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public ContactsUnit() {
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/repository/ContactsJobRepository.java
// public interface ContactsJobRepository extends CrudRepository<ContactsJob,Integer>{
//
// public Iterable<ContactsJob> findByContactsUnitId(int id);
//
// @Query("select c from ContactsJob c where c.name like CONCAT('%',:name,'%')")
// public Iterable<ContactsJob> findByNameLike(@Param("name") String name);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/contact/controller/ContactsController.java
import cn.edu.upc.yb.integrate.contact.model.ContactsJob;
import cn.edu.upc.yb.integrate.contact.model.ContactsUnit;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.contact.repository.ContactsJobRepository;
import cn.edu.upc.yb.integrate.contact.repository.ContactsUnitRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.contact.controller;
/**
* Created by lenovo on 2017/3/25.
*/
@RestController
@RequestMapping(value = "/contacts")
public class ContactsController {
@Autowired
ContactsJobRepository contactJobRepository;
@Autowired
ContactsUnitRepository contactsUnitRepository;
@Autowired
private HttpSession httpSession;
@RequestMapping(value = "/showunit",method = RequestMethod.GET)
public Object showUnit(){
YibanBasicUserInfo yibanBasicUserInfo = (YibanBasicUserInfo) httpSession.getAttribute("user");
System.out.println(yibanBasicUserInfo.visit_user.userid + "123");
return contactsUnitRepository.findAll();
}
@RequestMapping(value = "/showjob",method = RequestMethod.GET)
public Object showJob(int unitid){
return contactJobRepository.findByContactsUnitId(unitid);
}
@RequestMapping(value = "/findjob",method = RequestMethod.GET)
public Object findJob(String name){
return contactJobRepository.findByNameLike(name);
}
@GetMapping("/all")
public Object findAll(){
List<Map<String,Object>> maplist = new ArrayList<>();
| Iterable<ContactsUnit> contactsUnits = contactsUnitRepository.findAll(); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/ChooseController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dao/CommonAdminDao.java
// public interface CommonAdminDao extends CrudRepository<CommonAdmin, Integer> {
// public Iterable<CommonAdmin> findByYibanid(int Yibanid);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/model/CommonAdmin.java
// @Entity
// @Table(name = "common_admin")
// public class CommonAdmin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// public CommonAdmin() {
// }
//
// public CommonAdmin(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dao.CommonAdminDao;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.model.CommonAdmin;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
*/
@RestController
@RequestMapping("/choose")
public class
ChooseController {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dao/CommonAdminDao.java
// public interface CommonAdminDao extends CrudRepository<CommonAdmin, Integer> {
// public Iterable<CommonAdmin> findByYibanid(int Yibanid);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/model/CommonAdmin.java
// @Entity
// @Table(name = "common_admin")
// public class CommonAdmin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// public CommonAdmin() {
// }
//
// public CommonAdmin(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/ChooseController.java
import cn.edu.upc.yb.integrate.common.dao.CommonAdminDao;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.model.CommonAdmin;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
*/
@RestController
@RequestMapping("/choose")
public class
ChooseController {
@Autowired | private VarietyOfDishesDao varietyOfDishesDao; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/ChooseController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dao/CommonAdminDao.java
// public interface CommonAdminDao extends CrudRepository<CommonAdmin, Integer> {
// public Iterable<CommonAdmin> findByYibanid(int Yibanid);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/model/CommonAdmin.java
// @Entity
// @Table(name = "common_admin")
// public class CommonAdmin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// public CommonAdmin() {
// }
//
// public CommonAdmin(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import cn.edu.upc.yb.integrate.common.dao.CommonAdminDao;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.model.CommonAdmin;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
*/
@RestController
@RequestMapping("/choose")
public class
ChooseController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private HttpSession httpSession;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dao/CommonAdminDao.java
// public interface CommonAdminDao extends CrudRepository<CommonAdmin, Integer> {
// public Iterable<CommonAdmin> findByYibanid(int Yibanid);
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/model/CommonAdmin.java
// @Entity
// @Table(name = "common_admin")
// public class CommonAdmin {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// public CommonAdmin() {
// }
//
// public CommonAdmin(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/dao/VarietyOfDishesDao.java
// public interface VarietyOfDishesDao extends CrudRepository<VarietyOfDishes,Integer>{
// Iterable<VarietyOfDishes> findByName(String name);
//
// Iterable<VarietyOfDishes> findByRegion(String region);
//
// Iterable<VarietyOfDishes> findByKind(String kind);
//
// Iterable<VarietyOfDishes> findByRestaurant(String restaurant);
//
// Iterable<VarietyOfDishes> findByPrice(String price);//有空重写
//
// Iterable<VarietyOfDishes> findByRestaurantAndPrice(String restaurant,String price);
//
//
// Iterable<VarietyOfDishes> findByKindAndPrice(String kind,String price);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurant(String kind,String restaurant);
//
// Iterable<VarietyOfDishes> findByKindAndRestaurantAndPrice(String kind,String restaurant,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndPrice(String region,String price);
//
//
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurantAndPrice(String region, String kind, String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndRestaurant(String region, String kind, String restaurant);
//
// Iterable<VarietyOfDishes> findByRegionAndKindAndPrice(String region, String kind, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndKind(String region, String kind);
//
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurantAndPrice(String region,String restaurant, String price);
//
// Iterable<VarietyOfDishes> findByRegionAndRestaurant(String region, String restaurant);
//
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dto/JsonMes.java
// public class JsonMes {
// private int code;
// private String message;
//
// public JsonMes() {
// }
// public JsonMes(int code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliciousfood/controller/ChooseController.java
import cn.edu.upc.yb.integrate.common.dao.CommonAdminDao;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.model.CommonAdmin;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.deliciousfood.dao.VarietyOfDishesDao;
import cn.edu.upc.yb.integrate.deliciousfood.model.VarietyOfDishes;
import cn.edu.upc.yb.integrate.deliverwater.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.deliciousfood.controller;
/**
* Created by 陈子枫 on 2017/2/6.
*/
@RestController
@RequestMapping("/choose")
public class
ChooseController {
@Autowired
private VarietyOfDishesDao varietyOfDishesDao;
@Autowired
private HttpSession httpSession;
@Autowired | private CommonAdminDao commonAdminDao; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/speaktoteacher/service/TeacherService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.speaktoteacher.model.Teacher;
import cn.edu.upc.yb.integrate.speaktoteacher.repository.TeacherRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import javax.validation.constraints.Null;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.speaktoteacher.service;
/**
* Created by wanghaojun on 2017/3/30.
*/
@Service
public class TeacherService {
@Autowired
private TeacherRepository teacherRepository;
@Autowired
private HttpSession httpSession;
public boolean isTeacher(int ybid) {
if (httpSession.getAttribute("user") == null) {
return false;
} | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/speaktoteacher/service/TeacherService.java
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.speaktoteacher.model.Teacher;
import cn.edu.upc.yb.integrate.speaktoteacher.repository.TeacherRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import javax.validation.constraints.Null;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.speaktoteacher.service;
/**
* Created by wanghaojun on 2017/3/30.
*/
@Service
public class TeacherService {
@Autowired
private TeacherRepository teacherRepository;
@Autowired
private HttpSession httpSession;
public boolean isTeacher(int ybid) {
if (httpSession.getAttribute("user") == null) {
return false;
} | YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/second/service/YbInterfaceService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/second/dto/YibanOtherInfo.java
// public class YibanOtherInfo {
//
// public String status;
// public Info info;
//
// public class Info {
// public int yb_userid;
// public String yb_username;
// public String yb_usernick;
// public char yb_sex;
// public String yb_userhead;
// public String yb_schoolid;
// public String yb_schoolname;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanOtherInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection; | package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class YbInterfaceService {
@Autowired
private HttpSession httpSession;
| // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/second/dto/YibanOtherInfo.java
// public class YibanOtherInfo {
//
// public String status;
// public Info info;
//
// public class Info {
// public int yb_userid;
// public String yb_username;
// public String yb_usernick;
// public char yb_sex;
// public String yb_userhead;
// public String yb_schoolid;
// public String yb_schoolname;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/second/service/YbInterfaceService.java
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanOtherInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class YbInterfaceService {
@Autowired
private HttpSession httpSession;
| public YibanOtherInfo getOtherInfo(int id) throws IOException { |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/second/service/YbInterfaceService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/second/dto/YibanOtherInfo.java
// public class YibanOtherInfo {
//
// public String status;
// public Info info;
//
// public class Info {
// public int yb_userid;
// public String yb_username;
// public String yb_usernick;
// public char yb_sex;
// public String yb_userhead;
// public String yb_schoolid;
// public String yb_schoolname;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanOtherInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection; | package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class YbInterfaceService {
@Autowired
private HttpSession httpSession;
public YibanOtherInfo getOtherInfo(int id) throws IOException { | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/second/dto/YibanOtherInfo.java
// public class YibanOtherInfo {
//
// public String status;
// public Info info;
//
// public class Info {
// public int yb_userid;
// public String yb_username;
// public String yb_usernick;
// public char yb_sex;
// public String yb_userhead;
// public String yb_schoolid;
// public String yb_schoolname;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/second/service/YbInterfaceService.java
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanOtherInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class YbInterfaceService {
@Autowired
private HttpSession httpSession;
public YibanOtherInfo getOtherInfo(int id) throws IOException { | String access_token = ((YibanBasicUserInfo)httpSession.getAttribute("user")).visit_oauth.access_token; |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime; | package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired | private NotificationService notificationService; |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime; | package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired
private NotificationService notificationService;
@Autowired
private HttpSession httpSession;
@Test
@Transactional
public void testDB(){ | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired
private NotificationService notificationService;
@Autowired
private HttpSession httpSession;
@Test
@Transactional
public void testDB(){ | Notification notification = new Notification(119, "测试233", "222222", "w"); |
upcyiban/IntegrateApplication | src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime; | package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired
private NotificationService notificationService;
@Autowired
private HttpSession httpSession;
@Test
@Transactional
public void testDB(){
Notification notification = new Notification(119, "测试233", "222222", "w");
notificationDao.save(notification);
Notification notification1 = notificationDao.findFirstByOrderByIdDesc();
Assert.assertEquals(notification1.getTitle(), "测试233");
}
@Test
@Transactional
@Rollback
public void testPostNew(){ | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
// @Service
// public class NotificationService {
//
// @Autowired
// private HttpSession httpSession;
//
// @Autowired
// private CommonAdminService commonAdminService;
//
// @Autowired
// private NotificationDao notificationDao;
//
// public Object postNew(String title, String message, String tag){
// YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// Notification notification = new Notification(user.visit_user.userid, title, message, tag);
// notificationDao.save(notification);
// return new ErrorReporter(0, "success");
// }
//
// public Object deleteOne(int Nid){
// if (!commonAdminService.isCommonAdmin()){
// return new ErrorReporter(-1,"no-access");
// }
// notificationDao.delete(Nid);
// return new ErrorReporter(0, "success");
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/test/java/cn/edu/upc/yb/integrate/bulletinboard/dbtest.java
import cn.edu.upc.yb.integrate.IntegrateApplication;
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.bulletinboard.service.NotificationService;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
package cn.edu.upc.yb.integrate.bulletinboard;
/**
* Created by skyADMIN on 16/7/8.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@WebAppConfiguration
public class dbtest {
@Autowired
private NotificationDao notificationDao;
@Autowired
private NotificationService notificationService;
@Autowired
private HttpSession httpSession;
@Test
@Transactional
public void testDB(){
Notification notification = new Notification(119, "测试233", "222222", "w");
notificationDao.save(notification);
Notification notification1 = notificationDao.findFirstByOrderByIdDesc();
Assert.assertEquals(notification1.getTitle(), "测试233");
}
@Test
@Transactional
@Rollback
public void testPostNew(){ | YibanBasicUserInfo user = new YibanBasicUserInfo(); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/deliverwater/service/WriteExcelService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dao/DeliverWaterDao.java
// public interface DeliverWaterDao extends CrudRepository<DeliverWater,Integer> {
// Iterable<DeliverWater> findByIsdeal(boolean isdeal);
// Iterable<DeliverWater> findByIsdealOrderByBlockNumber(boolean isdeal);
// }
| import cn.edu.upc.yb.integrate.deliverwater.dao.DeliverWaterDao;
import cn.edu.upc.yb.integrate.deliverwater.model.DeliverWater;
import cn.edu.upc.yb.integrate.deliverwater.util.Time;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.deliverwater.service;
/**
* Created by Jaxlying on 2016/10/15.
*/
@Service
public class WriteExcelService {
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/dao/DeliverWaterDao.java
// public interface DeliverWaterDao extends CrudRepository<DeliverWater,Integer> {
// Iterable<DeliverWater> findByIsdeal(boolean isdeal);
// Iterable<DeliverWater> findByIsdealOrderByBlockNumber(boolean isdeal);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/deliverwater/service/WriteExcelService.java
import cn.edu.upc.yb.integrate.deliverwater.dao.DeliverWaterDao;
import cn.edu.upc.yb.integrate.deliverwater.model.DeliverWater;
import cn.edu.upc.yb.integrate.deliverwater.util.Time;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.deliverwater.service;
/**
* Created by Jaxlying on 2016/10/15.
*/
@Service
public class WriteExcelService {
@Autowired | private DeliverWaterDao deliverDao; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/common/controller/FileController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/storage/StorageService.java
// public interface StorageService {
//
// void init();
//
// void store(MultipartFile file, String name);
//
// Stream<Path> loadAll();
//
// Path load(String filename);
//
// Resource loadAsResource(String filename);
//
// void deleteAll();
//
// }
| import cn.edu.upc.yb.integrate.common.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; | package cn.edu.upc.yb.integrate.common.controller;
/**
* Created by lylllcc on 2017/4/17.
*/
@RestController
public class FileController {
| // Path: src/main/java/cn/edu/upc/yb/integrate/common/storage/StorageService.java
// public interface StorageService {
//
// void init();
//
// void store(MultipartFile file, String name);
//
// Stream<Path> loadAll();
//
// Path load(String filename);
//
// Resource loadAsResource(String filename);
//
// void deleteAll();
//
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/common/controller/FileController.java
import cn.edu.upc.yb.integrate.common.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
package cn.edu.upc.yb.integrate.common.controller;
/**
* Created by lylllcc on 2017/4/17.
*/
@RestController
public class FileController {
| private final StorageService storageService; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/competiton/controller/ComAuthController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/competiton/config/CompetionConfig.java
// @Component
// public class CompetionConfig {
// @Value("${yibanoauth.competition.APPID}")
// public String appid;
//
// @Value("${yibanoauth.competition.APPkey}")
// public String appkey;
// }
| import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.competiton.config.CompetionConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.competiton.controller;
/**
* Created by wanghaojun on 2017/4/9.
*/
@RestController
@RequestMapping("/competition")
public class ComAuthController {
@Autowired
private HttpSession httpSession;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/competiton/config/CompetionConfig.java
// @Component
// public class CompetionConfig {
// @Value("${yibanoauth.competition.APPID}")
// public String appid;
//
// @Value("${yibanoauth.competition.APPkey}")
// public String appkey;
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/competiton/controller/ComAuthController.java
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import cn.edu.upc.yb.integrate.competiton.config.CompetionConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.competiton.controller;
/**
* Created by wanghaojun on 2017/4/9.
*/
@RestController
@RequestMapping("/competition")
public class ComAuthController {
@Autowired
private HttpSession httpSession;
@Autowired | private CompetionConfig competionConfig; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.bulletinboard.service;
/**
* Created by skyADMIN on 16/7/11.
*/
@Service
public class NotificationService {
@Autowired
private HttpSession httpSession;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
private NotificationDao notificationDao;
public Object postNew(String title, String message, String tag){ | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.bulletinboard.service;
/**
* Created by skyADMIN on 16/7/11.
*/
@Service
public class NotificationService {
@Autowired
private HttpSession httpSession;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
private NotificationDao notificationDao;
public Object postNew(String title, String message, String tag){ | YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession; | package cn.edu.upc.yb.integrate.bulletinboard.service;
/**
* Created by skyADMIN on 16/7/11.
*/
@Service
public class NotificationService {
@Autowired
private HttpSession httpSession;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
private NotificationDao notificationDao;
public Object postNew(String title, String message, String tag){
YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
if (!commonAdminService.isCommonAdmin()){
return new ErrorReporter(-1,"no-access");
} | // Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/model/Notification.java
// @Entity
// @Table(name = "notification")
// public class Notification {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
//
// private int yibanid;
//
// private String title;
// private String message;
// private String tag;
//
// private LocalDateTime publishtime;
//
// public Notification() {
// }
//
// public Notification(int yibanid, String title, String message) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = "default";
// this.publishtime = LocalDateTime.now();
// }
//
// public Notification(int yibanid, String title, String message, String tag) {
// this.yibanid = yibanid;
// this.title = title;
// this.message = message;
// this.tag = tag;
// this.publishtime = LocalDateTime.now();
// }
//
// public int getYibanid() {
// return yibanid;
// }
//
// public void setYibanid(int yibanid) {
// this.yibanid = yibanid;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public String getTag() {
// return tag;
// }
//
// public void setTag(String tag) {
// this.tag = tag;
// }
//
// public LocalDateTime getPublishtime() {
// return publishtime;
// }
//
// public void setPublishtime(LocalDateTime publishtime) {
// this.publishtime = publishtime;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/bulletinboard/service/NotificationService.java
import cn.edu.upc.yb.integrate.bulletinboard.dao.NotificationDao;
import cn.edu.upc.yb.integrate.bulletinboard.model.Notification;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.common.service.CommonAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
package cn.edu.upc.yb.integrate.bulletinboard.service;
/**
* Created by skyADMIN on 16/7/11.
*/
@Service
public class NotificationService {
@Autowired
private HttpSession httpSession;
@Autowired
private CommonAdminService commonAdminService;
@Autowired
private NotificationDao notificationDao;
public Object postNew(String title, String message, String tag){
YibanBasicUserInfo user = (YibanBasicUserInfo) httpSession.getAttribute("user");
if (!commonAdminService.isCommonAdmin()){
return new ErrorReporter(-1,"no-access");
} | Notification notification = new Notification(user.visit_user.userid, title, message, tag); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/express/controller/ExpressIndexController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.express.model.ExpressOrder;
import cn.edu.upc.yb.integrate.express.repository.ExpressAddressRepository;
import cn.edu.upc.yb.integrate.express.repository.ExpressOrderRepository;
import cn.edu.upc.yb.integrate.express.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpSession;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.express.controller;
/**
* Created by wh980 on 2016/9/7.
*/
@RequestMapping("/express")
public class ExpressIndexController {
@Autowired
ExpressOrderRepository expressOrderRepository;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/express/controller/ExpressIndexController.java
import cn.edu.upc.yb.integrate.common.auth.YibanOAuth;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.express.model.ExpressOrder;
import cn.edu.upc.yb.integrate.express.repository.ExpressAddressRepository;
import cn.edu.upc.yb.integrate.express.repository.ExpressOrderRepository;
import cn.edu.upc.yb.integrate.express.dto.JsonMes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpSession;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.express.controller;
/**
* Created by wh980 on 2016/9/7.
*/
@RequestMapping("/express")
public class ExpressIndexController {
@Autowired
ExpressOrderRepository expressOrderRepository;
@Autowired | YibanBasicUserInfo yibanBasicUserInfo; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/second/service/UserService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
| import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import cn.edu.upc.yb.integrate.second.model.OurUser;
import cn.edu.upc.yb.integrate.second.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.IOException; | package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private YbInterfaceService ybInterfaceService;
public boolean isOurUser(){ | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/second/service/UserService.java
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.second.dto.YibanUserInfo;
import cn.edu.upc.yb.integrate.second.model.OurUser;
import cn.edu.upc.yb.integrate.second.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.io.IOException;
package cn.edu.upc.yb.integrate.second.service;
/**
* Created by Jaxlying on 2016/7/26.
*/
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
@Autowired
private HttpSession httpSession;
@Autowired
private YbInterfaceService ybInterfaceService;
public boolean isOurUser(){ | YibanBasicUserInfo user = (YibanBasicUserInfo)httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
| import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/11.
*/
@RestController
@RequestMapping(value = "/material")
public class MaterialController {
@Autowired
MaterialRepository materialRepository;
@Autowired | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialController.java
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
package cn.edu.upc.yb.integrate.material.controller;
/**
* Created by wanghaojun on 2017/2/11.
*/
@RestController
@RequestMapping(value = "/material")
public class MaterialController {
@Autowired
MaterialRepository materialRepository;
@Autowired | BorrowMaterialRepository borrowMaterialRepository; |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialController.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
| import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator; | while (borrowMaterialIterator.hasNext()){
BorrowMaterial borrowMaterial=borrowMaterialIterator.next();
if(borrowMaterial.getStartTime()<=time && !borrowMaterial.isReturn() && borrowMaterial.getIsAgree()==1){
number = borrowMaterial.getBorrowNumber()+number;
System.out.println(number);
}
}
}
catch (Exception e){
System.out.println(e.getMessage());
}
finally {
if (number == 0){
material.setNumber(material.getTotalNumber());
}
else {
material.setNumber(material.getTotalNumber()-number);
}
}
}
return materialRepository.findAll();
}
@RequestMapping(value = "/creat",method = RequestMethod.GET)
public Object creatBorrowMaterial(String borrowerName, String borrowerNumber,String reason,int materialId, int borrowNumber,long startTime,long endTime ){
if (httpSession.getAttribute("user")==null)
return new ErrorReporter(0,"没有登陆"); | // Path: src/main/java/cn/edu/upc/yb/integrate/common/dto/YibanBasicUserInfo.java
// public class YibanBasicUserInfo {
// public int visit_time;
// public VisitUser visit_user;
// public VisitOauth visit_oauth;
//
// public class VisitUser{
// public int userid;
// public String username;
// public String usernick;
// public char usersex;
// public String userhead;
// }
//
// public class VisitOauth{
// public String access_token;
// public int token_expires;
// }
// }
//
// Path: src/main/java/cn/edu/upc/yb/integrate/material/repository/BorrowMaterialRepository.java
// public interface BorrowMaterialRepository extends CrudRepository<BorrowMaterial,Integer> {
//
// public Iterable<BorrowMaterial> findByMaterialId(int id);
// public Iterable<BorrowMaterial> findByBorrowerYibanId(int id);
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/material/controller/MaterialController.java
import cn.edu.upc.yb.integrate.calendar.dto.JsonMes;
import cn.edu.upc.yb.integrate.common.dto.ErrorReporter;
import cn.edu.upc.yb.integrate.common.dto.YibanBasicUserInfo;
import cn.edu.upc.yb.integrate.material.model.BorrowMaterial;
import cn.edu.upc.yb.integrate.material.model.Material;
import cn.edu.upc.yb.integrate.material.repository.BorrowMaterialRepository;
import cn.edu.upc.yb.integrate.material.repository.MaterialRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.Iterator;
while (borrowMaterialIterator.hasNext()){
BorrowMaterial borrowMaterial=borrowMaterialIterator.next();
if(borrowMaterial.getStartTime()<=time && !borrowMaterial.isReturn() && borrowMaterial.getIsAgree()==1){
number = borrowMaterial.getBorrowNumber()+number;
System.out.println(number);
}
}
}
catch (Exception e){
System.out.println(e.getMessage());
}
finally {
if (number == 0){
material.setNumber(material.getTotalNumber());
}
else {
material.setNumber(material.getTotalNumber()-number);
}
}
}
return materialRepository.findAll();
}
@RequestMapping(value = "/creat",method = RequestMethod.GET)
public Object creatBorrowMaterial(String borrowerName, String borrowerNumber,String reason,int materialId, int borrowNumber,long startTime,long endTime ){
if (httpSession.getAttribute("user")==null)
return new ErrorReporter(0,"没有登陆"); | YibanBasicUserInfo yibanBasicUserInfo=(YibanBasicUserInfo) httpSession.getAttribute("user"); |
upcyiban/IntegrateApplication | src/main/java/cn/edu/upc/yb/integrate/common/service/FileUploadService.java | // Path: src/main/java/cn/edu/upc/yb/integrate/common/storage/StorageService.java
// public interface StorageService {
//
// void init();
//
// void store(MultipartFile file, String name);
//
// Stream<Path> loadAll();
//
// Path load(String filename);
//
// Resource loadAsResource(String filename);
//
// void deleteAll();
//
// }
| import cn.edu.upc.yb.integrate.common.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File; | package cn.edu.upc.yb.integrate.common.service;
/**
* Created by lylllcc on 2017/4/17.
*/
@Service
public class FileUploadService {
| // Path: src/main/java/cn/edu/upc/yb/integrate/common/storage/StorageService.java
// public interface StorageService {
//
// void init();
//
// void store(MultipartFile file, String name);
//
// Stream<Path> loadAll();
//
// Path load(String filename);
//
// Resource loadAsResource(String filename);
//
// void deleteAll();
//
// }
// Path: src/main/java/cn/edu/upc/yb/integrate/common/service/FileUploadService.java
import cn.edu.upc.yb.integrate.common.storage.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
package cn.edu.upc.yb.integrate.common.service;
/**
* Created by lylllcc on 2017/4/17.
*/
@Service
public class FileUploadService {
| private final StorageService storageService; |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/util/HouseAdsUtil.java | // Path: src/main/java/com/citysearch/webwidget/bean/HouseAd.java
// public class HouseAd {
// private String title;
// private String tagLine;
// private String destinationUrl;
// private String imageURL;
// private String trackingUrl;
// private String displayUrl;
//
// public String getTrackingUrl() {
// return trackingUrl;
// }
//
// public void setTrackingUrl(String trackingUrl) {
// this.trackingUrl = trackingUrl;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTagLine() {
// return tagLine;
// }
//
// public void setTagLine(String tagLine) {
// this.tagLine = tagLine;
// }
//
// public String getDestinationUrl() {
// return destinationUrl;
// }
//
// public void setDestinationUrl(String destinationUrl) {
// this.destinationUrl = destinationUrl;
// }
//
// public String getImageURL() {
// return imageURL;
// }
//
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
//
// public void setDisplayUrl(String displayUrl) {
// this.displayUrl = displayUrl;
// }
//
// public String getDisplayUrl() {
// return displayUrl;
// }
//
// }
//
// Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.jdom.Document;
import org.jdom.Element;
import com.citysearch.webwidget.bean.HouseAd;
import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.util;
public class HouseAdsUtil {
public static List<HouseAd> getHouseAds(String path, String dartTrackUrl) | // Path: src/main/java/com/citysearch/webwidget/bean/HouseAd.java
// public class HouseAd {
// private String title;
// private String tagLine;
// private String destinationUrl;
// private String imageURL;
// private String trackingUrl;
// private String displayUrl;
//
// public String getTrackingUrl() {
// return trackingUrl;
// }
//
// public void setTrackingUrl(String trackingUrl) {
// this.trackingUrl = trackingUrl;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getTagLine() {
// return tagLine;
// }
//
// public void setTagLine(String tagLine) {
// this.tagLine = tagLine;
// }
//
// public String getDestinationUrl() {
// return destinationUrl;
// }
//
// public void setDestinationUrl(String destinationUrl) {
// this.destinationUrl = destinationUrl;
// }
//
// public String getImageURL() {
// return imageURL;
// }
//
// public void setImageURL(String imageURL) {
// this.imageURL = imageURL;
// }
//
// public void setDisplayUrl(String displayUrl) {
// this.displayUrl = displayUrl;
// }
//
// public String getDisplayUrl() {
// return displayUrl;
// }
//
// }
//
// Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/util/HouseAdsUtil.java
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.jdom.Document;
import org.jdom.Element;
import com.citysearch.webwidget.bean.HouseAd;
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.util;
public class HouseAdsUtil {
public static List<HouseAd> getHouseAds(String path, String dartTrackUrl) | throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/facade/NearByPlacesFacadeFactory.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
//
// Path: src/main/java/com/citysearch/webwidget/util/CommonConstants.java
// public class CommonConstants {
// public static final Integer DEFAULT_NEARBY_DISPLAY_SIZE = 3;
//
// public static final String WHAT = "what";
// public static final String WHERE = "where";
// public static final String TAGS = "tags";
// public static final String TAG_SEARCH = "tag";
// public static final String PUBLISHER_CODE = "publishercode";
// public static final String LAT_URL = "lat";
// public static final String LON_URL = "lon";
// public static final String RADIUS = "radius";
// public static final String RES_CONTENT_TYPE = "text/html";
// public static final int RES_SUCCESS_CODE = 200;
// public static final String REDIRECT_URL_PARAM = "default.redirect.url";
// public static final String CALL_BACK_FUNCTION_PARAM = "callbackfunction";
// public static final String CALL_BACK_URL = "callbackURL";
// public static final String API_PROP_READ_ERROR = "api.properties";
// public static final String LATITUDE = "latitude";
// public static final String LONGITUDE = "longitude";
// public static final String PFP_WITHOUT_GEOGRAPHY = "pfpWithoutGeography";
// public static final String SEARCH_API_TYPE = "search";
// public static final String PFP_API_TYPE = "pfp";
// public static final String NAME = "name";
// public static final String STREET = "street";
// public static final String CITY = "city";
// public static final String STATE = "state";
// public static final String POSTALCODE = "postalcode";
// public static final String DISTANCE = "distance";
// public static final String SEARCHRESPONSE = "searchResponse";
// public static final String SEARCH_API_QUERIED = "searchAPIQueried";
// public static final String RATING = "rating";
// public static final String REVIEWCOUNT = "reviewCount";
// public static final String LISTING_ID = "listingId";
// public static final String CATEGORY = "category";
// public static final String DLAT = "dLat";
// public static final String DLON = "dLon";
// public static final String PHONENUMBER = "phonenumber";
// public static final String PHONE = "phone";
// public static final String DISPLAY_URL = "displayURL";
// public static final String IMAGE_URL = "imageURL";
// public static final String REVIEW_API_TYPE = "review";
// public static final String OFFERS = "offers";
//
// public final static String API_KEY_PROPERTY = "apikey";
//
// public final static String SYMBOL_AMPERSAND = "&";
//
// public static final String IMAGES_PROPERTIES_FILE = "images.properties";
// public static final String IMAGE_ERROR = "image.properties.error";
//
// public static final String DESCRIPTION_LENGTH = "description.length";
// public static final String NAME_LENGTH = "name.length";
// public static final String TAGLINE_LENGTH = "tagline.length";
// public static final String TITLE_LENGTH = "title.length";
// public static final String DISPLAY_URL_LENGTH = "displayurl.length";
// public static final String REVIEW_TITLE_LENGTH = "review.title.length";
// public static final String REVIEW_TEXT_LENGTH = "review.text.length";
// public static final String REVIEW_TEXT_SMALL_LENGTH = "review.text.small.length";
// public static final String REVIEW_PROS_LENGTH = "review.pros.length";
// public static final String REVIEW_CONS_LENGTH = "review.cons.length";
//
// public static final int EXTENDED_RADIUS = 25;
// public static final int DEFAULT_RADIUS = 25;
// public static final String DISTANCE_DISPLAY_CUTOFF = "nearby.distance.display.cutoff";
//
// public static final String MANTLE_AD_SIZE = "300x250";
// public static final String CONQUEST_AD_SIZE = "645x100";
// public static final int MANTLE_DISPLAY_SIZE = 3;
// public static final int CONQUEST_DISPLAY_SIZE = 2;
//
// public static final String AD_UNIT_NAME_NEARBY = "nearby";
// public static final String AD_UNIT_NAME_REVIEW = "review";
// public static final String AD_UNIT_NAME_OFFERS = "offers";
// public static final String AD_UNIT_NAME_DEALS = "deals";
// public static final String PUBLISHER_PROJECT_YELLOW = "yelp";
// public final static String PUBLISHER_CITYSEARCH = "citysearch";
// public final static String PUBLISHER_INSIDERPAGES = "insider_pages";
// public final static String PUBLISHER_URBANSPOON = "urbanspoon";
// public final static String PUBLISHER_CBS = "cbs";
// }
| import com.citysearch.webwidget.exception.CitysearchException;
import com.citysearch.webwidget.util.CommonConstants; | package com.citysearch.webwidget.facade;
public class NearByPlacesFacadeFactory {
public static AbstractNearByPlacesFacade getFacade(String publisher, String contextPath, | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
//
// Path: src/main/java/com/citysearch/webwidget/util/CommonConstants.java
// public class CommonConstants {
// public static final Integer DEFAULT_NEARBY_DISPLAY_SIZE = 3;
//
// public static final String WHAT = "what";
// public static final String WHERE = "where";
// public static final String TAGS = "tags";
// public static final String TAG_SEARCH = "tag";
// public static final String PUBLISHER_CODE = "publishercode";
// public static final String LAT_URL = "lat";
// public static final String LON_URL = "lon";
// public static final String RADIUS = "radius";
// public static final String RES_CONTENT_TYPE = "text/html";
// public static final int RES_SUCCESS_CODE = 200;
// public static final String REDIRECT_URL_PARAM = "default.redirect.url";
// public static final String CALL_BACK_FUNCTION_PARAM = "callbackfunction";
// public static final String CALL_BACK_URL = "callbackURL";
// public static final String API_PROP_READ_ERROR = "api.properties";
// public static final String LATITUDE = "latitude";
// public static final String LONGITUDE = "longitude";
// public static final String PFP_WITHOUT_GEOGRAPHY = "pfpWithoutGeography";
// public static final String SEARCH_API_TYPE = "search";
// public static final String PFP_API_TYPE = "pfp";
// public static final String NAME = "name";
// public static final String STREET = "street";
// public static final String CITY = "city";
// public static final String STATE = "state";
// public static final String POSTALCODE = "postalcode";
// public static final String DISTANCE = "distance";
// public static final String SEARCHRESPONSE = "searchResponse";
// public static final String SEARCH_API_QUERIED = "searchAPIQueried";
// public static final String RATING = "rating";
// public static final String REVIEWCOUNT = "reviewCount";
// public static final String LISTING_ID = "listingId";
// public static final String CATEGORY = "category";
// public static final String DLAT = "dLat";
// public static final String DLON = "dLon";
// public static final String PHONENUMBER = "phonenumber";
// public static final String PHONE = "phone";
// public static final String DISPLAY_URL = "displayURL";
// public static final String IMAGE_URL = "imageURL";
// public static final String REVIEW_API_TYPE = "review";
// public static final String OFFERS = "offers";
//
// public final static String API_KEY_PROPERTY = "apikey";
//
// public final static String SYMBOL_AMPERSAND = "&";
//
// public static final String IMAGES_PROPERTIES_FILE = "images.properties";
// public static final String IMAGE_ERROR = "image.properties.error";
//
// public static final String DESCRIPTION_LENGTH = "description.length";
// public static final String NAME_LENGTH = "name.length";
// public static final String TAGLINE_LENGTH = "tagline.length";
// public static final String TITLE_LENGTH = "title.length";
// public static final String DISPLAY_URL_LENGTH = "displayurl.length";
// public static final String REVIEW_TITLE_LENGTH = "review.title.length";
// public static final String REVIEW_TEXT_LENGTH = "review.text.length";
// public static final String REVIEW_TEXT_SMALL_LENGTH = "review.text.small.length";
// public static final String REVIEW_PROS_LENGTH = "review.pros.length";
// public static final String REVIEW_CONS_LENGTH = "review.cons.length";
//
// public static final int EXTENDED_RADIUS = 25;
// public static final int DEFAULT_RADIUS = 25;
// public static final String DISTANCE_DISPLAY_CUTOFF = "nearby.distance.display.cutoff";
//
// public static final String MANTLE_AD_SIZE = "300x250";
// public static final String CONQUEST_AD_SIZE = "645x100";
// public static final int MANTLE_DISPLAY_SIZE = 3;
// public static final int CONQUEST_DISPLAY_SIZE = 2;
//
// public static final String AD_UNIT_NAME_NEARBY = "nearby";
// public static final String AD_UNIT_NAME_REVIEW = "review";
// public static final String AD_UNIT_NAME_OFFERS = "offers";
// public static final String AD_UNIT_NAME_DEALS = "deals";
// public static final String PUBLISHER_PROJECT_YELLOW = "yelp";
// public final static String PUBLISHER_CITYSEARCH = "citysearch";
// public final static String PUBLISHER_INSIDERPAGES = "insider_pages";
// public final static String PUBLISHER_URBANSPOON = "urbanspoon";
// public final static String PUBLISHER_CBS = "cbs";
// }
// Path: src/main/java/com/citysearch/webwidget/facade/NearByPlacesFacadeFactory.java
import com.citysearch.webwidget.exception.CitysearchException;
import com.citysearch.webwidget.util.CommonConstants;
package com.citysearch.webwidget.facade;
public class NearByPlacesFacadeFactory {
public static AbstractNearByPlacesFacade getFacade(String publisher, String contextPath, | int displaySize) throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/util/HttpConnection.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import org.apache.log4j.Logger;
import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.util;
/**
* This class contains the functionality related to Http connection like getting
* the connecton and closing the connection
*
* @author Aspert Benjamin
*
*/
public class HttpConnection {
private static Logger log = Logger.getLogger(HttpConnection.class);
private static final String reqMethod = "GET";
private static final int resWaitTime = 10000;
private static final String error = "connection.error";
/**
* Gets the connection object for the given url Exception thrown if there is
* a connection failure
*
* @param urlString
* @param headers
* Map for HTTP Headers
* @return
* @throws CitysearchException
*/
public static HttpURLConnection getConnection(String urlString, | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/util/HttpConnection.java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import org.apache.log4j.Logger;
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.util;
/**
* This class contains the functionality related to Http connection like getting
* the connecton and closing the connection
*
* @author Aspert Benjamin
*
*/
public class HttpConnection {
private static Logger log = Logger.getLogger(HttpConnection.class);
private static final String reqMethod = "GET";
private static final int resWaitTime = 10000;
private static final String error = "connection.error";
/**
* Gets the connection object for the given url Exception thrown if there is
* a connection failure
*
* @param urlString
* @param headers
* Map for HTTP Headers
* @return
* @throws CitysearchException
*/
public static HttpURLConnection getConnection(String urlString, | Map<String, String> headers) throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/util/OneByOneTrackingUtil.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import com.citysearch.webwidget.exception.CitysearchException; | if (!StringUtils.isBlank(adunitName)) {
strBuilder.append(adunitName.toUpperCase());
strBuilder.append(".");
}
if (!StringUtils.isBlank(adunitSize)) {
strBuilder.append(adunitSize);
if (pfpResultsSize != null && pfpBackfillSize != null
&& searchResultsSize != null && houseAdsSize != null) {
strBuilder.append(".");
}
}
if (pfpResultsSize != null) {
strBuilder.append(String.valueOf(pfpResultsSize.intValue()));
strBuilder.append("P-");
}
if (pfpBackfillSize != null) {
strBuilder.append(String.valueOf(pfpBackfillSize.intValue()));
strBuilder.append("B-");
}
if (searchResultsSize != null) {
strBuilder.append(String.valueOf(searchResultsSize.intValue()));
strBuilder.append("S-");
}
if (houseAdsSize != null) {
strBuilder.append(String.valueOf(houseAdsSize.intValue()));
strBuilder.append("H");
}
return strBuilder.toString();
}
| // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/util/OneByOneTrackingUtil.java
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import com.citysearch.webwidget.exception.CitysearchException;
if (!StringUtils.isBlank(adunitName)) {
strBuilder.append(adunitName.toUpperCase());
strBuilder.append(".");
}
if (!StringUtils.isBlank(adunitSize)) {
strBuilder.append(adunitSize);
if (pfpResultsSize != null && pfpBackfillSize != null
&& searchResultsSize != null && houseAdsSize != null) {
strBuilder.append(".");
}
}
if (pfpResultsSize != null) {
strBuilder.append(String.valueOf(pfpResultsSize.intValue()));
strBuilder.append("P-");
}
if (pfpBackfillSize != null) {
strBuilder.append(String.valueOf(pfpBackfillSize.intValue()));
strBuilder.append("B-");
}
if (searchResultsSize != null) {
strBuilder.append(String.valueOf(searchResultsSize.intValue()));
strBuilder.append("S-");
}
if (houseAdsSize != null) {
strBuilder.append(String.valueOf(houseAdsSize.intValue()));
strBuilder.append("H");
}
return strBuilder.toString();
}
| public static String getTrackingUrl(String key) throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/util/PropertiesLoader.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.util;
/**
* This class loads properties from property files.
*
* @author Aspert Benjamin
*
*/
public class PropertiesLoader {
private static Logger log = Logger.getLogger(PropertiesLoader.class);
private static final String API_PROPERTIES_FILE = "/api.properties";
private static final String ERROR_PROPERTIES_FILE = "/error.properties";
private static final String APPLICATION_PROPERTIES_FILE = "/application.properties";
private static final String TRACKING_PROPERTIES_FILE = "/onebyonetracking.properties";
private static final String FIELD_PROPERTIES_FILE = "/field.properties";
private static Properties errorProperties;
private static Properties apiProperties;
private static Properties applicationProperties;
private static Properties fieldProperties;
/**
* Takes the file name as input and reads the properties from the file.
* Returns the Properties object that contains parameters as key,value pairs
*
* @param fileName
* @return Properties
*/
public static Properties getProperties(String fileName) | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/util/PropertiesLoader.java
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.util;
/**
* This class loads properties from property files.
*
* @author Aspert Benjamin
*
*/
public class PropertiesLoader {
private static Logger log = Logger.getLogger(PropertiesLoader.class);
private static final String API_PROPERTIES_FILE = "/api.properties";
private static final String ERROR_PROPERTIES_FILE = "/error.properties";
private static final String APPLICATION_PROPERTIES_FILE = "/application.properties";
private static final String TRACKING_PROPERTIES_FILE = "/onebyonetracking.properties";
private static final String FIELD_PROPERTIES_FILE = "/field.properties";
private static Properties errorProperties;
private static Properties apiProperties;
private static Properties applicationProperties;
private static Properties fieldProperties;
/**
* Takes the file name as input and reads the properties from the file.
* Returns the Properties object that contains parameters as key,value pairs
*
* @param fileName
* @return Properties
*/
public static Properties getProperties(String fileName) | throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/facade/OffersFacadeFactory.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.facade;
public class OffersFacadeFactory {
public static AbstractOffersFacade getFacade(String publisher, | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/facade/OffersFacadeFactory.java
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.facade;
public class OffersFacadeFactory {
public static AbstractOffersFacade getFacade(String publisher, | String contextPath, int displaySize) throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/facade/ReviewFacadeFactory.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.facade;
public class ReviewFacadeFactory {
public static AbstractReviewFacade getFacade(String publisher, | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/facade/ReviewFacadeFactory.java
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.facade;
public class ReviewFacadeFactory {
public static AbstractReviewFacade getFacade(String publisher, | String contextPath, int displaySize) throws CitysearchException { |
citysearch/web-widgets | src/main/java/com/citysearch/webwidget/util/Utils.java | // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.log4j.Logger;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import com.citysearch.webwidget.exception.CitysearchException; | package com.citysearch.webwidget.util;
public class Utils {
private static Logger log = Logger.getLogger(Utils.class);
private static final int TOTAL_RATING = 5;
private static final int EMPTY_STAR = 0;
private static final int HALF_STAR = 1;
private static final int FULL_STAR = 2;
private static final double KM_TO_MILE = 0.622;
private static final int RADIUS = 6371;
private static final String COMMA = ",";
private static final String SPACE = " ";
| // Path: src/main/java/com/citysearch/webwidget/exception/CitysearchException.java
// public class CitysearchException extends Exception {
// private static final long serialVersionUID = 1L;
// private String className;
// private String methodName;
//
// public CitysearchException(String className, String methodName) {
// super();
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message) {
// super(message);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, String message, Throwable cause) {
// super(message, cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public CitysearchException(String className, String methodName, Throwable cause) {
// super(cause);
// this.className = className;
// this.methodName = methodName;
// }
//
// public String getClassName() {
// return className;
// }
//
// public void setClassName(String className) {
// this.className = className;
// }
//
// public String getMethodName() {
// return methodName;
// }
//
// public void setMethodName(String methodName) {
// this.methodName = methodName;
// }
//
// public static long getSerialversionuid() {
// return serialVersionUID;
// }
// }
// Path: src/main/java/com/citysearch/webwidget/util/Utils.java
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.log4j.Logger;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import com.citysearch.webwidget.exception.CitysearchException;
package com.citysearch.webwidget.util;
public class Utils {
private static Logger log = Logger.getLogger(Utils.class);
private static final int TOTAL_RATING = 5;
private static final int EMPTY_STAR = 0;
private static final int HALF_STAR = 1;
private static final int FULL_STAR = 2;
private static final double KM_TO_MILE = 0.622;
private static final int RADIUS = 6371;
private static final String COMMA = ",";
private static final String SPACE = " ";
| public static String constructQueryParam(String name, String value) throws CitysearchException { |
tvbarthel/CameraColorPicker | CameraColorPicker/app/src/adult/java/fr/tvbarthel/apps/cameracolorpicker/views/ColorItemAdapter.java | // Path: CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/utils/BackgroundUtils.java
// public final class BackgroundUtils {
//
// /**
// * Non instantiable class.
// */
// private BackgroundUtils() {
//
// }
//
// /**
// * Build a background programmatically.
// *
// * @param view view to which assign the background
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// */
// public static void buildBackgroundDrawable(View view, int normalColor, int pressedColor) {
// BackgroundUtils.setBackground(
// view,
// BackgroundUtils.buildBackgroundDrawable(normalColor, pressedColor)
// );
// }
//
// /**
// * Build a background programmatically.
// *
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// * @return drawable well initialized.
// */
// public static Drawable buildBackgroundDrawable(int normalColor, int pressedColor) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// return BackgroundUtilsImplPostLollipop.getBackground(normalColor, pressedColor);
// } else {
// return BackgroundUtilsImplPreLollipop.getBackground(normalColor, pressedColor);
// }
// }
//
// /**
// * Proper way to set a background across android versions.
// *
// * @param view view to which the background will be set.
// * @param drawable drawable to set as background, null to remove the current background.
// */
// public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// view.setBackground(drawable);
// } else {
// view.setBackgroundDrawable(drawable);
// }
// }
// }
| import android.graphics.PorterDuff;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import fr.tvbarthel.apps.cameracolorpicker.R;
import fr.tvbarthel.apps.cameracolorpicker.data.ColorItem;
import fr.tvbarthel.apps.cameracolorpicker.utils.BackgroundUtils; | package fr.tvbarthel.apps.cameracolorpicker.views;
/**
* A {@link android.support.v7.widget.RecyclerView.Adapter} that adapts {@link ColorItem}s
* into {@link fr.tvbarthel.apps.cameracolorpicker.R.layout#row_color_item}
*/
/* package */
class ColorItemAdapter extends RecyclerView.Adapter<ColorItemAdapter.ColorItemHolder> {
private final List<ColorItem> mItems;
private final ColorItemAdapterListener mListener;
/* package */
ColorItemAdapter(ColorItemAdapterListener listener) {
this.mListener = listener;
this.mItems = new ArrayList<>();
}
@Override
public ColorItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_color_item, parent, false);
return new ColorItemHolder(view, mListener);
}
@Override
public void onBindViewHolder(ColorItemHolder holder, int position) {
final ColorItem colorItem = mItems.get(position);
holder.bind(colorItem);
}
@Override
public int getItemCount() {
return mItems.size();
}
/* package */
void setItems(List<ColorItem> items) {
mItems.clear();
mItems.addAll(items);
notifyDataSetChanged();
}
/* package */
void addItems(List<ColorItem> colorJustAdded) {
for (int i = colorJustAdded.size() - 1; i >= 0; i--) {
mItems.add(0, colorJustAdded.get(i));
}
notifyItemRangeInserted(0, colorJustAdded.size());
}
/**
* An interface for listening to {@link ColorItemAdapter} callbacks.
*/
/* package */
interface ColorItemAdapterListener {
/**
* Called when a {@link ColorItem} has just been clicked.
*
* @param colorItem the {@link ColorItem}.
* @param colorPreview the color preview.
*/
void onColorItemClicked(@NonNull ColorItem colorItem, @NonNull View colorPreview);
/**
* Called when a {@link ColorItem} has just been long clicked.
*
* @param colorItem the {@link ColorItem}.
*/
void onColorItemLongClicked(@NonNull ColorItem colorItem);
}
/**
* A simple {@link android.support.v7.widget.RecyclerView.ViewHolder} associated with {@link R.layout#row_color_item}.
*/
public static class ColorItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
/**
* The {@link View} to show a preview of the color item.
*/
private final View mColorPreview;
/**
* The {@link TextView} to display the hexadecimal code of the color item.
*/
private final TextView mColorText;
/**
* The underlying {@link View}
*/
private final View mUnderlyingView;
/**
* A {@link ColorItemAdapterListener} for callback.
*/
private final ColorItemAdapterListener mListener;
/**
* The {@link ColorItem} bound to this {@link ColorItemHolder}.
*/
private ColorItem mColorItem;
public ColorItemHolder(View view, ColorItemAdapterListener listener) {
super(view);
mListener = listener;
mUnderlyingView = view;
mColorPreview = view.findViewById(R.id.row_color_item_preview);
mColorText = (TextView) view.findViewById(R.id.row_color_item_text); | // Path: CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/utils/BackgroundUtils.java
// public final class BackgroundUtils {
//
// /**
// * Non instantiable class.
// */
// private BackgroundUtils() {
//
// }
//
// /**
// * Build a background programmatically.
// *
// * @param view view to which assign the background
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// */
// public static void buildBackgroundDrawable(View view, int normalColor, int pressedColor) {
// BackgroundUtils.setBackground(
// view,
// BackgroundUtils.buildBackgroundDrawable(normalColor, pressedColor)
// );
// }
//
// /**
// * Build a background programmatically.
// *
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// * @return drawable well initialized.
// */
// public static Drawable buildBackgroundDrawable(int normalColor, int pressedColor) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// return BackgroundUtilsImplPostLollipop.getBackground(normalColor, pressedColor);
// } else {
// return BackgroundUtilsImplPreLollipop.getBackground(normalColor, pressedColor);
// }
// }
//
// /**
// * Proper way to set a background across android versions.
// *
// * @param view view to which the background will be set.
// * @param drawable drawable to set as background, null to remove the current background.
// */
// public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// view.setBackground(drawable);
// } else {
// view.setBackgroundDrawable(drawable);
// }
// }
// }
// Path: CameraColorPicker/app/src/adult/java/fr/tvbarthel/apps/cameracolorpicker/views/ColorItemAdapter.java
import android.graphics.PorterDuff;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import fr.tvbarthel.apps.cameracolorpicker.R;
import fr.tvbarthel.apps.cameracolorpicker.data.ColorItem;
import fr.tvbarthel.apps.cameracolorpicker.utils.BackgroundUtils;
package fr.tvbarthel.apps.cameracolorpicker.views;
/**
* A {@link android.support.v7.widget.RecyclerView.Adapter} that adapts {@link ColorItem}s
* into {@link fr.tvbarthel.apps.cameracolorpicker.R.layout#row_color_item}
*/
/* package */
class ColorItemAdapter extends RecyclerView.Adapter<ColorItemAdapter.ColorItemHolder> {
private final List<ColorItem> mItems;
private final ColorItemAdapterListener mListener;
/* package */
ColorItemAdapter(ColorItemAdapterListener listener) {
this.mListener = listener;
this.mItems = new ArrayList<>();
}
@Override
public ColorItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_color_item, parent, false);
return new ColorItemHolder(view, mListener);
}
@Override
public void onBindViewHolder(ColorItemHolder holder, int position) {
final ColorItem colorItem = mItems.get(position);
holder.bind(colorItem);
}
@Override
public int getItemCount() {
return mItems.size();
}
/* package */
void setItems(List<ColorItem> items) {
mItems.clear();
mItems.addAll(items);
notifyDataSetChanged();
}
/* package */
void addItems(List<ColorItem> colorJustAdded) {
for (int i = colorJustAdded.size() - 1; i >= 0; i--) {
mItems.add(0, colorJustAdded.get(i));
}
notifyItemRangeInserted(0, colorJustAdded.size());
}
/**
* An interface for listening to {@link ColorItemAdapter} callbacks.
*/
/* package */
interface ColorItemAdapterListener {
/**
* Called when a {@link ColorItem} has just been clicked.
*
* @param colorItem the {@link ColorItem}.
* @param colorPreview the color preview.
*/
void onColorItemClicked(@NonNull ColorItem colorItem, @NonNull View colorPreview);
/**
* Called when a {@link ColorItem} has just been long clicked.
*
* @param colorItem the {@link ColorItem}.
*/
void onColorItemLongClicked(@NonNull ColorItem colorItem);
}
/**
* A simple {@link android.support.v7.widget.RecyclerView.ViewHolder} associated with {@link R.layout#row_color_item}.
*/
public static class ColorItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
/**
* The {@link View} to show a preview of the color item.
*/
private final View mColorPreview;
/**
* The {@link TextView} to display the hexadecimal code of the color item.
*/
private final TextView mColorText;
/**
* The underlying {@link View}
*/
private final View mUnderlyingView;
/**
* A {@link ColorItemAdapterListener} for callback.
*/
private final ColorItemAdapterListener mListener;
/**
* The {@link ColorItem} bound to this {@link ColorItemHolder}.
*/
private ColorItem mColorItem;
public ColorItemHolder(View view, ColorItemAdapterListener listener) {
super(view);
mListener = listener;
mUnderlyingView = view;
mColorPreview = view.findViewById(R.id.row_color_item_preview);
mColorText = (TextView) view.findViewById(R.id.row_color_item_text); | BackgroundUtils.setBackground( |
tvbarthel/CameraColorPicker | CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/views/ColorDotView.java | // Path: CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/utils/BackgroundUtils.java
// public final class BackgroundUtils {
//
// /**
// * Non instantiable class.
// */
// private BackgroundUtils() {
//
// }
//
// /**
// * Build a background programmatically.
// *
// * @param view view to which assign the background
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// */
// public static void buildBackgroundDrawable(View view, int normalColor, int pressedColor) {
// BackgroundUtils.setBackground(
// view,
// BackgroundUtils.buildBackgroundDrawable(normalColor, pressedColor)
// );
// }
//
// /**
// * Build a background programmatically.
// *
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// * @return drawable well initialized.
// */
// public static Drawable buildBackgroundDrawable(int normalColor, int pressedColor) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// return BackgroundUtilsImplPostLollipop.getBackground(normalColor, pressedColor);
// } else {
// return BackgroundUtilsImplPreLollipop.getBackground(normalColor, pressedColor);
// }
// }
//
// /**
// * Proper way to set a background across android versions.
// *
// * @param view view to which the background will be set.
// * @param drawable drawable to set as background, null to remove the current background.
// */
// public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// view.setBackground(drawable);
// } else {
// view.setBackgroundDrawable(drawable);
// }
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import fr.tvbarthel.apps.cameracolorpicker.utils.BackgroundUtils; | package fr.tvbarthel.apps.cameracolorpicker.views;
/**
* Simple view used to render a color dot.
*/
public class ColorDotView extends View {
/**
* Simple view used to render a color dot.
*
* @param context holding context.
*/
public ColorDotView(Context context) {
this(context, null);
}
/**
* Simple view used to render a color dot.
*
* @param context holding context.
* @param attrs attr from xml.
*/
public ColorDotView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
/**
* Simple view used to render a color dot.
*
* @param context holding context.
* @param attrs attr from xml.
* @param defStyleAttr style.
*/
public ColorDotView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
int size = Math.min(width, height);
int measureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
setMeasuredDimension(measureSpec, measureSpec);
}
/**
* Initialize internal component.
*
* @param context holding context.
*/
private void initialize(Context context) {
if (!isInEditMode()) { | // Path: CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/utils/BackgroundUtils.java
// public final class BackgroundUtils {
//
// /**
// * Non instantiable class.
// */
// private BackgroundUtils() {
//
// }
//
// /**
// * Build a background programmatically.
// *
// * @param view view to which assign the background
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// */
// public static void buildBackgroundDrawable(View view, int normalColor, int pressedColor) {
// BackgroundUtils.setBackground(
// view,
// BackgroundUtils.buildBackgroundDrawable(normalColor, pressedColor)
// );
// }
//
// /**
// * Build a background programmatically.
// *
// * @param normalColor background color.
// * @param pressedColor color used when the state is pressed.
// * @return drawable well initialized.
// */
// public static Drawable buildBackgroundDrawable(int normalColor, int pressedColor) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// return BackgroundUtilsImplPostLollipop.getBackground(normalColor, pressedColor);
// } else {
// return BackgroundUtilsImplPreLollipop.getBackground(normalColor, pressedColor);
// }
// }
//
// /**
// * Proper way to set a background across android versions.
// *
// * @param view view to which the background will be set.
// * @param drawable drawable to set as background, null to remove the current background.
// */
// public static void setBackground(@NonNull View view, @Nullable Drawable drawable) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// view.setBackground(drawable);
// } else {
// view.setBackgroundDrawable(drawable);
// }
// }
// }
// Path: CameraColorPicker/app/src/main/java/fr/tvbarthel/apps/cameracolorpicker/views/ColorDotView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import fr.tvbarthel.apps.cameracolorpicker.utils.BackgroundUtils;
package fr.tvbarthel.apps.cameracolorpicker.views;
/**
* Simple view used to render a color dot.
*/
public class ColorDotView extends View {
/**
* Simple view used to render a color dot.
*
* @param context holding context.
*/
public ColorDotView(Context context) {
this(context, null);
}
/**
* Simple view used to render a color dot.
*
* @param context holding context.
* @param attrs attr from xml.
*/
public ColorDotView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
/**
* Simple view used to render a color dot.
*
* @param context holding context.
* @param attrs attr from xml.
* @param defStyleAttr style.
*/
public ColorDotView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
int size = Math.min(width, height);
int measureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
setMeasuredDimension(measureSpec, measureSpec);
}
/**
* Initialize internal component.
*
* @param context holding context.
*/
private void initialize(Context context) {
if (!isInEditMode()) { | BackgroundUtils.setBackground(this, new ColorDotDrawable(context)); |
angusws/tcx2nikeplus | src/test/java/com/awsmithson/tcx2nikeplus/garmin/GarminDataTypeSlowTest.java | // Path: src/main/java/com/awsmithson/tcx2nikeplus/jaxb/JAXBObject.java
// public enum JAXBObject {
// GPX_TYPE {
// @Override
// @Nonnull Class[] getClassesToBeBound() {
// return new Class[] { GpxType.class, TrackPointExtensionT.class };
// }
// },
//
// TRAINING_CENTER_DATABASE {
// @Override
// @Nonnull Class[] getClassesToBeBound() {
// return new Class[] { TrainingCenterDatabaseT.class };
// }
// };
//
// abstract @Nonnull Class[] getClassesToBeBound();
//
// private final JAXBContext JAXB_CONTEXT = createJAXBContect();
// private @Nonnull JAXBContext createJAXBContect() {
// try {
// return JAXBContext.newInstance(getClassesToBeBound());
// } catch (JAXBException je) {
// throw new ExceptionInInitializerError(je);
// }
// }
//
// private final @Nonnull ThreadLocal<Marshaller> MARSHALLER = new ThreadLocal<Marshaller>() {
// protected synchronized Marshaller initialValue() {
// try {
// Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
// return marshaller;
// } catch (JAXBException e) {
// throw new ExceptionInInitializerError(e);
// }
// }
// };
//
// private final @Nonnull ThreadLocal<Unmarshaller> UNMARSHALLER = new ThreadLocal<Unmarshaller>() {
// protected synchronized Unmarshaller initialValue() {
// try {
// return JAXB_CONTEXT.createUnmarshaller();
// } catch (JAXBException e) {
// throw new ExceptionInInitializerError(e);
// }
// }
// };
//
// private @Nonnull Marshaller getMarshaller() {
// return MARSHALLER.get();
// }
//
// private @Nonnull Unmarshaller getUnmarshaller() {
// return UNMARSHALLER.get();
// }
//
// public void marshal(@Nonnull JAXBElement<?> jaxbElement, @Nonnull StringWriter stringWriter) throws JAXBException {
// Preconditions.checkNotNull(jaxbElement, "jaxbElement argument is null.");
// Preconditions.checkNotNull(stringWriter, "stringWriter argument is null.");
// getMarshaller().marshal(jaxbElement, stringWriter);
// }
//
// @Deprecated
// public void marshal(@Nonnull JAXBElement<?> jaxbElement, @Nonnull Document document) throws JAXBException {
// Preconditions.checkNotNull(jaxbElement, "jaxbElement argument is null.");
// Preconditions.checkNotNull(document, "document argument is null.");
// getMarshaller().marshal(jaxbElement, document);
// }
//
// public @Nonnull <T> T unmarshall(@Nonnull InputStream inputStream) throws JAXBException {
// Preconditions.checkNotNull(inputStream, "inputStream argument is null.");
//
// //noinspection unchecked
// return (T) getUnmarshaller().unmarshal(new StreamSource(inputStream), getClassesToBeBound()[0]).getValue();
// }
// }
| import com.awsmithson.tcx2nikeplus.jaxb.JAXBObject;
import com.garmin.xmlschemas.trainingcenterdatabase.v2.TrainingCenterDatabaseT;
import com.topografix.gpx._1._1.GpxType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.Nonnull;
import javax.xml.bind.JAXBException; | package com.awsmithson.tcx2nikeplus.garmin;
public class GarminDataTypeSlowTest {
private static final @Nonnull String ACTIVITY_148656142_TCX = "/garmin/tcx/activity_148656142.tcx";
public static final @Nonnull String ACTIVITY_148656142_GPX = "/garmin/gpx/activity_148656142.gpx";
@Test
public void testDownloadGarminTcx() throws IOException, JAXBException, URISyntaxException {
try (CloseableHttpClient closeableHttpClient = GarminDataType.getGarminHttpSession()) {
TrainingCenterDatabaseT trainingCenterDatabase = GarminDataType.TCX.downloadAndUnmarshall(closeableHttpClient, 148656142);
Assert.assertNotNull("trainingCenterDatabase was null", trainingCenterDatabase);
}
}
@Test
public void testDownloadGarminGpx() throws IOException, JAXBException, URISyntaxException {
try (CloseableHttpClient closeableHttpClient = GarminDataType.getGarminHttpSession()) {
GpxType gpxType = GarminDataType.GPX.downloadAndUnmarshall(closeableHttpClient, 148656142);
Assert.assertNotNull("gpxType was null", gpxType);
}
}
@Test
public void testUnmarshallTcx() throws IOException, JAXBException {
Assert.assertNotNull("Test file missing", getClass().getResource(ACTIVITY_148656142_TCX));
try (InputStream inputStream = getClass().getResourceAsStream(ACTIVITY_148656142_TCX)) { | // Path: src/main/java/com/awsmithson/tcx2nikeplus/jaxb/JAXBObject.java
// public enum JAXBObject {
// GPX_TYPE {
// @Override
// @Nonnull Class[] getClassesToBeBound() {
// return new Class[] { GpxType.class, TrackPointExtensionT.class };
// }
// },
//
// TRAINING_CENTER_DATABASE {
// @Override
// @Nonnull Class[] getClassesToBeBound() {
// return new Class[] { TrainingCenterDatabaseT.class };
// }
// };
//
// abstract @Nonnull Class[] getClassesToBeBound();
//
// private final JAXBContext JAXB_CONTEXT = createJAXBContect();
// private @Nonnull JAXBContext createJAXBContect() {
// try {
// return JAXBContext.newInstance(getClassesToBeBound());
// } catch (JAXBException je) {
// throw new ExceptionInInitializerError(je);
// }
// }
//
// private final @Nonnull ThreadLocal<Marshaller> MARSHALLER = new ThreadLocal<Marshaller>() {
// protected synchronized Marshaller initialValue() {
// try {
// Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
// return marshaller;
// } catch (JAXBException e) {
// throw new ExceptionInInitializerError(e);
// }
// }
// };
//
// private final @Nonnull ThreadLocal<Unmarshaller> UNMARSHALLER = new ThreadLocal<Unmarshaller>() {
// protected synchronized Unmarshaller initialValue() {
// try {
// return JAXB_CONTEXT.createUnmarshaller();
// } catch (JAXBException e) {
// throw new ExceptionInInitializerError(e);
// }
// }
// };
//
// private @Nonnull Marshaller getMarshaller() {
// return MARSHALLER.get();
// }
//
// private @Nonnull Unmarshaller getUnmarshaller() {
// return UNMARSHALLER.get();
// }
//
// public void marshal(@Nonnull JAXBElement<?> jaxbElement, @Nonnull StringWriter stringWriter) throws JAXBException {
// Preconditions.checkNotNull(jaxbElement, "jaxbElement argument is null.");
// Preconditions.checkNotNull(stringWriter, "stringWriter argument is null.");
// getMarshaller().marshal(jaxbElement, stringWriter);
// }
//
// @Deprecated
// public void marshal(@Nonnull JAXBElement<?> jaxbElement, @Nonnull Document document) throws JAXBException {
// Preconditions.checkNotNull(jaxbElement, "jaxbElement argument is null.");
// Preconditions.checkNotNull(document, "document argument is null.");
// getMarshaller().marshal(jaxbElement, document);
// }
//
// public @Nonnull <T> T unmarshall(@Nonnull InputStream inputStream) throws JAXBException {
// Preconditions.checkNotNull(inputStream, "inputStream argument is null.");
//
// //noinspection unchecked
// return (T) getUnmarshaller().unmarshal(new StreamSource(inputStream), getClassesToBeBound()[0]).getValue();
// }
// }
// Path: src/test/java/com/awsmithson/tcx2nikeplus/garmin/GarminDataTypeSlowTest.java
import com.awsmithson.tcx2nikeplus.jaxb.JAXBObject;
import com.garmin.xmlschemas.trainingcenterdatabase.v2.TrainingCenterDatabaseT;
import com.topografix.gpx._1._1.GpxType;
import org.apache.http.impl.client.CloseableHttpClient;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.Nonnull;
import javax.xml.bind.JAXBException;
package com.awsmithson.tcx2nikeplus.garmin;
public class GarminDataTypeSlowTest {
private static final @Nonnull String ACTIVITY_148656142_TCX = "/garmin/tcx/activity_148656142.tcx";
public static final @Nonnull String ACTIVITY_148656142_GPX = "/garmin/gpx/activity_148656142.gpx";
@Test
public void testDownloadGarminTcx() throws IOException, JAXBException, URISyntaxException {
try (CloseableHttpClient closeableHttpClient = GarminDataType.getGarminHttpSession()) {
TrainingCenterDatabaseT trainingCenterDatabase = GarminDataType.TCX.downloadAndUnmarshall(closeableHttpClient, 148656142);
Assert.assertNotNull("trainingCenterDatabase was null", trainingCenterDatabase);
}
}
@Test
public void testDownloadGarminGpx() throws IOException, JAXBException, URISyntaxException {
try (CloseableHttpClient closeableHttpClient = GarminDataType.getGarminHttpSession()) {
GpxType gpxType = GarminDataType.GPX.downloadAndUnmarshall(closeableHttpClient, 148656142);
Assert.assertNotNull("gpxType was null", gpxType);
}
}
@Test
public void testUnmarshallTcx() throws IOException, JAXBException {
Assert.assertNotNull("Test file missing", getClass().getResource(ACTIVITY_148656142_TCX));
try (InputStream inputStream = getClass().getResourceAsStream(ACTIVITY_148656142_TCX)) { | TrainingCenterDatabaseT trainingCenterDatabase = JAXBObject.TRAINING_CENTER_DATABASE.unmarshall(inputStream); |
angusws/tcx2nikeplus | src/main/java/com/awsmithson/tcx2nikeplus/servlet/ConvertServlet.java | // Path: src/main/java/com/awsmithson/tcx2nikeplus/util/Log.java
// public class Log {
// private static Log _context;
// private static Logger _log;
//
// private static final @Nonnull Predicate<StackTraceElement> CALLER_PREDICATE = new Predicate<StackTraceElement>() {
// @Override
// public boolean apply(@Nullable StackTraceElement element) {;
// return element != null && !(element.getClassName().equals(Thread.class.getName()) || element.getClassName().equals(Log.class.getName()));
// }
// };
//
// private Log() {
// _log = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
// }
//
// public static synchronized Log getInstance() {
// if (_context == null)
// _context = new Log();
//
// return _context;
// }
//
// public void out(Object message) {
// out(Level.INFO, null, message.toString(), (Object[])null);
// }
//
// public void out(String message, Object ... args) {
// out(Level.INFO, null, message, args);
// }
//
// public void out(Level level, Object message) {
// out(level, null, message.toString(), (Object[])null);
// }
//
// public void out(Level level, String message, Object ... args) {
// out(level, null, message, args);
// }
//
// public void out(Throwable throwable) {
// out(Level.SEVERE, throwable, "", (Object[])null);
// }
//
// public void out(Level level, Throwable throwable, Object message) {
// out(level, throwable, message.toString(), (Object[])null);
// }
//
// public void out(Level level, Throwable throwable, String message, Object ... args) {
// if (_log.isLoggable(level)) {
// if (args != null) {
// message = String.format(message, args);
// }
//
// // Get the caller class and method name (this is a *disgusting* hack which I've been forced into because I've
// // mis-used java.util.logging. Maybe I'll fix this one day, but it's not important for now.
// StackTraceElement caller = Iterables.find(Arrays.asList(Thread.currentThread().getStackTrace()), CALLER_PREDICATE);
// _log.logp(level, caller.getClassName(), caller.getMethodName(), message, throwable);
// }
// }
// }
| import com.awsmithson.tcx2nikeplus.util.Log;
import com.google.common.base.Preconditions;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | package com.awsmithson.tcx2nikeplus.servlet;
@MultipartConfig(
location="/tmp",
maxFileSize=1024*1024*8, // 8MB
maxRequestSize=1024*1024*20 // 20MB
)
public class ConvertServlet extends HttpServlet {
| // Path: src/main/java/com/awsmithson/tcx2nikeplus/util/Log.java
// public class Log {
// private static Log _context;
// private static Logger _log;
//
// private static final @Nonnull Predicate<StackTraceElement> CALLER_PREDICATE = new Predicate<StackTraceElement>() {
// @Override
// public boolean apply(@Nullable StackTraceElement element) {;
// return element != null && !(element.getClassName().equals(Thread.class.getName()) || element.getClassName().equals(Log.class.getName()));
// }
// };
//
// private Log() {
// _log = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
// }
//
// public static synchronized Log getInstance() {
// if (_context == null)
// _context = new Log();
//
// return _context;
// }
//
// public void out(Object message) {
// out(Level.INFO, null, message.toString(), (Object[])null);
// }
//
// public void out(String message, Object ... args) {
// out(Level.INFO, null, message, args);
// }
//
// public void out(Level level, Object message) {
// out(level, null, message.toString(), (Object[])null);
// }
//
// public void out(Level level, String message, Object ... args) {
// out(level, null, message, args);
// }
//
// public void out(Throwable throwable) {
// out(Level.SEVERE, throwable, "", (Object[])null);
// }
//
// public void out(Level level, Throwable throwable, Object message) {
// out(level, throwable, message.toString(), (Object[])null);
// }
//
// public void out(Level level, Throwable throwable, String message, Object ... args) {
// if (_log.isLoggable(level)) {
// if (args != null) {
// message = String.format(message, args);
// }
//
// // Get the caller class and method name (this is a *disgusting* hack which I've been forced into because I've
// // mis-used java.util.logging. Maybe I'll fix this one day, but it's not important for now.
// StackTraceElement caller = Iterables.find(Arrays.asList(Thread.currentThread().getStackTrace()), CALLER_PREDICATE);
// _log.logp(level, caller.getClassName(), caller.getMethodName(), message, throwable);
// }
// }
// }
// Path: src/main/java/com/awsmithson/tcx2nikeplus/servlet/ConvertServlet.java
import com.awsmithson.tcx2nikeplus.util.Log;
import com.google.common.base.Preconditions;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
package com.awsmithson.tcx2nikeplus.servlet;
@MultipartConfig(
location="/tmp",
maxFileSize=1024*1024*8, // 8MB
maxRequestSize=1024*1024*20 // 20MB
)
public class ConvertServlet extends HttpServlet {
| private static final Log log = Log.getInstance(); |
salk31/RedQueryBuilder | redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/SuggestEditorWidget.java | // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
//
// private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
// @Override
// public String quote(String id) {
// return "\"" + id + "\"";
// }
// };
//
// public void setIdentifierEscaper(IdentifierEscaper p) {
// identifierEscaper = p;
// }
//
// /**
// * Add double quotes around an identifier if required.
// *
// * @param s the identifier
// * @return the quoted identifier
// */
// public static String quoteIdentifier(String s) {
// return identifierEscaper.quote(s);
// }
//
// // XXX need commandBuilder and select?
// private CommandBuilder commandBuilder;
//
// private Select select;
//
// private Configuration config;
//
// private final ValueRegistry valueRegistry = new ValueRegistry();
//
// private final Database database;
//
// private final HandlerManager msgbus;
//
//
// // XXX 00 remove one of these constructors
// public Session(Configuration config2) {
// this(config2.getDatabase());
// this.config = config2;
// }
//
// @Deprecated
// public Session(Database database2) {
// database = database2;
// msgbus = new HandlerManager(this);
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public CommandBuilder getCommandBuilder() {
// return commandBuilder;
// }
//
// public void setCommandBuilder(CommandBuilder p) {
// commandBuilder = p;
// }
//
// public Database getDatabase() {
// return database;
// }
//
//
// public HandlerManager getMsgBus() {
// return msgbus;
// }
//
//
//
// public void setSelect(Select p) {
// select = p;
// }
//
// public Column resolveColumn(String alias, String columnName) {
// return select.resolveColumn(alias, columnName);
// }
//
// public ObjectArray<TableFilter> getFilters() {
// return select.getFilters();
// }
//
// public TableFilter getTableFilter(Table t) {
// for (TableFilter tf : select.getFilters()) {
// if (tf.getTable().equals(t)) {
// return tf;
// }
// }
// return null;
// }
//
// public TableFilter createTableFilter(Table t) {
// TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
// select.addTableFilter(tf, true); // XXX really is true?
// return tf;
// }
//
// public TableFilter getOrCreateTableFilter(Table t) {
// TableFilter tf = getTableFilter(t);
// if (tf == null) {
// tf = createTableFilter(t);
// }
// return tf;
// }
//
// //public Table getTable(String alias) {
// // return select.getTable(alias);
// //}
//
// public Table getRootTable() {
// // XXX maybe if no table then grab default?
// // or should select always have one table?
// // or ui shouldn't offer condition button till table?
// return select.getFilters().get(0).getTable();
// }
//
// public ValueRegistry getValueRegistry() {
// return valueRegistry;
// }
// }
| import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.redspr.redquerybuilder.core.client.engine.Session;
import com.redspr.redquerybuilder.core.shared.meta.Column;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest; |
@Override
public void onSuccess(Response result) {
callback.onSuggestionsReady(request, result);
}
});
}
@Override
public void requestSuggestions(final Request request,
final Callback callback) {
SuggestRequest sr = create(request);
session.getConfig().fireSuggest(sr, new AsyncCallback<Response>() {
@Override
public void onFailure(Throwable caught) {
// XXX
}
@Override
public void onSuccess(Response result) {
callback.onSuggestionsReady(request, result);
}
});
}
}
private final String tableName;
private final String columnName;
private final String columnType; | // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
//
// private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
// @Override
// public String quote(String id) {
// return "\"" + id + "\"";
// }
// };
//
// public void setIdentifierEscaper(IdentifierEscaper p) {
// identifierEscaper = p;
// }
//
// /**
// * Add double quotes around an identifier if required.
// *
// * @param s the identifier
// * @return the quoted identifier
// */
// public static String quoteIdentifier(String s) {
// return identifierEscaper.quote(s);
// }
//
// // XXX need commandBuilder and select?
// private CommandBuilder commandBuilder;
//
// private Select select;
//
// private Configuration config;
//
// private final ValueRegistry valueRegistry = new ValueRegistry();
//
// private final Database database;
//
// private final HandlerManager msgbus;
//
//
// // XXX 00 remove one of these constructors
// public Session(Configuration config2) {
// this(config2.getDatabase());
// this.config = config2;
// }
//
// @Deprecated
// public Session(Database database2) {
// database = database2;
// msgbus = new HandlerManager(this);
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public CommandBuilder getCommandBuilder() {
// return commandBuilder;
// }
//
// public void setCommandBuilder(CommandBuilder p) {
// commandBuilder = p;
// }
//
// public Database getDatabase() {
// return database;
// }
//
//
// public HandlerManager getMsgBus() {
// return msgbus;
// }
//
//
//
// public void setSelect(Select p) {
// select = p;
// }
//
// public Column resolveColumn(String alias, String columnName) {
// return select.resolveColumn(alias, columnName);
// }
//
// public ObjectArray<TableFilter> getFilters() {
// return select.getFilters();
// }
//
// public TableFilter getTableFilter(Table t) {
// for (TableFilter tf : select.getFilters()) {
// if (tf.getTable().equals(t)) {
// return tf;
// }
// }
// return null;
// }
//
// public TableFilter createTableFilter(Table t) {
// TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
// select.addTableFilter(tf, true); // XXX really is true?
// return tf;
// }
//
// public TableFilter getOrCreateTableFilter(Table t) {
// TableFilter tf = getTableFilter(t);
// if (tf == null) {
// tf = createTableFilter(t);
// }
// return tf;
// }
//
// //public Table getTable(String alias) {
// // return select.getTable(alias);
// //}
//
// public Table getRootTable() {
// // XXX maybe if no table then grab default?
// // or should select always have one table?
// // or ui shouldn't offer condition button till table?
// return select.getFilters().get(0).getTable();
// }
//
// public ValueRegistry getValueRegistry() {
// return valueRegistry;
// }
// }
// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/SuggestEditorWidget.java
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay;
import com.google.gwt.user.client.ui.SuggestOracle;
import com.redspr.redquerybuilder.core.client.engine.Session;
import com.redspr.redquerybuilder.core.shared.meta.Column;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest;
@Override
public void onSuccess(Response result) {
callback.onSuggestionsReady(request, result);
}
});
}
@Override
public void requestSuggestions(final Request request,
final Callback callback) {
SuggestRequest sr = create(request);
session.getConfig().fireSuggest(sr, new AsyncCallback<Response>() {
@Override
public void onFailure(Throwable caught) {
// XXX
}
@Override
public void onSuccess(Response result) {
callback.onSuggestionsReady(request, result);
}
});
}
}
private final String tableName;
private final String columnName;
private final String columnType; | private final Session session; |
salk31/RedQueryBuilder | redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/Configuration.java | // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/shared/meta/EnumerateRequest.java
// public class EnumerateRequest {
// private String tableName;
//
// private String columnName;
//
// private String columnType;
//
// public String getTableName() {
// return tableName;
// }
//
// public void setTableName(String p) {
// this.tableName = p;
// }
//
// public String getColumnName() {
// return columnName;
// }
//
// public void setColumnName(String p) {
// this.columnName = p;
// }
//
// public String getColumnTypeName() {
// return columnType;
// }
//
// public void setColumnTypeName(String p) {
// this.columnType = p;
// }
//
// }
| import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.SuggestOracle.Response;
import com.redspr.redquerybuilder.core.client.table.TableFilter;
import com.redspr.redquerybuilder.core.client.util.ObjectArray;
import com.redspr.redquerybuilder.core.shared.meta.Database;
import com.redspr.redquerybuilder.core.shared.meta.EnumerateRequest;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest; | package com.redspr.redquerybuilder.core.client;
/**
* Extend this class to integrate with RedQueryBuilder.
*/
public class Configuration {
private Database database = new Database();
private final From from = new From();
| // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/shared/meta/EnumerateRequest.java
// public class EnumerateRequest {
// private String tableName;
//
// private String columnName;
//
// private String columnType;
//
// public String getTableName() {
// return tableName;
// }
//
// public void setTableName(String p) {
// this.tableName = p;
// }
//
// public String getColumnName() {
// return columnName;
// }
//
// public void setColumnName(String p) {
// this.columnName = p;
// }
//
// public String getColumnTypeName() {
// return columnType;
// }
//
// public void setColumnTypeName(String p) {
// this.columnType = p;
// }
//
// }
// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/Configuration.java
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.SuggestOracle.Response;
import com.redspr.redquerybuilder.core.client.table.TableFilter;
import com.redspr.redquerybuilder.core.client.util.ObjectArray;
import com.redspr.redquerybuilder.core.shared.meta.Database;
import com.redspr.redquerybuilder.core.shared.meta.EnumerateRequest;
import com.redspr.redquerybuilder.core.shared.meta.SuggestRequest;
package com.redspr.redquerybuilder.core.client;
/**
* Extend this class to integrate with RedQueryBuilder.
*/
public class Configuration {
private Database database = new Database();
private final From from = new From();
| public void fireEnumerate(EnumerateRequest request, AsyncCallback<Response> callback) { |
salk31/RedQueryBuilder | redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/command/Message.java | // Path: redquerybuilder-core/src/main/java/java/sql/SQLException.java
// public class SQLException extends Exception {
// public SQLException(String m) {
// super(m);
// }
//
// public SQLException(String m, Throwable t) {
// super(m, t);
// }
//
//
// public int getErrorCode() {
// return 0;
// }
// }
| import java.sql.SQLException; | /*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*
* Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888
* Support for the operator "&&" as an alias for SPATIAL_INTERSECTS
*/
package com.redspr.redquerybuilder.core.client.command;
public final class Message {
private Message() {
}
| // Path: redquerybuilder-core/src/main/java/java/sql/SQLException.java
// public class SQLException extends Exception {
// public SQLException(String m) {
// super(m);
// }
//
// public SQLException(String m, Throwable t) {
// super(m, t);
// }
//
//
// public int getErrorCode() {
// return 0;
// }
// }
// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/command/Message.java
import java.sql.SQLException;
/*
* Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*
* Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888
* Support for the operator "&&" as an alias for SPATIAL_INTERSECTS
*/
package com.redspr.redquerybuilder.core.client.command;
public final class Message {
private Message() {
}
| public static SQLException addSQL(Exception e, String sql) { |
salk31/RedQueryBuilder | redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/Wildcard.java | // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
//
// private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
// @Override
// public String quote(String id) {
// return "\"" + id + "\"";
// }
// };
//
// public void setIdentifierEscaper(IdentifierEscaper p) {
// identifierEscaper = p;
// }
//
// /**
// * Add double quotes around an identifier if required.
// *
// * @param s the identifier
// * @return the quoted identifier
// */
// public static String quoteIdentifier(String s) {
// return identifierEscaper.quote(s);
// }
//
// // XXX need commandBuilder and select?
// private CommandBuilder commandBuilder;
//
// private Select select;
//
// private Configuration config;
//
// private final ValueRegistry valueRegistry = new ValueRegistry();
//
// private final Database database;
//
// private final HandlerManager msgbus;
//
//
// // XXX 00 remove one of these constructors
// public Session(Configuration config2) {
// this(config2.getDatabase());
// this.config = config2;
// }
//
// @Deprecated
// public Session(Database database2) {
// database = database2;
// msgbus = new HandlerManager(this);
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public CommandBuilder getCommandBuilder() {
// return commandBuilder;
// }
//
// public void setCommandBuilder(CommandBuilder p) {
// commandBuilder = p;
// }
//
// public Database getDatabase() {
// return database;
// }
//
//
// public HandlerManager getMsgBus() {
// return msgbus;
// }
//
//
//
// public void setSelect(Select p) {
// select = p;
// }
//
// public Column resolveColumn(String alias, String columnName) {
// return select.resolveColumn(alias, columnName);
// }
//
// public ObjectArray<TableFilter> getFilters() {
// return select.getFilters();
// }
//
// public TableFilter getTableFilter(Table t) {
// for (TableFilter tf : select.getFilters()) {
// if (tf.getTable().equals(t)) {
// return tf;
// }
// }
// return null;
// }
//
// public TableFilter createTableFilter(Table t) {
// TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
// select.addTableFilter(tf, true); // XXX really is true?
// return tf;
// }
//
// public TableFilter getOrCreateTableFilter(Table t) {
// TableFilter tf = getTableFilter(t);
// if (tf == null) {
// tf = createTableFilter(t);
// }
// return tf;
// }
//
// //public Table getTable(String alias) {
// // return select.getTable(alias);
// //}
//
// public Table getRootTable() {
// // XXX maybe if no table then grab default?
// // or should select always have one table?
// // or ui shouldn't offer condition button till table?
// return select.getFilters().get(0).getTable();
// }
//
// public ValueRegistry getValueRegistry() {
// return valueRegistry;
// }
// }
| import java.util.List;
import com.redspr.redquerybuilder.core.client.engine.Session; | package com.redspr.redquerybuilder.core.client.expression;
public class Wildcard extends Expression {
private final String table;
| // Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/engine/Session.java
// public class Session {
//
// private static IdentifierEscaper identifierEscaper = new IdentifierEscaper() {
// @Override
// public String quote(String id) {
// return "\"" + id + "\"";
// }
// };
//
// public void setIdentifierEscaper(IdentifierEscaper p) {
// identifierEscaper = p;
// }
//
// /**
// * Add double quotes around an identifier if required.
// *
// * @param s the identifier
// * @return the quoted identifier
// */
// public static String quoteIdentifier(String s) {
// return identifierEscaper.quote(s);
// }
//
// // XXX need commandBuilder and select?
// private CommandBuilder commandBuilder;
//
// private Select select;
//
// private Configuration config;
//
// private final ValueRegistry valueRegistry = new ValueRegistry();
//
// private final Database database;
//
// private final HandlerManager msgbus;
//
//
// // XXX 00 remove one of these constructors
// public Session(Configuration config2) {
// this(config2.getDatabase());
// this.config = config2;
// }
//
// @Deprecated
// public Session(Database database2) {
// database = database2;
// msgbus = new HandlerManager(this);
// }
//
// public Configuration getConfig() {
// return config;
// }
//
// public CommandBuilder getCommandBuilder() {
// return commandBuilder;
// }
//
// public void setCommandBuilder(CommandBuilder p) {
// commandBuilder = p;
// }
//
// public Database getDatabase() {
// return database;
// }
//
//
// public HandlerManager getMsgBus() {
// return msgbus;
// }
//
//
//
// public void setSelect(Select p) {
// select = p;
// }
//
// public Column resolveColumn(String alias, String columnName) {
// return select.resolveColumn(alias, columnName);
// }
//
// public ObjectArray<TableFilter> getFilters() {
// return select.getFilters();
// }
//
// public TableFilter getTableFilter(Table t) {
// for (TableFilter tf : select.getFilters()) {
// if (tf.getTable().equals(t)) {
// return tf;
// }
// }
// return null;
// }
//
// public TableFilter createTableFilter(Table t) {
// TableFilter tf = new TableFilter(this, t, TableFilter.newAlias(), select);
// select.addTableFilter(tf, true); // XXX really is true?
// return tf;
// }
//
// public TableFilter getOrCreateTableFilter(Table t) {
// TableFilter tf = getTableFilter(t);
// if (tf == null) {
// tf = createTableFilter(t);
// }
// return tf;
// }
//
// //public Table getTable(String alias) {
// // return select.getTable(alias);
// //}
//
// public Table getRootTable() {
// // XXX maybe if no table then grab default?
// // or should select always have one table?
// // or ui shouldn't offer condition button till table?
// return select.getFilters().get(0).getTable();
// }
//
// public ValueRegistry getValueRegistry() {
// return valueRegistry;
// }
// }
// Path: redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/Wildcard.java
import java.util.List;
import com.redspr.redquerybuilder.core.client.engine.Session;
package com.redspr.redquerybuilder.core.client.expression;
public class Wildcard extends Expression {
private final String table;
| public Wildcard(Session session, String schema, String table) { |
salk31/RedQueryBuilder | redquerybuilder-js/src/main/java/com/redspr/redquerybuilder/js/client/JsConfiguration.java | // Path: redquerybuilder-js/src/main/java/com/redspr/redquerybuilder/js/client/conf/JsFrom.java
// public class JsFrom extends JavaScriptObject {
// protected JsFrom() {
// }
//
// public final native boolean isVisible() /*-{ return this.visible; }-*/;
// }
| import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayMixed;
import com.redspr.redquerybuilder.core.client.table.TableFilter;
import com.redspr.redquerybuilder.core.client.util.ObjectArray;
import com.redspr.redquerybuilder.js.client.conf.JsFrom; | this.defaultSuggest(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}
}-*/;
public final native void fireSuggest(String tableName, String columnName, String columnTypeName, String query,
int limit, JsCallback jsCallback) /*-{
var arg = {tableName: tableName,
columnName: columnName,
columnTypeName : columnTypeName,
query: query,
limit:limit};
this.suggest(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}-*/;
public final native void fireEnumerate(String tableName, String columnName, String columnTypeName,
JsCallback jsCallback) /*-{
if (this.enumerate) {
var arg = {tableName: tableName,
columnName: columnName,
columnTypeName : columnTypeName};
this.enumerate(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}
}-*/;
| // Path: redquerybuilder-js/src/main/java/com/redspr/redquerybuilder/js/client/conf/JsFrom.java
// public class JsFrom extends JavaScriptObject {
// protected JsFrom() {
// }
//
// public final native boolean isVisible() /*-{ return this.visible; }-*/;
// }
// Path: redquerybuilder-js/src/main/java/com/redspr/redquerybuilder/js/client/JsConfiguration.java
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayMixed;
import com.redspr.redquerybuilder.core.client.table.TableFilter;
import com.redspr.redquerybuilder.core.client.util.ObjectArray;
import com.redspr.redquerybuilder.js.client.conf.JsFrom;
this.defaultSuggest(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}
}-*/;
public final native void fireSuggest(String tableName, String columnName, String columnTypeName, String query,
int limit, JsCallback jsCallback) /*-{
var arg = {tableName: tableName,
columnName: columnName,
columnTypeName : columnTypeName,
query: query,
limit:limit};
this.suggest(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}-*/;
public final native void fireEnumerate(String tableName, String columnName, String columnTypeName,
JsCallback jsCallback) /*-{
if (this.enumerate) {
var arg = {tableName: tableName,
columnName: columnName,
columnTypeName : columnTypeName};
this.enumerate(arg, function response(s) {
jsCallback.@com.redspr.redquerybuilder.js.client.JsCallback::response(Lcom/google/gwt/core/client/JavaScriptObject;)(s);
});
}
}-*/;
| public final native JsFrom getFrom() /*-{ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.