Bladeren bron

finished everything but voting count algorithm

NedRedmond 6 jaren geleden
bovenliggende
commit
6047752d67
18 gewijzigde bestanden met toevoegingen van 621 en 0 verwijderingen
  1. 8
    0
      pom.xml
  2. 76
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java
  3. 44
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java
  4. 31
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java
  5. 50
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java
  6. 32
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java
  7. 36
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/ComputeResultController.java
  8. 22
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/OptionCount.java
  9. 24
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dtos/VoteResult.java
  10. 62
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/error/ErrorDetail.java
  11. 23
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/error/ValidationError.java
  12. 20
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java
  13. 57
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/exception/RestExceptionHandler.java
  14. 10
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java
  15. 11
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java
  16. 22
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java
  17. 91
    0
      src/main/resources/import.sql
  18. 2
    0
      src/main/resources/messages.properties

+ 8
- 0
pom.xml Bestand weergeven

@@ -43,6 +43,14 @@
43 43
             <artifactId>javax.inject</artifactId>
44 44
             <version>1</version>
45 45
         </dependency>
46
+
47
+        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
48
+        <dependency>
49
+            <groupId>com.google.guava</groupId>
50
+            <artifactId>guava</artifactId>
51
+            <version>19.0</version>
52
+        </dependency>
53
+
46 54
     </dependencies>
47 55
 
48 56
 

+ 76
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Bestand weergeven

@@ -0,0 +1,76 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
5
+import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.data.domain.Page;
8
+import org.springframework.data.domain.PageRequest;
9
+import org.springframework.data.domain.Pageable;
10
+import org.springframework.http.HttpHeaders;
11
+import org.springframework.http.HttpStatus;
12
+import org.springframework.http.ResponseEntity;
13
+import org.springframework.web.bind.annotation.*;
14
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
15
+
16
+import javax.validation.Valid;
17
+import java.net.URI;
18
+import java.util.Iterator;
19
+
20
+@RestController
21
+public class PollController {
22
+
23
+    PollRepository pollRepository;
24
+
25
+    @Autowired
26
+    public PollController(PollRepository pollRepository) {
27
+        this.pollRepository = pollRepository;
28
+    }
29
+
30
+    @RequestMapping(value="/polls", method= RequestMethod.GET)
31
+    public ResponseEntity<Page<Poll>> getAllPolls(Pageable pageable) {
32
+        Page<Poll> allPolls = pollRepository.findAll(pageable);
33
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
34
+    }
35
+
36
+    @RequestMapping(value="/polls", method=RequestMethod.POST)
37
+    public ResponseEntity<?> createPoll(@Valid @RequestBody Poll poll) {
38
+        poll = pollRepository.save(poll);
39
+        final URI newPollUri = ServletUriComponentsBuilder
40
+                .fromCurrentRequest()
41
+                .path("/{id}")
42
+                .buildAndExpand(poll.getId())
43
+                .toUri();
44
+        final HttpHeaders headers = new HttpHeaders();
45
+        headers.setLocation(newPollUri);
46
+        return new ResponseEntity<>(headers, HttpStatus.CREATED);
47
+    }
48
+
49
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.GET)
50
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
51
+        verifyPoll(pollId);
52
+        Poll p = pollRepository.findOne(pollId);
53
+        return new ResponseEntity<> (p, HttpStatus.OK);
54
+    }
55
+
56
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
57
+    public ResponseEntity<?> updatePoll(@Valid @RequestBody Poll poll, @PathVariable Long pollId) {
58
+        verifyPoll(pollId);
59
+        Poll p = pollRepository.save(poll);
60
+        return new ResponseEntity<>(HttpStatus.OK);
61
+    }
62
+
63
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.DELETE)
64
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
65
+        verifyPoll(pollId);
66
+        pollRepository.delete(pollId);
67
+        return new ResponseEntity<>(HttpStatus.OK);
68
+    }
69
+
70
+    public void verifyPoll(Long id) {
71
+        if (pollRepository.findOne(id) == null) {
72
+            throw new ResourceNotFoundException("this is not a thing");
73
+        }
74
+    }
75
+
76
+}

+ 44
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java Bestand weergeven

