Przeglądaj źródła

Merge 30265dd80e8db6bb5cb53176b88e57bc1557d552 into f91a622cc731197181dd1b1e4b17c9bcb450ae8a

Brian 8 lat temu
rodzic
commit
c9e7aef3ba
Brak konta powiązanego z e-mailem autora
18 zmienionych plików z 627 dodań i 1 usunięć
  1. 0
    1
      pom.xml
  2. 44
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java
  3. 70
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java
  4. 37
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java
  5. 45
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java
  6. 50
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java
  7. 33
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java
  8. 22
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/OptionCount.java
  9. 25
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/VoteResult.java
  10. 66
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ErrorDetail.java
  11. 23
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ValidationError.java
  12. 20
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java
  13. 72
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/handler/RestExceptionHandler.java
  14. 8
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java
  15. 8
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java
  16. 13
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java
  17. 89
    0
      src/main/resources/import.sql
  18. 2
    0
      src/main/resources/messages.properties

+ 0
- 1
pom.xml Wyświetl plik

45
         </dependency>
45
         </dependency>
46
     </dependencies>
46
     </dependencies>
47
 
47
 
48
-
49
 </project>
48
 </project>

+ 44
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java Wyświetl plik

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.dto.OptionCount;
5
+import io.zipcoder.tc_spring_poll_application.dto.VoteResult;
6
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.web.bind.annotation.*;
10
+
11
+import javax.inject.Inject;
12
+import java.util.HashMap;
13
+import java.util.Map;
14
+
15
+@RestController
16
+public class ComputeResultController {
17
+
18
+    @Inject
19
+    private VoteRepository voteRepository;
20
+
21
+    @RequestMapping(value="/computeresult", method= RequestMethod.GET)
22
+    public ResponseEntity<?> computeResult(@RequestParam Long pollId) {
23
+        VoteResult voteResult = new VoteResult();
24
+        Iterable<Vote> allVotes = voteRepository.findVotesByPoll(pollId);
25
+
26
+        int totalVotes = 0;
27
+        Map<Long, OptionCount> tempMap = new HashMap<>();
28
+        for(Vote v : allVotes) {
29
+            totalVotes++;
30
+            OptionCount optionCount = tempMap.get(v.getOption().getId());
31
+            if(optionCount == null) {
32
+                optionCount = new OptionCount();
33
+                optionCount.setOptionId(v.getOption().getId());
34
+                tempMap.put(v.getOption().getId(), optionCount);
35
+            }
36
+            optionCount.setCount(optionCount.getCount() + 1);
37
+        }
38
+        voteResult.setTotalVotes(totalVotes);
39
+        voteResult.setResults(tempMap.values());
40
+
41
+        return new ResponseEntity<>(voteResult, HttpStatus.OK);
42
+    }
43
+
44
+}

+ 70
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+
4
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
5
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
6
+import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
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
+import javax.inject.Inject;
14
+import javax.validation.Valid;
15
+import java.net.URI;
16
+
17
+@RestController
18
+public class PollController {
19
+
20
+    @Inject
21
+    private PollRepository pollRepository;
22
+
23
+    @RequestMapping(value="/polls", method= RequestMethod.GET)
24
+    public ResponseEntity<Iterable<Poll>> getAllPolls() {
25
+        Iterable<Poll> allPolls = pollRepository.findAll();
26
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
27
+    }
28
+
29
+    @RequestMapping(value="/polls", method=RequestMethod.POST)
30
+    public ResponseEntity<?> createPoll(@Valid @RequestBody Poll poll) {
31
+        poll = pollRepository.save(poll);
32
+        HttpHeaders responseHeaders = new HttpHeaders();
33
+        URI newPollUri = ServletUriComponentsBuilder
34
+                .fromCurrentRequest()
35
+                .path("/{id}")
36
+                .buildAndExpand(poll.getId())
37
+                .toUri();
38
+        responseHeaders.setLocation(newPollUri);
39
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
40
+    }
41
+
42
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.GET)
43
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
44
+        Poll p = pollRepository.findOne(pollId);
45
+        verifyPoll(pollId);
46
+        return new ResponseEntity<>(p, HttpStatus.OK);
47
+    }
48
+
49
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
50
+    public ResponseEntity<?> updatePoll(@Valid @RequestBody Poll poll, @PathVariable Long pollId) {
51
+        Poll p = pollRepository.save(poll);
52
+        verifyPoll(pollId);
53
+        return new ResponseEntity<>(HttpStatus.OK);
54
+    }
55
+
56
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.DELETE)
57
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
58
+        pollRepository.delete(pollId);
59
+        verifyPoll(pollId);
60
+        return new ResponseEntity<>(HttpStatus.OK);
61
+    }
62
+
63
+    protected void verifyPoll(Long pollId) throws ResourceNotFoundException {
64
+        Poll poll = pollRepository.findOne(pollId);
65
+        if(poll == null) {
66
+            throw new ResourceNotFoundException("Poll with id " + pollId + " not found");
67
+        }
68
+    }
69
+
70
+}

