Bladeren bron

Merge 9cb7df6e43595272de8e94bf73f65c509a7fc922 into f91a622cc731197181dd1b1e4b17c9bcb450ae8a

bell7692 8 jaren geleden
bovenliggende
commit
523ce0e0f0
Geen account gekoppeld aan de committers e-mail
17 gewijzigde bestanden met toevoegingen van 649 en 0 verwijderingen
  1. 47
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java
  2. 80
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java
  3. 45
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java
  4. 45
    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. 23
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/OptionCount.java
  8. 25
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/VoteResult.java
  9. 64
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ErrorDetail.java
  10. 72
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/RestExceptionHandler.java
  11. 25
    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. 7
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java
  14. 7
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java
  15. 15
    0
      src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java
  16. 90
    0
      src/main/resources/import.sql
  17. 2
    0
      src/main/resources/messages.properties

+ 47
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java Bestand weergeven

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

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

@@ -0,0 +1,80 @@
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.http.HttpHeaders;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
11
+
12
+import javax.inject.Inject;
13
+import javax.validation.Valid;
14
+import java.net.URI;
15
+
16
+@RestController
17
+public class PollController {
18
+
19
+    @Inject
20
+    private PollRepository pollRepository;
21
+
22
+
23
+    //GET verb implementation for polls
24
+    @RequestMapping(value = "/polls", method= RequestMethod.GET)
25
+    public ResponseEntity<Iterable<Poll>> getAllPolls(){
26
+        Iterable<Poll> allPolls = pollRepository.findAll();
27
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
28
+    }
29
+
30
+
31
+    //implementation to create new poll
32
+    @RequestMapping(value="/polls", method=RequestMethod.POST)
33
+    public ResponseEntity<?> createPoll(@Valid @RequestBody Poll poll){
34
+        poll = pollRepository.save(poll);
35
+
36
+        //Set the location header for the newly created resource
37
+        HttpHeaders responseHeaders = new HttpHeaders();
38
+        URI newPollUri = ServletUriComponentsBuilder
39
+                .fromCurrentRequest()
40
+                .path("/{id}")
41
+                .buildAndExpand(poll.getId())
42
+                .toUri();
43
+        responseHeaders.setLocation(newPollUri);
44
+
45
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
46
+    }
47
+
48
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.GET)
49
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
50
+        verifyPoll(pollId);
51
+        Poll p = pollRepository.findOne(pollId);
52
+        return new ResponseEntity<>(p, HttpStatus.OK);
53
+    }
54
+
55
+
56
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
57
+    public ResponseEntity<?> updatePoll(@Valid @RequestBody Poll poll, @PathVariable Long pollId){
58
+        //save the entity
59
+        verifyPoll(pollId);
60
+        Poll p = pollRepository.save(poll);
61
+        return new ResponseEntity<>(HttpStatus.OK);
62
+    }
63
+
64
+
65
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.DELETE)
66
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId){
67
+        verifyPoll(pollId);
68
+        pollRepository.delete(pollId);
69
+        return new ResponseEntity<>(HttpStatus.OK);
70
+    }
71
+
72
+    void verifyPoll(Long pollId) throws ResourceNotFoundException{
73
+        Poll poll = pollRepository.findOne(pollId);
74
+        if (poll == null){
75
+            throw new ResourceNotFoundException("Poll with id "+ pollId + " not found");
76
+        }
77
+    }
78
+
79
+
80
+}

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

@@ -0,0 +1,45 @@
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
20
+            vote) {
21
+        vote = voteRepository.save(vote);
22
+        // Set the headers for the newly created resource
23
+        HttpHeaders responseHeaders = new HttpHeaders();
24
+        responseHeaders.setLocation(ServletUriComponentsBuilder.
25
+                fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
26
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
27
+    }
28
+
29
+    @RequestMapping(value="/polls/votes", method=RequestMethod.GET)
30
+    public Iterable<Vote> getAllVotes() {
31
+        return voteRepository.findAll();
32
+    }
33
+
34
+
35
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
36
+    public Iterable<Vote> getVote(@PathVariable Long pollId) {
37
+        return voteRepository.findVotesByPoll(pollId);
38
+    }
39
+
40
+
41
+}
42
+
43
+
44
+
45
+

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

@@ -0,0 +1,45 @@
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 pollId;
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 getPollId() {
39
+        return pollId;
40
+    }
41
+
42
+    public void setPollId(Long pollId) {
43
+        this.pollId = pollId;
44
+    }
45
+}

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

+ 23
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/OptionCount.java Bestand weergeven

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

+ 25
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/VoteResult.java Bestand weergeven

@@ -0,0 +1,25 @@
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
+}

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

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

+ 72
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/RestExceptionHandler.java Bestand weergeven

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

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

@@ -0,0 +1,25 @@
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
+
24
+
25
+}

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

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

@@ -0,0 +1,7 @@
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
+}

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

@@ -0,0 +1,7 @@
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
+}

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

@@ -0,0 +1,15 @@
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
+
9
+    @Query(value = "SELECT v.* " +
10
+            "FROM Option o, Vote v " +
11
+            "WHERE o.POLL_ID = ?1 " +
12
+            "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
13
+    Iterable<Vote> findVotesByPoll(Long pollId);
14
+
15
+}

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

