{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments/33078552","id":33078552,"diff_hunk":"@@ -0,0 +1,310 @@\n+package cromwell.engine.db.slick\n+\n+import java.util.{UUID, Date}\n+\n+import cromwell.binding.Call\n+import cromwell.binding.types.WdlType\n+import cromwell.binding.values.{WdlPrimitive, WdlValue}\n+import cromwell.engine.db._\n+import cromwell.engine.store.ExecutionStore.ExecutionStatus\n+import cromwell.engine.store.SymbolStore.SymbolStoreKey\n+import cromwell.engine.store.SymbolStoreEntry\n+import cromwell.engine.{WorkflowId, WorkflowState, WorkflowSubmitted}\n+import cromwell.util.DatabaseConfig\n+\n+import scala.concurrent.duration.Duration\n+import scala.concurrent.{ExecutionContext, Await, Future}\n+import scala.language.implicitConversions\n+\n+// TODO: Need lots of refactoring including: better futures handling, compiled queries, utility functions, etc.\n+object DataAccessController extends DataAccess {\n+  val dataAccess = new DataAccessComponent(DatabaseConfig.slickDriver)\n+\n+  import dataAccess.driver.api._\n+\n+  def database: Database = Database.forConfig(\"\", DatabaseConfig.databaseConfig)\n+\n+  // TODO: Pass in the execution context instead of using the global!!\n+  private implicit val executionContext = ExecutionContext.global\n+\n+  private implicit def date2timestamp(date: java.util.Date): java.sql.Timestamp =\n+    new java.sql.Timestamp(date.getTime)\n+\n+  // WdlValues have multiple ways they coerce back. This currently decoerces for a proper round trip.\n+  // TODO: Refactor into the type?\n+  private def wdlValueToString(wdlValue: WdlValue) = {\n+    wdlValue match {\n+      case wdlPrimitive: WdlPrimitive => wdlPrimitive.asString\n+      case other => other.toString\n+    }\n+  }\n+\n+  // Will stamp the start_dt column with DateTime.Now.\n+  // Will stamp the WorkflowState as Submitted.\n+  override def createWorkflow(id: WorkflowId, wdlUri: String, symbols: Seq[SymbolStoreEntry]): Unit = {\n+    val insertFuture: Future[Unit] = database.run((for {\n+      workflowExecutionInsert <- dataAccess.insertWorkflowExecution(\n+        new WorkflowExecution(id.toString, wdlUri, WorkflowSubmitted.toString, new Date())\n+      )\n+      symbolsInserts <- dataAccess.insertSymbols(\n+        symbols map { symbol =>\n+          new Symbol(\n+            workflowExecutionInsert.workflowExecutionId.get,\n+            symbol.key.scope, symbol.key.name, symbol.key.iteration,\n+            if (symbol.isInput) \"INPUT\" else \"OUTPUT\",\n+            symbol.wdlType.toWdlString, symbol.wdlValue.map(wdlValueToString).orNull)\n+        }\n+      )\n+    } yield ()).transactionally)\n+    // TODO: Return Future[Unit] instead of Unit?\n+    Await.result(insertFuture, Duration.Inf)\n+  }\n+\n+  override def updateCall(workflowId: WorkflowId, call: Call, notUsedByMethod: Option[CallStatus],\n+                          callInfoOption: Option[CallInfo], symbolsOption: Option[Seq[SymbolStoreEntry]]): Unit = {\n+    val workflowExecutionSelect = dataAccess.workflowExecutions.filter(\n+      _.workflowExecutionUuid === workflowId.toString).result.head\n+\n+    val callInsertsOrUpdates = callInfoOption map { callInfo =>","path":"src/main/scala/cromwell/engine/db/slick/DataAccessController.scala","position":68,"original_position":68,"commit_id":"3e16161a1e4c49f8f4d1de4d44f2cf84c15e6e04","original_commit_id":"3e16161a1e4c49f8f4d1de4d44f2cf84c15e6e04","user":{"login":"geoffjentry","id":961771,"avatar_url":"https://avatars.githubusercontent.com/u/961771?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffjentry","html_url":"https://github.com/geoffjentry","followers_url":"https://api.github.com/users/geoffjentry/followers","following_url":"https://api.github.com/users/geoffjentry/following{/other_user}","gists_url":"https://api.github.com/users/geoffjentry/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffjentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffjentry/subscriptions","organizations_url":"https://api.github.com/users/geoffjentry/orgs","repos_url":"https://api.github.com/users/geoffjentry/repos","events_url":"https://api.github.com/users/geoffjentry/events{/privacy}","received_events_url":"https://api.github.com/users/geoffjentry/received_events","type":"User","site_admin":false},"body":"I prefer keeping combinators and cases either single calls or a small closure. Also if the interior blocks were narrowed down to simpler calls I suspect this will naturally start morphing into a for comprehension (as it's a `map` which contains a bunch of `flatMap`s)","created_at":"2015-06-23T19:01:29Z","updated_at":"2015-06-23T19:01:29Z","html_url":"https://github.com/broadinstitute/cromwell/pull/56#discussion_r33078552","pull_request_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments/33078552"},"html":{"href":"https://github.com/broadinstitute/cromwell/pull/56#discussion_r33078552"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56","id":38168513,"html_url":"https://github.com/broadinstitute/cromwell/pull/56","diff_url":"https://github.com/broadinstitute/cromwell/pull/56.diff","patch_url":"https://github.com/broadinstitute/cromwell/pull/56.patch","issue_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/56","number":56,"state":"open","locked":false,"title":"WIP: Persistence","user":{"login":"geoffjentry","id":961771,"avatar_url":"https://avatars.githubusercontent.com/u/961771?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffjentry","html_url":"https://github.com/geoffjentry","followers_url":"https://api.github.com/users/geoffjentry/followers","following_url":"https://api.github.com/users/geoffjentry/following{/other_user}","gists_url":"https://api.github.com/users/geoffjentry/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffjentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffjentry/subscriptions","organizations_url":"https://api.github.com/users/geoffjentry/orgs","repos_url":"https://api.github.com/users/geoffjentry/repos","events_url":"https://api.github.com/users/geoffjentry/events{/privacy}","received_events_url":"https://api.github.com/users/geoffjentry/received_events","type":"User","site_admin":false},"body":"We've hit a point where we should start iterating on code review.\r\n\r\nRules: Pay attention, if someone comments on one of your changes, you're the responsible party","created_at":"2015-06-20T14:00:17Z","updated_at":"2015-06-23T19:01:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29ae928eab2f86af235cd8e3b9df4e2b0ae83701","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/56/comments","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/3e16161a1e4c49f8f4d1de4d44f2cf84c15e6e04","head":{"label":"broadinstitute:persistence","ref":"persistence","sha":"3e16161a1e4c49f8f4d1de4d44f2cf84c15e6e04","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34136406,"name":"cromwell","full_name":"broadinstitute/cromwell","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/cromwell","description":"Workflow Execution Engine using WDL","fork":false,"url":"https://api.github.com/repos/broadinstitute/cromwell","forks_url":"https://api.github.com/repos/broadinstitute/cromwell/forks","keys_url":"https://api.github.com/repos/broadinstitute/cromwell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/cromwell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/cromwell/teams","hooks_url":"https://api.github.com/repos/broadinstitute/cromwell/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/cromwell/events","assignees_url":"https://api.github.com/repos/broadinstitute/cromwell/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/cromwell/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/cromwell/tags","blobs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/cromwell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/cromwell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/cromwell/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/cromwell/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/cromwell/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/cromwell/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/cromwell/subscription","commits_url":"https://api.github.com/repos/broadinstitute/cromwell/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/cromwell/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/cromwell/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/cromwell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/cromwell/merges","archive_url":"https://api.github.com/repos/broadinstitute/cromwell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/cromwell/downloads","issues_url":"https://api.github.com/repos/broadinstitute/cromwell/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/cromwell/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/cromwell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/cromwell/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/cromwell/releases{/id}","created_at":"2015-04-17T19:39:36Z","updated_at":"2015-06-17T07:32:01Z","pushed_at":"2015-06-23T18:49:40Z","git_url":"git://github.com/broadinstitute/cromwell.git","ssh_url":"git@github.com:broadinstitute/cromwell.git","clone_url":"https://github.com/broadinstitute/cromwell.git","svn_url":"https://github.com/broadinstitute/cromwell","homepage":"http://broadinstitute.github.io/cromwell/","size":2978,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":4,"default_branch":"master"}},"base":{"label":"broadinstitute:develop","ref":"develop","sha":"4a03dc35cf296bc49719b7c38733083678eafea9","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":34136406,"name":"cromwell","full_name":"broadinstitute/cromwell","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/cromwell","description":"Workflow Execution Engine using WDL","fork":false,"url":"https://api.github.com/repos/broadinstitute/cromwell","forks_url":"https://api.github.com/repos/broadinstitute/cromwell/forks","keys_url":"https://api.github.com/repos/broadinstitute/cromwell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/cromwell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/cromwell/teams","hooks_url":"https://api.github.com/repos/broadinstitute/cromwell/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/cromwell/events","assignees_url":"https://api.github.com/repos/broadinstitute/cromwell/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/cromwell/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/cromwell/tags","blobs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/cromwell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/cromwell/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/cromwell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/cromwell/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/cromwell/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/cromwell/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/cromwell/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/cromwell/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/cromwell/subscription","commits_url":"https://api.github.com/repos/broadinstitute/cromwell/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/cromwell/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/cromwell/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/cromwell/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/cromwell/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/cromwell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/cromwell/merges","archive_url":"https://api.github.com/repos/broadinstitute/cromwell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/cromwell/downloads","issues_url":"https://api.github.com/repos/broadinstitute/cromwell/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/cromwell/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/cromwell/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/cromwell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/cromwell/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/cromwell/releases{/id}","created_at":"2015-04-17T19:39:36Z","updated_at":"2015-06-17T07:32:01Z","pushed_at":"2015-06-23T18:49:40Z","git_url":"git://github.com/broadinstitute/cromwell.git","ssh_url":"git@github.com:broadinstitute/cromwell.git","clone_url":"https://github.com/broadinstitute/cromwell.git","svn_url":"https://github.com/broadinstitute/cromwell","homepage":"http://broadinstitute.github.io/cromwell/","size":2978,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56"},"html":{"href":"https://github.com/broadinstitute/cromwell/pull/56"},"issue":{"href":"https://api.github.com/repos/broadinstitute/cromwell/issues/56"},"comments":{"href":"https://api.github.com/repos/broadinstitute/cromwell/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/cromwell/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/cromwell/statuses/3e16161a1e4c49f8f4d1de4d44f2cf84c15e6e04"}}}}