+ 37
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java Wyświetl plik

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.http.HttpHeaders;
6
+import org.springframework.http.HttpStatus;
7
+import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.*;
9
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
10
+
11
+import javax.inject.Inject;
12
+
13
+@RestController
14
+public class VoteController {
15
+    @Inject
16
+    private VoteRepository voteRepository;
17
+
18
+    @RequestMapping(value="/polls/{pollId}/votes", method= RequestMethod.POST)
19
+    public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote vote) {
20
+        vote = voteRepository.save(vote);
21
+        HttpHeaders responseHeaders = new HttpHeaders();
22
+        responseHeaders.setLocation(ServletUriComponentsBuilder
23
+                .fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
24
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
25
+    }
26
+
27
+    @RequestMapping(value="/polls/votes", method=RequestMethod.GET)
28
+    public Iterable<Vote> getAllVotes() {
29
+        return voteRepository.findAll();
30
+    }
31
+
32
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
33
+    public Iterable<Vote> getVote(@PathVariable Long pollId) {
34
+        return voteRepository.findVotesByPoll(pollId);
35
+    }
36
+
37
+}

+ 45
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.Column;
4
+import javax.persistence.Entity;
5
+import javax.persistence.GeneratedValue;
6
+import javax.persistence.Id;
7
+
8
+@Entity
9
+public class Option {
10
+
11
+    @Id
12
+    @GeneratedValue
13
+    @Column(name = "OPTION_ID")
14
+    private Long id;
15
+
16
+    @Column(name = "OPTION_VALUE")
17
+    private String value;
18
+
19
+    @Column(name = "POLL_ID")
20
+    private Long poll_id;
21
+
22
+    public Long getId() {
23
+        return id;
24
+    }
25
+
26
+    public void setId(Long id) {
27
+        this.id = id;
28
+    }
29
+
30
+    public String getValue() {
31
+        return value;
32
+    }
33
+
34
+    public void setValue(String value) {
35
+        this.value = value;
36
+    }
37
+
38
+    public Long getPoll_id() {
39
+        return poll_id;
40
+    }
41
+
42
+    public void setPoll_id(Long poll_id) {
43
+        this.poll_id = poll_id;
44
+    }
45
+}

+ 50
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java Wyświetl plik

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
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
+}

+ 33
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java Wyświetl plik

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
10
+    @Column(name = "VOTE_ID")
11
+    private Long id;
12
+
13
+
14
+    @ManyToOne
15
+    @JoinColumn(name = "OPTION_ID")
16
+    private Option option;
17
+
18
+    public Long getId() {
19
+        return id;
20
+    }
21
+
22
+    public void setId(Long id) {
23
+        this.id = id;
24
+    }
25
+
26
+    public Option getOption() {
27
+        return option;
28
+    }
29
+
30
+    public void setOption(Option option) {
31
+        this.option = option;
32
+    }
33
+}

+ 22
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/OptionCount.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.dto;
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
+}

+ 25
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/VoteResult.java Wyświetl plik

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

+ 66
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ErrorDetail.java Wyświetl plik

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

+ 23
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ValidationError.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.dto.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 Wyświetl plik

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() {
10
+
11
+    }
12
+
13
+    public ResourceNotFoundException(String message) {
14
+        super(message);
15
+    }
16
+
17
+    public ResourceNotFoundException(String message, Throwable cause) {
18
+        super(message, cause);
19
+    }
20
+}

