有没有人让GraphAware TimeTree使用他们的Java API来处理Spring Data Neo4J,并能提供一个简单的例子?
发布于 2015-07-28 01:52:16
发布于 2016-11-06 07:38:46
这是我的第一个仓库类。似乎是有效的,但Michael或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您应该能够创建看起来有点像这样的东西(以其最简单的形式)。

https://stackoverflow.com/questions/31595754
复制相似问题