Add constructors for models, add helper structure to repositories
This commit is contained in:
parent
ed862d2f8f
commit
045f526d79
|
@ -3,6 +3,7 @@ package de.hsh.inform.orientdb_project.model;
|
|||
import org.pcap4j.packet.EthernetPacket;
|
||||
|
||||
import com.orientechnologies.orient.core.metadata.schema.OType;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;
|
||||
|
||||
|
@ -46,6 +47,18 @@ public class EthernetFrameModel {
|
|||
this.microseconds = ms;
|
||||
}
|
||||
|
||||
public EthernetFrameModel(Vertex v) {
|
||||
this.ts = v.getProperty("timestamp");
|
||||
this.ms = v.getProperty("microseconds");
|
||||
this.sourceMac = v.getProperty("sourceMac");
|
||||
this.targetMac = v.getProperty("targetMac");
|
||||
this.rawData = v.getProperty("rawData");
|
||||
this.size = v.getProperty("size");
|
||||
this.payloadSize = v.getProperty("payloadSize");
|
||||
this.timestamp = ts;
|
||||
this.microseconds = ms;
|
||||
}
|
||||
|
||||
public Object[] getArguments() {
|
||||
Object[] arguments = {
|
||||
"sourceMac", this.sourceMac,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.hsh.inform.orientdb_project.model;
|
||||
|
||||
import com.orientechnologies.orient.core.metadata.schema.OType;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;
|
||||
|
||||
|
@ -24,6 +25,11 @@ public class HostModel {
|
|||
this.internal = internal;
|
||||
}
|
||||
|
||||
public HostModel(Vertex v) {
|
||||
this.internal = v.getProperty("internal");
|
||||
this.ipAddress = v.getProperty("ipAddress");
|
||||
}
|
||||
|
||||
public Object[] getArguments() {
|
||||
Object[] arguments = {
|
||||
"ipAddress", this.ipAddress,
|
||||
|
|
|
@ -60,7 +60,16 @@ public class TcpConnectionModel {
|
|||
}
|
||||
|
||||
public TcpConnectionModel(Vertex v) {
|
||||
// TODO!
|
||||
this.startTs = v.getProperty("startTs");
|
||||
this.startMs = v.getProperty("startMs");
|
||||
this.endTs = v.getProperty("endTs");
|
||||
this.endMs = v.getProperty("endMs");
|
||||
this.sourceIp = v.getProperty("sourceIp");
|
||||
this.sourcePort = v.getProperty("sourcePort");
|
||||
this.targetIp = v.getProperty("targetIp");
|
||||
this.targetPort = v.getProperty("targetPort");
|
||||
this.volumeSourceToTarget = v.getProperty("volumeSourceToTarget");
|
||||
this.volumeTargetToSource = v.getProperty("volumeTargetToSource");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package de.hsh.inform.orientdb_project.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.tinkerpop.blueprints.GraphQuery;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
|
||||
import de.hsh.inform.orientdb_project.model.EthernetFrameModel;
|
||||
|
@ -14,8 +17,18 @@ public class EthernetFrameRepository {
|
|||
}
|
||||
|
||||
public List<EthernetFrameModel> findAllByRawData(byte[] content) {
|
||||
// TODO!
|
||||
return null;
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "EthernetFrame");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
private List<EthernetFrameModel> getListFromVertices(Iterable<Vertex> vertices) {
|
||||
List<EthernetFrameModel> result = new ArrayList<EthernetFrameModel>();
|
||||
for(Vertex v : vertices) {
|
||||
result.add(new EthernetFrameModel(v));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package de.hsh.inform.orientdb_project.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.tinkerpop.blueprints.GraphQuery;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
|
||||
import de.hsh.inform.orientdb_project.model.HostModel;
|
||||
|
@ -15,20 +18,33 @@ public class HostRepository {
|
|||
}
|
||||
|
||||
public List<HostModel> findByConnectionsTo(String ipAddress, int port) {
|
||||
// TODO!
|
||||
return null;
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "Host");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
public List<HostModel> findAllByConnectionsToOutsideHosts() {
|
||||
// TODO!
|
||||
return null;
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "Host");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
|
||||
public List<HostModel> findByIncomingConnectionOnPort(int port) {
|
||||
return null;
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "Host");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
|
||||
private List<HostModel> getListFromVertices(Iterable<Vertex> vertices) {
|
||||
List<HostModel> result = new ArrayList<HostModel>();
|
||||
for(Vertex v : vertices) {
|
||||
result.add(new HostModel(v));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.hsh.inform.orientdb_project.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.tinkerpop.blueprints.GraphQuery;
|
||||
|
@ -35,20 +36,22 @@ public class TcpConnectionRepository {
|
|||
}
|
||||
}, ts);
|
||||
|
||||
System.out.println("Ergebnisse:");
|
||||
for(Vertex v : gq.vertices()) {
|
||||
for(String key : v.getPropertyKeys()) {
|
||||
System.out.print(key + ": " + v.getProperty(key) + ", ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("----");
|
||||
return null;
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
public List<TcpConnectionModel> getTotalDataVolumeBetweenHosts(String ipA, String ipB) {
|
||||
// TODO!
|
||||
return null;
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "TcpConnection");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
}
|
||||
|
||||
private List<TcpConnectionModel> getListFromVertices(Iterable<Vertex> vertices) {
|
||||
List<TcpConnectionModel> result = new ArrayList<TcpConnectionModel>();
|
||||
for(Vertex v : vertices) {
|
||||
result.add(new TcpConnectionModel(v));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue