Skip to content

Commit

Permalink
without tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asingh7115 committed Jun 10, 2018
1 parent 49d461e commit 39466e0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/scala/org/broadinstitute/dsde/firecloud/EntityClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,24 @@ class EntityClient (requestContext: RequestContext)(implicit protected val execu
// 1. The type of the tsv import file (membership, entity, or update)
// 2. The entity type we're trying to import or update, which is magically verified in the withFoo functions below.
tsv.firstColumnHeader.split(":") match {
case Array( tsvType, entityHeader ) =>
val entityType = entityHeader.stripSuffix("_id")
if( entityType == entityHeader ) {
case h: Array[String] if h.length == 1 || h.length == 2 =>
val entityType = h.last.stripSuffix("_id")
if (entityType == h.last) {
Future(RequestCompleteWithErrorReport(BadRequest, "Invalid first column header, entity type should end in _id"))
} else {
val strippedTsv = backwardsCompatStripIdSuffixes(tsv, entityType)
Try(TsvTypes.withName(tsvType)) match {
case Success(TsvTypes.MEMBERSHIP) => importMembershipTSV (pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Success(TsvTypes.ENTITY) => importEntityTSV (pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Success(TsvTypes.UPDATE) => importUpdateTSV (pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Failure(err) => Future(RequestCompleteWithErrorReport(BadRequest, err.toString))
if (h.length == 1) {
importEntityTSV(pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
} else {
Try(TsvTypes.withName(h.head)) match {
case Success(TsvTypes.MEMBERSHIP) => importMembershipTSV(pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Success(TsvTypes.ENTITY) => importEntityTSV(pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Success(TsvTypes.UPDATE) => importUpdateTSV(pipeline, workspaceNamespace, workspaceName, strippedTsv, entityType)
case Failure(err) => Future(RequestCompleteWithErrorReport(BadRequest, err.toString))
}
}
}
case _ =>
Future(RequestCompleteWithErrorReport(BadRequest, "Invalid first column header, should look like tsvType:entity_type_id"))
case _ => Future(RequestCompleteWithErrorReport(BadRequest, "Invalid first column header, should look like tsvType:entity_type_id"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ object MockTSVFormData {
val updateWithRequiredAttrs = wrapInMultipart("entities", MockTSVStrings.updateWithRequiredAttrs)
val updateWithRequiredAndOptionalAttrs = wrapInMultipart("entities", MockTSVStrings.updateWithRequiredAndOptionalAttrs)

val defaultHasNoRows = wrapInMultipart("", MockTSVStrings.entityHasNoRows)
val defaultUpdateWithRequiredAttrs = wrapInMultipart("", MockTSVStrings.entityUpdateWithRequiredAttrs)
val defaultUpdateWithRequiredAndOptionalAttrs = wrapInMultipart("", MockTSVStrings.entityUpdateWithRequiredAndOptionalAttrs)

val addNewWorkspaceAttributes = wrapInMultipart("attributes", MockTSVStrings.addNewWorkspaceAttributes)
val duplicateKeysWorkspaceAttributes = wrapInMultipart("attributes", MockTSVStrings.duplicateKeysWorkspaceAttributes)
val wrongHeaderWorkspaceAttributes = wrapInMultipart("attributes", MockTSVStrings.wrongHeaderWorkspaceAttributes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,41 @@ class WorkspaceApiServiceSpec extends BaseServiceSpec with WorkspaceApiService w
}
}
}

// "a default-type TSV" - {
// "that follows the same format as an entity-type TSV" - {
// "should 200 OK if there's no data" in {
// stubRawlsService(HttpMethods.POST, batchUpsertPath, NoContent)
// (Post(tsvImportPath, MockTSVFormData.defaultHasNoRows)
// ~> dummyUserIdHeaders("1234")
// ~> sealRoute(workspaceRoutes)) ~> check {
// status should equal(OK)
// }
// }
//
// "should 200 OK if it has the full set of required attribute headers" in {
// stubRawlsService(HttpMethods.POST, batchUpsertPath, NoContent)
// (Post(tsvImportPath, MockTSVFormData.defaultUpdateWithRequiredAttrs)
// ~> dummyUserIdHeaders("1234")
// ~> sealRoute(workspaceRoutes)) ~> check {
// status should equal(OK)
// }
// }
//
// "should 200 OK if it has the full set of required attribute headers, plus optionals" in {
// stubRawlsService(HttpMethods.POST, batchUpsertPath, NoContent)
// (Post(tsvImportPath, MockTSVFormData.defaultUpdateWithRequiredAndOptionalAttrs)
// ~> dummyUserIdHeaders("1234")
// ~> sealRoute(workspaceRoutes)) ~> check {
// status should equal(OK)
// }
// }
// }
//
// "that follows the same format as a membership-type TSV" - {
//
// }
// }
}
}

Expand Down

0 comments on commit 39466e0

Please sign in to comment.