Skip to content

Commit

Permalink
feat: Some improvements to how jobs json and the mock_jobid example
Browse files Browse the repository at this point in the history
  • Loading branch information
biomadeira committed Aug 10, 2022
1 parent afd0535 commit 866311a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/functional-predictions-webcomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ export class CanvasRendererComponent extends LitElement {
const sssJsonData = validateSubmittedJobIdInput(this.data);
const sssJsonResponse = await fetchData(sssJsonData);
const sssDataObj = dataAsType(sssJsonResponse, "SSSResultModel");

const iprmcXmlData = validateSubmittedDbfetchInput(sssDataObj);
// jobID has been validated
let iprmcXmlData;
if (this.data ===
"mock_jobid-I20200317-103136-0485-5599422-np2"
) {
iprmcXmlData = "https://raw.githubusercontent.com/ebi-jdispatcher/jdispatcher-viewers/master/src/testdata/iprmc.xml";
} else {
iprmcXmlData = validateSubmittedDbfetchInput(sssDataObj);
}
const iprmcXmlResponse = await fetchData(iprmcXmlData, "xml");
// convert XML into Flattened JSON
const iprmcJSONResponse = getIPRMCDataModelFlatFromXML(
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class JobIdInputForm {
if (jobId === "mock_jobid-I20200317-103136-0485-5599422-np2") {
canvasInstance.addCanvas(
jobId,
"../src/testdata/ncbiblast.json",
"testdata/ncbiblast.json",
submittedEvent.submitter.name.trim()
);
} else {
Expand Down Expand Up @@ -203,7 +203,7 @@ class FabricjsRenderer {
this.canvasInstance.jobId ===
"mock_jobid-I20200317-103136-0485-5599422-np2"
) {
iprmcXmlData = "../src/testdata/iprmc.xml";
iprmcXmlData = "testdata/iprmc.xml";
} else {
iprmcXmlData = validateSubmittedDbfetchInput(dataObj);
}
Expand Down
11 changes: 10 additions & 1 deletion src/other-utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ export function dataAsType(data: any, dtype: string) {

export function getJdispatcherJsonURL(jobId: string) {
const toolName = jobId.split("-")[0];
return `https://wwwdev.ebi.ac.uk/Tools/services/rest/${toolName}/result/${jobId}/jdp?format=json`;
if (jobId === "mock_jobid-I20200317-103136-0485-5599422-np2") {
// mock jobId
return "https://raw.githubusercontent.com/ebi-jdispatcher/jdispatcher-viewers/master/src/testdata/ncbiblast.json";
} else if (jobId.endsWith("-np2")) {
// wwwdev server (-np2$)
return `https://wwwdev.ebi.ac.uk/Tools/services/rest/${toolName}/result/${jobId}/json`;
} else {
// production servers (-p1m$ and -p2m$)
return `https://www.ebi.ac.uk/Tools/services/rest/${toolName}/result/${jobId}/json`;
}
}

export function validateJobId(
Expand Down

0 comments on commit 866311a

Please sign in to comment.