Skip to content

Commit

Permalink
[CAT-205] Add result file version to workflow submission query (#43)
Browse files Browse the repository at this point in the history
* result file version as optional input

* remove accidentaly space
  • Loading branch information
goatrocks authored Apr 27, 2022
1 parent cbbd667 commit 134ae25
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
22 changes: 18 additions & 4 deletions src/main/java/com/indico/mutation/WorkflowSubmission.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import com.indico.IndicoClient
import com.indico.exceptions.IndicoMutationException
import com.indico.graphql.WorkflowSubmissionGraphQL
import com.indico.graphql.inputs.FileInput
import com.indico.graphql.enums.SubmissionResultVersion as GraphQlResultVersion
import com.indico.type.SubmissionResultVersion
import org.apache.logging.log4j.LogManager
import org.json.JSONArray
import java.io.IOException
import java.util.*

Expand All @@ -15,6 +16,7 @@ class WorkflowSubmission(private val client: IndicoClient) : Mutation<List<Int?>
private var id = 0
private var duplicationId: UUID? = null
private var streams: Map<String, ByteArray>? = null
private var resultFileVersion: SubmissionResultVersion? = null
private val logger = LogManager.getLogger(javaClass)

/**
Expand Down Expand Up @@ -58,12 +60,16 @@ class WorkflowSubmission(private val client: IndicoClient) : Mutation<List<Int?>
return this
}

fun resultFileVersion(version: SubmissionResultVersion?): WorkflowSubmission{
resultFileVersion = version
return this
}

/**
* Executes request and returns Submissions
* @return Integer List
*/
override fun execute(): List<Int?>? {
var fileMetadata: JSONArray
val files: MutableList<FileInput> = ArrayList<FileInput>()
try {
if (this.files != null) {
Expand All @@ -78,10 +84,18 @@ class WorkflowSubmission(private val client: IndicoClient) : Mutation<List<Int?>
if (duplicationId == null) {
duplicationId = UUID.randomUUID()
}

val resultVersion =
if(resultFileVersion != null)
OptionalInput.Defined(GraphQlResultVersion.valueOf(resultFileVersion.toString()))
else OptionalInput.Undefined

return try {
val call = WorkflowSubmissionGraphQL(
WorkflowSubmissionGraphQL.Variables(
files = files, workflowId = id, duplicationId = OptionalInput.Defined(duplicationId.toString())))
files = files, workflowId = id, duplicationId = OptionalInput.Defined(duplicationId.toString()),
resultVersion = resultVersion
))
val response = client.execute(call)
handleErrors(response)
val workflowSubmission = response.data!!.workflowSubmission!!
Expand All @@ -95,4 +109,4 @@ class WorkflowSubmission(private val client: IndicoClient) : Mutation<List<Int?>
throw IndicoMutationException("Call to submit submission failed", ex)
}
}
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/indico/type/SubmissionResultVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.indico.type

/***
* Submission results file version.
*/
enum class SubmissionResultVersion {
ONE,
TWO,
THREE,
LATEST,
OLDEST_SUPPORTED
}
4 changes: 2 additions & 2 deletions src/main/resources/WorkflowSubmissionGraphQL.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation WorkflowSubmissionGraphQL($duplicationId: String, $workflowId: Int!, $files: [FileInput]!, $recordSubmission: Boolean) {
workflowSubmission(duplicationId: $duplicationId, workflowId: $workflowId, files: $files, recordSubmission: $recordSubmission) {
mutation WorkflowSubmissionGraphQL($duplicationId: String, $workflowId: Int!, $files: [FileInput]!, $resultVersion:SubmissionResultVersion) {
workflowSubmission(duplicationId: $duplicationId, workflowId: $workflowId, files: $files, resultVersion: $resultVersion) {
submissionIds
isDuplicateRequest
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,7 @@ enum SubmissionResultVersion {
OLDEST_SUPPORTED
ONE
TWO
THREE
}

"An enumeration."
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/indico/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.indico.storage.Blob;
import com.indico.storage.RetrieveBlob;
import com.indico.type.JobStatus;
import com.indico.type.SubmissionResultVersion;
import com.indico.type.SubmissionStatus;

import java.util.ArrayList;
Expand Down

0 comments on commit 134ae25

Please sign in to comment.