+ 72
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/handler/RestExceptionHandler.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.handler;
2
+
3
+import io.zipcoder.tc_spring_poll_application.dto.error.ErrorDetail;
4
+import io.zipcoder.tc_spring_poll_application.dto.error.ValidationError;
5
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
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
+import org.springframework.web.bind.annotation.ResponseBody;
14
+import org.springframework.web.bind.annotation.ResponseStatus;
15
+
16
+import javax.inject.Inject;
17
+import javax.servlet.http.HttpServletRequest;
18
+import java.util.ArrayList;
19
+import java.util.Date;
20
+import java.util.List;
21
+
22
+@ControllerAdvice
23
+public class RestExceptionHandler {
24
+
25
+    @Inject
26
+    private MessageSource messageSource;
27
+
28
+    @ExceptionHandler(ResourceNotFoundException.class)
29
+    public ResponseEntity<?> handleResourceNotFoundException(ResourceNotFoundException rnfe, HttpServletRequest request) {
30
+        ErrorDetail errorDetail = new ErrorDetail();
31
+        errorDetail.setTitle("Resource Not Found");
32
+        errorDetail.setStatus(HttpStatus.NOT_FOUND.value());
33
+        errorDetail.setDetail(rnfe.getMessage());
34
+        errorDetail.setTimeStamp(new Date().getTime());
35
+        errorDetail.setDeveloperMessage(rnfe.getClass().getName());
36
+
37
+        return new ResponseEntity<>(errorDetail, null, HttpStatus.NOT_FOUND);
38
+    }
39
+
40
+    @ExceptionHandler(MethodArgumentNotValidException.class)
41
+    @ResponseStatus(HttpStatus.BAD_REQUEST)
42
+    public @ResponseBody ErrorDetail handleValidationError(MethodArgumentNotValidException manve, HttpServletRequest request) {
43
+        ErrorDetail errorDetail = new ErrorDetail();
44
+        errorDetail.setTitle("Validation Failed");
45
+        errorDetail.setStatus(HttpStatus.BAD_REQUEST.value());
46
+        errorDetail.setDetail("Input validation failed");
47
+        errorDetail.setTimeStamp(new Date().getTime());
48
+        errorDetail.setDeveloperMessage(manve.getClass().getName());
49
+
50
+        String requestPath = (String) request.getAttribute("javax.servlet.error.request_uri");
51
+
52
+        if(requestPath == null) {
53
+            requestPath = request.getRequestURI();
54
+        }
55
+
56
+        List<FieldError> fieldErrors = manve.getBindingResult().getFieldErrors();
57
+        for(FieldError fe : fieldErrors) {
58
+            List<ValidationError> validationErrorList = errorDetail.getErrors().get(fe.getField());
59
+            if(validationErrorList == null) {
60
+                validationErrorList = new ArrayList<ValidationError>();
61
+                errorDetail.getErrors().put(fe.getField(), validationErrorList);
62
+            }
63
+            ValidationError validationError = new ValidationError();
64
+            validationError.setCode(fe.getCode());
65
+            validationError.setMessage(messageSource.getMessage(fe, null));
66
+            validationErrorList.add(validationError);
67
+
68
+        }
69
+        return errorDetail;
70
+    }
71
+}
72
+

+ 8
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Wyświetl plik

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
+
6
+public interface OptionRepository extends CrudRepository<Option, Long> {
7
+
8
+}

+ 8
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import org.springframework.data.repository.CrudRepository;
5
+
6
+public interface PollRepository extends CrudRepository<Poll, Long> {
7
+
8
+}

+ 13
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Wyświetl plik

