Commit 422e1cc0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

adding of gene mappings implemented

parent a7de276e
......@@ -464,6 +464,21 @@ ServerConnector.getReferenceGenomeGeneMappingUrl = function (queryParams, filter
});
};
/**
*
* @param {Object} queryParams
* @param {string} queryParams.genomeId
* @param {Object} [filterParams]
*
* @returns {string}
*/
ServerConnector.getReferenceGenomeGeneMappingsUrl = function (queryParams, filterParams) {
return this.getApiUrl({
type: "genomics/" + queryParams.genomeId + "/geneMapping/",
params: filterParams
});
};
/**
*
* @param {Object} queryParams
......@@ -2109,6 +2124,23 @@ ServerConnector.getReferenceGenome = function (params) {
}
};
/**
*
* @param {Object} params
* @param {string|number} params.genomeId
* @param {string} params.mappingName
* @param {string} params.mappingUrl
* @returns {PromiseLike}
*/
ServerConnector.addGeneMapping = function (params) {
var self = this;
var data = {
name: params.mappingName,
url: params.mappingUrl
};
return self.sendPostRequest(self.getReferenceGenomeGeneMappingsUrl(params), data);
};
/**
*
* @param {Object} params
......
......@@ -297,6 +297,25 @@ EditGenomeDialog.prototype.createGeneMappingTabContent = function () {
}).catch(GuiConnector.alert);
});
var menuRow = Functions.createElement({
type: "div",
className: "minerva-menu-row",
style: "display:table-row; margin:10px"
});
result.appendChild(menuRow);
var addGeneMappingButton = Functions.createElement({
type: "button",
name: "saveGenome",
content: '<span class="ui-icon ui-icon-disk"></span>&nbsp;ADD GENE MAPPING',
onclick: function () {
return self.openAddGeneMapping();
},
xss: false
});
menuRow.appendChild(addGeneMappingButton);
return result;
};
......@@ -497,7 +516,7 @@ EditGenomeDialog.prototype.init = function () {
var detailsTable = $("[name=detailsTable]", self.getElement())[0];
var dataTable = $(detailsTable).DataTable({
$(detailsTable).DataTable({
columns: [{
title: "Name"
}, {
......@@ -630,4 +649,42 @@ EditGenomeDialog.prototype.getSourceUrl = function () {
return ($("[name='genomeSourceUrl']", self.getElement()).val()).toString();
};
/**
*
*/
EditGenomeDialog.prototype.openAddGeneMapping = function () {
var self = this;
var html = '<form style="z-index:10000"><span>Name: </span><input type="text" name="gene-mapping-name"><br>' +
'<span>Url: </span><input type="text" name="gene-mapping-url"><br></form>';
$(html).dialog({
modal: true,
title: "Add gene mapping",
close: function () {
$(this).dialog('destroy').remove();
},
buttons: {
'ADD': function () {
var dialog = this;
var name = $('input[name="gene-mapping-name"]').val().toString();
var url = $('input[name="gene-mapping-url"]').val().toString();
return self.getServerConnector().addGeneMapping({
genomeId: self.getReferenceGenome().getId(),
mappingName: name,
mappingUrl: url
}).then(function () {
return self.getServerConnector().getReferenceGenome({genomeId: self.getReferenceGenome().getId()});
}).then(function (referenceGenome) {
self.setReferenceGenome(referenceGenome);
return self.refresh();
}).then(function () {
$(dialog).dialog('destroy').remove();
});
},
'Cancel': function () {
$(this).dialog('destroy').remove();
}
}
});
};
module.exports = EditGenomeDialog;
......@@ -111,4 +111,14 @@ public class ReferenceGenomeController extends BaseController {
return referenceGenomeController.removeGeneMapping(genomeId,mappingId, token);
}
@RequestMapping(value = "/genomics/{genomeId}/geneMapping/", method = { RequestMethod.POST }, produces = {
MediaType.APPLICATION_JSON_VALUE })
public Map<String, Object> addGeneMapping(//
@PathVariable(value = "genomeId") String genomeId, //
@RequestBody MultiValueMap<String, Object> formData, //
@CookieValue(value = Configuration.AUTH_TOKEN) String token //
) throws SecurityException, QueryException, IOException, ReferenceGenomeConnectorException {
return referenceGenomeController.addGeneMapping(formData, genomeId, token);
}
}
\ No newline at end of file
......@@ -241,6 +241,24 @@ public class ReferenceGenomeRestImpl extends BaseRestImpl {
}
}
public Map<String, Object> addGeneMapping(MultiValueMap<String, Object> formData, String genomeId, String token)
throws SecurityException, QueryException, IOException, ReferenceGenomeConnectorException {
if (!getUserService().userHasPrivilege(token, PrivilegeType.MANAGE_GENOMES)) {
throw new SecurityException("Access denied");
}
int id = Integer.parseInt(genomeId);
try {
ReferenceGenome genome = referenceGenomeService.getReferenceGenomeById(id, token);
String name = getFirstValue(formData.get("name"));
String url = getFirstValue(formData.get("url"));
referenceGenomeService.addReferenceGenomeGeneMapping(genome, name, url);
return okStatus();
} catch (URISyntaxException e) {
throw new QueryException("Problem wih given uri", e);
}
}
public Map<String, Object> removeGeneMapping(String genomeId, String mappingId, String token)
throws SecurityException, IOException, ObjectNotFoundException {
if (!getUserService().userHasPrivilege(token, PrivilegeType.MANAGE_GENOMES)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment