Skip to content

Commit

Permalink
GDC draft
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Aug 30, 2023
1 parent a550fa6 commit b21c984
Show file tree
Hide file tree
Showing 3 changed files with 453 additions and 3 deletions.
40 changes: 38 additions & 2 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const AuthProvider = require('./authprovider');
const BasicProvider = require('./basicprovider');
const OidcProvider = require('./oidcprovider');

const Capabilities = require('./capabilities');
const { GdcCapabilities, Migrate } = require('./gdc');
const FileTypes = require('./filetypes');
const UserFile = require('./userfile');
const Job = require('./job');
Expand All @@ -18,6 +18,7 @@ const Service = require('./service');
const Builder = require('./builder/builder');
const BuilderNode = require('./builder/node');


const CONFORMANCE_RELS = [
'conformance',
'http://www.opengis.net/def/rel/ogc/1.0/conformance'
Expand Down Expand Up @@ -120,7 +121,8 @@ class Connection {
}
}

this.capabilitiesObject = new Capabilities(data);
Migrate.connection = this;
this.capabilitiesObject = new GdcCapabilities(data);
return this.capabilitiesObject;
}

Expand Down Expand Up @@ -802,6 +804,37 @@ class Connection {
return await pg.describeUserProcess();
}

isOgcProcess(process) {

Check failure on line 807 in src/connection.js

View workflow job for this annotation

GitHub Actions / deploy

Missing JSDoc comment
let nodes = Object.values(process.process_graph);
return Boolean(nodes.find(node => {
let process = this.processes.get(node.process_id);

Check failure on line 810 in src/connection.js

View workflow job for this annotation

GitHub Actions / deploy

'process' is already declared in the upper scope on line 807 column 15
return Utils.isObject(process) && Boolean(process.ogcapi);
}));
}

async executeOgcProcess(process, abortController = null) {

Check failure on line 815 in src/connection.js

View workflow job for this annotation

GitHub Actions / deploy

Missing JSDoc comment
let openEO = this._normalizeUserProcess(process)
let p = Object.values(openEO.process.process_graph).find(v => {
let spec = this.processes.get(v.process_id);
return Boolean(spec && spec.ogcapi);
});
let requestBody = Migrate.execute(openEO);
console.log(p.process_id, requestBody); // @todo remove
let response = await this._post(`/processes/${p.process_id}/execution`, requestBody, Environment.getResponseType(), abortController);
let syncResult = {
data: response.data,
costs: null,
type: null,
logs: []
};

if (typeof response.headers['content-type'] === 'string') {
syncResult.type = response.headers['content-type'];
}

return syncResult;
}

/**
* Executes a process synchronously and returns the result as the response.
*
Expand All @@ -822,6 +855,9 @@ class Connection {
budget: budget
}
);
if (this.isOgcProcess(requestBody.process)) {
return this.executeOgcProcess(process, abortController);
}
let response = await this._post('/result', requestBody, Environment.getResponseType(), abortController);
let syncResult = {
data: response.data,
Expand Down
Loading

0 comments on commit b21c984

Please sign in to comment.