我目前正在使用 Neo4j TimeTree REST API,有没有办法导航到给定时间戳之前和之后的时间?我的决议是秒,我只是意识到如果分钟发生了变化,那么没有“下一个”关系将前一分钟的前一秒与当前的秒连接起来。这使得密码查询变得非常复杂,如果它已经可用,我只是不想再次重新发明轮子。在此先感谢您的回复,我们将不胜感激!
编辑
我必须再次重现丢失的 NEXT 关系问题,如下图所示。这从我第三次添加新的第二时间瞬间开始发生。
我实际上创建了一个 NodeEntity 来操作第二个节点。课程如下。
@NodeEntity(label = "Second")
public class TimeTreeSecond {
@GraphId
private Long id;
private Integer value;
@Relationship(type = "CREATED_ON", direction = Relationship.INCOMING)
private FilterVersionChange relatedFilterVersionChange;
@Relationship(type = "NEXT", direction = Relationship.OUTGOING)
private TimeTreeSecond nextTimeTreeSecond;
@Relationship(type = "NEXT", direction = Relationship.INCOMING)
private TimeTreeSecond prevTimeTreeSecond;
public TimeTreeSecond() {
}
public Long getId() {
return id;
}
public void next(TimeTreeSecond nextTimeTreeSecond) {
this.nextTimeTreeSecond = nextTimeTreeSecond;
}
public FilterVersionChange getRelatedFilterVersionChange() {
return relatedFilterVersionChange;
}
}
这里的问题是 Incoming NEXT 关系。当我省略它时,一切正常。有时,当我以短暂的延迟重复创建时间瞬间时,我什至会在控制台中遇到这种异常。
Exception in thread "main" org.neo4j.ogm.session.result.ResultProcessingException: Could not initialise response
at org.neo4j.ogm.session.response.GraphModelResponse.<init>(GraphModelResponse.java:38)
at org.neo4j.ogm.session.request.SessionRequestHandler.execute(SessionRequestHandler.java:55)
at org.neo4j.ogm.session.Neo4jSession.load(Neo4jSession.java:108)
at org.neo4j.ogm.session.Neo4jSession.load(Neo4jSession.java:100)
at org.springframework.data.neo4j.repository.GraphRepositoryImpl.findOne(GraphRepositoryImpl.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:452)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:437)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:409)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy32.findOne(Unknown Source)
at de.rwthaachen.service.core.FilterDefinitionServiceImpl.createNewFilterVersionChange(FilterDefinitionServiceImpl.java:100)
at sampleapp.FilterLauncher.main(FilterLauncher.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.neo4j.ogm.session.result.ResultProcessingException: "errors":[{"code":"Neo.ClientError.Statement.InvalidType","message":"Expected a numeric value for empty iterator, but got null"}]}
at org.neo4j.ogm.session.response.JsonResponse.parseErrors(JsonResponse.java:128)
at org.neo4j.ogm.session.response.JsonResponse.parseColumns(JsonResponse.java:102)
at org.neo4j.ogm.session.response.JsonResponse.initialiseScan(JsonResponse.java:46)
at org.neo4j.ogm.session.response.GraphModelResponse.initialiseScan(GraphModelResponse.java:66)
at org.neo4j.ogm.session.response.GraphModelResponse.<init>(GraphModelResponse.java:36)
... 27 more
2015-05-23 01:30:46,204 INFO ork.data.neo4j.config.Neo4jConfiguration: 62 - Intercepted exception
下面是我用来创建时间即时节点的一个 REST 调用示例: http://localhost:7474/graphaware/timetree/1202/single/1432337658713?resolution=Second&timezone=Europe/Amsterdam
我用来创建数据的方法:
public FilterVersionChange createNewFilterVersionChange(String projectName,
String filterVersionName,
String filterVersionChangeDescription,
Set<FilterState> filterStates)
{
Long filterVersionNodeId = filterVersionRepository.findFilterVersionByName(projectName, filterVersionName);
FilterVersion newFilterVersion = filterVersionRepository.findOne(filterVersionNodeId, 2);
// Populate all the existing filters in the current project
Map<String, Filter> existingFilters = new HashMap<String, Filter>();
try
{
for(Filter filter : newFilterVersion.getProject().getFilters())
{
existingFilters.put(filter.getMatchingString(), filter);
}
}
catch(Exception e) {}
// Map the filter states to the populated filters, if any. Otherwise, create new filter for it.
for(FilterState filterState : filterStates)
{
Filter filter = existingFilters.get(filterState.getMatchingString());
if(filter == null)
{
filter = new Filter(filterState.getMatchingString(), filterState.getMatchingType(), newFilterVersion.getProject());
}
filterState.stateOf(filter);
}
Long now = System.currentTimeMillis();
TimeTreeSecond timeInstantNode = timeTreeSecondRepository.findOne(timeTreeService.getFilterTimeInstantNodeId(projectName, now));
FilterVersionChange filterVersionChange = new FilterVersionChange(filterVersionChangeDescription, now, filterStates, filterStates, newFilterVersion, timeInstantNode);
FilterVersionChange addedFilterVersionChange = filterVersionChangeRepository.save(filterVersionChange);
return addedFilterVersionChange;
}