Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Niklas
committed
Jan 18, 2017
0 parents
commit 291baa3
Showing
68 changed files
with
118,696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>test</groupId> | ||
<artifactId>grouping_demo</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<dep.flink.version>1.1.2</dep.flink.version> | ||
<dep.gradoop.version>0.3.0-SNAPSHOT</dep.gradoop.version> | ||
<dep.jersey.version>1.19.3</dep.jersey.version> | ||
</properties> | ||
<dependencies> | ||
<!-- Gradoop --> | ||
<dependency> | ||
<groupId>org.gradoop</groupId> | ||
<artifactId>gradoop-common</artifactId> | ||
<version>${dep.gradoop.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.gradoop</groupId> | ||
<artifactId>gradoop-flink</artifactId> | ||
<version>${dep.gradoop.version}</version> | ||
</dependency> | ||
|
||
<!-- Jersey --> | ||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-core</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-client</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-server</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-grizzly2</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-grizzly2-servlet</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sun.jersey</groupId> | ||
<artifactId>jersey-json</artifactId> | ||
<version>${dep.jersey.version}</version> | ||
</dependency> | ||
|
||
|
||
<!-- Flink --> | ||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-java</artifactId> | ||
<version>${dep.flink.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-clients_2.11</artifactId> | ||
<version>${dep.flink.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-gelly_2.11</artifactId> | ||
<version>${dep.flink.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-hbase_2.11</artifactId> | ||
<version>${dep.flink.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package Server; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.codehaus.jettison.json.JSONArray; | ||
import org.codehaus.jettison.json.JSONException; | ||
import org.codehaus.jettison.json.JSONObject; | ||
import org.gradoop.common.model.impl.pojo.Edge; | ||
import org.gradoop.common.model.impl.pojo.GraphHead; | ||
import org.gradoop.common.model.impl.pojo.Vertex; | ||
import org.gradoop.common.model.impl.properties.Property; | ||
import org.gradoop.flink.model.impl.LogicalGraph; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* Created by teichmann on 22.09.15. | ||
*/ | ||
public class CytoJSONBuilder { | ||
/** | ||
* Key for vertex, edge and graph id. | ||
*/ | ||
private static final String IDENTIFIER = "id"; | ||
/** | ||
* Key for the type of the returned JSON, either graph or collection. | ||
*/ | ||
private static final String TYPE = "type"; | ||
/** | ||
* Key for meta Json object. | ||
*/ | ||
private static final String META = "meta"; | ||
/** | ||
* Key for data Json object. | ||
*/ | ||
private static final String DATA = "data"; | ||
/** | ||
* Key for vertex, edge and graph label. | ||
*/ | ||
private static final String LABEL = "label"; | ||
/** | ||
* Key for graph identifiers at vertices and edges. | ||
*/ | ||
private static final String GRAPHS = "graphs"; | ||
/** | ||
* Key for properties of graphs, vertices and edges. | ||
*/ | ||
private static final String PROPERTIES = "properties"; | ||
/** | ||
* Key for vertex identifiers at graphs. | ||
*/ | ||
private static final String VERTICES = "nodes"; | ||
/** | ||
* Key for edge identifiers at graphs. | ||
*/ | ||
private static final String EDGES = "edges"; | ||
/** | ||
* Key for edge source vertex id. | ||
*/ | ||
private static final String EDGE_SOURCE = "source"; | ||
/** | ||
* Key for edge target vertex id. | ||
*/ | ||
private static final String EDGE_TARGET = "target"; | ||
|
||
|
||
public CytoJSONBuilder() { | ||
} | ||
|
||
// this actually only returns single graphs, but i will change this later | ||
public String getJSON( | ||
GraphHead graphHead, | ||
List<Vertex> vertices, | ||
List<Edge> edges) throws Exception { | ||
|
||
JSONObject returnedJSON = new JSONObject(); | ||
|
||
returnedJSON.put(TYPE, "graph"); | ||
|
||
JSONArray graphArray = new JSONArray(); | ||
JSONObject graphObject = new JSONObject(); | ||
JSONObject graphProperties = new JSONObject(); | ||
graphObject.put(IDENTIFIER, graphHead.getId()); | ||
graphObject.put(LABEL, graphHead.getLabel()); | ||
if(graphHead.getProperties() != null) { | ||
for (Property prop : graphHead.getProperties()) { | ||
graphProperties.put(prop.getKey(), prop.getValue()); | ||
} | ||
} | ||
graphObject.put(PROPERTIES, graphProperties); | ||
graphArray.put(graphObject); | ||
|
||
returnedJSON.put(GRAPHS, graphArray); | ||
|
||
JSONArray vertexArray = new JSONArray(); | ||
for (Vertex vertex : vertices) { | ||
JSONObject vertexObject = new JSONObject(); | ||
JSONObject vertexData = new JSONObject(); | ||
|
||
vertexData.put(IDENTIFIER, vertex.getId()); | ||
vertexData.put(LABEL, vertex.getLabel()); | ||
JSONObject vertexProperties = new JSONObject(); | ||
if(vertex.getProperties() != null) { | ||
for (Property prop : vertex.getProperties()) { | ||
vertexProperties.put(prop.getKey(), prop.getValue()); | ||
} | ||
} | ||
vertexData.put(PROPERTIES, vertexProperties); | ||
vertexObject.put(DATA, vertexData); | ||
vertexArray.put(vertexObject); | ||
} | ||
returnedJSON.put(VERTICES, vertexArray); | ||
|
||
JSONArray edgeArray = new JSONArray(); | ||
for (Edge edge : edges) { | ||
JSONObject edgeObject = new JSONObject(); | ||
JSONObject edgeData = new JSONObject(); | ||
edgeData.put(EDGE_SOURCE, edge.getSourceId()); | ||
edgeData.put(EDGE_TARGET, edge.getTargetId()); | ||
edgeData.put(IDENTIFIER, edge.getId()); | ||
edgeData.put(LABEL, edge.getLabel()); | ||
JSONObject edgeProperties = new JSONObject(); | ||
if(edge.getProperties() != null) { | ||
for (Property prop : edge.getProperties()) { | ||
edgeProperties.put(prop.getKey(), prop.getValue()); | ||
} | ||
} | ||
edgeData.put(PROPERTIES, edgeProperties); | ||
edgeObject.put(DATA, edgeData); | ||
edgeArray.put(edgeObject); | ||
} | ||
|
||
|
||
returnedJSON.put(EDGES, edgeArray); | ||
return returnedJSON.toString(); | ||
|
||
} | ||
} |
Oops, something went wrong.