本文整理匯總了Java中es.uniovi.asw.dbManagement.model.Voter類的典型用法代碼示例。如果您正苦於以下問題:Java Voter類的具體用法?Java Voter怎麽用?Java Voter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Voter類屬於es.uniovi.asw.dbManagement.model包,在下文中一共展示了Voter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@Bean
public CommandLineRunner init(VoterRepository repository)
{
return (args) ->
{
// save a voter
repository.save(new Voter("Jack", "980151", "[email protected]", 1, "1"));
repository.save(new Voter("Jose", "730438", "[email protected]", 1, "2"));
repository.save(new Voter("Paula", "210953", "[email protected]", 1, "3"));
repository.save(new Voter("Alfonso", "455846", "[email protected]", 1, "4"));
repository.save(new Voter("Irene", "565861", "[email protected]", 2, "1"));
repository.save(new Voter("Fernando", "564512", "[email protected]", 3, "2"));
repository.save(new Voter("Vinuesa", "514685", "[email protected]", 3, "3"));
repository.save(new Voter("Sotorrío", "314896", "[email protected]", 3, "4"));
repository.save(new Voter("Hugo", "214848", "[email protected]", 4, "5"));
repository.save(new Voter("Diana", "197235", "[email protected]", 4, "6"));
repository.save(new Voter("Javier", "156585", "[email protected]", 4, "7"));
repository.save(new Voter("Luis", "126945", "luisValdé[email protected]", 4, "8"));
};
}
示例2: changePassword
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value="/changePassword",
method=RequestMethod.POST,
headers = "Accept=application/json",
produces="application/json")
public String changePassword(@RequestBody ChangePasswordResponse data)
{
log.info("Password: " + data.getPassword() + " New Password: " + data.getNewPassword());
if(data.getEmail().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_EMAIL);
if(data.getPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_PASSWORD);
if(data.getNewPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_NEW_PASSWORD);
Voter voter = Repository.voterR.findByEmail(data.getEmail());
if (voter != null)
{
if(changePassword(data.getPassword(),data.getNewPassword(), voter))
{
return "{\"Resultado\":\"Contraseña cambiada correctamente\"}";
}
else { throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.INCORRECT_PASSWORD); }
}
else // Voter no encontrado
{
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND);
}
}
示例3: userHTMLpost
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value = "/validarse", method = RequestMethod.POST)
public String userHTMLpost(@RequestBody String parametros, Model model)
{
String[] parametro = parametros.split("&");
if(parametro[0].split("=").length<=1)
throw ErrorFactory.getErrorResponse(Errors.REQUIRED_EMAIL);
if(parametro[1].split("=").length<=1)
throw ErrorFactory.getErrorResponse(Errors.REQUIRED_PASSWORD);
String email = parametro[0].split("=")[1].replace("%40", "@");
String contraseña = parametro[1].split("=")[1];
Voter voter = Repository.voterR.findByEmail(email);
if (voter != null)
{
if(voter.getPassword().compareTo(contraseña) == 0)
{
model.addAttribute("email", voter.getEmail());
model.addAttribute("name", voter.getName());
model.addAttribute("nif", voter.getNif());
model.addAttribute("polling", voter.getPollingPlace().getId());
}
else { throw ErrorFactory.getErrorResponse(Errors.INCORRECT_PASSWORD); }
}
else { throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND); }
return "result";
}
示例4: VoterInfoResponse
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
public VoterInfoResponse(Voter voter)
{
super();
setEmail(voter.getEmail());
setName(voter.getName());
setNif(voter.getNif());
setPoolingState(voter.getPollingPlace().getId());
}
示例5: getInfoVoter
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value="/user",
method= RequestMethod.POST,
headers ="Accept=application/json",
produces={"application/json","application/xml"})
public VoterInfoResponse getInfoVoter(@RequestBody Voter voter)
{
log.info("Datos peticion: "+voter.getEmail()+" "+voter.getPassword());
if(voter.getEmail().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_EMAIL);
else if(voter.getPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_PASSWORD);
Voter votr = Repository.voterR.findByEmail(voter.getEmail());
if(votr == null)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND);
else if(votr.getPassword().compareTo(voter.getPassword()) == 0)
return new VoterInfoResponse(votr);
else
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.INCORRECT_PASSWORD);
}
示例6: changePassword
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@Override
public boolean changePassword(String password, String newPassword,Voter voter) {
if (password.compareTo(voter.getPassword()) == 0)
{
voter.setPassword(newPassword);
this.voterRepository.save(voter);
return true;
}
return false;
}
示例7: changePassword
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value="/changePassword",
method=RequestMethod.POST,
headers = "Accept=application/json",
produces="application/json")
public String changePassword(@RequestBody ChangePasswordResponse data)
{
log.info("Password: " + data.getPassword() + " New Password: " + data.getNewPassword());
if(data.getEmail().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_EMAIL);
if(data.getPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_PASSWORD);
if(data.getNewPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_NEW_PASSWORD);
UpdatePassword cp = new UpdatePasswordDB(this.voterRepository);
GetVoter gv = new GetVoterDB(this.voterRepository);
Voter voter = gv.getVoter(data.getEmail());
if (voter != null)
{
if(cp.changePassword(data.getPassword(),data.getNewPassword(), voter))
{
return "{\"Resultado\":\"Contraseña cambiada correctamente\"}";
}
else { throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.INCORRECT_PASSWORD); }
}
else // Voter no encontrado
{
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND);
}
}
示例8: userHTMLpost
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value = "/validarse", method = RequestMethod.POST)
public String userHTMLpost(@RequestBody String parametros, Model model)
{
String[] parametro = parametros.split("&");
if(parametro[0].split("=").length<=1)
throw ErrorFactory.getErrorResponse(Errors.REQUIRED_EMAIL);
if(parametro[1].split("=").length<=1)
throw ErrorFactory.getErrorResponse(Errors.REQUIRED_PASSWORD);
String email = parametro[0].split("=")[1].replace("%40", "@");
String contraseña = parametro[1].split("=")[1];
GetVoter gv = new GetVoterDB(this.voterRepository);
Voter user = gv.getVoter(email);
if (user != null)
{
if(user.getPassword().compareTo(contraseña) == 0)
{
model.addAttribute("email", user.getEmail());
model.addAttribute("name", user.getName());
model.addAttribute("nif", user.getNIF());
model.addAttribute("polling", user.getPollingPlace());
}
else { throw ErrorFactory.getErrorResponse(Errors.INCORRECT_PASSWORD); }
}
else { throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND); }
return "result";
}
示例9: VoterInfoResponse
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
public VoterInfoResponse(Voter voter)
{
super();
setEmail(voter.getEmail());
setName(voter.getName());
setNif(voter.getNIF());
setPoolingState(voter.getPollingPlace());
}
示例10: getInfoVoter
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@RequestMapping(value="/user",
method= RequestMethod.POST,
headers ="Accept=application/json",
produces={"application/json","application/xml"})
public VoterInfoResponse getInfoVoter(@RequestBody Voter voter)
{
log.info("Datos peticion: "+voter.getEmail()+" "+voter.getPassword());
if(voter.getEmail().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_EMAIL);
else if(voter.getPassword().compareTo("")==0)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.REQUIRED_PASSWORD);
GetVoter gv = new GetVoterDB(this.voterRepository);
Voter user = gv.getVoter(voter.getEmail());
if(user == null)
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.USER_NOT_FOUND);
else if(user.getPassword().compareTo(voter.getPassword()) == 0)
return new VoterInfoResponse(user);
else
throw ErrorFactory.getErrorResponse(ErrorFactory.Errors.INCORRECT_PASSWORD);
}
示例11: main
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
PollingPlace col1= Repository.pollingPlaceR.findOne(1L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(1L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Jack", "980151", "[email protected]", col1, "1"));
Repository.voterR.save(new Voter("Jose", "730438", "[email protected]", col1, "2"));
Repository.voterR.save(new Voter("Paula", "210953", "[email protected]", col1, "3"));
Repository.voterR.save(new Voter("Alfonso", "455846", "[email protected]", col1, "4"));
col1= Repository.pollingPlaceR.findOne(2L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(2L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Irene", "565861", "[email protected]", col1, "1"));
col1= Repository.pollingPlaceR.findOne(3L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(3L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Fernando", "564512", "[email protected]", col1, "2"));
Repository.voterR.save(new Voter("Vinuesa", "514685", "[email protected]", col1, "3"));
Repository.voterR.save(new Voter("Sotorrío", "314896", "[email protected]", col1, "4"));
col1= Repository.pollingPlaceR.findOne(4L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(4L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Hugo", "214848", "[email protected]", col1, "5"));
Repository.voterR.save(new Voter("Diana", "197235", "[email protected]", col1, "6"));
Repository.voterR.save(new Voter("Javier", "156585", "[email protected]", col1, "7"));
Repository.voterR.save(new Voter("Luis", "126945", "luisValdé[email protected]", col1, "8"));
}
示例12: setUp
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@Before
public void setUp() throws Exception
{
this.base = new URL("http://localhost:" + port + "/");
template = new TestRestTemplate();
if (first) {
first = false;
System.out.println("Entro");
PollingPlace col1= Repository.pollingPlaceR.findOne(1L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(1L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Jack", "980151", "[email protected]", col1, "1"));
Repository.voterR.save(new Voter("Jose", "730438", "[email protected]", col1, "2"));
Repository.voterR.save(new Voter("Paula", "210953", "[email protected]", col1, "3"));
Repository.voterR.save(new Voter("Alfonso", "455846", "[email protected]", col1, "4"));
col1= Repository.pollingPlaceR.findOne(2L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(2L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Irene", "565861", "[email protected]", col1, "1"));
col1= Repository.pollingPlaceR.findOne(3L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(3L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Fernando", "564512", "[email protected]", col1, "2"));
Repository.voterR.save(new Voter("Vinuesa", "514685", "[email protected]", col1, "3"));
Repository.voterR.save(new Voter("Sotorrío", "314896", "[email protected]", col1, "4"));
col1= Repository.pollingPlaceR.findOne(4L);
if (col1 == null) {
col1 = new PollingPlace();
col1.setId(4L);
}
Repository.pollingPlaceR.save(col1);
Repository.voterR.save(new Voter("Hugo", "214848", "[email protected]", col1, "5"));
Repository.voterR.save(new Voter("Diana", "197235", "[email protected]", col1, "6"));
Repository.voterR.save(new Voter("Javier", "156585", "[email protected]", col1, "7"));
Repository.voterR.save(new Voter("Luis", "126945", "luisValdé[email protected]", col1, "8"));
}
}
示例13: merge
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@Override
public void merge(Turnout turnout) {
turnout.setElection(entityManager.find(Election.class, turnout.getElection().getId()));
turnout.setVoter(entityManager.find(Voter.class, turnout.getVoter().getId()));
entityManager.persist(turnout);
}
示例14: getVoter
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
@Override
public Voter getVoter(String email) {
return this.voterRepository.findByEmail(email);
}
示例15: findByEmailAndPassword
import es.uniovi.asw.dbManagement.model.Voter; //導入依賴的package包/類
Voter findByEmailAndPassword(String email, String password);