@@ -0,0 +1,44 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.data.domain.PageRequest;
7
+import org.springframework.http.HttpHeaders;
8
+import org.springframework.http.HttpStatus;
9
+import org.springframework.http.ResponseEntity;
10
+import org.springframework.web.bind.annotation.*;
11
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
12
+
13
+@RestController
14
+public class VoteController {
15
+
16
+    private VoteRepository voteRepository;
17
+
18
+    @Autowired
19
+    public VoteController(VoteRepository voteRepository) {
20
+        this.voteRepository = voteRepository;
21
+    }
22
+
23
+    @RequestMapping(value = "/polls/{pollId}/votes", method = RequestMethod.POST)
24
+    public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
25
+            vote) {
26
+        vote = voteRepository.save(vote);
27
+        // Set the headers for the newly created resource
28
+        HttpHeaders responseHeaders = new HttpHeaders();
29
+        responseHeaders.setLocation(ServletUriComponentsBuilder.
30
+                fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
31
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
32
+    }
33
+
34
+    @RequestMapping(value="/polls/votes", method=RequestMethod.GET)
35
+    public Iterable<Vote> getAllVotes() {
36
+        return voteRepository.findAll(new PageRequest(0,5));
37
+    }
38
+
39
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
40
+    public Iterable<Vote> getVote(@PathVariable Long pollId) {
41
+        return voteRepository.findVotesByPoll(pollId);
42
+    }
43
+
44
+}

+ 31
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java Bestand weergeven

@@ -0,0 +1,31 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.*;
4
+
5
+@Entity
6
+public class Option {
7
+
8
+    @Id
9
+    @GeneratedValue(strategy = GenerationType.AUTO)
10
+    @Column(name="OPTION_ID")
11
+    private Long id;
12
+
13
+    @Column(name="OPTION_VALUE")
14
+    private String value;
15
+
16
+    public Long getId() {
17
+        return id;
18
+    }
19
+
20
+    public void setId(Long id) {
21
+        this.id = id;
22
+    }
23
+
24
+    public String getValue() {
25
+        return value;
26
+    }
27
+
28
+    public void setValue(String value) {
29
+        this.value = value;
30
+    }
31
+}

+ 50
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java Bestand weergeven

@@ -0,0 +1,50 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import org.hibernate.validator.constraints.NotEmpty;
4
+
5
+import javax.persistence.*;
6
+import javax.validation.constraints.Size;
7
+import java.util.Set;
8
+
9
+@Entity
10
+public class Poll {
11
+
12
+    @Id
13
+    @GeneratedValue(strategy = GenerationType.AUTO)
14
+    @Column(name="POLL_ID")
15
+    private Long id;
16
+
17
+    @Column(name="QUESTION")
18
+    @NotEmpty
19
+    private String question;
20
+
21
+    @OneToMany(cascade = CascadeType.ALL)
22
+    @JoinColumn(name="POLL_ID")
23
+    @OrderBy
24
+    @Size(min = 2, max = 6)
25
+    private Set<Option> options;
26
+
27
+    public Long getId() {
28
+        return id;
29
+    }
30
+
31
+    public void setId(Long id) {
32
+        this.id = id;
33
+    }
34
+
35
+    public String getQuestion() {
36
+        return question;
37
+    }
38
+
39
+    public void setQuestion(String question) {
40
+        this.question = question;
41
+    }
42
+
43
+    public Set<Option> getOptions() {
44
+        return options;
45
+    }
46
+
47
+    public void setOptions(Set<Option> options) {
48
+        this.options = options;
49
+    }
50
+}

+ 32
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java Bestand weergeven

@@ -0,0 +1,32 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.*;
4
+
5
+@Entity
6
+public class Vote {
7
+
8
+    @Id
9
+    @GeneratedValue(strategy = GenerationType.AUTO)
10
+    @Column(name="VOTE_ID")
11
+    private Long id;
12
+
13
+    @ManyToOne
14
+    @JoinColumn(name="OPTION_ID")
15
+    private Option option;
16
+
17
+    public Long getId() {
18
+        return id;
19
+    }
20
+
21
+    public void setId(Long id) {
22
+        this.id = id;
23
+    }
24
+
25
+    public Option getOption() {
26
+        return option;
27
+    }
28
+
29
+    public void setOption(Option option) {
30
+        this.option = option;
31
+    }
32
+}

+ 36
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/ComputeResultController.java Bestand weergeven

