首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GraphAware Data Neo4J和Spring TimeTree

GraphAware Data Neo4J和Spring TimeTree
EN

Stack Overflow用户
提问于 2015-07-24 02:49:44
回答 2查看 380关注 0票数 1

有没有人让GraphAware TimeTree使用他们的Java API来处理Spring Data Neo4J,并能提供一个简单的例子?

EN

回答 2

Stack Overflow用户

发布于 2015-07-28 01:52:16

Spring扩展是服务器端代码,GraphAware Data Neo4j是客户端代码。记住这一点,您可以使用与herehere相同的方式注释使用SDN (假设为v4)的Java类,以便使映射与TimeTree结构相匹配。

也就是说,SDN (v4)还没有对非托管扩展和事务事件处理程序(GraphAware框架是这两者)的任何显式支持,因此您需要自己处理它。例如,如果您使用TimeTree自动附加功能并持久化来自SDN的事件,则需要重新加载它才能获取TimeTree节点。

票数 1
EN

Stack Overflow用户

发布于 2016-11-06 07:38:46

这是我的第一个仓库类。似乎是有效的,但Michael或Luanne (或某人)可能会在这方面有很大的改进。我还没有包含对某个范围内事件的查询,但它们很快就会出现。

这里有几个注意事项:

timeType参数是您的域节点和时间表树之间关系的名称。

代码语言:javascript
复制
package myproject.core.repository.timeline;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import myproject.BaseNode;

@Repository
public interface TimelineRepository extends Neo4jRepository<BaseNode> {

// Attaches a node to the time tree
    @Query("match (e:Event {domainId: {domainId}}) with e call ga.timetree.events.attach({node: e, time: {timestamp}, resolution: 'MILLISECOND', relationshipType: {timeType}}) yield node return node;")
    public void setTime(@Param("domainId") String domainId, @Param("timeType") String typeType, @Param("timestamp") Long timestamp);

// Detaches a node from the timetree
    @Query("match (e:Event {domainId: {domainId}})-[s]-() where type(s) = {timeType} delete s;")
    public void unsetTime(@Param("domainId") String domainId, @Param("timeType") String timeType);
}

下面是我的neo4j.conf中的配置。我使用的是neo4j 3.0.6。我在这里写的几乎所有内容都是直接从https://github.com/graphaware/neo4j-timetree的文档中获取的。

代码语言:javascript
复制
#For the framework to work at all, you need this
dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware

# Runtime must be enabled like this
com.graphaware.runtime.enabled=true

# A Runtime module that takes care of attaching the events like this (TT is the ID of the module)
com.graphaware.module.TT.1=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper

# autoAttach must be set to true
com.graphaware.module.TT.autoAttach=true

#Uncommenting this prevents properties of our Event class from persisting
# Optionally, nodes which represent events and should be attached automatically have to be defined (defaults to nodes with label Event)
#com.graphaware.module.TT.event=hasLabel('Message')

# Optionally, a property on the event nodes that represents the the time (long) at which the event took place must be specified (defaults to "timestamp")
#com.graphaware.module.TT.timestamp=time

# Optionally, a property on the event nodes that represents the node ID (long) of the root node for the tree, to which the event should be attached (defaults to "timeTreeRootId")
#com.graphaware.module.TT.customTimeTreeRootProperty=rootId

# Optionally, a resolution can be specified (defaults to DAY)
#com.graphaware.module.TT.resolution=MILLISECOND

# Optionally, a time zone can be specified (defaults to UTC)
#com.graphaware.module.TT.timezone=GMT+1

# Optionally, a relationship type with which the events will be attached to the tree can be specified (defaults to AT_TIME)
#com.graphaware.module.TT.relationship=SENT_ON

# Optionally, a relationship direction (from the tree's point of view), with which the events will be attached to the tree can be specified (defaults to INCOMING)
#com.graphaware.module.TT.direction=INCOMING

您应该能够创建看起来有点像这样的东西(以其最简单的形式)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31595754

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档