1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import org.springframework.data.jpa.repository.Query;
5
+import org.springframework.data.repository.CrudRepository;
6
+
7
+public interface VoteRepository extends CrudRepository<Vote, Long> {
8
+    @Query(value="SELECT v.* " +
9
+            "FROM Option o, Vote v " +
10
+            "WHERE o.POLL_ID = ?1 " +
11
+            "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
12
+    public Iterable<Vote> findVotesByPoll(Long pollId);
13
+}

+ 89
- 0
src/main/resources/import.sql Wyświetl plik

1
+insert into poll (poll_id, question) values (1, 'What is your favorite color?');
2
+
3
+insert into option (option_id, option_value, poll_id) values (1, 'Red', 1);
4
+insert into option (option_id, option_value, poll_id) values (2, 'Black', 1);
5
+insert into option (option_id, option_value, poll_id) values (3, 'Blue', 1);
6
+
7
+insert into poll (poll_id, question) values (2, 'What is your favorite movie?');
8
+
9
+insert into option (option_id, option_value, poll_id) values (4, 'Ready Player One', 2);
10
+insert into option (option_id, option_value, poll_id) values (5, 'Infinity War', 2);
11
+insert into option (option_id, option_value, poll_id) values (6, 'Black Panther', 2);
12
+
13
+insert into poll (poll_id, question) values (3, 'What is your favorite Holiday?');
14
+
15
+insert into option (option_id, option_value, poll_id) values (7, 'Christmas', 3);
16
+insert into option (option_id, option_value, poll_id) values (8, 'Easter', 3);
17
+insert into option (option_id, option_value, poll_id) values (9, 'Thanksgiving', 3);
18
+
19
+insert into poll (poll_id, question) values (4, 'Do you put your toilet paper facing in or out?');
20
+
21
+insert into option (option_id, option_value, poll_id) values (10, 'In', 4);
22
+insert into option (option_id, option_value, poll_id) values (11, 'Out', 4);
23
+insert into option (option_id, option_value, poll_id) values (12, 'Floor', 4);
24
+
25
+insert into poll (poll_id, question) values (5, 'What is your favorite TV show?');
26
+
27
+insert into option (option_id, option_value, poll_id) values (13, 'Suits', 5);
28
+insert into option (option_id, option_value, poll_id) values (14, 'Game of Thrones', 5);
29
+insert into option (option_id, option_value, poll_id) values (15, 'Breaking Bad', 5);
30
+
31
+insert into poll (poll_id, question) values (6, 'What is your favorite game?');
32
+
33
+insert into option (option_id, option_value, poll_id) values (16, 'Overwatch', 6);
34
+insert into option (option_id, option_value, poll_id) values (17, 'Monster Hunter', 6);
35
+insert into option (option_id, option_value, poll_id) values (18, 'Dark Souls', 6);
36
+
37
+insert into poll (poll_id, question) values (7, 'What is your favorite drink?');
38
+
39
+insert into option (option_id, option_value, poll_id) values (19, 'Coffee', 7);
40
+insert into option (option_id, option_value, poll_id) values (20, 'Tea', 7);
41
+insert into option (option_id, option_value, poll_id) values (21, 'Water', 7);
42
+
43
+insert into poll (poll_id, question) values (8, 'What is your favorite food?');
44
+
45
+insert into option (option_id, option_value, poll_id) values (22, 'Pizza', 8);
46
+insert into option (option_id, option_value, poll_id) values (23, 'Burgers', 8);
47
+insert into option (option_id, option_value, poll_id) values (24, 'Cheese', 8);
48
+
49
+insert into poll (poll_id, question) values (9, 'What is your favorite type of meat?');
50
+
51
+insert into option (option_id, option_value, poll_id) values (25, 'Beef', 9);
52
+insert into option (option_id, option_value, poll_id) values (26, 'Pork', 9);
53
+insert into option (option_id, option_value, poll_id) values (27, 'Chicken', 9);
54
+
55
+insert into poll (poll_id, question) values (10, 'What is your favorite fish?');
56
+
57
+insert into option (option_id, option_value, poll_id) values (28, 'Trout', 10);
58
+insert into option (option_id, option_value, poll_id) values (29, 'Salmon', 10);
59
+insert into option (option_id, option_value, poll_id) values (30, 'Flounder', 10);
60
+
61
+insert into poll (poll_id, question) values (11, 'What is your favorite way to cook eggs?');
62
+
63
+insert into option (option_id, option_value, poll_id) values (31, 'Poached', 11);
64
+insert into option (option_id, option_value, poll_id) values (32, 'Fried', 11);
65
+insert into option (option_id, option_value, poll_id) values (33, 'Scrambled', 11);
66
+
67
+insert into poll (poll_id, question) values (12, 'How do you like your steak?');
68
+
69
+insert into option (option_id, option_value, poll_id) values (34, 'Well Done', 12);
70
+insert into option (option_id, option_value, poll_id) values (35, 'Medium', 12);
71
+insert into option (option_id, option_value, poll_id) values (36, 'Rare', 12);
72
+
73
+insert into poll (poll_id, question) values (13, 'What is your favorite season?');
74
+
75
+insert into option (option_id, option_value, poll_id) values (37, 'Spring', 13);
76
+insert into option (option_id, option_value, poll_id) values (38, 'Fall', 13);
77
+insert into option (option_id, option_value, poll_id) values (39, 'Winter', 13);
78
+
79
+insert into poll (poll_id, question) values (14, 'What is your favorite workout?');
80
+
81
+insert into option (option_id, option_value, poll_id) values (40, 'Bench', 14);
82
+insert into option (option_id, option_value, poll_id) values (41, 'Squat', 14);
83
+insert into option (option_id, option_value, poll_id) values (42, 'Deadlift', 14);
84
+
85
+insert into poll (poll_id, question) values (15, 'What is your favorite OWL team?');
86
+
87
+insert into option (option_id, option_value, poll_id) values (43, 'Fusion', 15);
88
+insert into option (option_id, option_value, poll_id) values (44, 'Fuel', 15);
89
+insert into option (option_id, option_value, poll_id) values (45, 'Gladiators', 15);

+ 2
- 0
src/main/resources/messages.properties Wyświetl plik

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