@@ -0,0 +1,36 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos;
2
+
3
+import com.google.common.collect.Iterables;
4
+import com.google.common.collect.Iterators;
5
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
6
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.http.HttpStatus;
9
+import org.springframework.http.ResponseEntity;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestMethod;
12
+import org.springframework.web.bind.annotation.RequestParam;
13
+import org.springframework.web.bind.annotation.RestController;
14
+
15
+@RestController
16
+public class ComputeResultController {
17
+
18
+    private VoteRepository voteRepository;
19
+
20
+    @Autowired
21
+    public ComputeResultController(VoteRepository voteRepository) {
22
+        this.voteRepository = voteRepository;
23
+    }
24
+
25
+    @RequestMapping(value = "/computeresult", method = RequestMethod.GET)
26
+    public ResponseEntity<?> computeResult(@RequestParam Long pollId) {
27
+        VoteResult voteResult = new VoteResult();
28
+        Iterable<Vote> allVotes = voteRepository.findVotesByPoll(pollId);
29
+
30
+        voteResult.setTotalVotes(Iterables.size(allVotes));
31
+        //TODO: Implement algorithm to count votes
32
+
33
+        return new ResponseEntity<VoteResult>(voteResult, HttpStatus.OK);
34
+    }
35
+
36
+}

+ 22
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/OptionCount.java Bestand weergeven

@@ -0,0 +1,22 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos;
2
+
3
+public class OptionCount {
4
+    private Long optionId;
5
+    private int count;
6
+
7
+    public Long getOptionId() {
8
+        return optionId;
9
+    }
10
+
11
+    public void setOptionId(Long optionId) {
12
+        this.optionId = optionId;
13
+    }
14
+
15
+    public int getCount() {
16
+        return count;
17
+    }
18
+
19
+    public void setCount(int count) {
20
+        this.count = count;
21
+    }
22
+}

+ 24
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dtos/VoteResult.java Bestand weergeven

@@ -0,0 +1,24 @@
1
+package io.zipcoder.tc_spring_poll_application.dtos;
2
+
3
+import java.util.Collection;
4
+
5
+public class VoteResult {
6
+    private int totalVotes;
7
+    private Collection<OptionCount> results;
8
+
9
+    public int getTotalVotes() {
10
+        return totalVotes;
11
+    }
12
+
13
+    public void setTotalVotes(int totalVotes) {
14
+        this.totalVotes = totalVotes;
15
+    }
16
+
17
+    public Collection<OptionCount> getResults() {
18
+        return results;
19
+    }
20
+
21
+    public void setResults(Collection<OptionCount> results) {
22
+        this.results = results;
23
+    }
24
+}

+ 62
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/error/ErrorDetail.java Bestand weergeven

@@ -0,0 +1,62 @@
1
+package io.zipcoder.tc_spring_poll_application.error;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+public class ErrorDetail {
7
+
8
+    private String title;
9
+    private int status;
10
+    private String detail;
11
+    private long timeStamp;
12
+    private String developerMessage;
13
+    private Map<String, List<ValidationError>> errors;
14
+
15
+    public String getTitle() {
16
+        return title;
17
+    }
18
+
19
+    public void setTitle(String title) {
20
+        this.title = title;
21
+    }
22
+
23
+    public int getStatus() {
24
+        return status;
25
+    }
26
+
27
+    public void setStatus(int status) {
28
+        this.status = status;
29
+    }
30
+
31
+    public String getDetail() {
32
+        return detail;
33
+    }
34
+
35
+    public void setDetail(String detail) {
36
+        this.detail = detail;
37
+    }
38
+
39
+    public long getTimeStamp() {
40
+        return timeStamp;
41
+    }
42
+
43
+    public void setTimeStamp(long timeStamp) {
44
+        this.timeStamp = timeStamp;
45
+    }
46
+
47
+    public String getDeveloperMessage() {
48
+        return developerMessage;
49
+    }
50
+
51
+    public void setDeveloperMessage(String developerMessage) {
52
+        this.developerMessage = developerMessage;
53
+    }
54
+
55
+    public Map<String, List<ValidationError>> getErrors() {
56
+        return errors;
57
+    }
58
+
59
+    public void setErrors(Map<String, List<ValidationError>> errors) {
60
+        this.errors = errors;
61
+    }
62
+}

+ 23
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/error/ValidationError.java Bestand weergeven

