Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
@okram
okram / gist:4630935
Last active December 11, 2015 16:58
Core:
http://localhost:8182/graphs/egosystem/core/addEntity
{
entity: {uuid:'1234',name:'marko',type:'person'},
identities : [
{service:'twitter',handle:'@twarko',uri:'http://twitter.com/twarko'},
{service:'lanl', handle:209893, uri:'http://people.lanl.gov/209893'}
]
}
@okram
okram / gist:4660331
Last active December 11, 2015 21:09
Vertex source = GraphUtilities.getThing(g, request.getString(Tokens.SOURCE_IDENTITY));
Vertex target = GraphUtilities.getThing(g, request.getString(Tokens.TARGET_IDENTITY));
final String keywordProperty = request.getString(Tokens.KEYWORD_PROPERTY);
def m = [:];
source.out(Tokens.AUTHORED).in(Tokens.AUTHORED).loop(2) { it.loops < 4 & it.object != target }.simplePath.path.next(15).each {
for (int i = 1; i < it.size(); i = i + 2) {
it[i].out(Tokens.KEYWORD).property(keywordProperty).groupCount(m).iterate();
}
}
class GetPathTagCloudExtensionTest extends TestCase {
static {
Gremlin.load();
}
public void testCloud1() {
TransactionalGraph g = new TransactionalTinkerGraph();
AddArticleExtension aa = new AddArticleExtension();
JSONObject request = new JSONObject('''
@ExtensionNaming(namespace = "core", name = "getPathTagCloud")
class GetPathTagCloudExtension extends AbstractRexsterExtension {
static {
Gremlin.load();
}
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.POST)
@ExtensionDescriptor(description = "Generate a keyword distribution of a path")
public ExtensionResponse evaluate(@RexsterContext RexsterResourceContext context,
public void testQuery() {
EgoSystemGraph g = new EgoSystemGraph();
GetHomepageUriExtension gt = new GetHomepageUriExtension();
JSONObject request = new JSONObject('''
{
person : 'Marko A. Rodriguez',
institution : 'Aurelius'
}
''');
JSONObject result = gt.evaluate(new RexsterResourceContext(null, null, null, request, null, null, null), g).getJerseyResponse().getEntity();
if (!this.starts.hasNext()) {
for (final Map.Entry<K, Iterator<V>> entry : byMap.entrySet()) {
V2 previousReduceValue = this.reduceMap.get(entry.getKey());
if (null == previousReduceValue)
this.reduceMap.put(entry.getKey(), reduceFunction.compute(entry.getValue()));
else
this.reduceMap.put(entry.getKey(), reduceFunction.compute(new MultiIterator(entry.getValue(), new SingleIterator(previousReduceValue))));
}
this.byMap.clear();
}
package com.tinkerpop.pipes.sideeffect;
import com.tinkerpop.pipes.PipeFunction;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
{
"properties":{
"starttime":34543278387345,
"endtime":null,
"platonic":"person",
"name":"Rodriguez, Marko",
"locked":null
},
"identities":[
{
{
"properties":{
"hindex":null,
"gindex":null,
"handle":null,
"longitude":null,
"logo":null,
"service":"msacademic",
"latitude":null,
"name":"Marko A. Rodriguez",
{
"properties":{
"hindex":null,
"gindex":null,
"publicationcount":null,
"citationcount":null,
"handle":null,
"service":"msacademic",
"logo":null,
"longitude":null,