下面列出了怎么用com.mongodb.util.JSON的API类实例代码及写法,或者点击链接到github查看源代码。
@Test public void testFindWithMoreResults() throws KettleException, MongoDbException {
// no query or fields defined, should do a collection.find()
setupReturns();
when( mockCursor.hasNext() ).thenReturn( true );
ServerAddress serverAddress = mock( ServerAddress.class );
when( serverAddress.toString() ).thenReturn( "serveraddress" );
when( mockCursor.getServerAddress() ).thenReturn( serverAddress );
DBObject nextDoc = (DBObject) JSON.parse( "{ 'foo' : 'bar' }" );
when( mockCursor.next() ).thenReturn( nextDoc );
dbInput.setStopped( false );
dbInput.init( stepMetaInterface, stepDataInterface );
assertTrue( "more results -> should return true", dbInput.processRow( stepMetaInterface, stepDataInterface ) );
verify( mongoCollectionWrapper ).find();
verify( mockCursor ).next();
verify( mockLog ).logBasic( stringCaptor.capture() );
assertThat( stringCaptor.getValue(), containsString( "serveraddress" ) );
assertThat( stepDataInterface.cursor, equalTo( mockCursor ) );
assertThat( putRow[0], CoreMatchers.<Object>equalTo( JSON.serialize( nextDoc ) ) );
}
private JSONArray getJSONArrayFromDB(String db, String col) {
try {
JSONArray result = new JSONArray();
DBCollection collection = mongo.getDB(db).getCollectionFromString(col);
DBCursor cursor = collection.find();
while(cursor.hasNext()) {
DBObject obj = cursor.next();
JSONObject json = new JSONObject(JSON.serialize(obj));
result.put(json);
}
return result;
}
catch(Exception e) {
System.out.println("We got an error when creating a JSONArray: " + e);
return null;
}
}
@GetMapping(path = "/{collectionName}")
@ApiOperation(value = "List all data from collection")
@PreAuthorize("hasAuthority('SHOW_PRIVATE_STORAGE')")
public Object list(
@PathVariable("application") String applicationId,
@PathVariable("collectionName") String collection) throws BadServiceResponseException, NotFoundResponseException {
Tenant tenant = user.getTenant();
Application application = getApplication(applicationId);
ServiceResponse<List<PrivateStorage>> response = null;
try {
response = privateStorageService.findAll(tenant, application, user.getParentUser(), collection);
if (!response.isOk()) {
throw new NotFoundResponseException(response);
} else {
return response.getResult()
.stream()
.map(p -> JSON.parse(p.getCollectionContent()))
.collect(Collectors.toList());
}
} catch (JsonProcessingException e) {
throw new NotFoundResponseException(response);
}
}
/**
* Testing the use of Environment Substitution during initialization of fields.
* @throws Exception
*/
@Test public void testTopLevelArrayWithEnvironmentSubstitution() throws Exception {
List<MongoDbOutputMeta.MongoField> paths = asList( mf( "${ENV_FIELD}", true, "[0]" ),
mf( "field2", true, "${ENV_DOC_PATH}" ) );
RowMetaInterface rmi = new RowMeta();
rmi.addValueMeta( new ValueMetaString( "field1" ) );
rmi.addValueMeta( new ValueMetaInteger( "field2" ) );
Object[] row = new Object[ 2 ];
row[ 0 ] = "value1";
row[ 1 ] = 12L;
VariableSpace vs = new Variables();
vs.setVariable( "ENV_FIELD", "field1" );
vs.setVariable( "ENV_DOC_PATH", "[1]" );
for ( MongoDbOutputMeta.MongoField f : paths ) {
f.init( vs );
}
DBObject result = kettleRowToMongo( paths, rmi, row, MongoDbOutputData.MongoTopLevel.ARRAY, false );
assertEquals( JSON.serialize( result ), "[ { \"field1\" : \"value1\"} , { \"field2\" : 12}]" );
}
@Test public void testPipelineQueryIsLimited() throws KettleException, MongoDbException {
setupPerform();
String query = "{$sort : 1}";
// Setup DBObjects collection
List<DBObject> dbObjects = new ArrayList<DBObject>();
DBObject firstOp = (DBObject) JSON.parse( query );
DBObject[] remainder = { new BasicDBObject( "$limit", NUM_DOCS_TO_SAMPLE ) };
dbObjects.add( firstOp );
Collections.addAll( dbObjects, remainder );
AggregationOptions options = AggregationOptions.builder().build();
//when( MongodbInputDiscoverFieldsImpl.jsonPipelineToDBObjectList( query ) ).thenReturn( dbObjects );
when( collection.aggregate( anyList(), any( AggregationOptions.class ) ) )
.thenReturn( cursor );
discoverFields.discoverFields( new MongoProperties.Builder(), "mydb", "mycollection", query, "", true,
NUM_DOCS_TO_SAMPLE, inputMeta );
verify( collection ).aggregate( anyList(), any( AggregationOptions.class ) );
}
@PostMapping
@ApiOperation(value = "Create a application document")
@PreAuthorize("hasAuthority('ADD_APPLICATION')")
public Object create(
@PathVariable("application") String applicationId,
@PathVariable("collection") String collection,
@PathVariable("key") String key,
@ApiParam(name = "body", required = true)
@RequestBody String jsonCustomData) throws BadServiceResponseException, NotFoundResponseException {
Tenant tenant = user.getTenant();
Application application = getApplication(applicationId);
ServiceResponse<ApplicationDocumentStore> deviceResponse = applicationDocumentStoreService.save(tenant, application, collection, key, jsonCustomData);
if (!deviceResponse.isOk()) {
throw new BadServiceResponseException( deviceResponse, validationsCode);
} else {
return JSON.parse(deviceResponse.getResult().getJson());
}
}
@Test
public void shouldListData() throws Exception {
when(privateStorageService.findAll(any(Tenant.class), any(Application.class), any(User.class), anyString()))
.thenReturn(ServiceResponseBuilder.<List<PrivateStorage>>ok()
.withResult(allData).build());
getMockMvc().perform(MockMvcRequestBuilders.get(MessageFormat.format("/{0}/{1}/{2}", application.getName(), BASEPATH, "customers"))
.contentType("application/json")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.code", is(HttpStatus.OK.value())))
.andExpect(jsonPath("$.status", is("success")))
.andExpect(jsonPath("$.timestamp",greaterThan(1400000000)))
.andExpect(jsonPath("$.result").isArray())
.andExpect(jsonPath("$.result[0]", is(JSON.parse(json1))))
.andExpect(jsonPath("$.result[1]", is(JSON.parse(json2))));
}
@Test
public void shouldReadData() throws Exception {
when(privateStorageService.findByQuery(any(Tenant.class), any(Application.class), any(User.class), anyString(), any(Map.class), anyString(), any(Integer.class), any(Integer.class)))
.thenReturn(ServiceResponseBuilder.<List<PrivateStorage>>ok()
.withResult(Collections.singletonList(privateStorage1)).build());
getMockMvc().perform(MockMvcRequestBuilders.get(MessageFormat.format("/{0}/{1}/{2}/search", application.getName(), BASEPATH, "customers"))
.contentType("application/json")
.param("q", "customers=konker")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.code", is(HttpStatus.OK.value())))
.andExpect(jsonPath("$.status", is("success")))
.andExpect(jsonPath("$.timestamp",greaterThan(1400000000)))
.andExpect(jsonPath("$.result").isArray())
.andExpect(jsonPath("$.result[0]", is(JSON.parse(json1))));
}
@Test
public void shouldCreateData() throws Exception {
when(privateStorageService.save(any(Tenant.class), any(Application.class), any(User.class), anyString(), anyString()))
.thenReturn(ServiceResponseBuilder.<PrivateStorage>ok().withResult(privateStorage1).build());
getMockMvc().perform(MockMvcRequestBuilders.post(MessageFormat.format("/{0}/{1}/{2}", application.getName(), BASEPATH, "customers"))
.content(json1)
.contentType("application/json")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.code", is(HttpStatus.CREATED.value())))
.andExpect(jsonPath("$.status", is("success")))
.andExpect(jsonPath("$.timestamp",greaterThan(1400000000)))
.andExpect(jsonPath("$.result").isMap())
.andExpect(jsonPath("$.result", is(JSON.parse(json1))));
}
@Test
public void shouldCreateDevice() throws Exception {
when(deviceCustomDataService.save(tenant, application, device1, json1))
.thenReturn(ServiceResponseBuilder.<DeviceCustomData>ok().withResult(deviceCustomData1).build());
getMockMvc().perform(MockMvcRequestBuilders.post(MessageFormat.format("/{0}/{1}/{2}/{3}", application.getName(), BASEPATH, device1.getGuid(), CUSTOMDATAPATH))
.content(json1)
.contentType("application/json")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.code", is(HttpStatus.CREATED.value())))
.andExpect(jsonPath("$.status", is("success")))
.andExpect(jsonPath("$.timestamp",greaterThan(1400000000)))
.andExpect(jsonPath("$.result").isMap())
.andExpect(jsonPath("$.result", is(JSON.parse(json1))));
}
@Test public void testTopLevelObjectStructureOneLevelNestedDoc() throws Exception {
List<MongoDbOutputMeta.MongoField> paths = asList( mf( "field1", true, "" ), mf( "field2", true, "nestedDoc" ) );
RowMetaInterface rmi = new RowMeta();
rmi.addValueMeta( new ValueMetaString( "field1" ) );
rmi.addValueMeta( new ValueMetaInteger( "field2" ) );
Object[] row = new Object[ 2 ];
row[ 0 ] = "value1";
row[ 1 ] = 12L;
VariableSpace vs = new Variables();
for ( MongoDbOutputMeta.MongoField f : paths ) {
f.init( vs );
}
DBObject result = kettleRowToMongo( paths, rmi, row, MongoDbOutputData.MongoTopLevel.RECORD, false );
assertEquals( JSON.serialize( result ), "{ \"field1\" : \"value1\" , \"nestedDoc\" : { \"field2\" : 12}}" );
}
@Test
public void shouldCreateDevice() throws Exception {
when(applicationDocumentStoreService.save(tenant, application, "collection1", "keyA", json1))
.thenReturn(ServiceResponseBuilder.<ApplicationDocumentStore>ok().withResult(deviceCustomData1).build());
getMockMvc().perform(MockMvcRequestBuilders.post(MessageFormat.format("/{0}/{1}/{2}/{3}", application.getName(), BASEPATH, "collection1", "keyA", CUSTOMDATAPATH))
.content(json1)
.contentType("application/json")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.code", is(HttpStatus.CREATED.value())))
.andExpect(jsonPath("$.status", is("success")))
.andExpect(jsonPath("$.timestamp",greaterThan(1400000000)))
.andExpect(jsonPath("$.result").isMap())
.andExpect(jsonPath("$.result", is(JSON.parse(json1))));
}
/**
* Replaced the parameter place-holders with the actual parameter values from the given {@link ParameterBinding}s.
*
* @param query - the query string with placeholders
* @return - the string with values replaced
*/
@SuppressWarnings({"Duplicates", "WeakerAccess"})
protected String replacePlaceholders(String query) {
List<ParameterBinding> queryParameterBindings = parameterBindingParser.parseParameterBindingsFrom(query, JSON::parse);
if (queryParameterBindings.isEmpty()) {
return query;
}
String lquery = query;
if(query.contains("@@")) {
// strip quotes from the query
lquery = query.replace("\"", "").replace("@@", "@");
}
StringBuilder result = new StringBuilder(lquery);
for (ParameterBinding binding : queryParameterBindings) {
String parameter = binding.getParameter();
int idx = result.indexOf(parameter);
String parameterValueForBinding = getParameterValueForBinding(convertingParameterAccessor, binding);
if (idx != -1) {
result.replace(idx, idx + parameter.length(), parameterValueForBinding);
}
}
LOGGER.debug("Query after replacing place holders - {}", result);
return result.toString();
}
/**
* Replaced the parameter place-holders with the actual parameter values from the given {@link ParameterBinding}s.
*
* @param query - the query string with placeholders
* @return - the string with values replaced
*/
@SuppressWarnings({"Duplicates", "WeakerAccess"})
protected String replacePlaceholders(String query) {
List<ParameterBinding> queryParameterBindings = parameterBindingParser.parseParameterBindingsFrom(query, JSON::parse);
if (queryParameterBindings.isEmpty()) {
return query;
}
String lquery = query;
if(query.contains("@@")) {
// strip quotes from the query
lquery = query.replace("\"", "").replace("@@", "@");
}
StringBuilder result = new StringBuilder(lquery);
for (ParameterBinding binding : queryParameterBindings) {
String parameter = binding.getParameter();
int idx = result.indexOf(parameter);
String parameterValueForBinding = getParameterValueForBinding(convertingParameterAccessor, binding);
if (idx != -1) {
result.replace(idx, idx + parameter.length(), parameterValueForBinding);
}
}
LOGGER.debug("Query after replacing place holders - {}", result);
return result.toString();
}
public static List<Item> loadItemsFromFile(String filename){
List<Item> items=new ArrayList<Item>();
try{
BufferedReader br=new BufferedReader(new FileReader(filename));
String line=null;
while((line=br.readLine())!=null){
if(line.trim()!=""){
Item new_item=new Item();
DBObject dbObject = (DBObject) JSON.parse(line);
String id=(String) dbObject.get("id_str");
new_item.setId(id);
String text=(String) dbObject.get("text");
new_item.setTitle(text);
DBObject tmp_obj=(DBObject) dbObject.get("user");
String uploader=(String) tmp_obj.get("screen_name");
new_item.setAuthorScreenName(uploader);
items.add(new_item);
}
}
br.close();
}
catch(Exception ex){
ex.printStackTrace();
}
return items;
}
@Override
public int _countByCriteria(Table table) {
int count = 0;
Map<String, Object> coditon = new HashMap<String, Object>();
try {
QueryCriteria queryCriteria = table.getQueryCriteria();
com.mongodb.client.MongoDatabase db = database.getMongoDB();
for(Criteria criteria:queryCriteria.getOredCriteria()){
for(Criterion criterion:criteria.getAllCriteria()){
coditon = buildCriteria(criterion, coditon);
}
}
long size = db.getCollection(queryCriteria.getTable()).count(Document.parse((JSON.serialize(coditon))));
LOG.debug("countByCriteria->collection:"+queryCriteria.getTable()+",script:"+JSON.serialize(coditon));
count = (int) size;
} catch (MongoException e) {
LOG.error("mongo find error", e);
}
LOG.debug("_countByCriteria->result:"+count);
return count;
}
@Override
public int _updateByCriteria(Table table) {
Map<String, Object> coditon = new HashMap<String, Object>();
try {
QueryCriteria queryCriteria = table.getQueryCriteria();
com.mongodb.client.MongoDatabase db = database.getMongoDB();
for(Criteria criteria:queryCriteria.getOredCriteria()){
for(Criterion criterion:criteria.getAllCriteria()){
coditon = buildCriteria(criterion, coditon);
}
}
Map<String, Object> vaule = new HashMap<String, Object>();
vaule.put("$set", table.getParams());
db.getCollection(queryCriteria.getTable()).updateMany(Document.parse((JSON.serialize(coditon))), Document.parse(JSON.serialize(vaule)));
LOG.debug("updateByCriteria->collection:"+table.getTableName()+",value:"+JSON.serialize(vaule)+",condition:"+JSON.serialize(coditon));
} catch (MongoException e) {
LOG.error("mongo update error", e);
}
return 1;
}
@Override
public int _updateByPrimaryKey(Table table) {
try {
if(table.getConditions().containsKey("_id")){
com.mongodb.client.MongoDatabase db = database.getMongoDB();
Object id = table.getConditions().get("_id");
table.getParams().remove("id");//id被永久屏蔽
Map<String, Object> vaule = new HashMap<String, Object>();
vaule.put("$set", table.getParams());
db.getCollection(table.getTableName()).updateOne(eq("_id", new ObjectId(String.valueOf(id))), Document.parse(JSON.serialize(vaule)));
LOG.debug("updateByPrimaryKey->collection:"+table.getTableName()+",value:"+JSON.serialize(vaule)+",condition:"+eq("_id", new ObjectId(String.valueOf(id)).toString()));
return 1;
}
} catch (MongoException e) {
LOG.error("mongo update error", e);
}
return 0;
}
@Override
public int _deleteByCriteria(Table table) {
Map<String, Object> coditon = new HashMap<String, Object>();
try {
QueryCriteria queryCriteria = table.getQueryCriteria();
com.mongodb.client.MongoDatabase db = database.getMongoDB();
for(Criteria criteria:queryCriteria.getOredCriteria()){
for(Criterion criterion:criteria.getAllCriteria()){
coditon = buildCriteria(criterion, coditon);
}
}
db.getCollection(queryCriteria.getTable()).deleteMany(Document.parse((JSON.serialize(coditon))));
LOG.debug("deleteByCriteria->collection:"+table.getTableName()+",condition:"+JSON.serialize(coditon));
} catch (MongoException e) {
LOG.error("mongo delete error", e);
}
return 1;
}
@Test public void testTopLevelObjectStructureNoNestedDocs() throws Exception {
List<MongoDbOutputMeta.MongoField> paths = asList( mf( "field1", true, "" ), mf( "field2", true, "" ) );
RowMetaInterface rmi = new RowMeta();
rmi.addValueMeta( new ValueMetaString( "field1" ) );
rmi.addValueMeta( new ValueMetaInteger( "field2" ) );
Object[] row = new Object[ 2 ];
row[ 0 ] = "value1";
row[ 1 ] = 12L;
VariableSpace vs = new Variables();
for ( MongoDbOutputMeta.MongoField f : paths ) {
f.init( vs );
}
DBObject result = kettleRowToMongo( paths, rmi, row, MongoDbOutputData.MongoTopLevel.RECORD, false );
assertEquals( JSON.serialize( result ), "{ \"field1\" : \"value1\" , \"field2\" : 12}" );
}
@GET
@Path("/{feed}/{channel}/data")
public List<Sample> queryChannel(
@PathParam("feed") String feedId,
@PathParam("channel") String channelId,
@QueryParam("source") String sourceString,
@QueryParam("ts") long timeStart,
@QueryParam("range") long timeRange,
@QueryParam("query") JSONParam query,
@QueryParam("proj") JSONParam projection,
@QueryParam("limit") @DefaultValue("100") int limit) {
// Find the correct channel implementation
Channel channel = channelService.getChannel(feedId, channelId);
// The source may be null or JSON
Object source = null;
if(sourceString != null){
source = JSON.parse(sourceString);
}
// push it to the channel correct
DBObject dbQuery = query != null ? query.toDBObject() : null;
DBObject dbProjection = projection != null ? projection.toDBObject() : null;
return channel.query(source, timeStart, timeRange, dbQuery, dbProjection, limit);
}
@Test
public void buildDBObjectFromTreeWithSubNodes() throws Exception {
DBObject jsonObject = (DBObject) JSON.parse(IOUtils.toString(getClass().getResourceAsStream("simpleDocumentWithInnerNodes.json")));
// Hack to convert _id fron string to ObjectId
jsonObject.put("_id", new ObjectId(String.valueOf(jsonObject.get("_id"))));
NoSqlTreeNode treeNode = (NoSqlTreeNode) JsonTreeModel.buildJsonTree(jsonObject);
// Simulate updating from the treeNode
NoSqlTreeNode innerDocNode = (NoSqlTreeNode) treeNode.getChildAt(4);
NoSqlTreeNode soldOutNode = (NoSqlTreeNode) innerDocNode.getChildAt(2);
soldOutNode.getDescriptor().setValue("false");
DBObject dbObject = JsonTreeModel.buildDBObject(treeNode);
assertEquals("{ \"_id\" : { \"$oid\" : \"50b8d63414f85401b9268b99\"} , \"label\" : \"toto\" , \"visible\" : false , \"image\" : null , \"innerdoc\" : { \"title\" : \"What?\" , \"numberOfPages\" : 52 , \"soldOut\" : false}}",
dbObject.toString());
}
static Object parseJSONExpr( String jsonExpr ) throws OdaException
{
try
{
return JSON.parse( jsonExpr );
}
catch( JSONParseException ex )
{
String errMsg = Messages.bind( Messages.driverUtil_parsingError,
jsonExpr );
DriverUtil.getLogger().log( Level.INFO, errMsg, ex ); // caller may choose to ignore it; log at INFO level
OdaException newEx = new OdaException( errMsg );
newEx.initCause( ex );
throw newEx;
}
}
private void doInsert(MongoCollection collection, String opQuery, Object[] parameters) throws DataServiceFault {
if (opQuery != null) {
if (parameters.length > 0) {
if (opQuery.equals("#")) {
collection.save(JSON.parse(parameters[0].toString()));
} else {
collection.insert(opQuery, parameters);
}
} else {
collection.insert(opQuery);
}
} else {
throw new DataServiceFault("Mongo insert statements must contain a query");
}
}
@Test
public void findDocumentFromANode() throws Exception {
BasicDBList dbList = (BasicDBList) JSON.parse(IOUtils.toString(getClass().getResourceAsStream("arrayOfDocuments.json")));
DBObject first = (DBObject) dbList.get(0);
first.put("_id", new ObjectId(String.valueOf(first.get("_id"))));
DBObject second = (DBObject) dbList.get(1);
second.put("_id", new ObjectId(String.valueOf(second.get("_id"))));
NoSqlTreeNode treeNode = (NoSqlTreeNode) JsonTreeModel.buildJsonTree(dbList);
assertEquals(first, JsonTreeModel.findDocument((NoSqlTreeNode) treeNode.getChildAt(0)));
}
public void submitToPubmedDB(PubmedEntry entry) {
List<String> xPath = new ArrayList<String>();
xPath.add("MedlineCitation"); xPath.add("PMID");
int pmid = Integer.parseInt(entry.getXPathString(xPath));
if(this.dbPubmed != null) {
WriteResult result;
if (alreadyEntered(entry, pmid))
return;
DBObject doc = (DBObject)JSON.parse(entry.toJSON());
doc.put("_id", pmid);
this.dbPubmed.insert(doc);
} else
Logger.printf(0, "Pubmed Entry [%d]: %s\n", pmid, entry); // human readable...
}
public static void main(String[] args) {
put("/submitOrder", "application/json", (request, response) -> {
String body = request.body();
if (!isNullOrEmpty(body)) {
DBObject order = (DBObject) JSON.parse(body);
DB_COLLECTION.save(order);
response.status(HttpStatus.CREATED_201);
return "";
}
response.status(HttpStatus.BAD_REQUEST_400);
return "";
});
}
@Test
public void testDocToFields() {
Map<String, MongoField> fieldMap = new LinkedHashMap<String, MongoField>();
DBObject doc = (DBObject) JSON.parse( "{\"fred\" : {\"george\" : 1}, \"bob\" : [1 , 2]}" );
MongodbInputDiscoverFieldsImpl.docToFields( doc, fieldMap );
assertThat( 3, equalTo( fieldMap.size() ) );
assertThat( fieldMap.get( "$.fred.george" ), notNullValue() );
assertThat( fieldMap.get( "$.bob[0]" ), notNullValue() );
assertThat( fieldMap.get( "$.bob[1]" ), notNullValue() );
assertThat( fieldMap.get( "$.bob[2]" ), equalTo( null ) );
}
@Test
public void testConvertArrayIndicesToKettleValue() throws KettleException {
BasicDBObject dbObj = (BasicDBObject) JSON.parse( "{ parent : { fieldName : ['valA', 'valB'] } } " );
initField( "fieldName", "$.parent.fieldName[0]", "String" );
assertThat( field.convertToKettleValue( dbObj ), equalTo( (Object) "valA" ) );
initField( "fieldName", "$.parent.fieldName[1]", "String" );
assertThat( field.convertToKettleValue( dbObj ), equalTo( (Object) "valB" ) );
}
@Override
public EventVO apply(Event t) {
EventVO vo = new EventVO();
vo.setTimestamp(t.getCreationTimestamp().toString());
vo.setIngestedTimestamp(t.getIngestedTimestamp().toString());
vo.setIncoming(new EventActorVO().apply(t.getIncoming()));
vo.setOutgoing(new EventActorVO().apply(t.getOutgoing()));
vo.setGeolocation(new EventGeolocationVO().apply(t.getGeolocation()));
vo.setPayload(JSON.parse(t.getPayload()));
return vo;
}