@@ -0,0 +1,23 @@
1
+package io.zipcoder.tc_spring_poll_application.error;
2
+
3
+public class ValidationError {
4
+
5
+    private String code;
6
+    private String message;
7
+
8
+    public String getCode() {
9
+        return code;
10
+    }
11
+
12
+    public void setCode(String code) {
13
+        this.code = code;
14
+    }
15
+
16
+    public String getMessage() {
17
+        return message;
18
+    }
19
+
20
+    public void setMessage(String message) {
21
+        this.message = message;
22
+    }
23
+}

+ 20
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java Bestand weergeven

@@ -0,0 +1,20 @@
1
+package io.zipcoder.tc_spring_poll_application.exception;
2
+
3
+import org.springframework.http.HttpStatus;
4
+import org.springframework.web.bind.annotation.ResponseStatus;
5
+
6
+@ResponseStatus(HttpStatus.NOT_FOUND)
7
+public class ResourceNotFoundException extends RuntimeException {
8
+
9
+    public ResourceNotFoundException(String message) {
10
+        super(message);
11
+    }
12
+
13
+    public ResourceNotFoundException(String message, Throwable cause) {
14
+        super(message, cause);
15
+    }
16
+
17
+    public ResourceNotFoundException() {
18
+    }
19
+
20
+}

+ 57
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/RestExceptionHandler.java Bestand weergeven

@@ -0,0 +1,57 @@
1
+package io.zipcoder.tc_spring_poll_application.exception;
2
+
3
+import io.zipcoder.tc_spring_poll_application.error.ErrorDetail;
4
+import io.zipcoder.tc_spring_poll_application.error.ValidationError;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.MessageSource;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.validation.FieldError;
10
+import org.springframework.web.bind.MethodArgumentNotValidException;
11
+import org.springframework.web.bind.annotation.ControllerAdvice;
12
+import org.springframework.web.bind.annotation.ExceptionHandler;
13
+
14
+import javax.servlet.http.HttpServletRequest;
15
+import java.util.ArrayList;
16
+import java.util.Date;
17
+import java.util.List;
18
+
19
+@ControllerAdvice
20
+public class RestExceptionHandler {
21
+
22
+    @Autowired
23
+    private MessageSource messageSource;
24
+
25
+    @ExceptionHandler(ResourceNotFoundException.class)
26
+    public ResponseEntity<?> handleResourceNotFoundException(ResourceNotFoundException rnfe, HttpServletRequest request) {
27
+        ErrorDetail errorDetail = new ErrorDetail();
28
+        errorDetail.setTimeStamp(new Date().getTime());
29
+        errorDetail.setDeveloperMessage(rnfe.getMessage());
30
+        errorDetail.setDetail(rnfe.getLocalizedMessage());
31
+        return new ResponseEntity<>(errorDetail, HttpStatus.NOT_FOUND);
32
+    }
33
+
34
+    @ExceptionHandler(MethodArgumentNotValidException.class)
35
+    public ResponseEntity<?>
36
+    handleValidationError(MethodArgumentNotValidException manve, HttpServletRequest request){
37
+        ErrorDetail errorDetail = new ErrorDetail();
38
+        List<FieldError> fieldErrors =  manve.getBindingResult().getFieldErrors();
39
+
40
+        for(FieldError fe : fieldErrors) {
41
+
42
+            List<ValidationError> validationErrorList = errorDetail.getErrors().get(fe.getField());
43
+            if(validationErrorList == null) {
44
+                validationErrorList = new ArrayList<>();
45
+                errorDetail.getErrors().put(fe.getField(), validationErrorList);
46
+            }
47
+
48
+            ValidationError validationError = new ValidationError();
49
+            validationError.setCode(fe.getCode());
50
+            validationError.setMessage(messageSource.getMessage(fe, null));
51
+            validationErrorList.add(validationError);
52
+        }
53
+
54
+        return new ResponseEntity<>(errorDetail, HttpStatus.BAD_REQUEST);
55
+    }
56
+
57
+}

+ 10
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Bestand weergeven

@@ -0,0 +1,10 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Option;
4
+import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.data.repository.PagingAndSortingRepository;
6
+import org.springframework.stereotype.Repository;
7
+
8
+@Repository
9
+public interface OptionRepository extends PagingAndSortingRepository<Option, Long> {
10
+}

+ 11
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Bestand weergeven