@@ -0,0 +1,90 @@
1
+insert into poll (poll_id, question) values (1, 'Which color do your prefer?');
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, 'Blue', 1);
5
+insert into option (option_id, option_value, poll_id) values (3, 'Purple', 1);
6
+
7
+insert into poll (poll_id, question) values (2, 'Which drink do you prefer?');
8
+
9
+insert into option (option_id, option_value, poll_id) values (4, 'Coffee', 2);
10
+insert into option (option_id, option_value, poll_id) values (5, 'Tea', 2);
11
+insert into option (option_id, option_value, poll_id) values (6, 'Juice', 2);
12
+
13
+insert into poll (poll_id, question) values (3, 'Which fast food company do you prefer?');
14
+
15
+insert into option (option_id, option_value, poll_id) values (7, 'Burger King', 3);
16
+insert into option (option_id, option_value, poll_id) values (8, 'ChickFil-a', 3);
17
+insert into option (option_id, option_value, poll_id) values (9, 'Wendys', 3);
18
+
19
+insert into poll (poll_id, question) values (4, 'Which soda do you prefer?');
20
+
21
+insert into option (option_id, option_value, poll_id) values (10, 'Coke', 4);
22
+insert into option (option_id, option_value, poll_id) values (11, 'Dr.Pepper', 4);
23
+insert into option (option_id, option_value, poll_id) values (12, 'Sprite', 4);
24
+
25
+insert into poll (poll_id, question) values (5, 'Which phone do you prefer?');
26
+
27
+insert into option (option_id, option_value, poll_id) values (13, 'iPhone', 5);
28
+insert into option (option_id, option_value, poll_id) values (14, 'Samsung Galaxy', 5);
29
+insert into option (option_id, option_value, poll_id) values (15, 'Google Nexus', 5);
30
+
31
+insert into poll (poll_id, question) values (6, 'Which programming language do you prefer?');
32
+
33
+insert into option (option_id, option_value, poll_id) values (16, 'Java', 6);
34
+insert into option (option_id, option_value, poll_id) values (17, 'Python', 6);
35
+insert into option (option_id, option_value, poll_id) values (18, 'JavaScript', 6);
36
+
37
+insert into poll (poll_id, question) values (7, 'Which API framework do you prefer?');
38
+
39
+insert into option (option_id, option_value, poll_id) values (19, 'Red', 7);
40
+insert into option (option_id, option_value, poll_id) values (20, 'Blue', 7);
41
+insert into option (option_id, option_value, poll_id) values (21, 'Purple', 7);
42
+
43
+insert into poll (poll_id, question) values (8, 'Which databse software do you prefer?');
44
+
45
+insert into option (option_id, option_value, poll_id) values (22, 'MondoDB', 8);
46
+insert into option (option_id, option_value, poll_id) values (23, 'MySQL', 8);
47
+insert into option (option_id, option_value, poll_id) values (24, 'MariaDB', 8);
48
+
49
+insert into poll (poll_id, question) values (9, 'Which Integrated Develement Environment(IDE) do you prefer?');
50
+
51
+insert into option (option_id, option_value, poll_id) values (25, 'IntellJ', 9);
52
+insert into option (option_id, option_value, poll_id) values (26, 'Eclipse', 9);
53
+insert into option (option_id, option_value, poll_id) values (27, 'NetBeans', 9);
54
+
55
+insert into poll (poll_id, question) values (10, 'Which Cloud Computing service do you prefer?');
56
+
57
+insert into option (option_id, option_value, poll_id) values (28, 'Amazon Web Service', 10);
58
+insert into option (option_id, option_value, poll_id) values (29, 'Microsoft Azure', 10);
59
+insert into option (option_id, option_value, poll_id) values (30, 'Google Cloud', 10);
60
+
61
+insert into poll (poll_id, question) values (11, 'Which singer do you prefer?');
62
+
63
+insert into option (option_id, option_value, poll_id) values (31, 'Britney Spears', 11);
64
+insert into option (option_id, option_value, poll_id) values (32, 'Jennifer Lopez', 11);
65
+insert into option (option_id, option_value, poll_id) values (33, 'Miley Cyrus', 11);
66
+
67
+insert into poll (poll_id, question) values (12, 'Which actor do you prefer?');
68
+
69
+insert into option (option_id, option_value, poll_id) values (34, 'Denzel Washington', 12);
70
+insert into option (option_id, option_value, poll_id) values (35, 'Leonardo DiCaprio', 12);
71
+insert into option (option_id, option_value, poll_id) values (36, 'Brad Pitt', 12);
72
+
73
+insert into poll (poll_id, question) values (13, 'Which Disney movie do you prefer?');
74
+
75
+insert into option (option_id, option_value, poll_id) values (37, 'Aladdin', 13);
76
+insert into option (option_id, option_value, poll_id) values (38, 'Tangled', 13);
77
+insert into option (option_id, option_value, poll_id) values (39, 'Frozen', 13);
78
+
79
+insert into poll (poll_id, question) values (14, 'Which TV channel do you prefer?');
80
+
81
+insert into option (option_id, option_value, poll_id) values (40, 'ABC', 14);
82
+insert into option (option_id, option_value, poll_id) values (41, 'CBS', 14);
83
+insert into option (option_id, option_value, poll_id) values (42, 'NBC', 14);
84
+
85
+insert into poll (poll_id, question) values (15, 'Which operating system do you prefer?');
86
+
87
+insert into option (option_id, option_value, poll_id) values (43, 'Mac', 15);
88
+insert into option (option_id, option_value, poll_id) values (44, 'Windows', 15);
89
+insert into option (option_id, option_value, poll_id) values (45, 'Linux', 15);
90
+

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