From ecee7b69908fbbf7c291e06ee3ed95b078640b1c Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Mon, 26 Nov 2012 14:47:29 +0000 Subject: [PATCH] BIS-263 SP-400 : Retrieve sample information from the AS. SVN: 27768 --- .../1/as/webapps/bottom-up/html/openbis.js | 19 +++ .../1/as/webapps/bottom-up/html/webapp.js | 135 ++++++++++++++++-- .../1/as/webapps/bottom-up/plugin.properties | 2 +- .../sample-bottom-up-data/plugin.properties | 3 + .../sample-bottom-up-data/sample-bottom-up.py | 8 ++ 5 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/plugin.properties create mode 100644 deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/sample-bottom-up.py diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/openbis.js b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/openbis.js index 36c5c3e7219..86fe7a99717 100644 --- a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/openbis.js +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/openbis.js @@ -231,6 +231,25 @@ openbis.prototype.searchForSamples = function(searchCriteria, action) { }); } +/** + * See ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService.searchForSamples(String, SearchCriteria, EnumSet<SampleFetchOption>) + * + * @method + */ +openbis.prototype.searchForSamplesWithFetchOptions = function(searchCriteria, fetchOptions, action) { + ajaxRequest({ + url: this.generalInfoServiceUrl, + data: { + "method" : "searchForSamples", + "params" : [ + this.sessionToken, + searchCriteria, + fetchOptions ] + }, + success: action + }); +} + /** * See ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService.searchForDataSets(String, SearchCriteria) * diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js index 1760dfe166a..9b2e71293b8 100644 --- a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/html/webapp.js @@ -1,3 +1,15 @@ +// +// BEGIN CONFIGURATION PARAMTERS +// +// The following parameters must be configured for the webapp + +// The name of the dss +var DSS_NAME = "DSS1"; + +var FLOWCELL_SAMPLE_TYPE = "FLOWCELL"; + +// END CONFIGURATION PARAMTERS + /// The openbisServer we use for our data var webappContext = new openbisWebAppContext(); @@ -26,9 +38,57 @@ function SampleGraphModel() { SampleGraphModel.prototype.initializeModel = function() { this.sampleIdentifier = webappContext.getEntityIdentifier(); + var identifierTokens = this.sampleIdentifier.split("/"); + this.sampleSpace = identifierTokens[1]; + this.sampleCode = identifierTokens[2]; this.samplePermId = webappContext.getEntityPermId(); } +/** + * Request the data necessary to display the graph. This variant uses an aggregation service + */ +SampleGraphModel.prototype.requestGraphDataFromAggregationService = function(callback) +{ + var parameters = {'FLOWCELL_PERM_ID' : this.samplePermId}; + + openbisServer.createReportFromAggregationService(DSS_NAME, "sample-bottom-up-data", parameters, callback); +} + +/** + * Request the data necessary to display the graph. + */ +SampleGraphModel.prototype.requestGraphData = function(callback) +{ + var containerCriteria = { + matchClauses : + [ {"@type" : "AttributeMatchClause", + fieldType : "ATTRIBUTE", + attribute : "TYPE", + desiredValue : FLOWCELL_SAMPLE_TYPE + }, {"@type" : "AttributeMatchClause", + fieldType : "ATTRIBUTE", + attribute : "CODE", + desiredValue : this.sampleCode + }, {"@type" : "AttributeMatchClause", + fieldType : "ATTRIBUTE", + attribute : "SPACE", + desiredValue : this.sampleSpace + } ], + operator : "MATCH_ALL_CLAUSES" + }; + + var sampleCriteria = { + subCriterias : + [ {"@type" : "SearchSubCriteria", + criteria : containerCriteria, + targetEntityKind : "SAMPLE_CONTAINER" + } ] + }; + + openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES", "ANCESTORS", "DESCENDANTS"], callback); +} + + /** * The presenter that shows the model. */ @@ -47,14 +107,16 @@ SampleGraphPresenter.prototype.initializePresenter = function() // Create a div to house the tree visualization and the inspectors this.root = d3.select("#root"); + this.rootLabel = d3.select("#root-label"); + this.rootLabel.text(this.model.sampleIdentifier); this.didCreateVis = true; } /** - * Display the data returned by the server + * Display the table data returned by the server */ -SampleGraphPresenter.prototype.showGraph = function(data) +SampleGraphPresenter.prototype.showGraphTable = function(data) { if (data.error) { console.log(data.error); @@ -74,6 +136,59 @@ SampleGraphPresenter.prototype.showGraph = function(data) showTableData(table); } +/** + * Display the sample returned by the server + */ +SampleGraphPresenter.prototype.showGraphSamples = function(data) +{ + if (data.error) { + console.log(data.error); + this.root.append("p").text("Could not retrieve data."); + return; + } + + // This will show the object in the log -- helpful for debugging + // console.log(data.result); + var tableData = data.result; + + // Display the rows in a table + var table = this.root.selectAll("table").data([tableData]); + // Code under enter is run if there is no HTML element for a data element + table.enter().append("table").attr("class", "table"); + this.showEntityTableHeader(table); + this.showEntityTableData(table); +} + +/** + * Construct the table header. + */ +SampleGraphPresenter.prototype.showEntityTableHeader = function(table) +{ + var header = table.selectAll("thead").data(function(d) { return [["Identifier", "Multiplex"]] }); + header.enter().append("thead"); + var headerRows = header.selectAll("tr").data(function(d) { return [d] }); + headerRows.enter().append("tr"); + var headerData = headerRows.selectAll("th").data(function(d) { return d; }); + headerData.enter().append("th"); + headerData.text(function (d) { return d}) +} + +/** + * Construct the table data. + */ +SampleGraphPresenter.prototype.showEntityTableData = function(table) +{ + var tableBody = table.selectAll("tbody").data(function(d) { return d }); + tableBody.enter().append("tbody"); + var dataRows = tableBody.selectAll("tr").data(function(d) { return [d] }); + dataRows.enter().append("tr").on("click", function (d) { presenter.selectEntity(d); }); + dataRows.exit().remove(); + + var dataData = dataRows.selectAll("td").data(function(d) { console.log(d); return [d.identifier, "" + d.parents[0]["@id"] + " " + d.parents[0].identifier] }); + dataData.enter().append("td"); + dataData.text(function (d) { return d }); +} + SampleGraphPresenter.prototype.selectEntity = function(d) { } @@ -117,23 +232,19 @@ function showTableData(table) } -function displayRoot(data) +function displayGraphTable(data) { - presenter.showGraph(data) + presenter.showGraphTable(data) } -/** - * Request samples matching some criteria from the server and show them in the Page. - */ -function listRootLevelEntities() +function displayGraphSamples(data) { - var parameters = {requestKey : 'ROOT'}; - - openbisServer.createReportFromAggregationService("DSS1", "ipad-read-service-v1", parameters, displayRoot); + presenter.showGraphSamples(data) } function enterApp(data) { presenter = new SampleGraphPresenter(model); - listRootLevelEntities(); + //model.requestGraphDataFromAggregationService(displayGraphTable); + model.requestGraphData(displayGraphSamples); } \ No newline at end of file diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/plugin.properties b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/plugin.properties index 51f90650dc0..9b2c6c383ec 100644 --- a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/plugin.properties +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/bottom-up/plugin.properties @@ -4,4 +4,4 @@ webapp-folder = html label = Bottom-Up Graph sorting = 1 openbisui-contexts = sample-details-view -sample-entity-types = .* +sample-entity-types = FLOWCELL diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/plugin.properties b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/plugin.properties new file mode 100644 index 00000000000..4420c9f866f --- /dev/null +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/plugin.properties @@ -0,0 +1,3 @@ +label = Sample Bottom Up Data +class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.jython.JythonAggregationService +script-path = sample-bottom-up.py \ No newline at end of file diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/sample-bottom-up.py b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/sample-bottom-up.py new file mode 100644 index 00000000000..a698d3c98f5 --- /dev/null +++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/dss/reporting-plugins/sample-bottom-up-data/sample-bottom-up.py @@ -0,0 +1,8 @@ +"""An aggregation service that aggregates data for the sample-bottom-up display""" + +from ch.systemsx.cisd.openbis.generic.shared.api.v1.dto import SearchCriteria + +def aggregate(parameters, table_builder): + table_builder.addHeader("TEST") + row = table_builder.addRow() + row.setCell("TEST", "TEST") -- GitLab