{"action":"created","comment":{"url":"https://api.github.com/repos/qualfacul/hades/pulls/comments/71768191","id":71768191,"diff_hunk":"@@ -0,0 +1,135 @@\n+package com.qualfacul.hades.mec;\n+\n+import static java.lang.Double.parseDouble;\n+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Optional;\n+\n+import org.jsoup.nodes.Element;\n+import org.jsoup.select.Elements;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.stereotype.Service;\n+\n+import com.qualfacul.hades.college.College;\n+import com.qualfacul.hades.college.CollegeAddress;\n+import com.qualfacul.hades.college.CollegeAddressRepository;\n+import com.qualfacul.hades.course.Course;\n+import com.qualfacul.hades.course.CourseDegree;\n+import com.qualfacul.hades.course.CourseGrade;\n+import com.qualfacul.hades.course.CourseGradeOrigin;\n+import com.qualfacul.hades.course.CourseGradeRepository;\n+import com.qualfacul.hades.course.CourseModality;\n+\n+@Service\n+public class MecCourseService {\n+\n+\tprivate List<String> invalidCoursesName = new ArrayList<>();\n+\tprivate static final Logger LOGGER = LoggerFactory.getLogger(MecCourseService.class);\n+\t\n+\t@Autowired\n+\tprivate CollegeAddressRepository collegeAddressRepository;\t\n+\t@Autowired\n+\tprivate CourseGradeRepository courseGradeRepository;\n+\t\n+\t\n+\tpublic MecCourseService() {\n+\t\tinvalidCoursesName.add(\"Suspensão de Ingresso:\");\n+\t\tinvalidCoursesName.add(\"Vedação de Aumento de Vagas\");\n+\t\tinvalidCoursesName.add(\"Em Desativação/Extinção voluntária\");\n+\t\tinvalidCoursesName.add(\"Medida Cautelar: Suspensão de\");\n+\t\tinvalidCoursesName.add(\": Curso autorizado por \");\n+\t\tinvalidCoursesName.add(\"CPC 2014 não divulgado\");\n+\t}\n+\n+\t@SuppressWarnings(\"deprecation\")\n+\tpublic Course setupCourseInfo(Elements tds) {\n+\t\tCourse course = new Course();\n+\t\tString courseName = tds.get(1).text().trim();\n+\t\tcourseName = ((String) courseName.subSequence(courseName.indexOf(\")\") + 1, courseName.length())).trim();\n+\n+\t\tcourse.setName(courseName);\n+\t\tinvalidCoursesName.forEach(invalidWord -> {\n+\t\t\tint index = course.getName().indexOf(invalidWord);\n+\t\t\tif (index > 0) {\n+\t\t\t\tcourse.setName(course.getName().subSequence(0, index).toString().trim());\n+\t\t\t}\n+\t\t});\n+\n+\t\tString courseDegree = tds.get(2).text().trim();\n+\t\tif (equalsIgnoreCase(courseDegree, \"licenciatura\")) {\n+\t\t\tcourse.setDegree(CourseDegree.GRADUATION);\n+\t\t} else if (equalsIgnoreCase(courseDegree, \"sequencial\")) {\n+\t\t\tcourse.setDegree(CourseDegree.SEQUENTIAL);\n+\t\t} else if (equalsIgnoreCase(courseDegree, \"tecnologico\")) {\n+\t\t\tcourse.setDegree(CourseDegree.TECHNOLOGIST);\n+\t\t} else {\n+\t\t\tcourse.setDegree(CourseDegree.BACHELOR);\n+\t\t}\n+\n+\t\tString courseModality = tds.get(3).text().trim();\n+\t\tif (equalsIgnoreCase(courseModality, \"presencial\")) {\n+\t\t\tcourse.setModality(CourseModality.PRESENTIAL);\n+\t\t} else {\n+\t\t\tcourse.setModality(CourseModality.DISTANCE);\n+\t\t}\n+\n+\t\treturn course;\n+\t}\n+\n+\tpublic List<CourseGrade> setupCourseGrades(Elements tds, Course course) {\n+\t\tString cc = tds.get(4).text().trim();\n+\t\tDouble valueCC = null;\n+\t\tif (!equalsIgnoreCase(cc, \"-\") && !equalsIgnoreCase(cc, \"SC\")) {\n+\t\t\tvalueCC = parseDouble(cc);\n+\t\t}\n+\n+\t\tString cpc = tds.get(5).text().trim();\n+\t\tDouble valueCPC = null;\n+\t\tif (!equalsIgnoreCase(cpc, \"-\") && !equalsIgnoreCase(cpc, \"SC\")) {\n+\t\t\tvalueCPC = parseDouble(cpc);\n+\t\t}\n+\n+\t\tString enade = tds.get(6).text().trim();\n+\t\tDouble valueENADE = null;\n+\t\tif (!equalsIgnoreCase(enade, \"-\") && !equalsIgnoreCase(enade, \"SC\")) {\n+\t\t\tvalueENADE = parseDouble(enade);\n+\t\t}\n+\t\tList<CourseGrade> courseGrades = new ArrayList<>();\n+\t\tcourseGrades.add(new CourseGrade(CourseGradeOrigin.CC, valueCC, course));\n+\t\tcourseGrades.add(new CourseGrade(CourseGradeOrigin.CPC, valueCPC, course));\n+\t\tcourseGrades.add(new CourseGrade(CourseGradeOrigin.ENADE, valueENADE, course));\n+\n+\t\treturn courseGrades;\n+\t}\n+\t\n+\t@SuppressWarnings(\"deprecation\")\n+\tpublic CollegeAddress setupCourseAdresses(Element trAddress, College college, List<CourseGrade> courseGrades) {\n+\t\tElements tdsCourse = trAddress.select(\"td\");\n+\t\tCollegeAddress collegeAddress = new CollegeAddress();\n+\t\tcollegeAddress.setAddress(tdsCourse.get(0).text().trim());\n+\t\tcollegeAddress.setCep(tdsCourse.get(1).text().trim());\n+\t\tcollegeAddress.setCity(tdsCourse.get(2).text().trim());\n+\t\tcollegeAddress.setState(tdsCourse.get(3).text().trim());\n+\t\tcollegeAddress.setCollege(college);\n+\t\t\n+\t\tOptional<CollegeAddress> optionalAddress = collegeAddressRepository.findByAddressAndCep(collegeAddress.getAddress(), collegeAddress.getCep());\n+\t\t\n+\t\tif(optionalAddress.isPresent()) {","path":"src/main/java/com/qualfacul/hades/mec/MecCourseService.java","position":121,"original_position":121,"commit_id":"348c3412a45e36d99d0c53e47b339ea55c0e624a","original_commit_id":"348c3412a45e36d99d0c53e47b339ea55c0e624a","user":{"login":"ericdallo","id":7820865,"avatar_url":"https://avatars.githubusercontent.com/u/7820865?v=3","gravatar_id":"","url":"https://api.github.com/users/ericdallo","html_url":"https://github.com/ericdallo","followers_url":"https://api.github.com/users/ericdallo/followers","following_url":"https://api.github.com/users/ericdallo/following{/other_user}","gists_url":"https://api.github.com/users/ericdallo/gists{/gist_id}","starred_url":"https://api.github.com/users/ericdallo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericdallo/subscriptions","organizations_url":"https://api.github.com/users/ericdallo/orgs","repos_url":"https://api.github.com/users/ericdallo/repos","events_url":"https://api.github.com/users/ericdallo/events{/privacy}","received_events_url":"https://api.github.com/users/ericdallo/received_events","type":"User","site_admin":false},"body":"``optionalAddress.ifPresent(-> ...)`` ?","created_at":"2016-07-21T19:10:35Z","updated_at":"2016-07-21T19:10:35Z","html_url":"https://github.com/qualfacul/hades/pull/28#discussion_r71768191","pull_request_url":"https://api.github.com/repos/qualfacul/hades/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/comments/71768191"},"html":{"href":"https://github.com/qualfacul/hades/pull/28#discussion_r71768191"},"pull_request":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/qualfacul/hades/pulls/28","id":76372244,"html_url":"https://github.com/qualfacul/hades/pull/28","diff_url":"https://github.com/qualfacul/hades/pull/28.diff","patch_url":"https://github.com/qualfacul/hades/pull/28.patch","issue_url":"https://api.github.com/repos/qualfacul/hades/issues/28","number":28,"state":"open","locked":false,"title":"[77-fix]  - Buscar todas as faculdades, cursos e notas de faculdade","user":{"login":"andrade-ramon","id":7884943,"avatar_url":"https://avatars.githubusercontent.com/u/7884943?v=3","gravatar_id":"","url":"https://api.github.com/users/andrade-ramon","html_url":"https://github.com/andrade-ramon","followers_url":"https://api.github.com/users/andrade-ramon/followers","following_url":"https://api.github.com/users/andrade-ramon/following{/other_user}","gists_url":"https://api.github.com/users/andrade-ramon/gists{/gist_id}","starred_url":"https://api.github.com/users/andrade-ramon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrade-ramon/subscriptions","organizations_url":"https://api.github.com/users/andrade-ramon/orgs","repos_url":"https://api.github.com/users/andrade-ramon/repos","events_url":"https://api.github.com/users/andrade-ramon/events{/privacy}","received_events_url":"https://api.github.com/users/andrade-ramon/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-06T02:51:39Z","updated_at":"2016-07-21T19:10:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0dc043f107255faaa9d2ac0df5c7115cf544dee","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/qualfacul/hades/pulls/28/commits","review_comments_url":"https://api.github.com/repos/qualfacul/hades/pulls/28/comments","review_comment_url":"https://api.github.com/repos/qualfacul/hades/pulls/comments{/number}","comments_url":"https://api.github.com/repos/qualfacul/hades/issues/28/comments","statuses_url":"https://api.github.com/repos/qualfacul/hades/statuses/348c3412a45e36d99d0c53e47b339ea55c0e624a","head":{"label":"qualfacul:77-fix","ref":"77-fix","sha":"348c3412a45e36d99d0c53e47b339ea55c0e624a","user":{"login":"qualfacul","id":19375297,"avatar_url":"https://avatars.githubusercontent.com/u/19375297?v=3","gravatar_id":"","url":"https://api.github.com/users/qualfacul","html_url":"https://github.com/qualfacul","followers_url":"https://api.github.com/users/qualfacul/followers","following_url":"https://api.github.com/users/qualfacul/following{/other_user}","gists_url":"https://api.github.com/users/qualfacul/gists{/gist_id}","starred_url":"https://api.github.com/users/qualfacul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualfacul/subscriptions","organizations_url":"https://api.github.com/users/qualfacul/orgs","repos_url":"https://api.github.com/users/qualfacul/repos","events_url":"https://api.github.com/users/qualfacul/events{/privacy}","received_events_url":"https://api.github.com/users/qualfacul/received_events","type":"Organization","site_admin":false},"repo":{"id":52395775,"name":"hades","full_name":"qualfacul/hades","owner":{"login":"qualfacul","id":19375297,"avatar_url":"https://avatars.githubusercontent.com/u/19375297?v=3","gravatar_id":"","url":"https://api.github.com/users/qualfacul","html_url":"https://github.com/qualfacul","followers_url":"https://api.github.com/users/qualfacul/followers","following_url":"https://api.github.com/users/qualfacul/following{/other_user}","gists_url":"https://api.github.com/users/qualfacul/gists{/gist_id}","starred_url":"https://api.github.com/users/qualfacul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualfacul/subscriptions","organizations_url":"https://api.github.com/users/qualfacul/orgs","repos_url":"https://api.github.com/users/qualfacul/repos","events_url":"https://api.github.com/users/qualfacul/events{/privacy}","received_events_url":"https://api.github.com/users/qualfacul/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qualfacul/hades","description":"","fork":false,"url":"https://api.github.com/repos/qualfacul/hades","forks_url":"https://api.github.com/repos/qualfacul/hades/forks","keys_url":"https://api.github.com/repos/qualfacul/hades/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qualfacul/hades/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qualfacul/hades/teams","hooks_url":"https://api.github.com/repos/qualfacul/hades/hooks","issue_events_url":"https://api.github.com/repos/qualfacul/hades/issues/events{/number}","events_url":"https://api.github.com/repos/qualfacul/hades/events","assignees_url":"https://api.github.com/repos/qualfacul/hades/assignees{/user}","branches_url":"https://api.github.com/repos/qualfacul/hades/branches{/branch}","tags_url":"https://api.github.com/repos/qualfacul/hades/tags","blobs_url":"https://api.github.com/repos/qualfacul/hades/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qualfacul/hades/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qualfacul/hades/git/refs{/sha}","trees_url":"https://api.github.com/repos/qualfacul/hades/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qualfacul/hades/statuses/{sha}","languages_url":"https://api.github.com/repos/qualfacul/hades/languages","stargazers_url":"https://api.github.com/repos/qualfacul/hades/stargazers","contributors_url":"https://api.github.com/repos/qualfacul/hades/contributors","subscribers_url":"https://api.github.com/repos/qualfacul/hades/subscribers","subscription_url":"https://api.github.com/repos/qualfacul/hades/subscription","commits_url":"https://api.github.com/repos/qualfacul/hades/commits{/sha}","git_commits_url":"https://api.github.com/repos/qualfacul/hades/git/commits{/sha}","comments_url":"https://api.github.com/repos/qualfacul/hades/comments{/number}","issue_comment_url":"https://api.github.com/repos/qualfacul/hades/issues/comments{/number}","contents_url":"https://api.github.com/repos/qualfacul/hades/contents/{+path}","compare_url":"https://api.github.com/repos/qualfacul/hades/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qualfacul/hades/merges","archive_url":"https://api.github.com/repos/qualfacul/hades/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qualfacul/hades/downloads","issues_url":"https://api.github.com/repos/qualfacul/hades/issues{/number}","pulls_url":"https://api.github.com/repos/qualfacul/hades/pulls{/number}","milestones_url":"https://api.github.com/repos/qualfacul/hades/milestones{/number}","notifications_url":"https://api.github.com/repos/qualfacul/hades/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qualfacul/hades/labels{/name}","releases_url":"https://api.github.com/repos/qualfacul/hades/releases{/id}","deployments_url":"https://api.github.com/repos/qualfacul/hades/deployments","created_at":"2016-02-23T22:19:53Z","updated_at":"2016-06-23T19:13:36Z","pushed_at":"2016-07-20T12:27:34Z","git_url":"git://github.com/qualfacul/hades.git","ssh_url":"git@github.com:qualfacul/hades.git","clone_url":"https://github.com/qualfacul/hades.git","svn_url":"https://github.com/qualfacul/hades","homepage":null,"size":319,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"qualfacul:master","ref":"master","sha":"c845fb34ea80c5166f9c07646ea8dfdcc1e047a3","user":{"login":"qualfacul","id":19375297,"avatar_url":"https://avatars.githubusercontent.com/u/19375297?v=3","gravatar_id":"","url":"https://api.github.com/users/qualfacul","html_url":"https://github.com/qualfacul","followers_url":"https://api.github.com/users/qualfacul/followers","following_url":"https://api.github.com/users/qualfacul/following{/other_user}","gists_url":"https://api.github.com/users/qualfacul/gists{/gist_id}","starred_url":"https://api.github.com/users/qualfacul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualfacul/subscriptions","organizations_url":"https://api.github.com/users/qualfacul/orgs","repos_url":"https://api.github.com/users/qualfacul/repos","events_url":"https://api.github.com/users/qualfacul/events{/privacy}","received_events_url":"https://api.github.com/users/qualfacul/received_events","type":"Organization","site_admin":false},"repo":{"id":52395775,"name":"hades","full_name":"qualfacul/hades","owner":{"login":"qualfacul","id":19375297,"avatar_url":"https://avatars.githubusercontent.com/u/19375297?v=3","gravatar_id":"","url":"https://api.github.com/users/qualfacul","html_url":"https://github.com/qualfacul","followers_url":"https://api.github.com/users/qualfacul/followers","following_url":"https://api.github.com/users/qualfacul/following{/other_user}","gists_url":"https://api.github.com/users/qualfacul/gists{/gist_id}","starred_url":"https://api.github.com/users/qualfacul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qualfacul/subscriptions","organizations_url":"https://api.github.com/users/qualfacul/orgs","repos_url":"https://api.github.com/users/qualfacul/repos","events_url":"https://api.github.com/users/qualfacul/events{/privacy}","received_events_url":"https://api.github.com/users/qualfacul/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qualfacul/hades","description":"","fork":false,"url":"https://api.github.com/repos/qualfacul/hades","forks_url":"https://api.github.com/repos/qualfacul/hades/forks","keys_url":"https://api.github.com/repos/qualfacul/hades/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qualfacul/hades/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qualfacul/hades/teams","hooks_url":"https://api.github.com/repos/qualfacul/hades/hooks","issue_events_url":"https://api.github.com/repos/qualfacul/hades/issues/events{/number}","events_url":"https://api.github.com/repos/qualfacul/hades/events","assignees_url":"https://api.github.com/repos/qualfacul/hades/assignees{/user}","branches_url":"https://api.github.com/repos/qualfacul/hades/branches{/branch}","tags_url":"https://api.github.com/repos/qualfacul/hades/tags","blobs_url":"https://api.github.com/repos/qualfacul/hades/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qualfacul/hades/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qualfacul/hades/git/refs{/sha}","trees_url":"https://api.github.com/repos/qualfacul/hades/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qualfacul/hades/statuses/{sha}","languages_url":"https://api.github.com/repos/qualfacul/hades/languages","stargazers_url":"https://api.github.com/repos/qualfacul/hades/stargazers","contributors_url":"https://api.github.com/repos/qualfacul/hades/contributors","subscribers_url":"https://api.github.com/repos/qualfacul/hades/subscribers","subscription_url":"https://api.github.com/repos/qualfacul/hades/subscription","commits_url":"https://api.github.com/repos/qualfacul/hades/commits{/sha}","git_commits_url":"https://api.github.com/repos/qualfacul/hades/git/commits{/sha}","comments_url":"https://api.github.com/repos/qualfacul/hades/comments{/number}","issue_comment_url":"https://api.github.com/repos/qualfacul/hades/issues/comments{/number}","contents_url":"https://api.github.com/repos/qualfacul/hades/contents/{+path}","compare_url":"https://api.github.com/repos/qualfacul/hades/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qualfacul/hades/merges","archive_url":"https://api.github.com/repos/qualfacul/hades/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qualfacul/hades/downloads","issues_url":"https://api.github.com/repos/qualfacul/hades/issues{/number}","pulls_url":"https://api.github.com/repos/qualfacul/hades/pulls{/number}","milestones_url":"https://api.github.com/repos/qualfacul/hades/milestones{/number}","notifications_url":"https://api.github.com/repos/qualfacul/hades/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qualfacul/hades/labels{/name}","releases_url":"https://api.github.com/repos/qualfacul/hades/releases{/id}","deployments_url":"https://api.github.com/repos/qualfacul/hades/deployments","created_at":"2016-02-23T22:19:53Z","updated_at":"2016-06-23T19:13:36Z","pushed_at":"2016-07-20T12:27:34Z","git_url":"git://github.com/qualfacul/hades.git","ssh_url":"git@github.com:qualfacul/hades.git","clone_url":"https://github.com/qualfacul/hades.git","svn_url":"https://github.com/qualfacul/hades","homepage":null,"size":319,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/28"},"html":{"href":"https://github.com/qualfacul/hades/pull/28"},"issue":{"href":"https://api.github.com/repos/qualfacul/hades/issues/28"},"comments":{"href":"https://api.github.com/repos/qualfacul/hades/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/qualfacul/hades/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/qualfacul/hades/statuses/348c3412a45e36d99d0c53e47b339ea55c0e624a"}}}}
{"actor":{"display_login":"ericdallo"}}