Commit c1728d5a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '702-plugin-functionalities' into 'master'

Resolve "plugin functionalities"

Closes #702

See merge request !690
parents 6ef6c086 ccfcec24
Pipeline #9155 passed with stage
in 11 minutes and 2 seconds
minerva (12.3.0~alpha.0) unstable; urgency=low
* Feature: annotators are more flexible - you can define set of input and outputs used by
annotator (#617)
* Small improvement: added current username next to logout button in admin panel (#660)
* Small improvement: New comment dialog does not contain content of previous comment dialog (#680)
* Feature: annotators are more flexible - you can define set of input and
outputs used by annotator (#617)
* Small improvement: added current username next to logout button in admin
panel (#660)
* Small improvement: New comment dialog does not contain content of previous
comment dialog (#680)
* Small improvement: Left logo is configurable (#731)
* Bug fix: progress bar of gene genome mapping upload is refreshing properly (#728)
* Small improvement: Plugin API provides list of overview images (#702)
* Small improvement: Plugin API allows to show/hide overview images (#702)
* Small improvement: Plugin API allows to trigger search on the map (#702)
* Small improvement: Plugin API allows to clear search results on map (#702)
* Bug fix: progress bar of gene genome mapping upload is refreshing properly
(#728)
minerva (12.2.0~beta.2) unstable; urgency=medium
* Bug fix: order of the overlays is defined explicitly also for general
......
......@@ -255,7 +255,17 @@ OverviewDialog.prototype.drawClickableShapes = function (canvas, ratio) {
*
*/
OverviewDialog.prototype.destroy = function () {
$(this.getElement()).dialog("destroy");
var div = $(this.getElement());
if (div.hasClass("ui-dialog-content")) {
div.dialog("destroy");
}
};
/**
*
*/
OverviewDialog.prototype.close = function () {
$(this.getElement()).dialog('close');
};
module.exports = OverviewDialog;
......@@ -192,7 +192,7 @@ TopMenu.prototype.init = function () {
var commentCheckbox = self.getControlElement(PanelControlElementType.MENU_COMMENTS_CHECKBOX);
var refreshCommentButton = self.getControlElement(PanelControlElementType.MENU_REFRESH_COMMENTS_BUTTON);
commentCheckbox.onclick = function () {
ServerConnector.getSessionData(project).setShowComments(commentCheckbox.checked);
self.getServerConnector().getSessionData(project).setShowComments(commentCheckbox.checked);
if (commentCheckbox.checked) {
$(refreshCommentButton).css("display", "inline");
} else {
......@@ -228,9 +228,10 @@ TopMenu.prototype.init = function () {
return self._overviewDialog.showOverview();
};
$(showOverviewButton).css("display", "inline-block");
self.getMap().setOverviewDialog(self._overviewDialog);
}
if (ServerConnector.getSessionData().getShowComments()) {
if (self.getServerConnector().getSessionData().getShowComments()) {
self.getControlElement(PanelControlElementType.MENU_COMMENTS_CHECKBOX).checked = true;
return self.getMap().refreshComments();
} else {
......
......@@ -882,7 +882,7 @@ AbstractCustomMap.prototype.setElement = function (element) {
*
* @param {Point} coordinates
* new center point on map
* @returns {PromiseLike}
* @returns {Promise|PromiseLike}
*/
AbstractCustomMap.prototype.setCenter = function (coordinates) {
if (!(coordinates instanceof Point)) {
......@@ -916,6 +916,7 @@ AbstractCustomMap.prototype.getBounds = function () {
*
* @param {number} zoom
* new zoom level on map
* @return {Promise|PromiseLike}
*/
AbstractCustomMap.prototype.setZoom = function (zoom) {
var self = this;
......
......@@ -10,8 +10,9 @@ var Alias = require('./data/Alias');
var CommentDialog = require('../gui/CommentDialog');
var ConfigurationType = require('../ConfigurationType');
var CustomMapOptions = require('./CustomMapOptions');
var IdentifiedElement = require('./data/IdentifiedElement');
var DataOverlay = require('./data/DataOverlay');
var IdentifiedElement = require('./data/IdentifiedElement');
var OverviewDialog = require('../gui/OverviewDialog');
var Reaction = require('./data/Reaction');
var ReferenceGenome = require('./data/ReferenceGenome');
var SecurityError = require('../SecurityError');
......@@ -354,7 +355,7 @@ CustomMap.prototype.refreshComments = function () {
return commentDbOverlay.clear();
}
}
throw new Error("comment DbOverlay not found");
return Promise.reject(new Error("comment DbOverlay not found"));
};
/**
......@@ -1153,6 +1154,34 @@ CustomMap.prototype.getSelectedPolygon = function () {
return this._selectedPolygon;
};
/**
*
* @param {OverviewDialog} overviewDialog
*/
CustomMap.prototype.setOverviewDialog = function (overviewDialog) {
this._overviewDialog = overviewDialog;
};
/**
*
* @returns {OverviewDialog}
*/
CustomMap.prototype.getOverviewDialog = function () {
var self = this;
if (this._overviewDialog === undefined) {
logger.warn("OverviewDialog is not defined");
var overviewDialogDiv = Functions.createElement({type: "div"});
self.getElement().appendChild(overviewDialogDiv);
this._overviewDialog = new OverviewDialog({
customMap: self,
configuration: self.getConfiguration(),
project: self.getProject(),
element: overviewDialogDiv
});
}
return this._overviewDialog;
};
/**
*
* @param {number} params.modelId
......@@ -1244,6 +1273,13 @@ CustomMap.prototype.destroy = function () {
if (self.getSelectionContextMenu() !== undefined) {
self.getSelectionContextMenu().destroy();
}
if (self._overviewDialog !== undefined) {
var div = $(self._overviewDialog.getElement());
if (div.hasClass("ui-dialog-content")) {
div.dialog("destroy");
}
}
};
/**
......
......@@ -348,7 +348,7 @@ OpenLayerCanvas.prototype.fitBounds = function (bounds) {
};
OpenLayerCanvas.prototype.setCenter = function (center) {
this.getOpenLayersMap().getView().setCenter(this.fromPointToProjection(center));
return Promise.resolve(this.getOpenLayersMap().getView().setCenter(this.fromPointToProjection(center)));
};
/**
......
......@@ -3,20 +3,38 @@
var Annotation = require("./Annotation");
var TargettingStructure = require("./TargettingStructure");
/**
* @typedef {TargettingStructureOptions} ChemicalOptions
* @property {Annotation[]} references
* @property {string[]} synonyms
* @property {string} description
* @property {string} directEvidence
* @property {Annotation[]} directEvidenceReferences
*/
/**
*
* @param javaObject
* @param {ChemicalOptions|Chemical} javaObject
* @constructor
*/
function Chemical(javaObject) {
TargettingStructure.call(this, javaObject);
if (javaObject !== undefined) {
this.setReferences(javaObject.references);
this.setDescription(javaObject.description);
this.setSynonyms(javaObject.synonyms);
this.setDirectEvidence(javaObject.directEvidence);
this.setDirectEvidenceReferences(javaObject.directEvidenceReferences);
if (javaObject instanceof Chemical) {
this.setReferences(javaObject.getReferences());
this.setDescription(javaObject.getDescription());
this.setSynonyms(javaObject.getSynonyms());
this.setDirectEvidence(javaObject.getDirectEvidence());
this.setDirectEvidenceReferences(javaObject.getDirectEvidenceReferences());
} else {
this.setReferences(javaObject.references);
this.setDescription(javaObject.description);
this.setSynonyms(javaObject.synonyms);
this.setDirectEvidence(javaObject.directEvidence);
this.setDirectEvidenceReferences(javaObject.directEvidenceReferences);
}
}
}
......
......@@ -3,19 +3,36 @@
var Annotation = require("./Annotation");
var TargettingStructure = require("./TargettingStructure");
/**
* @typedef {TargettingStructureOptions} DrugOptions
* @property {string[]} brandNames
* @property {Annotation[]} references
* @property {string[]} synonyms
* @property {string} description
* @property {string} bloodBrainBarrier
*/
/**
*
* @param javaObject
* @param {DrugOptions|Drug} javaObject
* @constructor
*/
function Drug(javaObject) {
TargettingStructure.call(this, javaObject);
if (javaObject !== undefined) {
this.setBrandNames(javaObject.brandNames);
this.setReferences(javaObject.references);
this.setSynonyms(javaObject.synonyms);
this.setDescription(javaObject.description);
this.setBloodBrainBarrier(javaObject.bloodBrainBarrier);
if (javaObject instanceof Drug) {
this.setBrandNames(javaObject.getBrandNames());
this.setReferences(javaObject.getReferences());
this.setSynonyms(javaObject.getSynonyms());
this.setDescription(javaObject.getDescription());
this.setBloodBrainBarrier(javaObject.getBloodBrainBarrier());
} else {
this.setBrandNames(javaObject.brandNames);
this.setReferences(javaObject.references);
this.setSynonyms(javaObject.synonyms);
this.setDescription(javaObject.description);
this.setBloodBrainBarrier(javaObject.bloodBrainBarrier);
}
}
}
......
......@@ -2,9 +2,13 @@
var TargettingStructure = require("./TargettingStructure");
/**
* @typedef {TargettingStructureOptions} MiRnaOptions
*/
/**
*
* @param javaObject
* @param {MiRnaOptions|MiRna} javaObject
* @constructor
* @extends TargettingStructure
*/
......
......@@ -17,19 +17,26 @@ var logger = require('../../logger');
/**
*
* @param {TargetOptions} javaObject
* @param {TargetOptions|Target} javaObject
* @constructor
*/
function Target(javaObject) {
this.setName(javaObject.name);
this.setTargetElements(javaObject.targetElements);
this.setTargetParticipants(javaObject.targetParticipants);
this.setReferences(javaObject.references);
if (javaObject instanceof Target) {
this.setName(javaObject.getName());
this.setTargetElements(javaObject.getTargetElements());
this.setTargetParticipants(javaObject.getTargetParticipants());
this.setReferences(javaObject.getReferences());
} else {
this.setName(javaObject.name);
this.setTargetElements(javaObject.targetElements);
this.setTargetParticipants(javaObject.targetParticipants);
this.setReferences(javaObject.references);
}
}
/**
*
* @param {IdentifiedElementInput[]} targetElements
* @param {IdentifiedElementInput[]|IdentifiedElement[]} targetElements
*/
Target.prototype.setTargetElements = function (targetElements) {
this._targetElements = [];
......@@ -49,7 +56,7 @@ Target.prototype.getTargetElements = function () {
/**
*
* @param {AnnotationOptions[]} targetParticipants
* @param {AnnotationOptions[]|Annotation[]} targetParticipants
*/
Target.prototype.setTargetParticipants = function (targetParticipants) {
this._targetParticipants = [];
......@@ -100,7 +107,7 @@ Target.prototype.isVisible = function () {
/**
*
* @param {AnnotationOptions[]} references
* @param {AnnotationOptions[]|Annotation[]} references
*/
Target.prototype.setReferences = function (references) {
this._references = [];
......
......@@ -4,21 +4,32 @@
var Target = require("./Target");
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger');
/**
* @typedef {Object} TargettingStructureOptions
* @property {string} name
* @property {number} id
* @property {TargetOptions[]} targets
*/
/**
*
* @param {Object} [javaObject]
* @param {string} javaObject.name
* @param {number} javaObject.id
* @param {TargetOptions[]} javaObject.targets
* @param {TargettingStructureOptions|TargettingStructure} javaObject
* @constructor
*/
function TargettingStructure(javaObject) {
if (javaObject !== undefined) {
this.setName(javaObject.name);
this.setId(javaObject.id);
this.setTargets(javaObject.targets);
if (javaObject instanceof TargettingStructure) {
this.setName(javaObject.getName());
this.setId(javaObject.getId());
this.setTargets(javaObject.getTargets());
} else {
this.setName(javaObject.name);
this.setId(javaObject.id);
this.setTargets(javaObject.targets);
}
}
}
......@@ -26,7 +37,7 @@ function TargettingStructure(javaObject) {
*
* @param {string} name
*/
TargettingStructure.prototype.setName = function(name) {
TargettingStructure.prototype.setName = function (name) {
this._name = name;
};
......@@ -34,7 +45,7 @@ TargettingStructure.prototype.setName = function(name) {
*
* @returns {string}
*/
TargettingStructure.prototype.getName = function() {
TargettingStructure.prototype.getName = function () {
return this._name;
};
......@@ -42,7 +53,7 @@ TargettingStructure.prototype.getName = function() {
*
* @param {number} id
*/
TargettingStructure.prototype.setId = function(id) {
TargettingStructure.prototype.setId = function (id) {
this._id = id;
};
......@@ -50,15 +61,15 @@ TargettingStructure.prototype.setId = function(id) {
*
* @returns {number}
*/
TargettingStructure.prototype.getId = function() {
TargettingStructure.prototype.getId = function () {
return this._id;
};
/**
*
* @param {TargetOptions[]} targets
* @param {TargetOptions[]|Target[]} targets
*/
TargettingStructure.prototype.setTargets = function(targets) {
TargettingStructure.prototype.setTargets = function (targets) {
this._targets = [];
for (var i = 0; i < targets.length; i++) {
this._targets.push(new Target(targets[i]));
......@@ -69,7 +80,7 @@ TargettingStructure.prototype.setTargets = function(targets) {
*
* @returns {Target[]}
*/
TargettingStructure.prototype.getTargets = function() {
TargettingStructure.prototype.getTargets = function () {
return this._targets;
};
......@@ -78,11 +89,11 @@ TargettingStructure.prototype.getTargets = function() {
* @param {IdentifiedElement[]} targetIdentifiedElement
* @returns {Target[]}
*/
TargettingStructure.prototype.getTargetsForIdentifiedElement = function(targetIdentifiedElement) {
TargettingStructure.prototype.getTargetsForIdentifiedElement = function (targetIdentifiedElement) {
var result = [];
this.getTargets().forEach(function(target) {
this.getTargets().forEach(function (target) {
var targetOk = false;
target.getTargetElements().forEach(function(identifiedElement){
target.getTargetElements().forEach(function (identifiedElement) {
if (targetIdentifiedElement.equals(identifiedElement)) {
targetOk = true;
}
......
"use strict";
var Annotation = require('../map/data/Annotation');
var Chemical = require('../map/data/Chemical');
var Drug = require('../map/data/Drug');
var IdentifiedElement = require('../map/data/IdentifiedElement');
var MiRna = require('../map/data/MiRna');
var UserDbOverlay = require('../map/overlay/UserDbOverlay');
var SearchDbOverlay = require('../map/overlay/SearchDbOverlay');
var Configuration = require('../Configuration');
var Bounds = require('../map/canvas/Bounds');
......@@ -37,6 +41,7 @@ var Promise = require("bluebird");
* @property {function(): *} getDisease
* @property {function(): *} getOrganism
* @property {function(): *[]} getModels
* @property {function(): *[]} getOverviewImages
* @property {function(): DataOverlay[]} getDataOverlays
*/
......@@ -46,18 +51,22 @@ var Promise = require("bluebird");
* @property {function(): (Promise<DataOverlay[]>|*)} getVisibleDataOverlays
* @property {function(number|DataOverlay): (Promise<DataOverlay[]>|*)} showDataOverlay
* @property {function(number|DataOverlay): (Promise<DataOverlay[]>|*)} hideDataOverlay
* @property {function({id: number}): void} showOverviewImage
* @property {function(): void} hideOverviewImage
* @property {function(*)} addListener
* @property {function(*)} removeListener
* @property {function(): Array} removeAllListeners
* @property {(function(*=): Promise<Array|never>)} getHighlightedBioEntities
* @property {(function(*=): Promise<any|never>)} hideBioEntity
* @property {(function(*): PromiseLike)} setCenter
* @property {(function({modelId: number, x: number, y: number}): Promise|PromiseLike)} setCenter
* @property {(function(*): Point)} getCenter
* @property {(function(*): Bounds)} getBounds
* @property {(function(*): void)} fitBounds
* @property {(function(*): *)} setZoom
* @property {(function({modelId: number, zoom: number}): Promise|PromiseLike)} setZoom
* @property {(function(*): number)} getZoom
* @property {(function(*): PromiseLike)} openMap
* @property {function({dbOverlayName: string, [query]:string, [perfect]: boolean, [fitBounds]:boolean, [coordinates]:Point}): Promise|PromiseLike} triggerSearch
* @property {function(): Promise|PromiseLike} clear
*/
......@@ -95,10 +104,20 @@ function getFullElements(customMap, identifiedElements) {
identifiedElements,
function (item) {
if (item.length === undefined) {
return customMap.getSubmapById(item.getModelId()).getModel().getByIdentifiedElement(item, true).then(
function (fullElement) {
result.push(fullElement);
});
if (item instanceof IdentifiedElement) {
return customMap.getSubmapById(item.getModelId()).getModel().getByIdentifiedElement(item, true).then(
function (fullElement) {
result.push(fullElement);
});
} else if (item instanceof Drug) {
result.push(new Drug(item));
} else if (item instanceof Chemical) {
result.push(new Chemical(item));
} else if (item instanceof MiRna) {
result.push(new MiRna(item));
} else {
return Promise.reject(new Error("Unknown object type: " + item.constructor.name));
}
} else {
return getFullElements(customMap, item).then(function (resultRow) {
result.push(resultRow);
......@@ -284,6 +303,19 @@ function createProjectData(options) {
});
}
return result;
},
getOverviewImages: function () {
var result = [];
for (var i = 0; i < map.getProject().getOverviewImages().length; i++) {
var image = map.getProject().getOverviewImages()[i];
result.push({
id: image.idObject,
filename: image.filename,
width: image.width,
height: image.height
});
}
return result;
}
};
}
......@@ -401,6 +433,44 @@ function createProjectMap(options) {
var listenersData = [];
return {
/**
*
* @param {Object} params
* @param {string} params.dbOverlayName
* @param {string} [params.query]
* @param {boolean} [params.perfect]
* @param {boolean} [params.fitBounds]
* @param {Point} [params.coordinates]
* @param {number} [params.modelId]
* @param {number} [params.zoom]
*
*
* @return {Promise|PromiseLike}
*/
triggerSearch: function (params) {
var dbOverlay = getOverlayByName(map, params.dbOverlayName);
if (params.query !== undefined) {
return dbOverlay.searchByQuery(params.query, params.perfect, params.fitBounds);
} else if (dbOverlay instanceof SearchDbOverlay) {
return dbOverlay.searchByCoordinates({
coordinates: params.coordinates,
modelId: params.modelId,
fitBounds: params.fitBounds,
zoom: params.zoom
});
} else {
return Promise.reject(new Error("Don't know how to handle your query"));
}
},
/**
*
* @return {PromiseLike|Promise}
*/
clear: function () {
map.getServerConnector().getSessionData(map.getProject()).setShowComments(false);
return Promise.all([map.clearDbOverlays(), map.refreshComments()]);
},
getVisibleDataOverlays: function () {
return map.getVisibleDataOverlays();
},
......@@ -420,6 +490,21 @@ function createProjectMap(options) {
hideDataOverlay: function (param) {
return map.hideDataOverlay(param);
},
/**
*
* @param {Object} param
* @param {number} param.id
*/
showOverviewImage: function (param) {
map.getOverviewDialog().showOverview(param.id);
},
/**
*
*/
hideOverviewImage: function () {
map.getOverviewDialog().close();
},
/**
*
* @param {Object} param
......@@ -608,6 +693,15 @@ function createProjectMap(options) {
return map.getOverlayByName(pluginId).removeSurface(surfaceElements);
});
},
/**
*
* @param {Object} params
* @param {number} params.modelId
* @param {number} params.x
* @param {number} params.y
* @return {Promise|PromiseLike}
*/
setCenter: function (params) {
var submap = map.getSubmapById(params.modelId);
if (submap === null) {
......@@ -638,6 +732,14 @@ function createProjectMap(options) {