コード例 #1
0
  @GET
  @Path("/{networkId}/subnetworks")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getSubnetworks(@PathParam("networkId") Long networkId) {
    final CyRootNetwork root = getRootNetwork(networkId);
    final List<CySubNetwork> subnetworks = root.getSubNetworkList();
    final Set<Long> subnetIds =
        subnetworks.stream().map(subNet -> subNet.getSUID()).collect(Collectors.toSet());

    return getResponse(subnetIds);
  }
コード例 #2
0
  private final String getNetworkViewsAsCX(final CyRootNetwork root) {
    final CyNetworkViewWriterFactory cxWriterFactory =
        viewWriterFactoryManager.getFactory(CyNetworkViewWriterFactoryManager.CX_WRITER_ID);

    final ByteArrayOutputStream stream = new ByteArrayOutputStream();
    CyWriter writer = cxWriterFactory.createWriter(stream, root.getSubNetworkList().get(0));
    String jsonString = null;
    try {
      writer.run(null);
      jsonString = stream.toString("UTF-8");
      stream.close();
    } catch (Exception e) {
      throw getError(
          "Failed to serialize network into CX: " + root, e, Response.Status.INTERNAL_SERVER_ERROR);
    }
    return jsonString;
  }