<commit_before>/*************************************************************************   
* Copyright 2008-2012 Janssen Research & Development, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************/

Ext.onReady(function(){
    advancedWorkflowMenu();
});

var analysisConcept = null;
var module_array;

function advancedWorkflowMenu() {
	var advancedMenu = null;
	
	Ext.Ajax.request({
		url : pageInfo.basePath+"/plugin/modules",
		params: {pluginName:'R-Modules'},
		method : 'GET',
		timeout: '1800000',
		success : function(result, request)
		{
			createAdvancedWorkflowMenu(result);
		},
		failure : function(result, request)
		{
			//Ext.Msg.alert("Problem loading the list of available Analysis");
		}
	});
}

/**
 * Find module by module id
 * @param id
 * @returns {null}
 */
function findModuleById(id) {
	var v = null;
	if (module_array != null) {
		Ext.each(module_array, function (module, index) {
			if (module.id == id) {
				v = module;
				return false;
			}
		});
	}
	return v;
}

function createAdvancedWorkflowMenu(result) {
	var response = Ext.util.JSON.decode(result.responseText);
	if (response.success) {

		// reserve modules in a global var
		module_array = response.modules;

		var advMenuItems = createAdvancedWorkflowMenuItems(response.modules);
		var advMenu = new Ext.menu.Menu({
			id : 'advancedWorkflowMenu',
			minWidth: 250,
			items : advMenuItems
		});
		
		// add components to the advanced workflow toolbar
		Ext.getCmp('advancedWorkflowToolbar')
			.add(
			{
					text : 'Analysis',
					iconCls : 'comparebutton',
					disabled : false,
					menu : advMenu
			},
			'->',
			{
				text : 'Save to PDF',
				iconCls : 'savepdfbutton',
				hidden : false,
				id : 'savetopdfbtn',
				handler: function(){
					generatePdfFromHTML('dataAssociationBody', 'DataAssociation.pdf');
				}
			}
		);
	}
}

function createAdvancedWorkflowMenuItems(modules) {
	var menuItems = [];
	Ext.each(modules, function(module, index) {
		var menuItem = module;
		menuItem.handler = onItemClick;
		
		menuItems.push(menuItem);
	});
	
	return menuItems;
}

/**
 * This function will load the analysis page
 * @param itemId
 * @param isCompletedJob
 * @param jobName
 */
function loadAnalysisPage(itemId, isCompletedJob, jobName) {

	// get analysis module attribute
	var module = findModuleById(itemId);

	// translate group test module name ..
	// TODO: Please change with the consistent naming for all related files and variable
	if (itemId ==  'aCGHgroupTest' ) itemId = 'groupTestaCGH';
	
	// fyi ..  Ajax.Updater is a Prototype.js syntax
	// will update 'variableSelection' div with whatever the response from
	// the call
	new Ajax.Updater('variableSelection', pageInfo.basePath+'/dataAssociation/variableSelection',
	{
		asynchronous:true,
		evalScripts:true,
		onComplete: function(e) { 

			// load the plugin view
			loadPluginView(itemId);

			// if it's loading completed job then display the result as well
			if (isCompletedJob) {
				if (itemId == 'aCGHSurvivalAnalysis') {
					survivalAnalysisACGHView.generateResultGrid(jobName, survivalAnalysisACGHView);
				} else if (itemId == 'groupTestaCGH') {
					groupTestView.renderResults(jobName, groupTestView);
				}
			}
		},
		parameters:{analysis:itemId}
	});

	// update analysis element
	Ext.get('analysis').dom.value = itemId;<commit_msg>enable RNASeqgroupTest in analysis job result to be opened - FT-361 Create UI for RNASeq analysis job (input and analysis results)<commit_after>/*************************************************************************   
* Copyright 2008-2012 Janssen Research & Development, LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************/

Ext.onReady(function(){
    advancedWorkflowMenu();
});

var analysisConcept = null;
var module_array;

function advancedWorkflowMenu() {
	var advancedMenu = null;
	
	Ext.Ajax.request({
		url : pageInfo.basePath+"/plugin/modules",
		params: {pluginName:'R-Modules'},
		method : 'GET',
		timeout: '1800000',
		success : function(result, request)
		{
			createAdvancedWorkflowMenu(result);
		},
		failure : function(result, request)
		{
			//Ext.Msg.alert("Problem loading the list of available Analysis");
		}
	});
}

/**
 * Find module by module id
 * @param id
 * @returns {null}
 */
function findModuleById(id) {
	var v = null;
	if (module_array != null) {
		Ext.each(module_array, function (module, index) {
			if (module.id == id) {
				v = module;
				return false;
			}
		});
	}
	return v;
}

function createAdvancedWorkflowMenu(result) {
	var response = Ext.util.JSON.decode(result.responseText);
	if (response.success) {

		// reserve modules in a global var
		module_array = response.modules;

		var advMenuItems = createAdvancedWorkflowMenuItems(response.modules);
		var advMenu = new Ext.menu.Menu({
			id : 'advancedWorkflowMenu',
			minWidth: 250,
			items : advMenuItems
		});
		
		// add components to the advanced workflow toolbar
		Ext.getCmp('advancedWorkflowToolbar')
			.add(
			{
					text : 'Analysis',
					iconCls : 'comparebutton',
					disabled : false,
					menu : advMenu
			},
			'->',
			{
				text : 'Save to PDF',
				iconCls : 'savepdfbutton',
				hidden : false,
				id : 'savetopdfbtn',
				handler: function(){
					generatePdfFromHTML('dataAssociationBody', 'DataAssociation.pdf');
				}
			}
		);
	}
}

function createAdvancedWorkflowMenuItems(modules) {
	var menuItems = [];
	Ext.each(modules, function(module, index) {
		var menuItem = module;
		menuItem.handler = onItemClick;
		
		menuItems.push(menuItem);
	});
	
	return menuItems;
}

/**
 * This function will load the analysis page
 * @param itemId
 * @param isCompletedJob
 * @param jobName
 */
function loadAnalysisPage(itemId, isCompletedJob, jobName) {

	// get analysis module attribute
	var module = findModuleById(itemId);

	// translate group test module name ..
	// TODO: Please change with the consistent naming for all related files and variable
	if (itemId ==  'aCGHgroupTest' ) itemId = 'groupTestaCGH';
	if (itemId ==  'RNASeqgroupTest' ) itemId = 'groupTestRNASeq';

	// fyi ..  Ajax.Updater is a Prototype.js syntax
	// will update 'variableSelection' div with whatever the response from
	// the call
	new Ajax.Updater('variableSelection', pageInfo.basePath+'/dataAssociation/variableSelection',
	{
		asynchronous:true,
		evalScripts:true,
		onComplete: function(e) { 

			// load the plugin view
			loadPluginView(itemId);

			// if it's loading completed job then display the result as well
			if (isCompletedJob) {
				if (itemId == 'aCGHSurvivalAnalysis') {
					survivalAnalysisACGHView.generateResultGrid(jobName, survivalAnalysisACGHView);
				} else if (itemId == 'groupTestaCGH') {
					groupTestView.renderResults(jobName, groupTestView);
				} else if (itemId == 'groupTestRNASeq') {
                    RNASeqgroupTestView.renderResults(jobName, RNASeqgroupTestView);
                }
			}
		},
		parameters:{analysis:itemId}
	});

	// update analysis element
	Ext.get('analysis').dom.value = itemId;
{'fraction_non_alphanumeric': 0.14303314032277936, 'fraction_numerical': 0.00579031661944068, 'mean_word_length': 3.8552631578947367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4096804', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2366, 'n_words': 689}