Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/FlatmapVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,9 @@ export default {
}

// Emit error message for connectivity
this.emitConnectivityError(errorData);
if (errorData.length) {
this.emitConnectivityError(errorData);
}

// highlight all available features
const connectivityFeatures = featuresToHighlight.reduce((arr, path) => {
Expand Down
115 changes: 106 additions & 9 deletions src/services/flatmapQueries.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-alert, no-console */
import { querySingleConnectivityList } from '@abi-software/map-utilities';

// remove duplicates by stringifying the objects
const removeDuplicates = function (arrayOfAnything) {
if (!arrayOfAnything) return []
Expand Down Expand Up @@ -99,6 +101,14 @@ let FlatmapQueries = function () {
this.destinations = []
this.origins = []
this.components = []
this.destinationsWithDatasets = []
this.originsWithDatasets = []
this.componentsWithDatasets = []
this.destinationsCombinations = []
this.originsCombinations = []
this.componentsCombinations = []
this.singleConnectivityList = []
this.hasSingleConnectivityList = false
this.rawURLs = []
this.controller = undefined
this.uberons = []
Expand Down Expand Up @@ -140,6 +150,10 @@ let FlatmapQueries = function () {
destinationsWithDatasets: this.destinationsWithDatasets,
originsWithDatasets: this.originsWithDatasets,
componentsWithDatasets: this.componentsWithDatasets,
destinationsCombinations: this.destinationsCombinations,
originsCombinations: this.originsCombinations,
componentsCombinations: this.componentsCombinations,
hasSingleConnectivityList: this.singleConnectivityList.length > 0,
title: eventData.label,
featureId: eventData.resource,
hyperlinks: hyperlinks,
Expand All @@ -160,6 +174,9 @@ let FlatmapQueries = function () {
componentsWithDatasets: this.componentsWithDatasets,
destinations: this.destinations,
destinationsWithDatasets: this.destinationsWithDatasets,
destinationsCombinations: this.destinationsCombinations,
originsCombinations: this.originsCombinations,
componentsCombinations: this.componentsCombinations,
connectivitySource: this.connectivitySource,
noMapConnectivity: this.noMapConnectivity,
};
Expand Down Expand Up @@ -285,16 +302,36 @@ let FlatmapQueries = function () {
this.destinations = []
this.origins = []
this.components = []
this.destinationsWithDatasets = []
this.originsWithDatasets = []
this.componentsWithDatasets = []
this.destinationsCombinations = []
this.originsCombinations = []
this.componentsCombinations = []
this.singleConnectivityList = []
this.rawURLs = []
if (!keastIds || keastIds.length === 0 || !keastIds[0]) return

let prom1 = this.queryForConnectivityNew(mapImp, keastIds[0]) // This on returns a promise so dont need 'await'
let prom1 = await this.queryForConnectivityNew(mapImp, keastIds[0]) // This on returns a promise so dont need 'await'
let results = await Promise.all([prom1])
return results
}

this.queryForConnectivityNew = function (mapImp, keastId, connectivitySource = 'map', processConnectivity = true) {
this.connectivitySource = connectivitySource
this.queryForConnectivityNew = async function (mapImp, keastId, connectivitySource = 'map', processConnectivity = true) {
// The new service, CQ27, is available for SCKAN knowledge sources from 2026 onward.
const sourceMatch = /^sckan-(\d{4})/.exec(mapImp.knowledgeSource || '');
const sourceYear = sourceMatch ? Number(sourceMatch[1]) : 0;
const isCq27ServiceAvailable = sourceYear >= 2026;
const mapUUID = mapImp.mapMetadata.uuid;
const flatmapAPI = this.flatmapAPI;

connectivitySource = isCq27ServiceAvailable ? 'sckan' : connectivitySource;
this.connectivitySource = isCq27ServiceAvailable ? 'sckan' : connectivitySource;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason there are two lines here with one overwriting the argument?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it shouldn't be that way.
I've fixed it now in 9d26706.


if (isCq27ServiceAvailable) {
this.singleConnectivityList = await querySingleConnectivityList(flatmapAPI, mapUUID, keastId);
}

return new Promise((resolve) => {
const queryAPI = connectivitySource === 'map'
? this.queryMapConnectivity(mapImp.mapMetadata.uuid, keastId)
Expand Down Expand Up @@ -485,6 +522,66 @@ let FlatmapQueries = function () {
this.destinationsWithDatasets = this.uberons.filter(
(ub) => axonsFlat.indexOf(ub.id) !== -1
).sort(compareNames);

// Get combinations of SCKAN and Map
if (this.singleConnectivityList.length > 0) {
this.singleConnectivityList.forEach((value) => {
const { sckanNodeId, sckanNodeLabel, mapNodeId, mapNodeLabel } = value;

// The base ID is SCKAN ID
if (axons.find(axon => JSON.stringify(axon) === JSON.stringify(sckanNodeId))) {
this.destinationsCombinations.push({
sckanId: sckanNodeId,
sckanLabel: sckanNodeLabel,
mapId: mapNodeId,
mapLabel: mapNodeLabel,
})
mapNodeId.forEach((id, i) => {
const stringId = typeof id === 'string' ? id : id[0];
if (stringId) {
this.destinationsWithDatasets.push({
id: stringId,
name: mapNodeLabel.split(',')[i]
});
}
});
}
if (dendrites.find(dendrite => JSON.stringify(dendrite) === JSON.stringify(sckanNodeId))) {
this.originsCombinations.push({
sckanId: sckanNodeId,
sckanLabel: sckanNodeLabel,
mapId: mapNodeId,
mapLabel: mapNodeLabel,
})
mapNodeId.forEach((id, i) => {
const stringId = typeof id === 'string' ? id : id[0];
if (stringId) {
this.originsWithDatasets.push({
id: stringId,
name: mapNodeLabel.split(',')[i]
});
}
});
}
if (components.find(component => JSON.stringify(component) === JSON.stringify(sckanNodeId))) {
this.componentsCombinations.push({
sckanId: sckanNodeId,
sckanLabel: sckanNodeLabel,
mapId: mapNodeId,
mapLabel: mapNodeLabel,
})
mapNodeId.forEach((id, i) => {
const stringId = typeof id === 'string' ? id : id[0];
if (stringId) {
this.componentsWithDatasets.push({
id: stringId,
name: mapNodeLabel.split(',')[i]
});
}
});
}
});
}
}

this.processConnectivity = function (mapImp, connectivity) {
Expand Down Expand Up @@ -569,14 +666,14 @@ let FlatmapQueries = function () {
}

this.queryKnowledge = async (sql, params) => {
const url = `${this.flatmapAPI}/knowledge/query/`;
const url = `${this.flatmapAPI}knowledge/query/`;
const query = { sql, params };
const response = await fetch(url, {
method: 'POST',
headers: {
"Accept": "application/json"
},
body: JSON.stringify(query),
method: 'POST',
headers: {
"Accept": "application/json"
},
body: JSON.stringify(query),
})
if (!response.ok) {
throw new Error(`Cannot access ${url}`);
Expand Down
Loading