I\'m trying to utilize the timetree library in my spring data neo4j 4.0.0 project.
As elaborated in this page, https://github.com/graphaware/neo4j-timetree, I\'ve e
Defining the possible labels for the TimeTree has a little different syntax as explained in the InclusionPolicy documentation https://github.com/graphaware/neo4j-framework/tree/master/common#inclusion-policies
The syntax is the following :
com.graphaware.module.TT.event=hasLabel('StructureVersionChange')||hasLabel('RuleVersionChange')||hasLabel('FilterVersionChange')
For debugging purposes you may want to add these lines to your conf/custom-logback.xml file :
<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>
and look at the extensions.log file
The dependency is only useful if you're using the timetree programatically. If your application is running against a Neo4j server, then you need to download and save to your Neo4j server plugins directory:
a) The GraphAware framework (choose either Community or Enterprise)
b) The TimeTree module
Both can be downloaded from http://graphaware.com/products/
Without this, even with a configuration in neo4j.properties, the GraphAware Runtime isn't started and the timetree will not work.
If you want to run your code via a test, then you need to include the dependencies for the TimeTree and GraphAware Runtime and start the GraphAware Runtime yourself, with code such as:
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();
Then you can write tests such as
@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)"
);
}