春季数据中的Neo4j时间树Neo4j 4.0

春季数据中的Neo4j时间树Neo4j 4.0,neo4j,spring-data-neo4j,graphaware,spring-data-neo4j-4,Neo4j,Spring Data Neo4j,Graphaware,Spring Data Neo4j 4,我试图在我的SpringDataNeo4J4.0.0项目中利用时间树库 如本页所述,我编辑了neo4j.properties文件以启用自动事件附加,将时间树依赖项添加到我的gradle中,并在具有长数据类型的事件节点中设置属性“creationDate”。尽管一切看起来都应该如此,但它仍然没有创建任何时间树 这是我的neo4j.property文件: # Runtime must be enabled like this com.graphaware.runtime.enabled=true

我试图在我的SpringDataNeo4J4.0.0项目中利用时间树库

如本页所述,我编辑了neo4j.properties文件以启用自动事件附加,将时间树依赖项添加到我的gradle中,并在具有长数据类型的事件节点中设置属性“creationDate”。尽管一切看起来都应该如此,但它仍然没有创建任何时间树

这是我的neo4j.property文件:

# 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

# Nodes which represent events and should be attached automatically have to be defined
com.graphaware.module.TT.event=hasLabel('StructureVersionChange'),hasLabel('RuleVersionChange'),hasLabel('FilterVersionChange')

# 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=creationDate

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

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

# 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=CREATED_ON

# autoAttach must be set to true
com.graphaware.module.TT.autoAttach=true
实际上,在此之前,我曾尝试在我的项目中使用JAVA API版本的Timetree,但后来我被Timetree构造函数的参数类型(即节点)弄糊涂了。然而,在spring中,我的节点有其类的类型

提前感谢您,我们将非常感谢您的建议

编辑:

neo4j.特性

# 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

# Nodes which represent events and should be attached automatically have to be defined
com.graphaware.module.TT.event=hasLabel('FilterVersionChange') || hasLabel('StructureVersionChange') || hasLabel('CodeUnitVersionChange') || hasLabel('RuleVersionChange') || hasLabel('EpisodeVersion')

# 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=creationDate

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

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

# 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=CREATED_ON

# autoAttach must be set to true
com.graphaware.module.TT.autoAttach=true
data/log/neo4j.0.0

May 17, 2015 4:07:42 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:07:42 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:07:43 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:11:39 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:11:39 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:11:39 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:28:49 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:28:49 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
May 17, 2015 4:28:49 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
data/graph.db/messages

2015-05-17 14:28:46.537+0000 INFO  [o.n.k.i.DiagnosticsManager]: --- INITIALIZED diagnostics START ---
2015-05-17 14:28:46.538+0000 INFO  [o.n.k.i.DiagnosticsManager]: Neo4j Kernel properties:
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.resolution=DAY
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.timestamp=creationDate
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.relationship=CREATED_ON
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.event=hasLabel('FilterVersionChange') || hasLabel('ArchitectureUnitVersionChange') || hasLabel('CodeUnitVersionChange') || hasLabel('RuleVersionChange') || hasLabel('EpisodeVersion')
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: store_dir=C:\NEO4J-~1.1\data\graph.db
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.runtime.enabled=true
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.autoAttach=true
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: remote_shell_enabled=true
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.timezone=CEST
2015-05-17 14:28:46.541+0000 INFO  [o.n.k.i.DiagnosticsManager]: com.graphaware.module.TT.1=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
2015-05-17 14:28:46.544+0000 INFO  [o.n.k.i.DiagnosticsManager]: Diagnostics providers:
2015-05-17 14:28:46.544+0000 INFO  [o.n.k.i.DiagnosticsManager]: org.neo4j.kernel.configuration.Config
...
...
2015-05-17 14:28:48.656+0000 INFO  [o.n.k.i.DiagnosticsManager]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END ---
2015-05-17 14:28:48.696+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: Database is now ready
2015-05-17 14:28:48.696+0000 INFO  [o.n.s.d.LifecycleManagingDatabase]: Successfully started database
2015-05-17 14:28:48.699+0000 INFO  [o.n.k.i.DiagnosticsManager]: --- SERVER STARTED START ---
2015-05-17 14:28:48.736+0000 INFO  [o.n.s.CommunityNeoServer]: Starting HTTP on port :7474 with 8 threads available
2015-05-17 14:28:48.872+0000 INFO  [o.n.s.CommunityNeoServer]: Enabling HTTPS on port :7473
2015-05-17 14:28:48.989+0000 INFO  [o.n.s.w.Jetty9WebServer]: Mounting static content at [/webadmin] from [webadmin-html]
2015-05-17 14:28:49.023+0000 INFO  [o.n.s.w.Jetty9WebServer]: Mounting static content at [/browser] from [browser]
2015-05-17 14:28:49.956+0000 INFO  [o.n.s.CommunityNeoServer]: Server started on: http://localhost:7474/
2015-05-17 14:28:49.956+0000 INFO  [o.n.s.CommunityNeoServer]: Remote interface ready and available at [http://localhost:7474/]
2015-05-17 14:28:49.956+0000 INFO  [o.n.k.i.DiagnosticsManager]: --- SERVER STARTED END ---
类实体

@NodeEntity
public class FilterVersionChange extends UnitVersion {
    @GraphId
    private Long id;

    public FilterVersionChange() {
        super();
    }

    public FilterVersionChange(String description, Date creationDate)
    {
        super(description, creationDate);
    }

    @Relationship(type="CONTAINS", direction = Relationship.OUTGOING)
    private Set<FilterState> filterStates;

    @Relationship(type="PREVIOUS", direction = Relationship.OUTGOING)
    private FilterVersionChange previousFilterVersionChange;

    @Relationship(type="REFERENCES", direction = Relationship.OUTGOING)
    private FilterVersionChange referencedFilterVersionChange;

    @Relationship(type="ADDED", direction = Relationship.OUTGOING)
    private Set<FilterState> newFilterStates;

    @Relationship(type="DELETED", direction = Relationship.OUTGOING)
    private Set<FilterState> deletedFilterStates;

    @Relationship(type="MODIFIED", direction = Relationship.OUTGOING)
    private Set<ModifiedUnitState> modifiedFilterStates;

    public void contains(Set<FilterState> filterStates) {
        this.filterStates = filterStates;
    }

    public void previous(FilterVersionChange previousFilterVersionChange) {
        this.previousFilterVersionChange = previousFilterVersionChange;
    }

    public void references(FilterVersionChange referencedFilterVersionChange) {
        this.referencedFilterVersionChange = referencedFilterVersionChange;
    }

    public void added(Set<FilterState> newFilterStates) {
        this.newFilterStates = newFilterStates;
    }

    public void deleted(Set<FilterState> deletedFilterStates) {
        this.deletedFilterStates = deletedFilterStates;
    }

    public void modified(Set<ModifiedUnitState> modifiedFilterStates) {
        this.modifiedFilterStates = modifiedFilterStates;
    }
}

定义时间树的可能标签的语法稍有不同,如InclusionPolicy文档中所述

语法如下所示:

com.graphaware.module.TT.event=hasLabel('StructureVersionChange')||hasLabel('RuleVersionChange')||hasLabel('FilterVersionChange')
出于调试目的,您可能希望将以下行添加到conf/custom logback.xml文件中:

<appender name="EXTENSIONLOG"  class="ch.qos.logback.core.FileAppender">
  <file>data/log/extensions.log</file>
  <encoder>
      <pattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ} %-5level [%logger{15}]: %message%n</pattern>
  </encoder>
