Java 用图形表示集合的最有效方法

Java 用图形表示集合的最有效方法,java,xpages,tinkerpop,Java,Xpages,Tinkerpop,我正在用graph db重写一个IBM Teamroom应用程序。我想知道收集和显示顶点集合最有效的方法是什么 例如,我有: public JsonJavaArray getProfiles() { DFramedTransactionalGraph<DGraph> graph = GraphHelper.getProfilesGraph(); Iterable<Profile> all = graph.getElements(Profil

我正在用graph db重写一个IBM Teamroom应用程序。我想知道收集和显示顶点集合最有效的方法是什么

例如,我有:

public JsonJavaArray getProfiles() {
        DFramedTransactionalGraph<DGraph> graph = GraphHelper.getProfilesGraph();
        Iterable<Profile> all = graph.getElements(Profile.class);
        JsonJavaArray json = new JsonJavaArray();
        int count = 0;
        for (Profile profile : all) {
            JsonJavaObject jo = new JsonJavaObject();
            jo.putString("name", profile.getName());
            jo.putString("department", profile.getDepartment());
            jo.putString("location", profile.getLocation());
            json.put(count, jo);
            count++;
        }
        return json;
    }
publicjsonjavaarray getProfiles(){
DFramedTransactionalGraph=GraphHelper.getProfilesGraph();
Iterable all=graph.getElements(Profile.class);
JsonJavaArray json=新的JsonJavaArray();
整数计数=0;
用于(配置文件:全部){
JsonJavaObject jo=新的JsonJavaObject();
putString(“name”,profile.getName());
jo.putString(“department”,profile.getDepartment());
putString(“location”,profile.getLocation());
put(count,jo);
计数++;
}
返回json;
}
因此,我可以在XPage上显示它,如下表所示:

<table class="table table-sm table-inverse">
  <thead>
    <tr>
      <th>Name</th>
      <th>Department</th>
      <th>Location</th>
    </tr>
  </thead>
  <tbody>
    <xp:repeat rows="30"
        value="#{javascript:profiles.getProfiles();}" var="col"
        indexVar="index">
        <tr>
        <td>
            <xp:text escape="true" 
                value="#{col.name}">
            </xp:text>
        </td>
        <td>
        <xp:text escape="true" 
            value="#{col.department}">
        </xp:text>
        </td>
        <td>
        <xp:text escape="true" 
            value="#{col.location}">
        </xp:text></td>
        </tr>
    </xp:repeat>
  </tbody>
</table>

名称
部门
位置
我的个人资料类别:

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("profile")
public interface Profile extends DVertexFrame {

    @Property("$$Key")
    public String getKey();

    // optional fields
    @Property("Name")
    public String getName();

    @Property("Name")
    public void setName(String n);

    @Property("Department")
    public String getDepartment();

    @Property("Department")
    public void setDepartment(String n);

    @Property("Location")
    public String getLocation();

    @Property("Location")
    public void setLocation(String n);

    @Property("Email")
    public String getMail();

    @Property("Email")
    public void setMail(String n);

    // real edges!
    @AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
    public void addTopic(Post post);

    @AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
    public void removeTopic(Post post);

    @AdjacencyUnique(label = "hasWritten", direction = Direction.IN)
    public Iterable<Post> getPosts();

}
package com.wordpress.quintessens.graph.teamroom;
导入org.openntf.domino.graph2.annotations.AdjacencyUnique;
导入org.openntf.domino.graph2.builtin.DVertexFrame;
导入com.tinkerop.blueprints.Direction;
导入com.tinkerpop.frames.Property;
导入com.tinkerpop.frames.modules.typedgraph.TypeValue;
@类型值(“配置文件”)
公共接口配置文件扩展了DVertexFrame{
@属性($$Key)
公共字符串getKey();
//可选字段
@财产(“名称”)
公共字符串getName();
@财产(“名称”)
公共无效集合名(字符串n);
@物业(“部门”)
公共字符串getDepartment();
@物业(“部门”)
公共部门(字符串n);
@财产(“位置”)
公共字符串getLocation();
@财产(“位置”)
公共无效设置位置(字符串n);
@财产(“电子邮件”)
公共字符串getMail();
@财产(“电子邮件”)
公共无效setMail(字符串n);
//真正的优势!
@邻接Yunique(label=“hasWrite”,direction=direction.IN)
公共话题(帖子);
@邻接Yunique(label=“hasWrite”,direction=direction.IN)
清除公共空间(邮政);
@邻接Yunique(label=“hasWrite”,direction=direction.IN)
public-Iterable-getPosts();
}

都是很“香草”的,效果很好。尽管如此,我还是想知道我是否选择了正确的方法,或者我是否忽略了什么(阅读:使体系结构更简单)?

您是否检查了OpenNTF Domino API中的tinker pop实现?是的,我正在使用的tinker pop实现?您是否检查了OpenNTF Domino API中的tinker pop实现?是的,我正在使用的