Skip to content

Commit

Permalink
Merge pull request #7 from deligianp/connect-to-cluster
Browse files Browse the repository at this point in the history
Connect to cluster
  • Loading branch information
schatzopoulos authored Dec 9, 2020
2 parents 922f767 + e6f422e commit 0d08f59
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 24 deletions.
63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"bootstrap": "4.3.1",
"chart.js": "^2.9.4",
"cytoscape": "^3.12.1",
"cytoscape-cose-bilkent": "^4.1.0",
"file-saver": "^2.0.2",
"loaders.css": "0.1.2",
"lodash": "^4.17.15",
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/athenarc/imsi/sdl/web/rest/AnalysisResource.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package athenarc.imsi.sdl.web.rest;

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -209,13 +211,29 @@ public Document get(String id, String analysis, Integer page) {
analysisDomain.append("selectField", selectField);
analysisDomain.append("dataset", dataset);
analysisDomain.append("entity", primaryEntiry);
meta.append("analysis_domain",analysisDomain);
meta.append("analysis_domain", analysisDomain);

Document hin = null;
if (analysis.equals("Ranking")) {
String fileName="RANKING_HIN_SCHEMA.json";
String targetHinJsonFilePath = Paths.get((String) configuration.get("local_out_dir"),fileName).toString();
// check if hin json exists
File targetHinJsonFile = new File(targetHinJsonFilePath);
if (targetHinJsonFile.exists()) {
// if it does load it
hin = Document.parse(FileUtil.readJsonFile(targetHinJsonFilePath));
}
}

response.append("id", id)
.append("analysis", analysis)
.append("_meta", meta)
.append("docs", docs);

if (hin != null && (page == null || !(page > 1))) {
response.append("hin", hin);
}

} catch (IOException e) {
throw new RuntimeException("Error results from file");
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/app/modules/analysis/jobs.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export default (state: JobState = initialState, action): JobState => {
});
results[data.analysis] = {
docs: indexedDocs,
meta: data._meta
meta: data._meta,
hin: data.hin || null
};

return {
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/app/modules/analysis/results/hin-graph.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.hin-graph {
width: 100%;
height: 576px;
}
77 changes: 77 additions & 0 deletions src/main/webapp/app/modules/analysis/results/hin-graph.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { useEffect } from 'react';
import cytoscape from 'cytoscape/dist/cytoscape.esm';
import coseBilkent from 'cytoscape-cose-bilkent';

import './hin-graph.css'


const HinGraph = props => {
// props.data: either array of ranking result objects or object of community->array of results objects
// props.id: DOM id to override the default (default: 'hin-graph')
let cy = null;

cytoscape.use(coseBilkent);
const data = []
if (props.data) {
props.data.nodes.forEach(node=>{
if (node.parent)
data.push({group:'nodes',data:{id:node.id,label:node.label,value:node.value,parent:node.parent}})
else
data.push({group:'nodes',data:{id:node.id,label:node.label,value:node.value}})
});
props.data.edges.forEach( ({ source, target, weight }) =>{
data.push({group:'edges',data:{source, target, id:`e-${source}-${target}`}})
});
}
useEffect(() => {
const containerDiv = document.getElementById(props.id || 'hin-graph');
cy = cytoscape({
container: containerDiv,
style: [
{
selector: 'node',
style: {
'label': 'data(label)',
'background-color': '#17a2b8',
'font-size': '5px'
}
},

{
selector: ':parent',
style: {
'background-opacity': 0.333
}
},

{
selector: 'edge',
style: {
'width': 1,
'line-color': '#48c7ea'
}
}
],

elements: data
});
cy.ready(() => {
cy.nodes().forEach(node=>{
const n = (node.data('value')*30.0);
const r = 10+Math.round(n);
node.css('width',r);
node.css('height',r);
});
cy.layout({name: 'cose-bilkent', animationDuration: 1000}).run();
});
return ()=>{
cy.unmount();
}
},[]);

return (
<div className={'hin-graph'} id={props.id || 'hin-graph'}/>
);
};

export default HinGraph;
Loading

0 comments on commit 0d08f59

Please sign in to comment.