</appender>

<logger name="com.graphaware" level="debug">
  <appender-ref ref="EXTENSIONLOG"/>
</logger>

data/log/extensions.log
%日期{yyyy-MM-dd HH:MM:ss.SSSZ}%-5级[%logger{15}]:%消息%n

请看extensions.log文件

定义时间树的可能标签的语法稍有不同,如InclusionPolicy文档中所述

语法如下所示:

com.graphaware.module.TT.event=hasLabel('StructureVersionChange')||hasLabel('RuleVersionChange')||hasLabel('FilterVersionChange')
出于调试目的,您可能希望将以下行添加到conf/custom logback.xml文件中:

<appender name="EXTENSIONLOG"  class="ch.qos.logback.core.FileAppender">
  <file>data/log/extensions.log</file>
  <encoder>
      <pattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ} %-5level [%logger{15}]: %message%n</pattern>
  </encoder>
</appender>

<logger name="com.graphaware" level="debug">
  <appender-ref ref="EXTENSIONLOG"/>
</logger>

data/log/extensions.log
%日期{yyyy-MM-dd HH:MM:ss.SSSZ}%-5级[%logger{15}]:%消息%n

请看extensions.log文件

只有在以编程方式使用时间树时,依赖关系才有用。如果您的应用程序是针对Neo4j服务器运行的,那么您需要保存到Neo4j服务器插件目录:

a) GraphAware框架(选择社区或企业)

b) 时间树模块

两者都可以从

否则,即使使用neo4j.properties中的配置,GraphAware运行时也不会启动,时间树也不会工作

如果希望通过测试运行代码,则需要包含时间树和GraphAware运行时的依赖项,并自己启动GraphAware运行时,代码如下:

 GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
        runtime.registerModule(new TimeTreeModule("timetree",
                TimeTreeConfiguration
                        .defaultConfiguration()
                        .with(new NodeInclusionPolicy() {
                            @Override
                            public boolean include(Node node) {
                                return node.hasLabel(DynamicLabel.label("User"));
                            }
                        })

                        })
                        .withRelationshipType(DynamicRelationshipType.withName("CREATED_ON"))
                        .withTimeZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+1")))
                        .withTimestampProperty("createdOn")
                        .withResolution(Resolution.DAY)
                ,
                getDatabase()));
        runtime.start();