@@ -0,0 +1,11 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Option;
4
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
5
+import org.springframework.data.repository.CrudRepository;
6
+import org.springframework.data.repository.PagingAndSortingRepository;
7
+import org.springframework.stereotype.Repository;
8
+
9
+@Repository
10
+public interface PollRepository extends PagingAndSortingRepository<Poll, Long> {
11
+}

+ 22
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Bestand weergeven

@@ -0,0 +1,22 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
5
+import org.springframework.data.domain.PageRequest;
6
+import org.springframework.data.domain.Pageable;
7
+import org.springframework.data.domain.Sort;
8
+import org.springframework.data.jpa.repository.Query;
9
+import org.springframework.data.repository.CrudRepository;
10
+import org.springframework.data.repository.PagingAndSortingRepository;
11
+import org.springframework.stereotype.Repository;
12
+
13
+@Repository
14
+public interface VoteRepository extends PagingAndSortingRepository<Vote, Long> {
15
+
16
+    @Query(value = "SELECT v.* " +
17
+            "FROM Option o, Vote v " +
18
+            "WHERE o.POLL_ID = ?1 " +
19
+            "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
20
+
21
+    public Iterable<Vote> findVotesByPoll(Long pollId);
22
+}

+ 91
- 0
src/main/resources/import.sql Bestand weergeven

@@ -0,0 +1,91 @@
1
+insert into poll (poll_id, question) values (1, 'What is your favorite primary color?');
2
+insert into option (option_id, option_value, poll_id) values (1, 'Red', 1);
3
+insert into option (option_id, option_value, poll_id) values (2, 'Blue', 1);
4
+insert into option (option_id, option_value, poll_id) values (3, 'Yellow', 1);
5
+
6
+insert into poll (poll_id, question) values (2, 'What is your favorite secondary color?');
7
+insert into option (option_id, option_value, poll_id) values (3, 'Orange', 2);
8
+insert into option (option_id, option_value, poll_id) values (4, 'Green', 2);
9
+insert into option (option_id, option_value, poll_id) values (5, 'Purple', 2);
10
+
11
+insert into poll (poll_id, question) values (3, 'What is your favorite tertiary color?');
12
+insert into option (option_id, option_value, poll_id) values (6, 'Amber', 3);
13
+insert into option (option_id, option_value, poll_id) values (7, 'Vermillion', 3);
14
+insert into option (option_id, option_value, poll_id) values (8, 'Magenta', 3);
15
+insert into option (option_id, option_value, poll_id) values (9, 'Violet', 3);
16
+insert into option (option_id, option_value, poll_id) values (10, 'Teal', 3);
17
+insert into option (option_id, option_value, poll_id) values (11, 'Chartreuse', 3);
18
+
19
+insert into poll (poll_id, question) values (4, 'What is your favorite quaternary color?');
20
+insert into option (option_id, option_value, poll_id) values (12, 'Golden Yellow', 4);
21
+insert into option (option_id, option_value, poll_id) values (13, 'Orange Peel', 4);
22
+insert into option (option_id, option_value, poll_id) values (14, 'Persimmon', 4);
23
+insert into option (option_id, option_value, poll_id) values (15, 'Scarlet', 4);
24
+insert into option (option_id, option_value, poll_id) values (16, 'Crimson', 4);
25
+insert into option (option_id, option_value, poll_id) values (17, 'Aubergine', 4);
26
+insert into option (option_id, option_value, poll_id) values (18, 'Amethyst', 4);
27
+insert into option (option_id, option_value, poll_id) values (19, 'Indigo', 4);
28
+insert into option (option_id, option_value, poll_id) values (20, 'Cerulean', 4);
29
+insert into option (option_id, option_value, poll_id) values (21, 'Viridian', 4);
30
+insert into option (option_id, option_value, poll_id) values (22, 'Apple Green', 4);
31
+insert into option (option_id, option_value, poll_id) values (23, 'Lemon Lime', 4);
32
+
33
+insert into poll (poll_id, question) values (5, 'What is your favorite Gen 1 Pokemon game?');
34
+insert into option (option_id, option_value, poll_id) values (24, 'Red', 5);
35
+insert into option (option_id, option_value, poll_id) values (25, 'Blue', 5);
36
+insert into option (option_id, option_value, poll_id) values (26, 'Yellow', 5);
37
+
38
+insert into poll (poll_id, question) values (6, 'What is your favorite Gen 2 Pokemon game?');
39
+insert into option (option_id, option_value, poll_id) values (27, 'Gold', 6);
40
+insert into option (option_id, option_value, poll_id) values (28, 'Silver', 6);
41
+insert into option (option_id, option_value, poll_id) values (29, 'Crystal', 6);
42
+
43
+insert into poll (poll_id, question) values (7, 'What is your favorite Gen 3 Pokemon game?');
44
+insert into option (option_id, option_value, poll_id) values (30, 'Ruby', 7);
45
+insert into option (option_id, option_value, poll_id) values (31, 'Sapphire', 7);
46
+insert into option (option_id, option_value, poll_id) values (32, 'Emerald', 7);
47
+
48
+insert into poll (poll_id, question) values (8, 'What is your favorite Gen 4 Pokemon game?');
49
+insert into option (option_id, option_value, poll_id) values (33, 'Diamond', 8);
50
+insert into option (option_id, option_value, poll_id) values (34, 'Pearl', 8);
51
+insert into option (option_id, option_value, poll_id) values (35, 'Platinum', 8);
52
+
53
+insert into poll (poll_id, question) values (9, 'What is your favorite Gen 5 Pokemon game?');
54
+insert into option (option_id, option_value, poll_id) values (36, 'Black', 9);
55
+insert into option (option_id, option_value, poll_id) values (37, 'White', 9);
56
+insert into option (option_id, option_value, poll_id) values (38, 'Black 2', 9);
57
+insert into option (option_id, option_value, poll_id) values (39, 'White 2', 9);
58
+
59
+insert into poll (poll_id, question) values (10, 'What is your favorite Gen 6 Pokemon game?');
60
+insert into option (option_id, option_value, poll_id) values (40, 'X', 10);
61
+insert into option (option_id, option_value, poll_id) values (41, 'Y', 10);
62
+
63
+insert into poll (poll_id, question) values (11, 'What is your favorite Gen 7 Pokemon game?');
64
+insert into option (option_id, option_value, poll_id) values (42, 'Sun', 11);
65
+insert into option (option_id, option_value, poll_id) values (43, 'Moon', 11);
66
+insert into option (option_id, option_value, poll_id) values (44, 'Ultra Sun', 11);
67
+insert into option (option_id, option_value, poll_id) values (45, 'Ultra Moon', 11);
68
+
69
+insert into poll (poll_id, question) values (12, 'What is your favorite option?');
70
+insert into option (option_id, option_value, poll_id) values (46, 'This one', 12);
71
+insert into option (option_id, option_value, poll_id) values (47, 'This one', 12);
72
+insert into option (option_id, option_value, poll_id) values (48, 'This one', 12);
73
+insert into option (option_id, option_value, poll_id) values (49, 'None of the above', 12);
74
+
75
+insert into poll (poll_id, question) values (13, 'What does she want to eat?');
76
+insert into option (option_id, option_value, poll_id) values (50, 'Sushi', 13);
77
+insert into option (option_id, option_value, poll_id) values (51, 'Nothing', 13);
78
+insert into option (option_id, option_value, poll_id) values (52, 'Meat', 13);
79
+insert into option (option_id, option_value, poll_id) values (53, 'You are wrong', 13);
80
+
81
+insert into poll (poll_id, question) values (14, 'What are they?');
82
+insert into option (option_id, option_value, poll_id) values (54, 'What are what?', 14);
83
+insert into option (option_id, option_value, poll_id) values (55, 'Everything', 14);
84
+insert into option (option_id, option_value, poll_id) values (56, 'Nothing', 14);
85
+insert into option (option_id, option_value, poll_id) values (57, 'All of the above', 14);
86
+
87
+insert into poll (poll_id, question) values (15, 'What is he building in there?');
88
+insert into option (option_id, option_value, poll_id) values (58, 'Wait, this sounds familiar', 15);
89
+insert into option (option_id, option_value, poll_id) values (59, 'Is that from a song?', 15);
90
+insert into option (option_id, option_value, poll_id) values (60, 'Bob Dylan?', 15);
91
+insert into option (option_id, option_value, poll_id) values (61, 'Tom Waits I think', 15);

+ 2
- 0
src/main/resources/messages.properties Bestand weergeven

@@ -0,0 +1,2 @@
1
+NotEmpty.poll.question=Question is a required field
2
+Size.poll.options=Options must be greater than {2} and less than {1}