1

有没有人使用他们的 Java API 让 GraphAware TimeTree 与 Spring Data Neo4J 一起工作,并且可以提供一个简单的例子吗?

4

2 回答 2

1

GraphAware extensions are server-side code and Spring Data Neo4j is client-side. Bearing that in mind, you could annotate your Java classes that use SDN (assuming v4) along the same lines as here and here in order to make your mapping match the TimeTree structure.

That said, SDN (v4) does not yet have any explicit support for unmanaged extensions and transaction event handlers (GraphAware Framework is both of these), so you will need to handle this yourself. For instance, if you use the TimeTree auto-attachment feature and persist an Event from SDN, you will need to reload it in order to fetch the TimeTree nodes.

于 2015-07-27T17:52:15.740 回答
1

这是我的第一个存储库类。似乎工作,但迈克尔或 Luanne(或某人)可能能够显着改善这一点。我还没有包含对某个范围内的事件的查询,但它们即将到来。

关于此处内容的几点说明:

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

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上的文档。

#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

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

事件示例

于 2016-11-05T23:38:46.137 回答