2016-08-18 21 views
0

我正在使用OpenNTF Domino API在XPages應用程序中探索Graph數據建模功能。我舉例說明了IBM Domino附帶的Teamroom。嘗試將IBM Notes數據遷移到圖表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

嘗試改變'POST'到'POST'。看起來你指的是類而不是對象。 –

回答

3

除非OpenNTF或TinkerPop使用提供的註釋做某種魔術,否則您正試圖在接口上調用非靜態方法。你確定你不想改變:

Post.addResponse(vertexResponse); 

post.addResponse(vertexResponse); 
+0

是的,這是正確的。調用實例上的方法而不是接口。它會正常工作。 –

+0

你是對的!我應該休息一下...... –