然后您可以编写测试,例如

 @Test
    public void shouldSaveUser()
    {
        User user = new User( "Michal" );
        user.setCreatedOn(1431937636995l);
        userRepository.save( user );

        assertSameGraph( getDatabase(), "CREATE (u:User:Person {name:'Michal', createdOn:1431937636995})," +
                "(root:TimeTreeRoot)," +
                        "(root)-[:FIRST]->(year:Year {value:2015})," +
                        "(root)-[:CHILD]->(year)," +
                        "(root)-[:LAST]->(year)," +
                        "(year)-[:FIRST]->(month:Month {value:5})," +
                        "(year)-[:CHILD]->(month)," +
                        "(year)-[:LAST]->(month)," +
                        "(month)-[:FIRST]->(day:Day {value:18})," +
                        "(month)-[:CHILD]->(day)," +
                        "(month)-[:LAST]->(day)," +
                        "(day)<-[:CREATED_ON]-(u)"
        );

    }
@测试
public void shouldSaveUser()
{
用户=新用户(“Michal”);
user.setCreatedOn(1431937636995l);
userRepository.save(用户);
assertSameGraph(getDatabase(),“创建(u:User:Person{name:'Michal',createdOn:1431937636995})”+
“(根:TimeTreeRoot),”+
(根)-[:FIRST]->(年份:年份{value:2015})+
(根)-[:CHILD]->(年)+
(根)-[:上一个]->(年)+
(年)-[:第一]->(月:月{值:5})+
(年)-[:儿童]->(月)+
(年)-[:上一个]->(月)+
(月)-[:第一]->(日:日{值:18})+
(月)-[:儿童]->(日)+
(月)-[:最后一天]>(天)+

“(day)仅当您以编程方式使用时间树时,依赖项才有用。如果您的应用程序运行在Neo4j服务器上,则您需要保存到Neo4j服务器插件目录:

a) GraphAware框架(选择社区或企业)

b) 时间树模块

两者都可以从

否则,即使使用neo4j.properties中的配置,GraphAware运行时也不会启动,时间树也不会工作

如果希望通过测试运行代码,则需要包含时间树和GraphAware运行时的依赖项,并自己启动GraphAware运行时,代码如下:

 GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
        runtime.registerModule(new TimeTreeModule("timetree",
                TimeTreeConfiguration
                        .defaultConfiguration()
                        .with(new NodeInclusionPolicy() {
                            @Override
                            public boolean include(Node node) {
                                return node.hasLabel(DynamicLabel.label("User"));
                            }
                        })

                        })
                        .withRelationshipType(DynamicRelationshipType.withName("CREATED_ON"))
                        .withTimeZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT+1")))
                        .withTimestampProperty("createdOn")
                        .withResolution(Resolution.DAY)
                ,
                getDatabase()));
        runtime.start();
然后您可以编写测试,例如

 @Test
    public void shouldSaveUser()
    {
        User user = new User( "Michal" );
        user.setCreatedOn(1431937636995l);
        userRepository.save( user );

        assertSameGraph( getDatabase(), "CREATE (u:User:Person {name:'Michal', createdOn:1431937636995})," +
                "(root:TimeTreeRoot)," +
                        "(root)-[:FIRST]->(year:Year {value:2015})," +
                        "(root)-[:CHILD]->(year)," +
                        "(root)-[:LAST]->(year)," +
                        "(year)-[:FIRST]->(month:Month {value:5})," +
                        "(year)-[:CHILD]->(month)," +
                        "(year)-[:LAST]->(month)," +
                        "(month)-[:FIRST]->(day:Day {value:18})," +
                        "(month)-[:CHILD]->(day)," +
                        "(month)-[:LAST]->(day)," +
                        "(day)<-[:CREATED_ON]-(u)"
        );

    }
@测试
public void shouldSaveUser()
{
用户=新用户(“Michal”);
user.setCreatedOn(1431937636995l);
userRepository.save(用户);
assertSameGraph(getDatabase(),“创建(u:User:Person{name:'Michal',createdOn:1431937636995})”+
“(根:TimeTreeRoot),”+
(根)-[:FIRST]->(年份:年份{value:2015})+
(根)-[:CHILD]->(年)+
(根)-[:上一个]->(年)+
(年)-[:第一]->(月:月{值:5})+
(年)-[:儿童]->(月)+
(年)-[:上一个]->(月)+
(月)-[:第一]->(日:日{值:18})+
(月)-[:儿童]->(日)+
(月)-[:最后一天]>(天)+

“(日)感谢您指出这一点!但是,我不知道为什么它仍然不起作用。这里仍然没有创建时间树节点。除了添加时间树依赖项、设置此属性文件和在事件节点上提供长类型的时间属性之外,我还遗漏了什么吗?在data/log/console.log和data/g中是否有任何输出raph.db/messages.log文件?您还可以粘贴您使用的触发时间树的代码。我已经编辑了我的帖子。我似乎找不到console.log文件。在我的db目录下只有消息文件。我像往常一样创建事件节点。我希望这个自动附加系统不会在编程方面使用任何额外的代码。console.log位于data/log下谢谢您指出这一点!但是,我不知道为什么它仍然不起作用。这里仍然没有创建时间树节点。除了添加时间树依赖项、设置此属性文件和