{"action":"created","comment":{"url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/comments/25176000","id":25176000,"diff_hunk":"@@ -0,0 +1,201 @@\n+package uk.ac.cam.cl.echo.extrusionfinder.server.sourcer.crawlers;\n+\n+import uk.ac.cam.cl.echo.extrusionfinder.server.parts.Part;\n+import uk.ac.cam.cl.echo.extrusionfinder.server.parts.Size.Unit;\n+import uk.ac.cam.cl.echo.extrusionfinder.server.parts.Size;\n+import uk.ac.cam.cl.echo.extrusionfinder.server.sourcer.metadata.MetadataParser;\n+import uk.ac.cam.cl.echo.extrusionfinder.server.sourcer.metadata.MetadataParserException;\n+\n+import edu.uci.ics.crawler4j.crawler.Page;\n+import edu.uci.ics.crawler4j.parser.HtmlParseData;\n+import edu.uci.ics.crawler4j.url.WebURL;\n+\n+import java.util.regex.Pattern;\n+import java.util.regex.Matcher;\n+import java.util.List;\n+\n+import org.jsoup.nodes.Element;\n+import org.jsoup.select.Elements;\n+\n+/**\n+ * Seagate Plastics specific crawler (part sourcer).\n+ */\n+\n+public class SeagateCrawler extends ExtendedCrawler {\n+\n+    /* Vendor specific unique id */\n+    public static final String MANUFACTURER_ID = \"1\";\n+\n+    /* This is where we start our search */\n+    private static final String[] SEEDS = { \"http://seagateplastics.com/\" };\n+\n+    /* We are not interested in entering pages with these file endings */\n+    private final static Pattern FILTERS =\n+        Pattern.compile(\".*(\\\\.(css|js|gif|jpe?g|png|mp3|mp3|zip|gz|pdf))$\");\n+\n+    /* This pattern is used to find bad Seagate link (see details at usage) */\n+    private static final Pattern FAULTY_PDF_FILTER =\n+        Pattern.compile(\".*[a-zA-Z0-9].pdf\");\n+\n+    /* Patterns for extracting metadata.\n+     * 0: 3.4 DIA. MM\n+     * 1: 1.2 OD X 2.3 ID IN\n+     * 2: 0.125 X 3.0 IN\n+     * 3: 0.325 MM\n+     */\n+    private static final String F = MetadataParser.floatRegex();\n+    private static final Pattern[] METADATA_FILTERS = new Pattern[] {\n+            Pattern.compile(\"((\"+ F +\")( )DIA. (MM|IN)) (.*)\"),\n+            Pattern.compile(\"((\"+ F +\") OD [xX] (\"+ F +\") ID (MM|IN)) (.*)\"),\n+            Pattern.compile(\"((\"+ F +\") [xX] (\"+ F +\") (MM|IN)) (.*)\"),\n+            Pattern.compile(\"((\"+ F +\")( )(MM|IN)) (.*)\")\n+    };\n+\n+    /* This is the stream that we manipulate via side effects.\n+     * Note that if used, it HAS to be assigned with configure method.\n+     */\n+    private static List<Part> parts;\n+\n+    /**\n+     * {@inheritDoc}\n+     */\n+    @Override\n+    public void configure(List<Part> parts) {\n+        this.parts = parts;\n+    }\n+\n+    /**\n+     * {@inheritDoc}\n+     */\n+    @Override\n+    public String[] getSeeds() {\n+        return SEEDS;\n+    }\n+\n+    /**\n+     * {@inheritDoc}\n+     */\n+    @Override\n+    public String getManufacturerId() {\n+        return MANUFACTURER_ID;\n+    }\n+\n+    /**\n+     * Filters out the pages we want to visit.\n+     * @param referringPage The parent page of this URL\n+     * @param url           The current URL that we want to check\n+     * @return              True if the URL should be visited\n+     */\n+    @Override\n+    public boolean shouldVisit(Page referringPage, WebURL url) {\n+\n+        String href = url.getURL().toLowerCase();\n+        return !FILTERS.matcher(href).matches() && (href.startsWith(SEEDS[0]));\n+    }\n+\n+    /**\n+     * Process the page, namely get information about parts.\n+     * @param page  The fetched page\n+     */\n+    @Override\n+    public void visit(Page page) {\n+\n+        String url = page.getWebURL().getURL();\n+\n+        if (page.getParseData() instanceof HtmlParseData) {","path":"server/src/main/java/uk/ac/cam/cl/echo/extrusionfinder/server/sourcer/crawlers/SeagateCrawler.java","position":105,"original_position":105,"commit_id":"d1a7249db0b866a989360d716a2042514c02244e","original_commit_id":"d1a7249db0b866a989360d716a2042514c02244e","user":{"login":"as2388","id":7963608,"avatar_url":"https://avatars.githubusercontent.com/u/7963608?v=3","gravatar_id":"","url":"https://api.github.com/users/as2388","html_url":"https://github.com/as2388","followers_url":"https://api.github.com/users/as2388/followers","following_url":"https://api.github.com/users/as2388/following{/other_user}","gists_url":"https://api.github.com/users/as2388/gists{/gist_id}","starred_url":"https://api.github.com/users/as2388/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/as2388/subscriptions","organizations_url":"https://api.github.com/users/as2388/orgs","repos_url":"https://api.github.com/users/as2388/repos","events_url":"https://api.github.com/users/as2388/events{/privacy}","received_events_url":"https://api.github.com/users/as2388/received_events","type":"User","site_admin":false},"body":"What else can it be an instanceof? And is it ok to ignore those cases?","created_at":"2015-02-23T16:12:41Z","updated_at":"2015-02-23T16:12:41Z","html_url":"https://github.com/oscarkey/extrusionfinder/pull/34#discussion_r25176000","pull_request_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/comments/25176000"},"html":{"href":"https://github.com/oscarkey/extrusionfinder/pull/34#discussion_r25176000"},"pull_request":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34","id":29809813,"html_url":"https://github.com/oscarkey/extrusionfinder/pull/34","diff_url":"https://github.com/oscarkey/extrusionfinder/pull/34.diff","patch_url":"https://github.com/oscarkey/extrusionfinder/pull/34.patch","issue_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/34","number":34,"state":"open","locked":false,"title":"Implementation of part sourcer + tests, added size field to part","user":{"login":"ihc","id":3596158,"avatar_url":"https://avatars.githubusercontent.com/u/3596158?v=3","gravatar_id":"","url":"https://api.github.com/users/ihc","html_url":"https://github.com/ihc","followers_url":"https://api.github.com/users/ihc/followers","following_url":"https://api.github.com/users/ihc/following{/other_user}","gists_url":"https://api.github.com/users/ihc/gists{/gist_id}","starred_url":"https://api.github.com/users/ihc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ihc/subscriptions","organizations_url":"https://api.github.com/users/ihc/orgs","repos_url":"https://api.github.com/users/ihc/repos","events_url":"https://api.github.com/users/ihc/events{/privacy}","received_events_url":"https://api.github.com/users/ihc/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-23T13:53:01Z","updated_at":"2015-02-23T16:12:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83a8d7ce1181187179af274a17c1344ab31c5d2e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34/commits","review_comments_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34/comments","review_comment_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/34/comments","statuses_url":"https://api.github.com/repos/oscarkey/extrusionfinder/statuses/d1a7249db0b866a989360d716a2042514c02244e","head":{"label":"oscarkey:sourcer","ref":"sourcer","sha":"d1a7249db0b866a989360d716a2042514c02244e","user":{"login":"oscarkey","id":229659,"avatar_url":"https://avatars.githubusercontent.com/u/229659?v=3","gravatar_id":"","url":"https://api.github.com/users/oscarkey","html_url":"https://github.com/oscarkey","followers_url":"https://api.github.com/users/oscarkey/followers","following_url":"https://api.github.com/users/oscarkey/following{/other_user}","gists_url":"https://api.github.com/users/oscarkey/gists{/gist_id}","starred_url":"https://api.github.com/users/oscarkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscarkey/subscriptions","organizations_url":"https://api.github.com/users/oscarkey/orgs","repos_url":"https://api.github.com/users/oscarkey/repos","events_url":"https://api.github.com/users/oscarkey/events{/privacy}","received_events_url":"https://api.github.com/users/oscarkey/received_events","type":"User","site_admin":false},"repo":{"id":29526681,"name":"extrusionfinder","full_name":"oscarkey/extrusionfinder","owner":{"login":"oscarkey","id":229659,"avatar_url":"https://avatars.githubusercontent.com/u/229659?v=3","gravatar_id":"","url":"https://api.github.com/users/oscarkey","html_url":"https://github.com/oscarkey","followers_url":"https://api.github.com/users/oscarkey/followers","following_url":"https://api.github.com/users/oscarkey/following{/other_user}","gists_url":"https://api.github.com/users/oscarkey/gists{/gist_id}","starred_url":"https://api.github.com/users/oscarkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscarkey/subscriptions","organizations_url":"https://api.github.com/users/oscarkey/orgs","repos_url":"https://api.github.com/users/oscarkey/repos","events_url":"https://api.github.com/users/oscarkey/events{/privacy}","received_events_url":"https://api.github.com/users/oscarkey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oscarkey/extrusionfinder","description":"","fork":false,"url":"https://api.github.com/repos/oscarkey/extrusionfinder","forks_url":"https://api.github.com/repos/oscarkey/extrusionfinder/forks","keys_url":"https://api.github.com/repos/oscarkey/extrusionfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oscarkey/extrusionfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oscarkey/extrusionfinder/teams","hooks_url":"https://api.github.com/repos/oscarkey/extrusionfinder/hooks","issue_events_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/events{/number}","events_url":"https://api.github.com/repos/oscarkey/extrusionfinder/events","assignees_url":"https://api.github.com/repos/oscarkey/extrusionfinder/assignees{/user}","branches_url":"https://api.github.com/repos/oscarkey/extrusionfinder/branches{/branch}","tags_url":"https://api.github.com/repos/oscarkey/extrusionfinder/tags","blobs_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oscarkey/extrusionfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/oscarkey/extrusionfinder/languages","stargazers_url":"https://api.github.com/repos/oscarkey/extrusionfinder/stargazers","contributors_url":"https://api.github.com/repos/oscarkey/extrusionfinder/contributors","subscribers_url":"https://api.github.com/repos/oscarkey/extrusionfinder/subscribers","subscription_url":"https://api.github.com/repos/oscarkey/extrusionfinder/subscription","commits_url":"https://api.github.com/repos/oscarkey/extrusionfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/oscarkey/extrusionfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/oscarkey/extrusionfinder/contents/{+path}","compare_url":"https://api.github.com/repos/oscarkey/extrusionfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oscarkey/extrusionfinder/merges","archive_url":"https://api.github.com/repos/oscarkey/extrusionfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oscarkey/extrusionfinder/downloads","issues_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues{/number}","pulls_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/oscarkey/extrusionfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/oscarkey/extrusionfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oscarkey/extrusionfinder/labels{/name}","releases_url":"https://api.github.com/repos/oscarkey/extrusionfinder/releases{/id}","created_at":"2015-01-20T11:30:03Z","updated_at":"2015-02-23T16:07:35Z","pushed_at":"2015-02-23T16:07:40Z","git_url":"git://github.com/oscarkey/extrusionfinder.git","ssh_url":"git@github.com:oscarkey/extrusionfinder.git","clone_url":"https://github.com/oscarkey/extrusionfinder.git","svn_url":"https://github.com/oscarkey/extrusionfinder","homepage":null,"size":880,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"oscarkey:master","ref":"master","sha":"514f97984b1720ffc06ba4a4666d2f21ded2b7b9","user":{"login":"oscarkey","id":229659,"avatar_url":"https://avatars.githubusercontent.com/u/229659?v=3","gravatar_id":"","url":"https://api.github.com/users/oscarkey","html_url":"https://github.com/oscarkey","followers_url":"https://api.github.com/users/oscarkey/followers","following_url":"https://api.github.com/users/oscarkey/following{/other_user}","gists_url":"https://api.github.com/users/oscarkey/gists{/gist_id}","starred_url":"https://api.github.com/users/oscarkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscarkey/subscriptions","organizations_url":"https://api.github.com/users/oscarkey/orgs","repos_url":"https://api.github.com/users/oscarkey/repos","events_url":"https://api.github.com/users/oscarkey/events{/privacy}","received_events_url":"https://api.github.com/users/oscarkey/received_events","type":"User","site_admin":false},"repo":{"id":29526681,"name":"extrusionfinder","full_name":"oscarkey/extrusionfinder","owner":{"login":"oscarkey","id":229659,"avatar_url":"https://avatars.githubusercontent.com/u/229659?v=3","gravatar_id":"","url":"https://api.github.com/users/oscarkey","html_url":"https://github.com/oscarkey","followers_url":"https://api.github.com/users/oscarkey/followers","following_url":"https://api.github.com/users/oscarkey/following{/other_user}","gists_url":"https://api.github.com/users/oscarkey/gists{/gist_id}","starred_url":"https://api.github.com/users/oscarkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oscarkey/subscriptions","organizations_url":"https://api.github.com/users/oscarkey/orgs","repos_url":"https://api.github.com/users/oscarkey/repos","events_url":"https://api.github.com/users/oscarkey/events{/privacy}","received_events_url":"https://api.github.com/users/oscarkey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oscarkey/extrusionfinder","description":"","fork":false,"url":"https://api.github.com/repos/oscarkey/extrusionfinder","forks_url":"https://api.github.com/repos/oscarkey/extrusionfinder/forks","keys_url":"https://api.github.com/repos/oscarkey/extrusionfinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oscarkey/extrusionfinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oscarkey/extrusionfinder/teams","hooks_url":"https://api.github.com/repos/oscarkey/extrusionfinder/hooks","issue_events_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/events{/number}","events_url":"https://api.github.com/repos/oscarkey/extrusionfinder/events","assignees_url":"https://api.github.com/repos/oscarkey/extrusionfinder/assignees{/user}","branches_url":"https://api.github.com/repos/oscarkey/extrusionfinder/branches{/branch}","tags_url":"https://api.github.com/repos/oscarkey/extrusionfinder/tags","blobs_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oscarkey/extrusionfinder/statuses/{sha}","languages_url":"https://api.github.com/repos/oscarkey/extrusionfinder/languages","stargazers_url":"https://api.github.com/repos/oscarkey/extrusionfinder/stargazers","contributors_url":"https://api.github.com/repos/oscarkey/extrusionfinder/contributors","subscribers_url":"https://api.github.com/repos/oscarkey/extrusionfinder/subscribers","subscription_url":"https://api.github.com/repos/oscarkey/extrusionfinder/subscription","commits_url":"https://api.github.com/repos/oscarkey/extrusionfinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/oscarkey/extrusionfinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/oscarkey/extrusionfinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/oscarkey/extrusionfinder/contents/{+path}","compare_url":"https://api.github.com/repos/oscarkey/extrusionfinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oscarkey/extrusionfinder/merges","archive_url":"https://api.github.com/repos/oscarkey/extrusionfinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oscarkey/extrusionfinder/downloads","issues_url":"https://api.github.com/repos/oscarkey/extrusionfinder/issues{/number}","pulls_url":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls{/number}","milestones_url":"https://api.github.com/repos/oscarkey/extrusionfinder/milestones{/number}","notifications_url":"https://api.github.com/repos/oscarkey/extrusionfinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oscarkey/extrusionfinder/labels{/name}","releases_url":"https://api.github.com/repos/oscarkey/extrusionfinder/releases{/id}","created_at":"2015-01-20T11:30:03Z","updated_at":"2015-02-23T16:07:35Z","pushed_at":"2015-02-23T16:07:40Z","git_url":"git://github.com/oscarkey/extrusionfinder.git","ssh_url":"git@github.com:oscarkey/extrusionfinder.git","clone_url":"https://github.com/oscarkey/extrusionfinder.git","svn_url":"https://github.com/oscarkey/extrusionfinder","homepage":null,"size":880,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34"},"html":{"href":"https://github.com/oscarkey/extrusionfinder/pull/34"},"issue":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/34"},"comments":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/oscarkey/extrusionfinder/statuses/d1a7249db0b866a989360d716a2042514c02244e"}}}}