我正在使用OpenNTF Domino API在XPage应用程序中工作,以探索Graph数据建模功能。例如,我采用了IBM Domino附带的Teamroom。
我已经定义了一个将响应文档迁移到Grap db的方法,但是我收到了错误消息:无法对非静态方法进行静态引用
以下是该方法的样子:
private void migrateResponses(DFramedTransactionalGraph<DGraph> profilesGraph) {
try {
Database db = Factory.getSession().getCurrentDatabase();
View view = db.getView("responsesOnly");
DocumentCollection col = view.getAllDocuments();
System.out.println("number of docs found " + col.getCount());
for (Document response : col) {
System.out.println("form:" + response.getFormName());
System.out.println("id:" + response.getUniversalID());
org.openntf.domino.ext.Document parent = response.getParentDocument();
if (null == parent.getParentDocument()){
//has no parent document so this parent document is a MainTopic/Post
Post post = profilesGraph.addVertex(parent.getMetaversalID(), Post.class);
Response vertexResponse = profilesGraph.addVertex(response.getUniversalID(), Response.class);
vertexResponse.setSubject(response.getItemValueString("Subject"));
Post.addResponse(vertexResponse);
}
}
profilesGraph.commit();
} catch (Throwable t) {
XspOpenLogUtil.logError(t);
}
}
错误发生在行中:
Post.addResponse(vertexResponse);
这是我的Post类的样子:
package com.wordpress.quintessens.graph.teamroom;
import org.openntf.domino.graph2.annotations.AdjacencyUnique;
import org.openntf.domino.graph2.builtin.DVertexFrame;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
@TypeValue("post")
public interface Post extends DVertexFrame {
@Property("$$Key")
public String getKey();
@Property("subject")
public String getSubject();
@Property("subject")
public void setSubject(String n);
// real edges!
@AdjacencyUnique(label = "hasWritten", direction = Direction.OUT)
public Iterable<Profile> getAuthors();
@AdjacencyUnique(label = "hasReaction", direction = Direction.IN)
public void addResponse(Response response);
@AdjacencyUnique(label = "hasReaction", direction = Direction.IN)
public void removeResponse(Response response);
@AdjacencyUnique(label = "hasReaction", direction = Direction.IN)
public Iterable<Response> getResponses();
}
您是否有建议如何调整我的代码以使其正常工作?
答案 0 :(得分:3)
除非OpenNTF或TinkerPop使用提供的注释进行某种魔术,否则您尝试在接口上调用非静态方法。你确定你不想改变:
Post.addResponse(vertexResponse);
到
post.addResponse(vertexResponse);