{"action":"created","comment":{"url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/comments/61955256","id":61955256,"diff_hunk":"@@ -0,0 +1,91 @@\n+package com.devfreaks.tripper.validators;\n+\n+import com.devfreaks.tripper.entities.Flight;\n+import com.devfreaks.tripper.entities.enums.FlightStatus;\n+import com.devfreaks.tripper.repositories.AirplaneRepository;\n+import com.devfreaks.tripper.repositories.AirportRepository;\n+import com.devfreaks.tripper.repositories.FlightRepository;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.stereotype.Component;\n+import org.springframework.util.StringUtils;\n+import org.springframework.validation.Errors;\n+import org.springframework.validation.Validator;\n+import org.apache.commons.validator.routines.DateValidator;\n+import org.apache.commons.validator.routines.DoubleValidator;\n+import java.util.Date;\n+\n+\n+@Component\n+public class FlightValidator implements Validator {\n+\n+    @Autowired\n+    private FlightRepository repository;\n+\n+    @Autowired\n+    private AirportRepository airportRepo;\n+\n+    @Autowired\n+    private AirplaneRepository airplaneRepo;\n+\n+    @Override\n+    public boolean supports(Class<?> aClass) {\n+        return aClass == Flight.class;\n+    }\n+\n+    public void validate(Object o, Errors errors){\n+        Flight flight = (Flight)o;\n+\n+        if (StringUtils.isEmpty(flight.getCode())) {\n+            errors.rejectValue(\"code\", \"required\", \"flight.code.required\");\n+        }\n+\n+        if(airportRepo.findOne(flight.getFrom().getId()) != null){\n+            errors.rejectValue(\"from_airport\", \"required\", \"flight.from_airport.required\");\n+        }\n+\n+        if (airportRepo.findOne(flight.getTo().getId()) != null) {\n+            errors.rejectValue(\"to_airport\", \"required\", \"flight.to_airport.required\");\n+        }\n+\n+        if(flight.getDeparture() != null){","path":"src/main/java/com/devfreaks/tripper/validators/FlightValidator.java","position":50,"original_position":50,"commit_id":"7d2536ff174728e374b6f5e0ac8eb88c34b38ba0","original_commit_id":"7d2536ff174728e374b6f5e0ac8eb88c34b38ba0","user":{"login":"flakron","id":203035,"avatar_url":"https://avatars.githubusercontent.com/u/203035?v=3","gravatar_id":"","url":"https://api.github.com/users/flakron","html_url":"https://github.com/flakron","followers_url":"https://api.github.com/users/flakron/followers","following_url":"https://api.github.com/users/flakron/following{/other_user}","gists_url":"https://api.github.com/users/flakron/gists{/gist_id}","starred_url":"https://api.github.com/users/flakron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flakron/subscriptions","organizations_url":"https://api.github.com/users/flakron/orgs","repos_url":"https://api.github.com/users/flakron/repos","events_url":"https://api.github.com/users/flakron/events{/privacy}","received_events_url":"https://api.github.com/users/flakron/received_events","type":"User","site_admin":false},"body":"departure edhe flight nuk guxojn me kan te njejta","created_at":"2016-05-03T21:00:31Z","updated_at":"2016-05-03T21:00:31Z","html_url":"https://github.com/Dev-Freaks/Tripper-Api/pull/10#discussion_r61955256","pull_request_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/comments/61955256"},"html":{"href":"https://github.com/Dev-Freaks/Tripper-Api/pull/10#discussion_r61955256"},"pull_request":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10","id":66404855,"html_url":"https://github.com/Dev-Freaks/Tripper-Api/pull/10","diff_url":"https://github.com/Dev-Freaks/Tripper-Api/pull/10.diff","patch_url":"https://github.com/Dev-Freaks/Tripper-Api/pull/10.patch","issue_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/10","number":10,"state":"open","locked":false,"title":"Feature/flight crud","user":{"login":"flakron","id":203035,"avatar_url":"https://avatars.githubusercontent.com/u/203035?v=3","gravatar_id":"","url":"https://api.github.com/users/flakron","html_url":"https://github.com/flakron","followers_url":"https://api.github.com/users/flakron/followers","following_url":"https://api.github.com/users/flakron/following{/other_user}","gists_url":"https://api.github.com/users/flakron/gists{/gist_id}","starred_url":"https://api.github.com/users/flakron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flakron/subscriptions","organizations_url":"https://api.github.com/users/flakron/orgs","repos_url":"https://api.github.com/users/flakron/repos","events_url":"https://api.github.com/users/flakron/events{/privacy}","received_events_url":"https://api.github.com/users/flakron/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T22:53:31Z","updated_at":"2016-05-03T21:00:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"036adefe6eac3faf9d6ef72e745ccf1add41bcf3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10/commits","review_comments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10/comments","review_comment_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/10/comments","statuses_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/statuses/7d2536ff174728e374b6f5e0ac8eb88c34b38ba0","head":{"label":"Dev-Freaks:feature/flight-crud","ref":"feature/flight-crud","sha":"7d2536ff174728e374b6f5e0ac8eb88c34b38ba0","user":{"login":"Dev-Freaks","id":7047275,"avatar_url":"https://avatars.githubusercontent.com/u/7047275?v=3","gravatar_id":"","url":"https://api.github.com/users/Dev-Freaks","html_url":"https://github.com/Dev-Freaks","followers_url":"https://api.github.com/users/Dev-Freaks/followers","following_url":"https://api.github.com/users/Dev-Freaks/following{/other_user}","gists_url":"https://api.github.com/users/Dev-Freaks/gists{/gist_id}","starred_url":"https://api.github.com/users/Dev-Freaks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dev-Freaks/subscriptions","organizations_url":"https://api.github.com/users/Dev-Freaks/orgs","repos_url":"https://api.github.com/users/Dev-Freaks/repos","events_url":"https://api.github.com/users/Dev-Freaks/events{/privacy}","received_events_url":"https://api.github.com/users/Dev-Freaks/received_events","type":"Organization","site_admin":false},"repo":{"id":54224814,"name":"Tripper-Api","full_name":"Dev-Freaks/Tripper-Api","owner":{"login":"Dev-Freaks","id":7047275,"avatar_url":"https://avatars.githubusercontent.com/u/7047275?v=3","gravatar_id":"","url":"https://api.github.com/users/Dev-Freaks","html_url":"https://github.com/Dev-Freaks","followers_url":"https://api.github.com/users/Dev-Freaks/followers","following_url":"https://api.github.com/users/Dev-Freaks/following{/other_user}","gists_url":"https://api.github.com/users/Dev-Freaks/gists{/gist_id}","starred_url":"https://api.github.com/users/Dev-Freaks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dev-Freaks/subscriptions","organizations_url":"https://api.github.com/users/Dev-Freaks/orgs","repos_url":"https://api.github.com/users/Dev-Freaks/repos","events_url":"https://api.github.com/users/Dev-Freaks/events{/privacy}","received_events_url":"https://api.github.com/users/Dev-Freaks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Dev-Freaks/Tripper-Api","description":"","fork":false,"url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api","forks_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/forks","keys_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/teams","hooks_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/hooks","issue_events_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/events{/number}","events_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/events","assignees_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/assignees{/user}","branches_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/branches{/branch}","tags_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/tags","blobs_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/statuses/{sha}","languages_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/languages","stargazers_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/stargazers","contributors_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/contributors","subscribers_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/subscribers","subscription_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/subscription","commits_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/contents/{+path}","compare_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/merges","archive_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/downloads","issues_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues{/number}","pulls_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls{/number}","milestones_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/milestones{/number}","notifications_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/labels{/name}","releases_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/releases{/id}","deployments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/deployments","created_at":"2016-03-18T18:57:26Z","updated_at":"2016-03-20T21:20:56Z","pushed_at":"2016-05-03T16:22:13Z","git_url":"git://github.com/Dev-Freaks/Tripper-Api.git","ssh_url":"git@github.com:Dev-Freaks/Tripper-Api.git","clone_url":"https://github.com/Dev-Freaks/Tripper-Api.git","svn_url":"https://github.com/Dev-Freaks/Tripper-Api","homepage":null,"size":79,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"Dev-Freaks:master","ref":"master","sha":"0490b049f56b40ca93d0552c9a365a316c1bab70","user":{"login":"Dev-Freaks","id":7047275,"avatar_url":"https://avatars.githubusercontent.com/u/7047275?v=3","gravatar_id":"","url":"https://api.github.com/users/Dev-Freaks","html_url":"https://github.com/Dev-Freaks","followers_url":"https://api.github.com/users/Dev-Freaks/followers","following_url":"https://api.github.com/users/Dev-Freaks/following{/other_user}","gists_url":"https://api.github.com/users/Dev-Freaks/gists{/gist_id}","starred_url":"https://api.github.com/users/Dev-Freaks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dev-Freaks/subscriptions","organizations_url":"https://api.github.com/users/Dev-Freaks/orgs","repos_url":"https://api.github.com/users/Dev-Freaks/repos","events_url":"https://api.github.com/users/Dev-Freaks/events{/privacy}","received_events_url":"https://api.github.com/users/Dev-Freaks/received_events","type":"Organization","site_admin":false},"repo":{"id":54224814,"name":"Tripper-Api","full_name":"Dev-Freaks/Tripper-Api","owner":{"login":"Dev-Freaks","id":7047275,"avatar_url":"https://avatars.githubusercontent.com/u/7047275?v=3","gravatar_id":"","url":"https://api.github.com/users/Dev-Freaks","html_url":"https://github.com/Dev-Freaks","followers_url":"https://api.github.com/users/Dev-Freaks/followers","following_url":"https://api.github.com/users/Dev-Freaks/following{/other_user}","gists_url":"https://api.github.com/users/Dev-Freaks/gists{/gist_id}","starred_url":"https://api.github.com/users/Dev-Freaks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dev-Freaks/subscriptions","organizations_url":"https://api.github.com/users/Dev-Freaks/orgs","repos_url":"https://api.github.com/users/Dev-Freaks/repos","events_url":"https://api.github.com/users/Dev-Freaks/events{/privacy}","received_events_url":"https://api.github.com/users/Dev-Freaks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Dev-Freaks/Tripper-Api","description":"","fork":false,"url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api","forks_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/forks","keys_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/teams","hooks_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/hooks","issue_events_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/events{/number}","events_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/events","assignees_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/assignees{/user}","branches_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/branches{/branch}","tags_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/tags","blobs_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/statuses/{sha}","languages_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/languages","stargazers_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/stargazers","contributors_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/contributors","subscribers_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/subscribers","subscription_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/subscription","commits_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/contents/{+path}","compare_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/merges","archive_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/downloads","issues_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues{/number}","pulls_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls{/number}","milestones_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/milestones{/number}","notifications_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/labels{/name}","releases_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/releases{/id}","deployments_url":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/deployments","created_at":"2016-03-18T18:57:26Z","updated_at":"2016-03-20T21:20:56Z","pushed_at":"2016-05-03T16:22:13Z","git_url":"git://github.com/Dev-Freaks/Tripper-Api.git","ssh_url":"git@github.com:Dev-Freaks/Tripper-Api.git","clone_url":"https://github.com/Dev-Freaks/Tripper-Api.git","svn_url":"https://github.com/Dev-Freaks/Tripper-Api","homepage":null,"size":79,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10"},"html":{"href":"https://github.com/Dev-Freaks/Tripper-Api/pull/10"},"issue":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/10"},"comments":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/Dev-Freaks/Tripper-Api/statuses/7d2536ff174728e374b6f5e0ac8eb88c34b38ba0"}}}}