我正在用图表db重写IBM Teamroom应用程序。我想知道收集和显示顶点集合的效率最高吗?
E.g。我有:
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;
}
所以我可以在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();
}
所有漂亮的“香草”,它工作正常。不过我想知道我是选择了正确的方法还是忽略了一些东西(读:让架构更简单)?