Commit b9fa407d authored by Daria Zenkova's avatar Daria Zenkova

my first serious commit to this integration project

parent 057c935f
# Created by .ignore support plugin (hsz.mobi)
.idea/
node_modules/
morpheus.js
morpheus-external.js
morpheus-external.min.js
......@@ -66,7 +66,8 @@ module.exports = function (grunt) {
'js/hopscotch.min.js', 'js/typed.min.js',
'js/jquery.event.drag-2.2.js',
'js/clipboard.min.js', 'js/slick.min.js',
'js/js.cookie.js', 'js/d3.layout.cloud.js']
'js/js.cookie.js', 'js/d3.layout.cloud.js',
'js/long.js', 'js/bytebuffer.js', 'js/protobuf.js']
},
morpheus: {
nonull: true,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Originally written by Saptarshi Guha for RHIPE (http://www.rhipe.org)
// Released under Apache License 2.0, and reused with permission here
// Extended in November 2014 with new types to support encoding
// language, environment, and function types from R.
package rexp;
option java_package = "org.godhuli.rhipe";
option java_outer_classname = "REXPProtos";
// TODO(mstokely): Refine this using the new protobuf 2.6 oneof field
// for unions.
message REXP {
enum RClass {
STRING = 0;
RAW = 1;
REAL = 2;
COMPLEX = 3;
INTEGER = 4;
LIST = 5;
LOGICAL = 6;
NULLTYPE = 7;
NATIVE = 8;
}
enum RBOOLEAN {
F=0;
T=1;
NA=2;
}
required RClass rclass = 1;
repeated double realValue = 2 [packed=true];
repeated sint32 intValue = 3 [packed=true];
repeated RBOOLEAN booleanValue = 4;
repeated STRING stringValue = 5;
optional bytes rawValue = 6;
repeated CMPLX complexValue = 7;
repeated REXP rexpValue = 8;
repeated string attrName = 11;
repeated REXP attrValue = 12;
optional bytes nativeValue = 13;
}
message STRING {
optional string strval = 1;
optional bool isNA = 2 [default=false];
}
message CMPLX {
optional double real = 1 [default=0];
required double imag = 2;
}
\ No newline at end of file
morpheus.TestTool = function () {
};
morpheus.TestTool.prototype = {
toString : function () {
return 'Test';
},
gui : function () {
return [
];
},
execute : function (options) {
var project = options.project;
var dataset = project.getFullDataset();
var matrix = dataset.seriesArrays;
ocpu.seturl("http://localhost:7120/ocpu/library/base/R");
var req = ocpu.call("ncol", {
"x" : matrix
}, function (session) {
session.getConsole(function (output) {
console.log(output);
});
});
req.fail(function () {
console.log("test tool failed");
});
}
};
......@@ -140,6 +140,10 @@ morpheus.HeatMapToolBar = function (controller) {
toolbarHtml
.push('<button type="button" class="btn btn-default btn-xs" data-toggle="tooltip" title="Reset Zoom" name="resetZoom">100%</button>');
}
toolbarHtml.push('<div class="morpheus-button-divider"></div>');
if (controller.options.toolbar.sort) {
toolbarHtml
......@@ -243,6 +247,73 @@ morpheus.HeatMapToolBar = function (controller) {
toolbarHtml.push('</div>');
}
toolbarHtml.push('<div class="morpheus-button-divider"></div>');
toolbarHtml.push('<button type="button" class="btn btn-default btn-xs" data-toggle="tooltip" title="Test" name="test">Test</button>');
$buttons.on('click', '[name=test]', function (e) {
console.log("test button clicked");
var project = controller.getProject();
var dataset = project.getFullDataset();
var matrix = dataset.seriesArrays[0];
console.log(dataset);
var rows = dataset.rows;
var columns = dataset.columns;
var array = [];
for (var i = 0; i < rows; i++) {
for (var j = 0; j < columns; j++) {
array.push(matrix[i][j]);
}
}
ProtoBuf = dcodeIO.ProtoBuf;
var builder = ProtoBuf.loadProtoFile("./message.proto"),
rexp = builder.build("rexp"),
REXP = rexp.REXP;
var msgMatrix2 = new REXP({
rclass : REXP.RClass.LIST,
rexpValue : [{
rclass: REXP.RClass.REAL,
realValue: array,
attrName: "dim",
attrValue: {
rclass: REXP.RClass.INTEGER,
intValue: [rows, columns]
}
},
{
rclass : REXP.RClass.REAL,
realValue : 1
}, {
rclass : REXP.RClass.REAL,
realValue : 2
}],
attrName : "names",
attrValue : {
rclass : REXP.RClass.STRING,
stringValue : [{
strval : "es"
},
{
strval : "c1"
}, {
strval : "c2"
}]
}
});
var res = morpheus.ocpu.call(msgMatrix2, {
library : "testproject",
fun : "pcaPlot",
host : "localhost:5721"
});
if (res != -1) {
alert(res);
}
});
var $lineOneColumn = $el.find('[data-name=lineOneColumn]');
$search.appendTo($lineOneColumn);
var $toolbarForm = $(toolbarHtml.join(''));
......
/**
* Created by baba_beda on 8/16/16.
*/
morpheus.ocpu = function () {
};
morpheus.ocpu.call = function(obj, settings) {
settings.host = settings.host || "localhost:8004";
if (settings.library == null) {
alert("Library is not specified. Call terminated");
return -1;
}
if (settings.fun == null) {
alert("Function is not specified. Call terminated");
return -1;
}
if (obj == null) {
alert("No arguments for function presented. Call terminated");
return -1;
}
var http = new XMLHttpRequest();
var url = "http://" + settings.host + "/ocpu/library/" + settings.library + "/R/" + settings.fun;
http.open("POST", url, false);
settings.contentType = settings.contentType || "application/x-protobuf";
http.setRequestHeader("Content-Type", settings.contentType);
var params = new Uint8Array(obj.toArrayBuffer());
http.send(params);
var loc;
if (http.status == 201) {
loc = http.getResponseHeader("Location");
}
else {
alert("Some problems occurred during POST request. Call terminated");
return -1;
}
var url2 = loc + "R/.val/print";
var http2 = new XMLHttpRequest();
http2.open("GET", url2, false);
http2.send(null);
if (http2.status == 200) {
return http2.responseText;
}
else {
alert("Some problems occurred during GET request. Call terminated");
return -1;
}
};
\ No newline at end of file
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