return CommandType.notInHistory;
}
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
final Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
final Set<LabeledLink> incomingLinks = alignment.getCurrentIncomingLinksToNode(nodeId);
final Set<LabeledLink> outgoingLinks = alignment.getCurrentOutgoingLinksToNode(nodeId);
UpdateContainer upd = new UpdateContainer(new AbstractUpdate() {
@Override
public void generateJson(String prefix, PrintWriter pw,
VWorkspace vWorkspace) {
JSONObject obj = new JSONObject();
JSONArray edgesArray = new JSONArray();
try {
obj.put(JsonKeys.updateType.name(), "GetCurrentLinks");
/** Add the incoming links **/
if (incomingLinks != null && !incomingLinks.isEmpty()) {
for (LabeledLink inLink:incomingLinks) {
addLink(inLink, LINK_DIRECTION.incoming, edgesArray);
}
}
/** Add the outgoing links **/
if (outgoingLinks != null && !outgoingLinks.isEmpty()) {
for (LabeledLink outLink:outgoingLinks) {
if (!(outLink.getTarget() instanceof ColumnNode)) {
addLink(outLink, LINK_DIRECTION.outgoing, edgesArray);
}
}
}
obj.put(JsonKeys.edges.name(), edgesArray);
pw.println(obj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
private void addLink(LabeledLink link, LINK_DIRECTION direction, JSONArray edgesArray)
throws JSONException {
String linkLabel = link.getLabel().getDisplayName();
Node edgeSource = alignment.getNodeById(LinkIdFactory.
getLinkSourceId(link.getId()));
Node edgeTarget = alignment.getNodeById(LinkIdFactory.
getLinkTargetId(link.getId()));
String edgeSourceLabel = edgeSource.getDisplayId();
String edgeSourceId = edgeSource.getId();
String edgeSourceUri = edgeSource.getUri();